#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 */
struct timeval {
  int dummy;
};

/* Variables and functions */
int fib_analytic(int);
int get_current_year();
int /*<<< orphan*/ gettimeofday(struct timeval *, int /*<<< orphan*/ *);
int /*<<< orphan*/ print_elapsed(struct timeval *, struct timeval *);
int /*<<< orphan*/ printf(char *, int, int);
int main() {
  struct timeval t1, t2;
  gettimeofday(&t1, NULL);
  int digits = get_current_year();
  int result = fib_analytic(digits);
  gettimeofday(&t2, NULL);
  printf("First Fibonacci term with %d digits is the %dth\n", digits, result);
  print_elapsed(&t1, &t2);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
lea    -0x8(%rbp),%rdi
xor    %eax,%eax
mov    %eax,%esi
call   1050 <gettimeofday@plt>
mov    $0x0,%al
call   1070 <get_current_year@plt>
mov    %eax,-0x14(%rbp)
mov    -0x14(%rbp),%edi
call   1030 <fib_analytic@plt>
mov    %eax,-0x18(%rbp)
lea    -0x10(%rbp),%rdi
xor    %eax,%eax
mov    %eax,%esi
call   1050 <gettimeofday@plt>
mov    -0x14(%rbp),%esi
mov    -0x18(%rbp),%edx
lea    0xe65(%rip),%rdi
call   1040 <printf@plt>
lea    -0x8(%rbp),%rdi
lea    -0x10(%rbp),%rsi
call   1060 <print_elapsed@plt>
xor    %eax,%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %rbx
sub    $0x18,%rsp
lea    0x10(%rsp),%r14
mov    %r14,%rdi
xor    %esi,%esi
call   1050 <gettimeofday@plt>
xor    %eax,%eax
call   1070 <get_current_year@plt>
mov    %eax,%ebp
mov    %eax,%edi
call   1030 <fib_analytic@plt>
mov    %eax,%ebx
lea    0x8(%rsp),%r15
mov    %r15,%rdi
xor    %esi,%esi
call   1050 <gettimeofday@plt>
lea    0xe6f(%rip),%rdi
mov    %ebp,%esi
mov    %ebx,%edx
call   1040 <printf@plt>
mov    %r14,%rdi
mov    %r15,%rsi
call   1060 <print_elapsed@plt>
xor    %eax,%eax
add    $0x18,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
%struct.timeval = type { i32 }
@.str = [49 x i8] c"First Fibonacci term with %d digits is the %dth\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca %struct.timeval
%3 = alloca %struct.timeval
%4 = alloca i32
%5 = alloca i32
store i32 0, i32* %1
%6 = call i32 @gettimeofday(%struct.timeval* %2, i32* null)
%7 = call i32 (...) @get_current_year()
store i32 %7, i32* %4
%8 = load i32, i32* %4
%9 = call i32 @fib_analytic(i32 %8)
store i32 %9, i32* %5
%10 = call i32 @gettimeofday(%struct.timeval* %3, i32* null)
%11 = load i32, i32* %4
%12 = load i32, i32* %5
%13 = call i32 @printf(i8* getelementptr inbounds ([49 x i8], [49 x i8]* @.str, i64 0, i64 0), i32 %11, i32 %12)
%14 = call i32 @print_elapsed(%struct.timeval* %2, %struct.timeval* %3)
ret i32 0
}

LLVM IR (-O2):
%struct.timeval = type { i32 }
@.str = [49 x i8] c"First Fibonacci term with %d digits is the %dth\0A\00"
define i32 @main() {
%1 = alloca %struct.timeval
%2 = alloca %struct.timeval
%3 = bitcast %struct.timeval* %1 to i8*
%4 = bitcast %struct.timeval* %2 to i8*
%5 = call i32 @gettimeofday(%struct.timeval* %1, i32* null)
%6 = tail call i32 (...) @get_current_year()
%7 = tail call i32 @fib_analytic(i32 %6)
%8 = call i32 @gettimeofday(%struct.timeval* %2, i32* null)
%9 = tail call i32 @printf(i8* getelementptr inbounds ([49 x i8], [49 x i8]* @.str, i64 0, i64 0), i32 %6, i32 %7)
%10 = call i32 @print_elapsed(%struct.timeval* %1, %struct.timeval* %2)
ret i32 0
}