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

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!