#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 */
long fib_sum(long const);
int /*<<< orphan*/ printf(char *, float);
float timeit();
int main(int argc, char *argv[]) {
  float start = timeit();
  const long limit = 4000000;
  long ans = fib_sum(limit);
  float stop = timeit();
  printf("Answer: %ld\n", ans);
  printf("Time: %.8f\n", stop - start);
  return 0;
}


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)
mov    $0x0,%al
call   1050 <timeit@plt>
movss  %xmm0,-0x14(%rbp)
movq   $0x3d0900,-0x20(%rbp)
mov    $0x3d0900,%edi
call   1030 <fib_sum@plt>
mov    %rax,-0x28(%rbp)
mov    $0x0,%al
call   1050 <timeit@plt>
movss  %xmm0,-0x2c(%rbp)
cvtsi2ssq -0x28(%rbp),%xmm0
lea    0xe7f(%rip),%rdi
call   1040 <printf@plt>
movss  -0x2c(%rbp),%xmm0
subss  -0x14(%rbp),%xmm0
lea    0xe76(%rip),%rdi
call   1040 <printf@plt>
xor    %eax,%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbx
sub    $0x10,%rsp
xor    %eax,%eax
call   1050 <timeit@plt>
movss  %xmm0,0xc(%rsp)
mov    $0x3d0900,%edi
call   1030 <fib_sum@plt>
mov    %rax,%rbx
xor    %eax,%eax
call   1050 <timeit@plt>
movss  %xmm0,0x8(%rsp)
xorps  %xmm0,%xmm0
cvtsi2ss %rbx,%xmm0
lea    0xe95(%rip),%rdi
call   1040 <printf@plt>
movss  0x8(%rsp),%xmm0
subss  0xc(%rsp),%xmm0
lea    0xe8a(%rip),%rdi
call   1040 <printf@plt>
xor    %eax,%eax
add    $0x10,%rsp
pop    %rbx
ret

LLVM IR (-O0):
@.str = [13 x i8] c"Answer: %ld\0A\00"
@.str.1 = [12 x i8] c"Time: %.8f\0A\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca float
%7 = alloca i64
%8 = alloca i64
%9 = alloca float
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%10 = call float (...) @timeit()
store float %10, float* %6
store i64 4000000, i64* %7
%11 = call i64 @fib_sum(i64 4000000)
store i64 %11, i64* %8
%12 = call float (...) @timeit()
store float %12, float* %9
%13 = load i64, i64* %8
%14 = sitofp i64 %13 to float
%15 = call i32 @printf(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str, i64 0, i64 0), float %14)
%16 = load float, float* %9
%17 = load float, float* %6
%18 = fsub float %16, %17
%19 = call i32 @printf(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.1, i64 0, i64 0), float %18)
ret i32 0
}

LLVM IR (-O2):
@.str = [13 x i8] c"Answer: %ld\0A\00"
@.str.1 = [12 x i8] c"Time: %.8f\0A\00"
define i32 @main(i32 %0, i8** nocapture readnone %1) {
%3 = tail call float (...) @timeit()
%4 = tail call i64 @fib_sum(i64 4000000)
%5 = tail call float (...) @timeit()
%6 = sitofp i64 %4 to float
%7 = tail call i32 @printf(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str, i64 0, i64 0), float %6)
%8 = fsub float %5, %3
%9 = tail call i32 @printf(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.1, i64 0, i64 0), float %8)
ret i32 0
}