#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 double clock_t;

/* Variables and functions */
float CLOCKS_PER_SEC;
double clock();
int /*<<< orphan*/ printf(char *, int, ...);
int main() {
  int fib[40];
  fib[0] = 0;
  fib[1] = 1;
  int i;
  clock_t t;
  t = clock();
  for (i = 2; i < 40; i++)
    fib[i] = fib[i - 1] + fib[i - 2];
  printf("%f time \n", t, ((float)t) / CLOCKS_PER_SEC);
  printf("%d\n", fib[40 - 1]);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0xc0,%rsp
movl   $0x0,-0x4(%rbp)
movl   $0x0,-0xb0(%rbp)
movl   $0x1,-0xac(%rbp)
mov    $0x0,%al
call   1030 <clock@plt>
movsd  %xmm0,-0xc0(%rbp)
ff
movl   $0x2,-0xb4(%rbp)
cmpl   $0x28,-0xb4(%rbp)
jge    11b2 <main+0x92>
mov    -0xb4(%rbp),%eax
sub    $0x1,%eax
cltq
mov    -0xb0(%rbp,%rax,4),%ecx
mov    -0xb4(%rbp),%eax
sub    $0x2,%eax
cltq
add    -0xb0(%rbp,%rax,4),%ecx
movslq -0xb4(%rbp),%rax
mov    %ecx,-0xb0(%rbp,%rax,4)
mov    -0xb4(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xb4(%rbp)
jmp    115f <main+0x3f>
cvttsd2si -0xc0(%rbp),%esi
ff
movsd  -0xc0(%rbp),%xmm0
ff
cvtsd2ss %xmm0,%xmm0
mov    0x2e1b(%rip),%rax
divss  (%rax),%xmm0
cvtss2sd %xmm0,%xmm0
lea    0xe24(%rip),%rdi
mov    $0x1,%al
call   1040 <printf@plt>
mov    -0x14(%rbp),%esi
lea    0xe1d(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
xor    %eax,%eax
add    $0xc0,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
sub    $0xa8,%rsp
movabs $0x100000000,%rax
mov    %rax,(%rsp)
xor    %eax,%eax
call   1030 <clock@plt>
movl   $0x1,0x8(%rsp)
mov    $0x1,%eax
mov    $0x6,%ecx
xchg   %ax,%ax
add    -0x14(%rsp,%rcx,4),%eax
mov    %eax,-0xc(%rsp,%rcx,4)
cmp    $0x2a,%rcx
je     117b <main+0x5b>
add    -0x10(%rsp,%rcx,4),%eax
mov    %eax,-0x8(%rsp,%rcx,4)
mov    -0xc(%rsp,%rcx,4),%edx
add    %eax,%edx
mov    %edx,-0x4(%rsp,%rcx,4)
add    %edx,%eax
mov    %eax,(%rsp,%rcx,4)
add    $0x4,%rcx
jmp    1150 <main+0x30>
cvttsd2si %xmm0,%esi
cvtsd2ss %xmm0,%xmm0
mov    0x2e5e(%rip),%rax
divss  (%rax),%xmm0
cvtss2sd %xmm0,%xmm0
lea    0xe67(%rip),%rdi
mov    $0x1,%al
call   1040 <printf@plt>
mov    0x9c(%rsp),%esi
lea    0xe5c(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
xor    %eax,%eax
add    $0xa8,%rsp
ret

LLVM IR (-O0):
@.str = [10 x i8] c"%f time \0A\00"
@CLOCKS_PER_SEC = global float 0.000000e+00
@.str.1 = [4 x i8] c"%d\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca [40 x i32]
%3 = alloca i32
%4 = alloca double
store i32 0, i32* %1
%5 = getelementptr inbounds [40 x i32], [40 x i32]* %2, i64 0, i64 0
store i32 0, i32* %5
%6 = getelementptr inbounds [40 x i32], [40 x i32]* %2, i64 0, i64 1
store i32 1, i32* %6
%7 = call double (...) @clock()
store double %7, double* %4
store i32 2, i32* %3
br label %8
8: ; preds = %26, %0
%9 = load i32, i32* %3
%10 = icmp slt i32 %9, 40
br i1 %10, label %11, label %29
11: ; preds = %8
%12 = load i32, i32* %3
%13 = sub nsw i32 %12, 1
%14 = sext i32 %13 to i64
%15 = getelementptr inbounds [40 x i32], [40 x i32]* %2, i64 0, i64 %14
%16 = load i32, i32* %15
%17 = load i32, i32* %3
%18 = sub nsw i32 %17, 2
%19 = sext i32 %18 to i64
%20 = getelementptr inbounds [40 x i32], [40 x i32]* %2, i64 0, i64 %19
%21 = load i32, i32* %20
%22 = add nsw i32 %16, %21
%23 = load i32, i32* %3
%24 = sext i32 %23 to i64
%25 = getelementptr inbounds [40 x i32], [40 x i32]* %2, i64 0, i64 %24
store i32 %22, i32* %25
br label %26
26: ; preds = %11
%27 = load i32, i32* %3
%28 = add nsw i32 %27, 1
store i32 %28, i32* %3
br label %8
29: ; preds = %8
%30 = load double, double* %4
%31 = fptosi double %30 to i32
%32 = load double, double* %4
%33 = fptrunc double %32 to float
%34 = load float, float* @CLOCKS_PER_SEC
%35 = fdiv float %33, %34
%36 = fpext float %35 to double
%37 = call i32 (i8*, i32, ...) @printf(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str, i64 0, i64 0), i32 %31, double %36)
%38 = getelementptr inbounds [40 x i32], [40 x i32]* %2, i64 0, i64 39
%39 = load i32, i32* %38
%40 = call i32 (i8*, i32, ...) @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i32 %39)
ret i32 0
}

LLVM IR (-O2):
@.str = [10 x i8] c"%f time \0A\00"
@CLOCKS_PER_SEC = global float 0.000000e+00
@.str.1 = [4 x i8] c"%d\0A\00"
define i32 @main() {
%1 = alloca [40 x i32]
%2 = bitcast [40 x i32]* %1 to i8*
%3 = getelementptr inbounds [40 x i32], [40 x i32]* %1, i64 0, i64 0
store i32 0, i32* %3
%4 = getelementptr inbounds [40 x i32], [40 x i32]* %1, i64 0, i64 1
store i32 1, i32* %4
%5 = tail call double (...) @clock()
%6 = getelementptr inbounds [40 x i32], [40 x i32]* %1, i64 0, i64 2
store i32 1, i32* %6
br label %7
7: ; preds = %18, %0
%8 = phi i64 [ 3, %0 ], [ %34, %18 ]
%9 = phi i32 [ 1, %0 ], [ %32, %18 ]
%10 = phi i64 [ 2, %0 ], [ %29, %18 ]
%11 = add nsw i64 %10, -1
%12 = getelementptr inbounds [40 x i32], [40 x i32]* %1, i64 0, i64 %11
%13 = load i32, i32* %12
%14 = add nsw i32 %13, %9
%15 = getelementptr inbounds [40 x i32], [40 x i32]* %1, i64 0, i64 %8
store i32 %14, i32* %15
%16 = add nuw nsw i64 %8, 1
%17 = icmp eq i64 %16, 40
br i1 %17, label %35, label %18
18: ; preds = %7
%19 = add nsw i64 %8, -1
%20 = getelementptr inbounds [40 x i32], [40 x i32]* %1, i64 0, i64 %19
%21 = load i32, i32* %20
%22 = add nsw i32 %21, %14
%23 = getelementptr inbounds [40 x i32], [40 x i32]* %1, i64 0, i64 %16
store i32 %22, i32* %23
%24 = add nuw nsw i64 %8, 2
%25 = getelementptr inbounds [40 x i32], [40 x i32]* %1, i64 0, i64 %8
%26 = load i32, i32* %25
%27 = add nsw i32 %26, %22
%28 = getelementptr inbounds [40 x i32], [40 x i32]* %1, i64 0, i64 %24
store i32 %27, i32* %28
%29 = add nuw nsw i64 %8, 3
%30 = getelementptr inbounds [40 x i32], [40 x i32]* %1, i64 0, i64 %16
%31 = load i32, i32* %30
%32 = add nsw i32 %31, %27
%33 = getelementptr inbounds [40 x i32], [40 x i32]* %1, i64 0, i64 %29
store i32 %32, i32* %33
%34 = add nuw nsw i64 %8, 4
br label %7
35: ; preds = %7
%36 = fptosi double %5 to i32
%37 = fptrunc double %5 to float
%38 = load float, float* @CLOCKS_PER_SEC
%39 = fdiv float %37, %38
%40 = fpext float %39 to double
%41 = tail call i32 (i8*, i32, ...) @printf(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str, i64 0, i64 0), i32 %36, double %40)
%42 = getelementptr inbounds [40 x i32], [40 x i32]* %1, i64 0, i64 39
%43 = load i32, i32* %42
%44 = tail call i32 (i8*, i32, ...) @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i32 %43)
ret i32 0
}