list.c lines 18 to 27 of 42 18 __attribute__ ( ( noinline ) ) static struct node * reverse ( struct node … 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 dword ptr [rax + rax] 10019 20 mov rcx, rax rcx 28b410b0 1 10019 23 mov rax, rdi rax 28b41090 4 10019 26 21 mov rdi, qword ptr [rdi + 8] 28b41098 28b41070 9 10019 2a 22 mov qword ptr [rax + 8], rcx 10019 2e 20 test rdi, rdi 10019 31 jne 1001920 taken 10019 33 pop rbp registers stack heap code data rwx read-only rax 28b41090 4 rbx 0 rcx 28b410b0 1 rdx 0 rsi 28b410c0 0 rdi 28b41070 9 rbp 7ffe970f17b0 7ffe970f17d0 7ffe970f1880 7ffe970f18e0 0 rsp 7ffe970f17b0 7ffe970f17d0 7ffe970f1880 7ffe970f18e0 0 r8 7f2ba3019ac0 0 r9 0x20 32 r10 0x10 16 r11 7f2ba3019ac8 28b410c0 0 r12 7ffe970f1908 7ffe970f2fce "zig-out/targets/list" r13 1 r14 7f2ba32ac000 7f2ba32ad3c0 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 rsp rbp 7ffe970f17 b0 7ffe970f17d0 7ffe970f1880 7ffe970f17 b8 10018b0 main+80 7ffe970f17 c0 7f2ba3020de8 7ffe970f1918 7ffe970f17 c8 0 7ffe970f17 d0 7ffe970f1880 7ffe970f18e0 0 7ffe970f17 d8 7f2ba2e27781 libc+27781 reverse main the list its bytes value next malloc's never read the heap, 28b41050 to 28b410bf 28b410 50 10 00 00 00 00 00 00 00 30 10 b4 28 00 00 00 00 16 28b41030 28b410 60 21 00 00 00 00 00 00 00 malloc's: a chunk of 32 28b410 70 09 00 00 00 00 00 00 00 50 10 b4 28 00 00 00 00 9 28b41050 28b410 80 21 00 00 00 00 00 00 00 malloc's: a chunk of 32 28b410 90 04 00 00 00 00 00 00 00 70 10 b4 28 00 00 00 00 4 28b41070 28b410 a0 21 00 00 00 00 00 00 00 malloc's: a chunk of 32 28b410 b0 01 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 1 NULL 28b410b0 1 rcx 28b41090 4 rax 28b41070 9 rdi 28b41050 16 28b41030 25 28b41010 36 moment 71 of 95 The load read the word at 28b41098: the address of the next node. rdi holds it now, and points at the node whose value is 9.