Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

I\'m having trouble creating an equivalent C code from the assembly code. It\'s

ID: 3748480 • Letter: I

Question

I'm having trouble creating an equivalent C code from the assembly code. It's just x86-64 Intel architecture.

Problem 1 Consider the following assembly code: LC0: .string "ans %d " main: LFB0: pushq %rbp movq %rsp, %rbp subq $16, %rsp movl $0, -4(%rbp) movabsq movq %rax, -16(%rbp) $58217882423726, %rax L2 : movq -16(%rbp), %rax andl $1, %eax movl %eax, %edx movi -4(%rbp), %eax xor1 %edx, %eax movl %eax, -4(Xrbp) shrq16%rbp) cmpq $e, -16(%rbp) jne .L2 movl -4(Xrbp), %eax movl %eax, %esi mov1 $.LCO, %edi movl $0, %eax call printf movl $0, %eax leave ret

Explanation / Answer

int main(){

int output = 0;

unsigned long value = 58217882423726;

do{

output = value & 1;

value = value >> output;

}while(value!=0x0);

printf("ans %d ",output);

return 0;

}

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote