#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 fibonacci(int, int, int);
int /*<<< orphan*/ printf(char *, int, int);
int main(int argc, const char *argv[]) {
  int fn, f1, f0;
  int n = 15;
  {
    f1 = 1;
    f0 = 0;
    fn = fibonacci(n, f1, f0);
  }
  printf("F_%d = %d\n", n, fn);
  {
    if (n >= 2) {
      for (int i = 2; i <= n; i++) {
        fn = f1 + f0;
        f0 = f1;
        f1 = fn;
      }
    } else if (n == 1) {
      fn = f1;
    } else {
      fn = f0;
    }
  }
  printf("F_%d = %d\n", n, fn);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
movl   $0xf,-0x20(%rbp)
movl   $0x1,-0x18(%rbp)
movl   $0x0,-0x1c(%rbp)
mov    -0x20(%rbp),%edi
mov    -0x18(%rbp),%esi
mov    -0x1c(%rbp),%edx
call   1040 <fibonacci@plt>
mov    %eax,-0x14(%rbp)
mov    -0x20(%rbp),%esi
mov    -0x14(%rbp),%edx
lea    0xe97(%rip),%rdi
call   1030 <printf@plt>
cmpl   $0x2,-0x20(%rbp)
jl     11b3 <main+0x93>
movl   $0x2,-0x24(%rbp)
mov    -0x24(%rbp),%eax
cmp    -0x20(%rbp),%eax
jg     11ae <main+0x8e>
mov    -0x18(%rbp),%eax
add    -0x1c(%rbp),%eax
mov    %eax,-0x14(%rbp)
mov    -0x18(%rbp),%eax
mov    %eax,-0x1c(%rbp)
mov    -0x14(%rbp),%eax
mov    %eax,-0x18(%rbp)
mov    -0x24(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x24(%rbp)
jmp    117f <main+0x5f>
jmp    11d3 <main+0xb3>
cmpl   $0x1,-0x20(%rbp)
jne    11c8 <main+0xa8>
mov    -0x18(%rbp),%eax
mov    %eax,-0x14(%rbp)
jmp    11ce <main+0xae>
mov    -0x1c(%rbp),%eax
mov    %eax,-0x14(%rbp)
jmp    11d3 <main+0xb3>
mov    -0x20(%rbp),%esi
mov    -0x14(%rbp),%edx
lea    0xe20(%rip),%rdi
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbx
mov    $0xf,%edi
mov    $0x1,%esi
xor    %edx,%edx
call   1040 <fibonacci@plt>
lea    0xec7(%rip),%rbx
mov    %rbx,%rdi
mov    $0xf,%esi
mov    %eax,%edx
call   1030 <printf@plt>
mov    %rbx,%rdi
mov    $0xf,%esi
mov    $0x262,%edx
call   1030 <printf@plt>
xor    %eax,%eax
pop    %rbx
ret

LLVM IR (-O0):
@.str = [11 x i8] c"F_%d = %d\0A\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i32
%7 = alloca i32
%8 = alloca i32
%9 = alloca i32
%10 = alloca i32
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
store i32 15, i32* %9
store i32 1, i32* %7
store i32 0, i32* %8
%11 = load i32, i32* %9
%12 = load i32, i32* %7
%13 = load i32, i32* %8
%14 = call i32 @fibonacci(i32 %11, i32 %12, i32 %13)
store i32 %14, i32* %6
%15 = load i32, i32* %9
%16 = load i32, i32* %6
%17 = call i32 @printf(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str, i64 0, i64 0), i32 %15, i32 %16)
%18 = load i32, i32* %9
%19 = icmp sge i32 %18, 2
br i1 %19, label %20, label %35
20: ; preds = %2
store i32 2, i32* %10
br label %21
21: ; preds = %31, %20
%22 = load i32, i32* %10
%23 = load i32, i32* %9
%24 = icmp sle i32 %22, %23
br i1 %24, label %25, label %34
25: ; preds = %21
%26 = load i32, i32* %7
%27 = load i32, i32* %8
%28 = add nsw i32 %26, %27
store i32 %28, i32* %6
%29 = load i32, i32* %7
store i32 %29, i32* %8
%30 = load i32, i32* %6
store i32 %30, i32* %7
br label %31
31: ; preds = %25
%32 = load i32, i32* %10
%33 = add nsw i32 %32, 1
store i32 %33, i32* %10
br label %21
34: ; preds = %21
br label %43
35: ; preds = %2
%36 = load i32, i32* %9
%37 = icmp eq i32 %36, 1
br i1 %37, label %38, label %40
38: ; preds = %35
%39 = load i32, i32* %7
store i32 %39, i32* %6
br label %42
40: ; preds = %35
%41 = load i32, i32* %8
store i32 %41, i32* %6
br label %42
42: ; preds = %40, %38
br label %43
43: ; preds = %42, %34
%44 = load i32, i32* %9
%45 = load i32, i32* %6
%46 = call i32 @printf(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str, i64 0, i64 0), i32 %44, i32 %45)
ret i32 0
}

LLVM IR (-O2):
@.str = [11 x i8] c"F_%d = %d\0A\00"
define i32 @main(i32 %0, i8** nocapture readnone %1) {
%3 = tail call i32 @fibonacci(i32 15, i32 1, i32 0)
%4 = tail call i32 @printf(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str, i64 0, i64 0), i32 15, i32 %3)
%5 = tail call i32 @printf(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str, i64 0, i64 0), i32 15, i32 610)
ret i32 0
}