the blocks of sort its blocks · the visits · the path ×5 ×5 +0 ×1 +17 ×6 +1f ×5 +5f ×11 +65 ×11 +9a ×5 +9e ×6 +aa disassembly sort · +84 to +a1 4011 c7 12 lea rcx, [rax*4] 4011 cf lea rax, [rip + 0x2e4a] 4011 d6 mov eax, [rcx + rax*1] 404034 ◂ 5 4011 d9 cmp edx, eax 17 : 5 zf sf of 4011 db jg 401162 taken · reads zf sf of 4011 dd 10 add [rbp - 8] , 1 4011 e1 mov eax, [rbp - 8] sort.c lines 1 to 21 of 22 1 int a [ 8 ] = { 4 , 9 , 17 , 31 , 12 , 26 , 5 , 20 } ; 2 3 void swap ( int * x , int * y ) { 4 int t = * x ; 5 * x = * y ; 6 * y = t ; 7 } 8 9 void sort ( int n ) { 10 for ( int i = 1 ; i < n ; i + + ) { 11 int j = i ; 12 while ( j > 0 & & a [ j - 1 ] > a [ j ] ) { 13 swap ( & a [ j - 1 ] , & a [ j ] ) ; 14 j - - ; 15 } 16 } 17 } 18 19 int main ( void ) { 20 sort ( 8 ) ; 21 return 0 ; registers stack heap code data rwx read-only rax 5 rbx 0 rcx 0x10 16 rdx 0x11 17 rsi 404034 0x1f0000001a rdi 404030 0x1a00000005 rbp 7fffffffecf0 7fffffffed00 7fffffffedb0 7fffffffee10 0 rsp 7fffffffecd8 0x800000000 r8 7ffff7e19680 r9 7ffff7e1afa0 r10 7fffffffea60 0 r11 7ffff7ffca90 0x786843bb9f54c5c1 r12 7fffffffee38 7fffffffefea "./sort" r13 1 r14 7ffff7ffd000 7ffff7ffe3c0 0 r15 403e10 4010e0 __do_global_dtors_aux rip 4011db sort+152 cf PF AF zf sf IF df of stack six words from rsp · the frames they belong to rsp +0 7fffffffe cd8 0x800000000 +8 7fffffffe ce0 0 +10 i, j 7fffffffe ce8 0x400000006 rbp +18 saved rbp 7fffffffe cf0 7fffffffed00 +20 7fffffffe cf8 4011ff main+14 +28 7fffffffe d00 7fffffffedb0 7fffffffee10 0 sort(8) moment 370 of 465 The sixth pass, its third compare: 17 : 5, so jg goes back to the swap. The swap has run 5 times so far; the outer loop has turned 5.