program LoopTest {
section module {
}
section data {
int rax = 0
string str_0 = "for loop index: "
string str_1 = "while index: "
string str_2 = "repeat test: "
string str_3 = " no 5: "
string fmt_int = "%lld "
string fmt_str = "%s "
string newline = "\n"
int i = 0
}
section code {
start:
mov i, 0
FOR_0:
cmp i, 20
jg ENDFOR_1
cmp i, 10
jge ELSE_3
jmp FOR_CONTINUE_2
ELSE_3:
print fmt_str, str_0
print fmt_int, i
print newline
FOR_CONTINUE_2:
add i, 1
jmp FOR_0
ENDFOR_1:
mov i, 0
WHILE_7:
cmp i, 10
jge ENDWHILE_8
add i, 1
cmp i, 5
jle ELSE_11
jmp WHILE_7
ELSE_11:
print fmt_str, str_1
print fmt_int, i
print newline
jmp WHILE_7
ENDWHILE_8:
mov i, 10
REPEAT_15:
sub i, 1
print fmt_str, str_2
print fmt_int, i
print newline
cmp i, 5
jne ELSE_18
jmp REPEAT_CONTINUE_17
ELSE_18:
print fmt_str, str_3
print fmt_int, i
print newline
REPEAT_CONTINUE_17:
cmp i, 0
jne REPEAT_15
UNTIL_16:
done
}
}