So I'm working on my Binary bomb lab and i've gotten to the point where I used gdb to pull out this bit of assembly code. However I'm having trouble turning it into workable C code.
0x0000000000400dd0 <+0>: push %rbp
0x0000000000400dd1 <+1>: push %rbx
0x0000000000400dd2 <+2>: sub $0x28,%rsp
0x0000000000400dd6 <+6>: mov %rsp,%rsi
0x0000000000400dd9 <+9>: callq 0x4013a3 <read_six_numbers>
0x0000000000400dde <+14>: cmpl $0x1,(%rsp)
0x0000000000400de2 <+18>: jne 0x400ded <phase_2+29>
0x0000000000400de4 <+20>: mov %rsp,%rbx
0x0000000000400de7 <+23>: lea 0x14(%rbx),%rbp
0x0000000000400deb <+27>: jmp 0x400e02 <phase_2+50>
0x0000000000400ded <+29>: callq 0x401381 <explode_bomb>
0x0000000000400df2 <+34>: jmp 0x400de4 <phase_2+20>
0x0000000000400df4 <+36>: callq 0x401381 <explode_bomb>
0x0000000000400df9 <+41>: add $0x4,%rbx
0x0000000000400dfd <+45>: cmp %rbp,%rbx
0x0000000000400e00 <+48>: je 0x400e0d <phase_2+61>
0x0000000000400e02 <+50>: mov (%rbx),%eax
0x0000000000400e04 <+52>: add %eax,%eax
0x0000000000400e06 <+54>: cmp %eax,0x4(%rbx)
0x0000000000400e09 <+57>: je 0x400df9 <phase_2+41>
0x0000000000400e0b <+59>: jmp 0x400df4 <phase_2+36>
0x0000000000400e0d <+61>: add $0x28,%rsp
0x0000000000400e11 <+65>: pop %rbx
0x0000000000400e12 <+66>: pop %rbp
0x0000000000400e13 <+67>: retq
Right now this is what I have :
push rbp
push rbx
rsp = rsp - 40
rsi = rsp
(read_six_numbers)
if rsp != 1 goto <phase_2+29>(AKA EXPLODE)
else{
rbx = rsp
rbp = rbx + 20
goto <phase_2+50>
}
eax = rbx (THIS IS <phase_2+50>)
eax = eax + eax
if eax = rbx + 4 goto <phase_2+41>(AKA REPEAT)
else{
goto <phase_2+36> (AKA EXPLODE)
}
rbx = rbx + 4 (THIS IS <phase_2+41>)
if rbp == rbx goto <phase_2+61> (AKA END)
else{
goto <phase_2+50>
All I can figure out right now is that when it loops we +4 to the value, but I'm pretty sure I'm missing something very important. If you could help me out that would be amazing. Thank you.