Write the C code that produces the assembly code: (gdb) x/8x 0x4005b8 0x4005b8:
ID: 3752830 • Letter: W
Question
Write the C code that produces the assembly code:
(gdb) x/8x 0x4005b8 0x4005b8: 0x00000000004004e6 0x0000000000400516 0x4005c8: 0x00000000004004ed 0x0000000000400502 0x4005d8: 0x00000000004005160x0000000000400509 0x4005e8: 0x0000000000400516 0x000000000040050f Dump of assembler code for function main: push mov mov mov mov %rdX,-8x28 (%rbp) mov-0x18 (%rbp),%rax mov %rax,-0x8(%rbp) mov-0x20 (%rbp),%rax sub cmp %rbp %rsp,%rbp %rdi,-0x18(%rbp) %rsi,-9x20(%rbp) 0x00000000004004b6 : Ox00000000004004ce : $exd,%rax $0x7,%rax 0x00000000004004d6 : 0x00000000004004daExplanation / Answer
long switch_prob(long x, long n)
{
long result = n;
switch(x){
case 60: result = n*8; break;
case 62: result = n*8; break;
case 63: result = n;
result >>= 0x3;
break;
case 64: result = n;
result <<= 0x4;
result -= n;
n = result;
n *= n;
result = n + 75;
break;
case 65: n *= n;
result = n + 75;
break;
default: result = n + 75;
}
return result;
}
Related Questions
Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.