title: Binary Bomb Lab - Phase 6 What is happening to my nodes?
body: <p>After looking through the assembly, I know I need a pass that is </p>
  
  <p>6 ints long
   - Each int in the pass is unique
   - The ints are in the range of 1 to 6</p>
  
  <pre><code>(gdb) disas
  Dump of assembler code for function phase_6:
     0x0000000000401182 &lt;+0&gt;:     push   %r14
     0x0000000000401184 &lt;+2&gt;:     push   %r13
     0x0000000000401186 &lt;+4&gt;:     push   %r12
     0x0000000000401188 &lt;+6&gt;:     push   %rbp
     0x0000000000401189 &lt;+7&gt;:     push   %rbx
     0x000000000040118a &lt;+8&gt;:     sub    $0x50,%rsp
     0x000000000040118e &lt;+12&gt;:    mov    %rsp,%rsi
     0x0000000000401191 &lt;+15&gt;:    callq  0x401801 &lt;read_six_numbers&gt;
     0x0000000000401196 &lt;+20&gt;:    mov    %rsp,%r12
     0x0000000000401199 &lt;+23&gt;:    mov    %rsp,%r14
     0x000000000040119c &lt;+26&gt;:    mov    $0x0,%r13d
     0x00000000004011a2 &lt;+32&gt;:    mov    %r14,%rbp
     0x00000000004011a5 &lt;+35&gt;:    mov    (%r14),%eax
     0x00000000004011a8 &lt;+38&gt;:    sub    $0x1,%eax
     0x00000000004011ab &lt;+41&gt;:    cmp    $0x5,%eax
     0x00000000004011ae &lt;+44&gt;:    jbe    0x4011b5 &lt;phase_6+51&gt;
     0x00000000004011b0 &lt;+46&gt;:    callq  0x4016a5 &lt;explode_bomb&gt;
     0x00000000004011b5 &lt;+51&gt;:    add    $0x1,%r13d
     0x00000000004011b9 &lt;+55&gt;:    cmp    $0x6,%r13d
     0x00000000004011bd &lt;+59&gt;:    je     0x4011e0 &lt;phase_6+94&gt;
     0x00000000004011bf &lt;+61&gt;:    mov    %r13d,%ebx
     0x00000000004011c2 &lt;+64&gt;:    movslq %ebx,%rax
     0x00000000004011c5 &lt;+67&gt;:    mov    (%rsp,%rax,4),%edx
     0x00000000004011c8 &lt;+70&gt;:    cmp    %edx,0x0(%rbp)
     0x00000000004011cb &lt;+73&gt;:    jne    0x4011d2 &lt;phase_6+80&gt;
     0x00000000004011cd &lt;+75&gt;:    callq  0x4016a5 &lt;explode_bomb&gt;
     0x00000000004011d2 &lt;+80&gt;:    add    $0x1,%ebx
     0x00000000004011d5 &lt;+83&gt;:    cmp    $0x5,%ebx
     0x00000000004011d8 &lt;+86&gt;:    jle    0x4011c2 &lt;phase_6+64&gt;
     0x00000000004011da &lt;+88&gt;:    add    $0x4,%r14
     0x00000000004011de &lt;+92&gt;:    jmp    0x4011a2 &lt;phase_6+32&gt;
     0x00000000004011e0 &lt;+94&gt;:    lea    0x18(%rsp),%rcx
     0x00000000004011e5 &lt;+99&gt;:    mov    $0x7,%edx
  ---Type &lt;return&gt; to continue, or q &lt;return&gt; to quit---
     0x00000000004011ea &lt;+104&gt;:   mov    %edx,%eax
     0x00000000004011ec &lt;+106&gt;:   sub    (%r12),%eax
     0x00000000004011f0 &lt;+110&gt;:   mov    %eax,(%r12)
     0x00000000004011f4 &lt;+114&gt;:   add    $0x4,%r12
     0x00000000004011f8 &lt;+118&gt;:   cmp    %rcx,%r12
     0x00000000004011fb &lt;+121&gt;:   jne    0x4011ea &lt;phase_6+104&gt;
     0x00000000004011fd &lt;+123&gt;:   mov    $0x0,%esi
     0x0000000000401202 &lt;+128&gt;:   jmp    0x40121e &lt;phase_6+156&gt;
     0x0000000000401204 &lt;+130&gt;:   mov    0x8(%rdx),%rdx
     0x0000000000401208 &lt;+134&gt;:   add    $0x1,%eax
     0x000000000040120b &lt;+137&gt;:   cmp    %ecx,%eax
     0x000000000040120d &lt;+139&gt;:   jne    0x401204 &lt;phase_6+130&gt;
     0x000000000040120f &lt;+141&gt;:   mov    %rdx,0x20(%rsp,%rsi,2)
     0x0000000000401214 &lt;+146&gt;:   add    $0x4,%rsi
     0x0000000000401218 &lt;+150&gt;:   cmp    $0x18,%rsi
     0x000000000040121c &lt;+154&gt;:   je     0x401232 &lt;phase_6+176&gt;
     0x000000000040121e &lt;+156&gt;:   mov    (%rsp,%rsi,1),%ecx
     0x0000000000401221 &lt;+159&gt;:   mov    $0x1,%eax
     0x0000000000401226 &lt;+164&gt;:   mov    $0x604320,%edx
     0x000000000040122b &lt;+169&gt;:   cmp    $0x1,%ecx
     0x000000000040122e &lt;+172&gt;:   jg     0x401204 &lt;phase_6+130&gt;
     0x0000000000401230 &lt;+174&gt;:   jmp    0x40120f &lt;phase_6+141&gt;
     0x0000000000401232 &lt;+176&gt;:   mov    0x20(%rsp),%rbx
     0x0000000000401237 &lt;+181&gt;:   mov    0x28(%rsp),%rax
     0x000000000040123c &lt;+186&gt;:   mov    %rax,0x8(%rbx)
     0x0000000000401240 &lt;+190&gt;:   mov    0x30(%rsp),%rdx
     0x0000000000401245 &lt;+195&gt;:   mov    %rdx,0x8(%rax)
     0x0000000000401249 &lt;+199&gt;:   mov    0x38(%rsp),%rax
     0x000000000040124e &lt;+204&gt;:   mov    %rax,0x8(%rdx)
     0x0000000000401252 &lt;+208&gt;:   mov    0x40(%rsp),%rdx
     0x0000000000401257 &lt;+213&gt;:   mov    %rdx,0x8(%rax)
     0x000000000040125b &lt;+217&gt;:   mov    0x48(%rsp),%rax
     0x0000000000401260 &lt;+222&gt;:   mov    %rax,0x8(%rdx)
     0x0000000000401264 &lt;+226&gt;:   movq   $0x0,0x8(%rax)
  ---Type &lt;return&gt; to continue, or q &lt;return&gt; to quit---
     0x000000000040126c &lt;+234&gt;:   mov    $0x5,%ebp
     0x0000000000401271 &lt;+239&gt;:   mov    0x8(%rbx),%rax
     0x0000000000401275 &lt;+243&gt;:   mov    (%rax),%edx
  =&gt; 0x0000000000401277 &lt;+245&gt;:   cmp    %edx,(%rbx)
     0x0000000000401279 &lt;+247&gt;:   jge    0x401280 &lt;phase_6+254&gt;
     0x000000000040127b &lt;+249&gt;:   callq  0x4016a5 &lt;explode_bomb&gt;
     0x0000000000401280 &lt;+254&gt;:   mov    0x8(%rbx),%rbx
     0x0000000000401284 &lt;+258&gt;:   sub    $0x1,%ebp
     0x0000000000401287 &lt;+261&gt;:   jne    0x401271 &lt;phase_6+239&gt;
     0x0000000000401289 &lt;+263&gt;:   add    $0x50,%rsp
     0x000000000040128d &lt;+267&gt;:   pop    %rbx
     0x000000000040128e &lt;+268&gt;:   pop    %rbp
     0x000000000040128f &lt;+269&gt;:   pop    %r12
     0x0000000000401291 &lt;+271&gt;:   pop    %r13
     0x0000000000401293 &lt;+273&gt;:   pop    %r14
     0x0000000000401295 &lt;+275&gt;:   retq
  End of assembler dump.
  (gdb) x/3x $rbx
  0x604370 &lt;node6&gt;:       0x00000139      0x00000006      0x00604360
  (gdb) x/3x *($rbx+8)
  0x604360 &lt;node5&gt;:       0x000000af      0x00000005      0x00604350
  (gdb) x/3x *(*($rbx+8)+8)
  0x604350 &lt;node4&gt;:       0x00000149      0x00000004      0x00604340
  (gdb) x/3x *(*(*($rbx+8)+8)+8)
  0x604340 &lt;node3&gt;:       0x0000033b      0x00000003      0x00604330
  (gdb) x/3x *(*(*(*($rbx+8)+8)+8)+8)
  0x604330 &lt;node2&gt;:       0x0000023f      0x00000002      0x00604320
  (gdb) x/3x *(*(*(*(*($rbx+8)+8)+8)+8)+8)
  0x604320 &lt;node1&gt;:       0x0000006d      0x00000001      0x00000000
  </code></pre>
  
  <p>My input was 1 2 3 4 5 6, but the linked list made was 6 5 4 3 2 1, so it should making the list from the end first. After organizing the numbers from greatest to smallest which gave me 3 2 4 6 5 1. I put in 1 5 6 4 2 3 hoping that 3 will be placed first as its the biggest but what was made instead was this</p>
  
  <pre><code>(gdb) x/3x $rbx
  0x604370 &lt;node6&gt;:       0x00000139      0x00000006      0x00604330
  (gdb) x/3x *($rbx+8)
  0x604330 &lt;node2&gt;:       0x0000023f      0x00000002      0x00604320
  (gdb) x/3x *(*($rbx+8)+8)
  0x604320 &lt;node1&gt;:       0x0000006d      0x00000001      0x00604340
  (gdb) x/3x *(*(*($rbx+8)+8)+8)
  0x604340 &lt;node3&gt;:       0x0000033b      0x00000003      0x00604360
  (gdb) x/3x *(*(*(*($rbx+8)+8)+8)+8)
  0x604360 &lt;node5&gt;:       0x000000af      0x00000005      0x00604350
  (gdb) x/3x *(*(*(*(*($rbx+8)+8)+8)+8)+8)
  0x604350 &lt;node4&gt;:       0x00000149      0x00000004      0x00000000
  </code></pre>
  
  <p>Giving me a linked list of 6 2 1 3 5 4. What am I doing wrong that is causing this to happen?</p>