#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 */
typedef scalar_t__ clock_t;

/* Variables and functions */
double CLOCKS_PER_SEC;
scalar_t__ clock();
long fibonacci(int);
int /*<<< orphan*/ printf(char *, int, long);
int main(void) {
  int i;
  long l;
  clock_t begin, end;
  double time_spent;
  begin = clock();
  for (i = 0; i < 45; i++) {
    l = fibonacci(i);
    printf("%4d %20ld\n", i, l);
  }
  end = clock();
  time_spent = (double)(end - begin) / CLOCKS_PER_SEC;
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
movl   $0x0,-0x4(%rbp)
mov    $0x0,%al
call   1030 <clock@plt>
mov    %rax,-0x18(%rbp)
movl   $0x0,-0x8(%rbp)
cmpl   $0x2d,-0x8(%rbp)
jge    1188 <main+0x58>
mov    -0x8(%rbp),%edi
call   1050 <fibonacci@plt>
mov    %rax,-0x10(%rbp)
mov    -0x8(%rbp),%esi
mov    -0x10(%rbp),%rdx
lea    0xe8b(%rip),%rdi
call   1040 <printf@plt>
mov    -0x8(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x8(%rbp)
jmp    1151 <main+0x21>
mov    $0x0,%al
call   1030 <clock@plt>
mov    %rax,-0x20(%rbp)
mov    -0x20(%rbp),%rax
sub    -0x18(%rbp),%rax
cvtsi2sd %rax,%xmm0
mov    0x2e41(%rip),%rax
divsd  (%rax),%xmm0
movsd  %xmm0,-0x28(%rbp)
xor    %eax,%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r14
push   %rbx
push   %rax
xor    %ebx,%ebx
xor    %eax,%eax
call   1030 <clock@plt>
lea    0xebc(%rip),%r14
cs nopw 0x0(%rax,%rax,1)
xchg   %ax,%ax
mov    %ebx,%edi
call   1050 <fibonacci@plt>
mov    %r14,%rdi
mov    %ebx,%esi
mov    %rax,%rdx
call   1040 <printf@plt>
add    $0x1,%ebx
cmp    $0x2d,%ebx
jne    1150 <main+0x20>
xor    %eax,%eax
call   1030 <clock@plt>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
@.str = [11 x i8] c"%4d %20ld\0A\00"
@CLOCKS_PER_SEC = global double 0.000000e+00
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i64
%4 = alloca i64
%5 = alloca i64
%6 = alloca double
store i32 0, i32* %1
%7 = call i64 (...) @clock()
store i64 %7, i64* %4
store i32 0, i32* %2
br label %8
8: ; preds = %17, %0
%9 = load i32, i32* %2
%10 = icmp slt i32 %9, 45
br i1 %10, label %11, label %20
11: ; preds = %8
%12 = load i32, i32* %2
%13 = call i64 @fibonacci(i32 %12)
store i64 %13, i64* %3
%14 = load i32, i32* %2
%15 = load i64, i64* %3
%16 = call i32 @printf(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str, i64 0, i64 0), i32 %14, i64 %15)
br label %17
17: ; preds = %11
%18 = load i32, i32* %2
%19 = add nsw i32 %18, 1
store i32 %19, i32* %2
br label %8
20: ; preds = %8
%21 = call i64 (...) @clock()
store i64 %21, i64* %5
%22 = load i64, i64* %5
%23 = load i64, i64* %4
%24 = sub nsw i64 %22, %23
%25 = sitofp i64 %24 to double
%26 = load double, double* @CLOCKS_PER_SEC
%27 = fdiv double %25, %26
store double %27, double* %6
ret i32 0
}

LLVM IR (-O2):
@.str = [11 x i8] c"%4d %20ld\0A\00"
@CLOCKS_PER_SEC = global double 0.000000e+00
define i32 @main() {
%1 = tail call i64 (...) @clock()
br label %2
2: ; preds = %0, %2
%3 = phi i32 [ 0, %0 ], [ %6, %2 ]
%4 = tail call i64 @fibonacci(i32 %3)
%5 = tail call i32 @printf(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str, i64 0, i64 0), i32 %3, i64 %4)
%6 = add nuw nsw i32 %3, 1
%7 = icmp eq i32 %6, 45
br i1 %7, label %8, label %2
8: ; preds = %2
%9 = tail call i64 (...) @clock()
ret i32 0
}