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

Bomblab p2 - finding 6 numbers Dump of assembler code for function phase_2: => 0

ID: 3856412 • Letter: B

Question

Bomblab p2 - finding 6 numbers

Dump of assembler code for function phase_2:
=> 0x0000000000400e6c <+0>:   push %rbp
0x0000000000400e6d <+1>:   push %rbx
0x0000000000400e6e <+2>:   sub $0x28,%rsp
0x0000000000400e72 <+6>:   mov %rsp,%rsi
0x0000000000400e75 <+9>:   callq 0x401361 <read_six_numbers>
0x0000000000400e7a <+14>:   cmpl $0x1,(%rsp)
0x0000000000400e7e <+18>:   je 0x400ea0 <phase_2+52>
0x0000000000400e80 <+20>:   callq 0x40133f <explode_bomb>
0x0000000000400e85 <+25>:   jmp 0x400ea0 <phase_2+52>
0x0000000000400e87 <+27>:   mov -0x4(%rbx),%eax
0x0000000000400e8a <+30>:   add %eax,%eax
0x0000000000400e8c <+32>:   cmp %eax,(%rbx)
0x0000000000400e8e <+34>:   je 0x400e95 <phase_2+41>
0x0000000000400e90 <+36>:   callq 0x40133f <explode_bomb>
0x0000000000400e95 <+41>:   add $0x4,%rbx
0x0000000000400e99 <+45>:   cmp %rbp,%rbx
0x0000000000400e9c <+48>:   jne 0x400e87 <phase_2+27>
0x0000000000400e9e <+50>:   jmp 0x400eac <phase_2+64>
0x0000000000400ea0 <+52>:   lea 0x4(%rsp),%rbx
0x0000000000400ea5 <+57>:   lea 0x18(%rsp),%rbp
0x0000000000400eaa <+62>:   jmp 0x400e87 <phase_2+27>
0x0000000000400eac <+64>:   add $0x28,%rsp
0x0000000000400eb0 <+68>:   pop %rbx
0x0000000000400eb1 <+69>:   pop %rbp
0x0000000000400eb2 <+70>:   retq   

I'm using gdb to try and determine the 6 sequential numbers that will be output for this, but I'm having a lot of trouble. I decompiled this and found this phase_2 code, but I'm struggling with it:

void phase_2(struct s0* rdi, struct s0* rsi, struct s0* rdx, struct s0* rcx, struct s0** r8, void* r9) {
struct s0* rsp7;
struct s0* rsi8;
int32_t* rsp9;
int32_t v10;
struct s0** v11;
struct s0** v12;
int64_t v13;
int32_t* rbx14;
int32_t* rbp15;
int32_t v16;
int32_t v17;
struct s0** v18;
struct s0** v19;
int64_t v20;

rsp7 = reinterpret_cast<struct s0*>(reinterpret_cast<int64_t>(__zero_stack_offset()) - 8 - 8 - 40);
rsi8 = rsp7;
read_six_numbers(rdi, rsi8);
rsp9 = reinterpret_cast<int32_t*>(reinterpret_cast<unsigned char>(rsp7) - 8 + 8);
if (v10 != 1) {
explode_bomb(rdi, rsi8, rdx, rcx, r8, r9, v11, v12, v13);
rsp9 = rsp9 - 2 + 2;
}
rbx14 = rsp9 + 1;
rbp15 = rsp9 + 6;
do {
if (v16 != v17 + v17) {
explode_bomb(rdi, rsi8, rdx, rcx, r8, r9, v18, v19, v20);
}
++rbx14;
} while (rbx14 != rbp15);
return;
}

Can anyone point me in the right direction?

Explanation / Answer

void phase_2(struct s0* rdi, struct s0* rsi, struct s0* rdx, struct s0* rcx, struct s0** r8, void* r9) {
struct s0* rsp7;
struct s0* rsi8;
int32_t* rsp9;
int32_t v10;
struct s0** v11;
struct s0** v12;
int64_t v13;
int32_t* rbx14;
int32_t* rbp15;
int32_t v16;
int32_t v17;
struct s0** v18;
struct s0** v19;
int64_t v20;

rsp7 = reinterpret_cast<struct s0*>(reinterpret_cast<int64_t>(__zero_stack_offset()) - 8 - 8 - 40);
rsi8 = rsp7;
read_six_numbers(rdi, rsi8);
rsp9 = reinterpret_cast<int32_t*>(reinterpret_cast<unsigned char>(rsp7) - 8 + 8);
if (v10 != 1) {
explode_bomb(rdi, rsi8, rdx, rcx, r8, r9, v11, v12, v13);
rsp9 = rsp9 - 2 + 2;
}
rbx14 = rsp9 + 1;
rbp15 = rsp9 + 6;
do {
if (v16 != v17 + v17) {
explode_bomb(rdi, rsi8, rdx, rcx, r8, r9, v18, v19, v20);
}
++rbx14;
} while (rbx14 != rbp15);
return;
}