title: Linked Lists Nodes in Assembly (Bomb Lab Phase 6)
body: <p>I'm struggling to figure out how the nodes are being compared to the inputs. So far I've been able to discern that it requires six integers, which correspond to nodes. Also, the numbers can't be repeated.</p>
  
  <p>I noticed that $rbx was continually getting incremented by 8 and after poking around I was able to find these: </p>
  
  <pre><code>0x6042e0 &lt;node1&gt;:       0x87    0x03    0x00 = 135
  0x6042f0 &lt;node2&gt;:       0x92    0x02    0x00 = 146
  0x604300 &lt;node3&gt;:       0x46    0x02    0x00 = 70
  0x604310 &lt;node4&gt;:       0x1c    0x02    0x00 = 28
  0x604320 &lt;node5&gt;:       0xf5    0x02    0x00 = 245
  0x604330 &lt;node6&gt;:       0xc1    0x03    0x00 = 193
  </code></pre>
  
  <p>I also understand that the code is using a for loop to traverse the linked list. I just can't figure out what type of operation/comparison is being performed. </p>
  
  <p>Here is the assembly:</p>
  
  <pre><code>=&gt; 0x00000000004010b0 &lt;+0&gt;:     push   %r13
     0x00000000004010b2 &lt;+2&gt;:     push   %r12
     0x00000000004010b4 &lt;+4&gt;:     push   %rbp
     0x00000000004010b5 &lt;+5&gt;:     push   %rbx
     0x00000000004010b6 &lt;+6&gt;:     sub    $0x58,%rsp
     0x00000000004010ba &lt;+10&gt;:    lea    0x30(%rsp),%rsi
     0x00000000004010bf &lt;+15&gt;:    callq  0x4014cb &lt;read_six_numbers&gt;
     0x00000000004010c4 &lt;+20&gt;:    lea    0x30(%rsp),%r12
     0x00000000004010c9 &lt;+25&gt;:    mov    $0x0,%r13d
     0x00000000004010cf &lt;+31&gt;:    mov    %r12,%rbp
     0x00000000004010d2 &lt;+34&gt;:    mov    (%r12),%eax
     0x00000000004010d6 &lt;+38&gt;:    sub    $0x1,%eax
     0x00000000004010d9 &lt;+41&gt;:    cmp    $0x5,%eax
     0x00000000004010dc &lt;+44&gt;:    jbe    0x4010e3 &lt;phase_6+51&gt;
     0x00000000004010de &lt;+46&gt;:    callq  0x401495 &lt;explode_bomb&gt;
     0x00000000004010e3 &lt;+51&gt;:    add    $0x1,%r13d
     0x00000000004010e7 &lt;+55&gt;:    cmp    $0x6,%r13d
     0x00000000004010eb &lt;+59&gt;:    je     0x40112a &lt;phase_6+122&gt;
     0x00000000004010ed &lt;+61&gt;:    mov    %r13d,%ebx
     0x00000000004010f0 &lt;+64&gt;:    movslq %ebx,%rax
     0x00000000004010f3 &lt;+67&gt;:    mov    0x30(%rsp,%rax,4),%eax
     0x00000000004010f7 &lt;+71&gt;:    cmp    %eax,0x0(%rbp)
     0x00000000004010fa &lt;+74&gt;:    jne    0x401101 &lt;phase_6+81&gt;
     0x00000000004010fc &lt;+76&gt;:    callq  0x401495 &lt;explode_bomb&gt;
     0x0000000000401101 &lt;+81&gt;:    add    $0x1,%ebx
     0x0000000000401104 &lt;+84&gt;:    cmp    $0x5,%ebx
     0x0000000000401107 &lt;+87&gt;:    jle    0x4010f0 &lt;phase_6+64&gt;
     0x0000000000401109 &lt;+89&gt;:    add    $0x4,%r12
     0x000000000040110d &lt;+93&gt;:    jmp    0x4010cf &lt;phase_6+31&gt;
     0x000000000040110f &lt;+95&gt;:    mov    0x8(%rdx),%rdx
     0x0000000000401113 &lt;+99&gt;:    add    $0x1,%eax
     0x0000000000401116 &lt;+102&gt;:   cmp    %ecx,%eax
     0x0000000000401118 &lt;+104&gt;:   jne    0x40110f &lt;phase_6+95&gt;
     0x000000000040111a &lt;+106&gt;:   mov    %rdx,(%rsp,%rsi,2)
     0x000000000040111e &lt;+110&gt;:   add    $0x4,%rsi
     0x0000000000401122 &lt;+114&gt;:   cmp    $0x18,%rsi
     0x0000000000401126 &lt;+118&gt;:   jne    0x40112f &lt;phase_6+127&gt;
     0x0000000000401128 &lt;+120&gt;:   jmp    0x401144 &lt;phase_6+148&gt;
     0x000000000040112a &lt;+122&gt;:   mov    $0x0,%esi
     0x000000000040112f &lt;+127&gt;:   mov    0x30(%rsp,%rsi,1),%ecx
     0x0000000000401133 &lt;+131&gt;:   mov    $0x1,%eax
     0x0000000000401138 &lt;+136&gt;:   mov    $0x6042e0,%edx
     0x000000000040113d &lt;+141&gt;:   cmp    $0x1,%ecx
     0x0000000000401140 &lt;+144&gt;:   jg     0x40110f &lt;phase_6+95&gt;
     0x0000000000401142 &lt;+146&gt;:   jmp    0x40111a &lt;phase_6+106&gt;
     0x0000000000401144 &lt;+148&gt;:   mov    (%rsp),%rbx
     0x0000000000401148 &lt;+152&gt;:   mov    %rsp,%rax
     0x000000000040114b &lt;+155&gt;:   lea    0x28(%rsp),%rsi
     0x0000000000401150 &lt;+160&gt;:   mov    %rbx,%rcx
     0x0000000000401153 &lt;+163&gt;:   mov    0x8(%rax),%rdx
     0x0000000000401157 &lt;+167&gt;:   mov    %rdx,0x8(%rcx)
     0x000000000040115b &lt;+171&gt;:   add    $0x8,%rax
     0x000000000040115f &lt;+175&gt;:   mov    %rdx,%rcx
     0x0000000000401162 &lt;+178&gt;:   cmp    %rsi,%rax
     0x0000000000401165 &lt;+181&gt;:   jne    0x401153 &lt;phase_6+163&gt;
     0x0000000000401167 &lt;+183&gt;:   movq   $0x0,0x8(%rdx)
     0x000000000040116f &lt;+191&gt;:   mov    $0x5,%ebp
     0x0000000000401174 &lt;+196&gt;:   mov    0x8(%rbx),%rax
     0x0000000000401178 &lt;+200&gt;:   mov    (%rax),%eax
     0x000000000040117a &lt;+202&gt;:   cmp    %eax,(%rbx)
     0x000000000040117c &lt;+204&gt;:   jge    0x401183 &lt;phase_6+211&gt;
     0x000000000040117e &lt;+206&gt;:   callq  0x401495 &lt;explode_bomb&gt;
     0x0000000000401183 &lt;+211&gt;:   mov    0x8(%rbx),%rbx
     0x0000000000401187 &lt;+215&gt;:   sub    $0x1,%ebp
     0x000000000040118a &lt;+218&gt;:   jne    0x401174 &lt;phase_6+196&gt;
     0x000000000040118c &lt;+220&gt;:   add    $0x58,%rsp
     0x0000000000401190 &lt;+224&gt;:   pop    %rbx
     0x0000000000401191 &lt;+225&gt;:   pop    %rbp
     0x0000000000401192 &lt;+226&gt;:   pop    %r12
     0x0000000000401194 &lt;+228&gt;:   pop    %r13
     0x0000000000401196 &lt;+230&gt;:   retq   
  
  </code></pre>
  
  <p>Thanks in advance for your help.</p>