Question
Consider the following assembly code: .LC0: .string ans %d main: .LFB0: pushq %rbp movq %rsp, %rbp subq $16, %rsp movl $0, -4(%rbp) movabsq $58217882423726,
Consider the following assembly code:
.LC0:
.string "ans %d "
main:
.LFB0:
pushq %rbp
movq %rsp, %rbp
subq $16, %rsp
movl $0, -4(%rbp)
movabsq $58217882423726, %rax
movq %rax, -16(%rbp)
.L2:
movq -16(%rbp), %rax
andl $1, %eax
movl %eax, %edx
movl -4(%rbp), %eax
xorl %edx, %eax
movl %eax, -4(%rbp)
shrq -16(%rbp)
cmpq $0, -16(%rbp)
jne .L2
movl -4(%rbp), %eax
movl %eax, %esi
movl $.LC0, %edi
movl $0, %eax
call printf
movl $0, %eax
leave
ret
This code came from skeleton C file below after optimizing with O0. This means gcc -O0 -S command was used to convert C File into assembly file. Complete the C code given below using the provided assembly code. Step 1 might be to ignore the skeleton file and create a equivalent C code from the assembly code, and then rewrite the code to fit the skeleton file.
int main() {
int output = ________________;
unsigned long value = ________________;
do {
output = ________________;
value = ________________; }
while (value ________________ 0x________________);
printf("ans %d ", output);
return 0;
}
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started