#define NULL ((void *)0)
typedef unsigned long size_t; // Customize by platform.
typedef long intptr_t;
typedef unsigned long uintptr_t;
typedef long scalar_t__; // Either arithmetic or pointer type.
/* By default, we understand bool (as a convenience). */
typedef int bool;
#define false 0
#define true 1

/* Forward declarations */

/* Type definitions */

/* Variables and functions */
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *, size_t);
int /*<<< orphan*/ stdout;
size_t fibonacci(size_t n, size_t fn1, size_t fn) {
  if (n <= 0) {
    return fn;
  } else {
    fprintf(stdout, "%zu\n", fn + fn1);
    return fibonacci(n - 1, fn, fn + fn1);
  }
}


x86 assembly (clang, -O0):
<fibonacci>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
mov    %rdx,-0x20(%rbp)
cmpq   $0x0,-0x10(%rbp)
ja     114c <fibonacci+0x2c>
mov    -0x20(%rbp),%rax
mov    %rax,-0x8(%rbp)
jmp    1186 <fibonacci+0x66>
mov    0x2e8d(%rip),%rax
mov    (%rax),%edi
mov    -0x20(%rbp),%rdx
add    -0x18(%rbp),%rdx
lea    0xe9c(%rip),%rsi
call   1030 <fprintf@plt>
mov    -0x10(%rbp),%rdi
sub    $0x1,%rdi
mov    -0x20(%rbp),%rsi
mov    -0x20(%rbp),%rdx
add    -0x18(%rbp),%rdx
call   1040 <fibonacci@plt>
mov    %rax,-0x8(%rbp)
mov    -0x8(%rbp),%rax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<fibonacci>:
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
mov    %rdx,%rbx
test   %rdi,%rdi
je     1161 <fibonacci+0x51>
mov    %rdi,%r14
mov    0x2eb5(%rip),%r12
lea    0xece(%rip),%r15
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax)
mov    %rbx,%r13
mov    (%r12),%edi
mov    %rsi,%rbx
add    %r13,%rbx
mov    %r15,%rsi
mov    %rbx,%rdx
call   1030 <fprintf@plt>
mov    %r13,%rsi
add    $0xffffffffffffffff,%r14
jne    1140 <fibonacci+0x30>
mov    %rbx,%rax
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@stdout = global i32 0
@.str = [5 x i8] c"%zu\0A\00"
define i64 @fibonacci(i64 %0, i64 %1, i64 %2) {
%4 = alloca i64
%5 = alloca i64
%6 = alloca i64
%7 = alloca i64
store i64 %0, i64* %5
store i64 %1, i64* %6
store i64 %2, i64* %7
%8 = load i64, i64* %5
%9 = icmp ule i64 %8, 0
br i1 %9, label %10, label %12
10: ; preds = %3
%11 = load i64, i64* %7
store i64 %11, i64* %4
br label %25
12: ; preds = %3
%13 = load i32, i32* @stdout
%14 = load i64, i64* %7
%15 = load i64, i64* %6
%16 = add i64 %14, %15
%17 = call i32 @fprintf(i32 %13, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0), i64 %16)
%18 = load i64, i64* %5
%19 = sub i64 %18, 1
%20 = load i64, i64* %7
%21 = load i64, i64* %7
%22 = load i64, i64* %6
%23 = add i64 %21, %22
%24 = call i64 @fibonacci(i64 %19, i64 %20, i64 %23)
store i64 %24, i64* %4
br label %25
25: ; preds = %12, %10
%26 = load i64, i64* %4
ret i64 %26
}

LLVM IR (-O2):
@stdout = global i32 0
@.str = [5 x i8] c"%zu\0A\00"
define i64 @fibonacci(i64 %0, i64 %1, i64 %2) {
%4 = icmp eq i64 %0, 0
br i1 %4, label %14, label %5
5: ; preds = %3, %5
%6 = phi i64 [ %10, %5 ], [ %2, %3 ]
%7 = phi i64 [ %6, %5 ], [ %1, %3 ]
%8 = phi i64 [ %12, %5 ], [ %0, %3 ]
%9 = load i32, i32* @stdout
%10 = add i64 %6, %7
%11 = tail call i32 @fprintf(i32 %9, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0), i64 %10)
%12 = add i64 %8, -1
%13 = icmp eq i64 %12, 0
br i1 %13, label %14, label %5
14: ; preds = %5, %3
%15 = phi i64 [ %2, %3 ], [ %10, %5 ]
ret i64 %15
}