Skip to content

Instantly share code, notes, and snippets.

@yutopp
Created September 20, 2018 18:52
Show Gist options
  • Save yutopp/7b654c3eac7de98fb39916c9275465df to your computer and use it in GitHub Desktop.
Save yutopp/7b654c3eac7de98fb39916c9275465df to your computer and use it in GitHub Desktop.
int main(void) {
puts("IF");
if (1) {
puts("if0-1: true!");
}
if (0) {
puts("if0-0: true!");
}
if (1) {
puts("if1-1: true!");
} else {
puts("if1-1: false!");
}
if (0) {
puts("if1-0: true!");
} else {
puts("if1-0: false!");
}
puts("END!");
return 0;
}
%0 = SYMBOL main
%1 = SYMBOL puts
%2 = "IF"
%3 = SYMBOL puts
%4 = "if0-1: true!"
%5 = SYMBOL puts
%6 = "if0-0: true!"
%7 = SYMBOL puts
%8 = "if1-1: true!"
%9 = SYMBOL puts
%10 = "if1-1: false!"
%11 = SYMBOL puts
%12 = "if1-0: true!"
%13 = SYMBOL puts
%14 = "if1-0: false!"
%15 = SYMBOL puts
%16 = "END!"
main:
0:
%0 = g@1
%1 = g@2
%2 = &1
%3 = call %0 %2
%4 = 1
BR %4: then -> 1, else -> 2
1:
%5 = g@3
%6 = g@4
%7 = &6
%8 = call %5 %7
JUMP -> 2
2:
%9 = 0
BR %9: then -> 3, else -> 4
3:
%10 = g@5
%11 = g@6
%12 = &11
%13 = call %10 %12
JUMP -> 4
4:
%14 = 1
BR %14: then -> 5, else -> 6
5:
%15 = g@7
%16 = g@8
%17 = &16
%18 = call %15 %17
JUMP -> 7
6:
%19 = g@9
%20 = g@10
%21 = &20
%22 = call %19 %21
JUMP -> 7
7:
%23 = 0
BR %23: then -> 8, else -> 9
8:
%24 = g@11
%25 = g@12
%26 = &25
%27 = call %24 %26
JUMP -> 10
9:
%28 = g@13
%29 = g@14
%30 = &29
%31 = call %28 %30
JUMP -> 10
10:
%32 = g@15
%33 = g@16
%34 = &33
%35 = call %32 %34
%36 = 0
RET %36
.file "cond_00.c"
.text
.section .rodata
.S0000000:
.string "IF"
.section .rodata
.S0000001:
.string "if0-1: true!"
.section .rodata
.S0000002:
.string "if0-0: true!"
.section .rodata
.S0000003:
.string "if1-1: true!"
.section .rodata
.S0000004:
.string "if1-1: false!"
.section .rodata
.S0000005:
.string "if1-0: true!"
.section .rodata
.S0000006:
.string "if1-0: false!"
.section .rodata
.S0000007:
.string "END!"
.text
.globl main
.type main, @function
main:
pushq %rbp
movq %rsp, %rbp
subq $296, %rsp
.L0000000:
leaq .S0000000(%rip), %rax
movq %rax, %rdi
call puts
movq %rax, 24(%rsp)
movq $1, %rax
cmp $0, %rax
je .L0000002
jmp .L0000001
.L0000001:
leaq .S0000001(%rip), %rax
movq %rax, %rdi
call puts
movq %rax, 64(%rsp)
jmp .L0000002
.L0000002:
movq $0, %rax
cmp $0, %rax
je .L0000004
jmp .L0000003
.L0000003:
leaq .S0000002(%rip), %rax
movq %rax, %rdi
call puts
movq %rax, 104(%rsp)
jmp .L0000004
.L0000004:
movq $1, %rax
cmp $0, %rax
je .L0000006
jmp .L0000005
.L0000005:
leaq .S0000003(%rip), %rax
movq %rax, %rdi
call puts
movq %rax, 144(%rsp)
jmp .L0000007
.L0000006:
leaq .S0000004(%rip), %rax
movq %rax, %rdi
call puts
movq %rax, 176(%rsp)
jmp .L0000007
.L0000007:
movq $0, %rax
cmp $0, %rax
je .L0000009
jmp .L0000008
.L0000008:
leaq .S0000005(%rip), %rax
movq %rax, %rdi
call puts
movq %rax, 216(%rsp)
jmp .L0000010
.L0000009:
leaq .S0000006(%rip), %rax
movq %rax, %rdi
call puts
movq %rax, 248(%rsp)
jmp .L0000010
.L0000010:
leaq .S0000007(%rip), %rax
movq %rax, %rdi
call puts
movq %rax, 280(%rsp)
movq $0, %rax
movq %rbp, %rsp
popq %rbp
ret
IF
if0-1: true!
if1-1: true!
if1-0: false!
END!
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment