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

/* Variables and functions */
double CLOCKS_PER_SEC;
scalar_t__ clock();
double difftime(int /*<<< orphan*/, int /*<<< orphan*/);
double fibonacci2(int);
int /*<<< orphan*/ printf(char *, double);
int /*<<< orphan*/ time(int /*<<< orphan*/ *);
int main() {
  double cpu_time;
  time_t t_start, t_end;
  clock_t st, ed;
  st = clock();
  t_start = time(NULL);
  printf("fibonacci(50): %ld\n", fibonacci2(50));
  ed = clock();
  t_end = time(NULL);
  cpu_time = (double)(ed - st) / CLOCKS_PER_SEC;
  printf("time: %fs\n", difftime(t_end, t_start));
  printf("cputime: %f\n", cpu_time);
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    $0x0,%al
call   1030 <clock@plt>
mov    %rax,-0x18(%rbp)
xor    %eax,%eax
mov    %eax,%edi
call   1070 <time@plt>
mov    %eax,-0xc(%rbp)
mov    $0x32,%edi
call   1060 <fibonacci2@plt>
lea    0xe80(%rip),%rdi
call   1040 <printf@plt>
mov    $0x0,%al
call   1030 <clock@plt>
mov    %rax,-0x20(%rbp)
xor    %eax,%eax
mov    %eax,%edi
call   1070 <time@plt>
mov    %eax,-0x10(%rbp)
mov    -0x20(%rbp),%rax
sub    -0x18(%rbp),%rax
cvtsi2sd %rax,%xmm0
mov    0x2e38(%rip),%rax
divsd  (%rax),%xmm0
movsd  %xmm0,-0x8(%rbp)
mov    -0x10(%rbp),%edi
mov    -0xc(%rbp),%esi
call   1050 <difftime@plt>
lea    0xe49(%rip),%rdi
call   1040 <printf@plt>
movsd  -0x8(%rbp),%xmm0
lea    0xe43(%rip),%rdi
call   1040 <printf@plt>
xor    %eax,%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r14
push   %rbx
sub    $0x10,%rsp
xor    %eax,%eax
call   1030 <clock@plt>
mov    %rax,%rbx
xor    %edi,%edi
call   1070 <time@plt>
mov    %eax,%r14d
mov    $0x32,%edi
call   1060 <fibonacci2@plt>
lea    0xe83(%rip),%rdi
call   1040 <printf@plt>
xor    %eax,%eax
call   1030 <clock@plt>
mov    %rax,%rbp
xor    %edi,%edi
call   1070 <time@plt>
sub    %rbx,%rbp
xorps  %xmm0,%xmm0
cvtsi2sd %rbp,%xmm0
mov    0x2e43(%rip),%rcx
divsd  (%rcx),%xmm0
movsd  %xmm0,0x8(%rsp)
mov    %eax,%edi
mov    %r14d,%esi
call   1050 <difftime@plt>
lea    0xe54(%rip),%rdi
call   1040 <printf@plt>
lea    0xe53(%rip),%rdi
movsd  0x8(%rsp),%xmm0
call   1040 <printf@plt>
xor    %eax,%eax
add    $0x10,%rsp
pop    %rbx
pop    %r14
pop    %rbp
ret

LLVM IR (-O0):
@.str = [20 x i8] c"fibonacci(50): %ld\0A\00"
@CLOCKS_PER_SEC = global double 0.000000e+00
@.str.1 = [11 x i8] c"time: %fs\0A\00"
@.str.2 = [13 x i8] c"cputime: %f\0A\00"
define i32 @main() {
%1 = alloca double
%2 = alloca i32
%3 = alloca i32
%4 = alloca i64
%5 = alloca i64
%6 = call i64 (...) @clock()
store i64 %6, i64* %4
%7 = call i32 @time(i32* null)
store i32 %7, i32* %2
%8 = call double @fibonacci2(i32 50)
%9 = call i32 @printf(i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str, i64 0, i64 0), double %8)
%10 = call i64 (...) @clock()
store i64 %10, i64* %5
%11 = call i32 @time(i32* null)
store i32 %11, i32* %3
%12 = load i64, i64* %5
%13 = load i64, i64* %4
%14 = sub nsw i64 %12, %13
%15 = sitofp i64 %14 to double
%16 = load double, double* @CLOCKS_PER_SEC
%17 = fdiv double %15, %16
store double %17, double* %1
%18 = load i32, i32* %3
%19 = load i32, i32* %2
%20 = call double @difftime(i32 %18, i32 %19)
%21 = call i32 @printf(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.1, i64 0, i64 0), double %20)
%22 = load double, double* %1
%23 = call i32 @printf(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.2, i64 0, i64 0), double %22)
ret i32 0
}

LLVM IR (-O2):
@.str = [20 x i8] c"fibonacci(50): %ld\0A\00"
@CLOCKS_PER_SEC = global double 0.000000e+00
@.str.1 = [11 x i8] c"time: %fs\0A\00"
@.str.2 = [13 x i8] c"cputime: %f\0A\00"
define i32 @main() {
%1 = tail call i64 (...) @clock()
%2 = tail call i32 @time(i32* null)
%3 = tail call double @fibonacci2(i32 50)
%4 = tail call i32 @printf(i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str, i64 0, i64 0), double %3)
%5 = tail call i64 (...) @clock()
%6 = tail call i32 @time(i32* null)
%7 = sub nsw i64 %5, %1
%8 = sitofp i64 %7 to double
%9 = load double, double* @CLOCKS_PER_SEC
%10 = fdiv double %8, %9
%11 = tail call double @difftime(i32 %6, i32 %2)
%12 = tail call i32 @printf(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.1, i64 0, i64 0), double %11)
%13 = tail call i32 @printf(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.2, i64 0, i64 0), double %10)
ret i32 0
}