Created
April 30, 2019 06:33
-
-
Save lukaskollmer/3c3c20ca3b05b9c29009d3534b4e40fc to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
; ModuleID = 'main' | |
source_filename = "main" | |
target datalayout = "e-m:o-i64:64-f80:128-n8:16:32:64-S128" | |
target triple = "x86_64-apple-darwin18.5.0" | |
declare i32 @atoi(i8*) | |
define i32 @main(i32 %argc, i8** %argv) { | |
entry: | |
%0 = alloca i32 | |
%1 = getelementptr i8*, i8** %argv, i64 1 | |
%2 = load i8*, i8** %1 | |
%3 = call i32 @atoi(i8* %2) | |
%4 = call i32 @_F3fibii(i32 %3) | |
store i32 %4, i32* %0 | |
br label %return | |
return: ; preds = %entry | |
%5 = load i32, i32* %0 | |
ret i32 %5 | |
} | |
define i32 @_F3fibii(i32 %n) { | |
entry: | |
%0 = alloca i32 | |
%1 = sext i32 %n to i64 | |
%2 = icmp eq i64 %1, 0 | |
%3 = sext i32 %n to i64 | |
%4 = icmp eq i64 %3, 1 | |
%5 = or i1 %2, %4 | |
br i1 %5, label %7, label %6 | |
; <label>:6: ; preds = %entry | |
br label %8 | |
; <label>:7: ; preds = %entry | |
br label %match_merge | |
; <label>:8: ; preds = %6 | |
%9 = sub i32 %n, 1 | |
%10 = call i32 @_F3fibii(i32 %9) | |
%11 = sub i32 %n, 2 | |
%12 = call i32 @_F3fibii(i32 %11) | |
%13 = add i32 %10, %12 | |
br label %match_merge | |
match_merge: ; preds = %8, %7 | |
%14 = phi i32 [ %n, %7 ], [ %13, %8 ] | |
store i32 %14, i32* %0 | |
br label %return | |
return: ; preds = %match_merge | |
%15 = load i32, i32* %0 | |
ret i32 %15 | |
; uselistorder directives | |
uselistorder i32 (i32)* @_F3fibii, { 1, 2, 0 } | |
uselistorder i64 1, { 1, 0 } | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
fib: | |
(__TEXT,__text) section | |
_main: | |
0000000100000f30 pushq %rax | |
0000000100000f31 movq 0x8(%rsi), %rdi | |
0000000100000f35 callq 0x100000f88 ## symbol stub for: _atoi | |
0000000100000f3a movl %eax, %edi | |
0000000100000f3c callq __F3fibii | |
0000000100000f41 movl %eax, 0x4(%rsp) | |
0000000100000f45 movl 0x4(%rsp), %eax | |
0000000100000f49 popq %rcx | |
0000000100000f4a retq | |
0000000100000f4b nop | |
0000000100000f4c nop | |
0000000100000f4d nop | |
0000000100000f4e nop | |
0000000100000f4f nop | |
__F3fibii: | |
0000000100000f50 pushq %rbp | |
0000000100000f51 pushq %rbx | |
0000000100000f52 pushq %rax | |
0000000100000f53 movl %edi, %ebx | |
0000000100000f55 movslq %edi, %rax | |
0000000100000f58 testq %rax, %rax | |
0000000100000f5b je 0x100000f7b | |
0000000100000f5d cmpq $0x1, %rax | |
0000000100000f61 je 0x100000f7b | |
0000000100000f63 leal -0x1(%rbx), %edi | |
0000000100000f66 callq __F3fibii | |
0000000100000f6b movl %eax, %ebp | |
0000000100000f6d addl $-0x2, %ebx | |
0000000100000f70 movl %ebx, %edi | |
0000000100000f72 callq __F3fibii | |
0000000100000f77 movl %eax, %ebx | |
0000000100000f79 addl %ebp, %ebx | |
0000000100000f7b movl %ebx, 0x4(%rsp) | |
0000000100000f7f movl %ebx, %eax | |
0000000100000f81 addq $0x8, %rsp | |
0000000100000f85 popq %rbx | |
0000000100000f86 popq %rbp | |
0000000100000f87 retq |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment