#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*/ printf(char *, int);
int fibonacci() {
  int f0 = 0, f1 = 1, fibo_sum, n = 1, i;
  for (i = 0; i < n && n < 21; i++) {
    if (i <= 1) {
      printf("%d\t", i);
      n++;
    } else {
      fibo_sum = f0 + f1;
      printf("%d\t", fibo_sum);
      f0 = f1;
      f1 = fibo_sum;
      n++;
    }
  }
  return (fibo_sum);
}


x86 assembly (clang, -O0):
<fibonacci>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
movl   $0x1,-0x8(%rbp)
movl   $0x1,-0x10(%rbp)
movl   $0x0,-0x14(%rbp)
mov    -0x14(%rbp),%ecx
xor    %eax,%eax
cmp    -0x10(%rbp),%ecx
mov    %al,-0x15(%rbp)
jge    114f <fibonacci+0x3f>
cmpl   $0x15,-0x10(%rbp)
setl   %al
mov    %al,-0x15(%rbp)
mov    -0x15(%rbp),%al
test   $0x1,%al
jne    115f <fibonacci+0x4f>
jmp    11c6 <fibonacci+0xb6>
cmpl   $0x1,-0x14(%rbp)
jg     1186 <fibonacci+0x76>
mov    -0x14(%rbp),%esi
lea    0xe8d(%rip),%rdi
call   1030 <printf@plt>
mov    -0x10(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x10(%rbp)
jmp    11b3 <fibonacci+0xa3>
mov    -0x4(%rbp),%eax
add    -0x8(%rbp),%eax
mov    %eax,-0xc(%rbp)
mov    -0xc(%rbp),%esi
lea    0xe67(%rip),%rdi
call   1030 <printf@plt>
mov    -0x8(%rbp),%eax
mov    %eax,-0x4(%rbp)
mov    -0xc(%rbp),%eax
mov    %eax,-0x8(%rbp)
mov    -0x10(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x10(%rbp)
jmp    11b8 <fibonacci+0xa8>
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    1134 <fibonacci+0x24>
mov    -0xc(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<fibonacci>:
push   %rbx
lea    0xee8(%rip),%rbx
mov    %rbx,%rdi
xor    %esi,%esi
call   1030 <printf@plt>
mov    %rbx,%rdi
mov    $0x1,%esi
call   1030 <printf@plt>
mov    %rbx,%rdi
mov    $0x1,%esi
call   1030 <printf@plt>
mov    %rbx,%rdi
mov    $0x2,%esi
call   1030 <printf@plt>
mov    %rbx,%rdi
mov    $0x3,%esi
call   1030 <printf@plt>
mov    %rbx,%rdi
mov    $0x5,%esi
call   1030 <printf@plt>
mov    %rbx,%rdi
mov    $0x8,%esi
call   1030 <printf@plt>
mov    %rbx,%rdi
mov    $0xd,%esi
call   1030 <printf@plt>
mov    %rbx,%rdi
mov    $0x15,%esi
call   1030 <printf@plt>
mov    %rbx,%rdi
mov    $0x22,%esi
call   1030 <printf@plt>
mov    %rbx,%rdi
mov    $0x37,%esi
call   1030 <printf@plt>
mov    %rbx,%rdi
mov    $0x59,%esi
call   1030 <printf@plt>
mov    %rbx,%rdi
mov    $0x90,%esi
call   1030 <printf@plt>
mov    %rbx,%rdi
mov    $0xe9,%esi
call   1030 <printf@plt>
mov    %rbx,%rdi
mov    $0x179,%esi
call   1030 <printf@plt>
mov    %rbx,%rdi
mov    $0x262,%esi
call   1030 <printf@plt>
mov    %rbx,%rdi
mov    $0x3db,%esi
call   1030 <printf@plt>
mov    %rbx,%rdi
mov    $0x63d,%esi
call   1030 <printf@plt>
mov    %rbx,%rdi
mov    $0xa18,%esi
call   1030 <printf@plt>
mov    %rbx,%rdi
mov    $0x1055,%esi
call   1030 <printf@plt>
mov    $0x1055,%eax
pop    %rbx
ret

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

LLVM IR (-O2):
@.str = [4 x i8] c"%d\09\00"
define i32 @fibonacci() {
%1 = tail call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i32 0)
%2 = tail call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i32 1)
%3 = tail call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i32 1)
%4 = tail call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i32 2)
%5 = tail call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i32 3)
%6 = tail call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i32 5)
%7 = tail call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i32 8)
%8 = tail call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i32 13)
%9 = tail call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i32 21)
%10 = tail call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i32 34)
%11 = tail call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i32 55)
%12 = tail call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i32 89)
%13 = tail call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i32 144)
%14 = tail call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i32 233)
%15 = tail call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i32 377)
%16 = tail call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i32 610)
%17 = tail call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i32 987)
%18 = tail call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i32 1597)
%19 = tail call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i32 2584)
%20 = tail call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i32 4181)
ret i32 4181
}