#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;
int EXIT_SUCCESS;
scalar_t__ clock();
int fib(int);
int /*<<< orphan*/ printf(char *, double);
int main(int argc, char *argv[]) {
  int N;
  int res;
  clock_t t_start, t_end;
  N = 44;
  t_start = clock();
  res = fib(N);
  t_end = clock();
  printf("res=%d\n", res);
  printf("Took %g s\n", (double)(t_end - t_start) / CLOCKS_PER_SEC);
  return EXIT_SUCCESS;
}


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   $0x2c,-0x14(%rbp)
mov    $0x0,%al
call   1030 <clock@plt>
mov    %rax,-0x20(%rbp)
mov    -0x14(%rbp),%edi
call   1050 <fib@plt>
mov    %eax,-0x18(%rbp)
mov    $0x0,%al
call   1030 <clock@plt>
mov    %rax,-0x28(%rbp)
cvtsi2sdl -0x18(%rbp),%xmm0
lea    0xe86(%rip),%rdi
call   1040 <printf@plt>
mov    -0x28(%rbp),%rax
sub    -0x20(%rbp),%rax
cvtsi2sd %rax,%xmm0
mov    0x2e55(%rip),%rax
divsd  (%rax),%xmm0
lea    0xe6a(%rip),%rdi
call   1040 <printf@plt>
mov    0x2e2e(%rip),%rax
mov    (%rax),%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r14
push   %rbx
xor    %eax,%eax
call   1030 <clock@plt>
mov    %rax,%r14
mov    $0x2c,%edi
call   1050 <fib@plt>
mov    %eax,%ebp
xor    %eax,%eax
call   1030 <clock@plt>
mov    %rax,%rbx
cvtsi2sd %ebp,%xmm0
lea    0xea1(%rip),%rdi
call   1040 <printf@plt>
sub    %r14,%rbx
xorps  %xmm0,%xmm0
cvtsi2sd %rbx,%xmm0
mov    0x2e72(%rip),%rax
divsd  (%rax),%xmm0
lea    0xe87(%rip),%rdi
call   1040 <printf@plt>
mov    0x2e4b(%rip),%rax
mov    (%rax),%eax
pop    %rbx
pop    %r14
pop    %rbp
ret

LLVM IR (-O0):
@.str = [8 x i8] c"res=%d\0A\00"
@.str.1 = [11 x i8] c"Took %g s\0A\00"
@CLOCKS_PER_SEC = global double 0.000000e+00
@EXIT_SUCCESS = global i32 0
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i32
%7 = alloca i32
%8 = alloca i64
%9 = alloca i64
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
store i32 44, i32* %6
%10 = call i64 (...) @clock()
store i64 %10, i64* %8
%11 = load i32, i32* %6
%12 = call i32 @fib(i32 %11)
store i32 %12, i32* %7
%13 = call i64 (...) @clock()
store i64 %13, i64* %9
%14 = load i32, i32* %7
%15 = sitofp i32 %14 to double
%16 = call i32 @printf(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str, i64 0, i64 0), double %15)
%17 = load i64, i64* %9
%18 = load i64, i64* %8
%19 = sub nsw i64 %17, %18
%20 = sitofp i64 %19 to double
%21 = load double, double* @CLOCKS_PER_SEC
%22 = fdiv double %20, %21
%23 = call i32 @printf(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.1, i64 0, i64 0), double %22)
%24 = load i32, i32* @EXIT_SUCCESS
ret i32 %24
}

LLVM IR (-O2):
@.str = [8 x i8] c"res=%d\0A\00"
@.str.1 = [11 x i8] c"Took %g s\0A\00"
@CLOCKS_PER_SEC = global double 0.000000e+00
@EXIT_SUCCESS = global i32 0
define i32 @main(i32 %0, i8** nocapture readnone %1) {
%3 = tail call i64 (...) @clock()
%4 = tail call i32 @fib(i32 44)
%5 = tail call i64 (...) @clock()
%6 = sitofp i32 %4 to double
%7 = tail call i32 @printf(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str, i64 0, i64 0), double %6)
%8 = sub nsw i64 %5, %3
%9 = sitofp i64 %8 to double
%10 = load double, double* @CLOCKS_PER_SEC
%11 = fdiv double %9, %10
%12 = tail call i32 @printf(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.1, i64 0, i64 0), double %11)
%13 = load i32, i32* @EXIT_SUCCESS
ret i32 %13
}