list.c lines 18 to 27 of 42 18 __attribute__ ( ( noinline ) ) static struct node * reverse ( struct n … 19 struct node * prev = NULL ; 20 while ( head ) { 21 struct node * next = head - > next ; 22 head - > next = prev ; 23 prev = head ; 24 head = next ; 25 } 26 return prev ; 27 } disassembly reverse 10019 19 20 xor eax, eax 10019 1b nop [rax + rax] 10019 20 mov rcx, rax 10019 23 mov rax, rdi 10019 26 21 mov rdi, [rdi + 8] 1004098 1004070 9 10019 2a 22 mov [rax + 8], rcx 10019 2e 20 test rdi, rdi 10019 31 jne 1001920 10019 33 pop rbp registers stack heap code data rwx read-only rax 1004090 4 rbx 0 rcx 10040b0 1 rdx 0 rsi 10040c0 0 rdi 1004070 9 rbp 7fffffffece0 7fffffffed00 7fffffffedb0 7fffffffee10 0 rsp 7fffffffece0 7fffffffed00 7fffffffedb0 7fffffffee10 0 r8 7ffff7e19ac0 r9 0x20 32 r10 0x10 16 r11 7ffff7e19ac8 r12 7fffffffee38 7fffffffefea "./list" r13 1 r14 7ffff7ffd000 7ffff7ffe3c0 0 r15 10029c0 1 rip 1001926 reverse+22 cf PF af zf sf IF df of stack six words from rsp · the frames they belong to rbp rsp +0 saved rbp 7fffffffe ce0 7fffffffed00 +8 7fffffffe ce8 10018b0 main+80 +10 7fffffffe cf0 7ffff7e20de8 +18 saved rbx 7fffffffe cf8 0 +20 saved rbp 7fffffffe d00 7fffffffedb0 +28 7fffffffe d08 7ffff7c27781 libc+27781 reverse main its bytes the heap, 1004050 to 10040bf 10040 50 10 00 00 00 00 00 00 00 16 30 40 00 01 00 00 00 00 1004030 10040 60 00 00 00 00 00 00 00 00 21 00 00 00 00 00 00 00 malloc's: a chunk of 32 10040 70 09 00 00 00 00 00 00 00 9 50 40 00 01 00 00 00 00 1004050 10040 80 00 00 00 00 00 00 00 00 21 00 00 00 00 00 00 00 malloc's: a chunk of 32 10040 90 04 00 00 00 00 00 00 00 4 70 40 00 01 00 00 00 00 1004070 10040 a0 00 00 00 00 00 00 00 00 21 00 00 00 00 00 00 00 malloc's: a chunk of 32 10040 b0 01 00 00 00 00 00 00 00 1 00 00 00 00 00 00 00 00 NULL the list 10040b0 1 rcx 1004090 4 rax 1004070 9 rdi 1004050 16 1004030 25 1004010 36 moment 3 of 4 The load read the word at 1004098: the address of the next node. rdi holds it now, and points at the node whose value is 9.