sort.c
lines 1 to 22 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
;
22
}
the map: sort's disassembly as its track, in the second column (1024 to 1904), at the 11th compare
disassembly · sort
its blocks · visits · the edges taken · the loops' turns
×5
×5
401150
lines 9 to 10
×1
+0
9
push
rbp
+1
mov
rbp, rsp
+4
sub
rsp, 0x10
+8
mov
[rbp - 4], edi
+b
10
mov
[rbp - 8]
, 1
401162
line 10
×6
+12
10
mov
eax, [rbp - 8]
+15
cmp
eax, [rbp - 4]
+18
jge
4011f7
taken 0 · not 6
40116e
line 11
×6
+1e
11
mov
eax, [rbp - 8]
+21
mov
[rbp - 0xc], eax
401174
line 12
×11
+24
12
xor
eax, eax
+26
cmp
[rbp - 0xc]
, 0
+2a
mov
[rbp - 0xd], al
+2d
jle
4011a6
taken 0 · not 11
40117f
line 12
×11
+2f
12
mov
eax, [rbp - 0xc]
+32
sub
eax, 1
+35
movsxd
rcx, eax
+38
lea
rax, [rip + 0x2e81]
+3f
mov
eax, [rax + rcx*4]
+42
movsxd
rdx, [rbp - 0xc]
+46
lea
rcx, [rip + 0x2e73]
+4d
cmp
eax, [rcx + rdx*4]
+50
setg
al
+53
mov
[rbp - 0xd], al
4011a6
line 12
×11
+56
12
mov
al, [rbp - 0xd]
7fffffffecd3
◂
1
+59
test
al, 1
1
:
1
zf
+5b
jne
4011af
taken
· reads zf
4011af
lines 12 to 14
×5
+5f
13
mov
eax, [rbp - 0xc]
+62
sub
eax, 1
+65
cdqe
+67
lea
rdi, [rip + 0x2e52]
+6e
shl
rax, 2
+72
add
rdi, rax
+75
movsxd
rax, [rbp - 0xc]
+79
lea
rsi, [rip + 0x2e40]
+80
shl
rax, 2
+84
add
rsi, rax
+87
call
401120
swap
+8c
14
mov
eax, [rbp - 0xc]
+8f
add
eax, 0xffffffff
+92
mov
[rbp - 0xc], eax
+95
12
jmp
401174
4011ad
line 12
×5
+5d
12
jmp
4011e7
4011e7
line 16
×5
+97
16
jmp
4011e9
4011e9
line 10
×5
+99
10
mov
eax, [rbp - 8]
+9c
add
eax, 1
+9f
mov
[rbp - 8], eax
+a2
jmp
401162
4011f7
line 17
+a7
17
add
rsp, 0x10
+ab
pop
rbp
+ac
ret
the map's stage ends at 1784