#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;
scalar_t__ clock();
long fibonacci(long);
int /*<<< orphan*/ printf(char *, ...);
int /*<<< orphan*/ scanf(char *, long *);
int main() {
  long result, number;
  long counter;
  clock_t start, end;
  printf("Enter an integer number: ");
  scanf("%ld", &number);
  printf("Enter repeatitions: ");
  scanf("%ld", &counter);
  start = clock();
  while (counter-- > 0)
    result = fibonacci(number);
  end = clock();
  printf("Fibonacci(%ld) = %ld\n", number, result);
  printf("Calculation time %f\n", ((double)(end - start)) / CLOCKS_PER_SEC);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
movl   $0x0,-0x4(%rbp)
lea    0xeaa(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
lea    0xeb6(%rip),%rdi
lea    -0x18(%rbp),%rsi
call   1060 <scanf@plt>
lea    0xeaa(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
lea    0xe98(%rip),%rdi
lea    -0x20(%rbp),%rsi
call   1060 <scanf@plt>
mov    $0x0,%al
call   1030 <clock@plt>
mov    %rax,-0x28(%rbp)
mov    -0x20(%rbp),%rax
mov    %rax,%rcx
add    $0xffffffffffffffff,%rcx
mov    %rcx,-0x20(%rbp)
cmp    $0x0,%rax
jle    11c1 <main+0x81>
mov    -0x18(%rbp),%rdi
call   1050 <fibonacci@plt>
mov    %rax,-0x10(%rbp)
jmp    1196 <main+0x56>
mov    $0x0,%al
call   1030 <clock@plt>
mov    %rax,-0x30(%rbp)
mov    -0x18(%rbp),%rsi
mov    -0x10(%rbp),%rdx
lea    0xe58(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    -0x30(%rbp),%rax
sub    -0x28(%rbp),%rax
cvtsi2sd %rax,%xmm0
mov    0x2df2(%rip),%rax
divsd  (%rax),%xmm0
lea    0xe48(%rip),%rdi
mov    $0x1,%al
call   1040 <printf@plt>
xor    %eax,%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r15
push   %r14
push   %rbx
sub    $0x10,%rsp
lea    0xeb0(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
lea    0xebc(%rip),%rbx
lea    0x8(%rsp),%rsi
mov    %rbx,%rdi
call   1060 <scanf@plt>
lea    0xeac(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
mov    %rsp,%rsi
mov    %rbx,%rdi
call   1060 <scanf@plt>
xor    %eax,%eax
call   1030 <clock@plt>
mov    %rax,%r14
mov    (%rsp),%rax
lea    -0x1(%rax),%rcx
mov    %rcx,(%rsp)
test   %rax,%rax
jle    11c0 <main+0x80>
nop
mov    0x8(%rsp),%rdi
call   1050 <fibonacci@plt>
mov    %rax,%rbx
mov    (%rsp),%rax
lea    -0x1(%rax),%rcx
mov    %rcx,(%rsp)
test   %rax,%rax
jg     11a0 <main+0x60>
jmp    11c0 <main+0x80>
xor    %eax,%eax
call   1030 <clock@plt>
mov    %rax,%r15
mov    0x8(%rsp),%rsi
lea    0xe5d(%rip),%rdi
mov    %rbx,%rdx
xor    %eax,%eax
call   1040 <printf@plt>
sub    %r14,%r15
cvtsi2sd %r15,%xmm0
mov    0x2df9(%rip),%rax
divsd  (%rax),%xmm0
lea    0xe4f(%rip),%rdi
mov    $0x1,%al
call   1040 <printf@plt>
xor    %eax,%eax
add    $0x10,%rsp
pop    %rbx
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@.str = [26 x i8] c"Enter an integer number: \00"
@.str.1 = [4 x i8] c"%ld\00"
@.str.2 = [21 x i8] c"Enter repeatitions: \00"
@.str.3 = [22 x i8] c"Fibonacci(%ld) = %ld\0A\00"
@.str.4 = [21 x i8] c"Calculation time %f\0A\00"
@CLOCKS_PER_SEC = global double 0.000000e+00
define i32 @main() {
%1 = alloca i32
%2 = alloca i64
%3 = alloca i64
%4 = alloca i64
%5 = alloca i64
%6 = alloca i64
store i32 0, i32* %1
%7 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str, i64 0, i64 0))
%8 = call i32 @scanf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i64* %3)
%9 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.2, i64 0, i64 0))
%10 = call i32 @scanf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i64* %4)
%11 = call i64 (...) @clock()
store i64 %11, i64* %5
br label %12
12: ; preds = %16, %0
%13 = load i64, i64* %4
%14 = add nsw i64 %13, -1
store i64 %14, i64* %4
%15 = icmp sgt i64 %13, 0
br i1 %15, label %16, label %19
16: ; preds = %12
%17 = load i64, i64* %3
%18 = call i64 @fibonacci(i64 %17)
store i64 %18, i64* %2
br label %12
19: ; preds = %12
%20 = call i64 (...) @clock()
store i64 %20, i64* %6
%21 = load i64, i64* %3
%22 = load i64, i64* %2
%23 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.3, i64 0, i64 0), i64 %21, i64 %22)
%24 = load i64, i64* %6
%25 = load i64, i64* %5
%26 = sub nsw i64 %24, %25
%27 = sitofp i64 %26 to double
%28 = load double, double* @CLOCKS_PER_SEC
%29 = fdiv double %27, %28
%30 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.4, i64 0, i64 0), double %29)
ret i32 0
}

LLVM IR (-O2):
@.str = [26 x i8] c"Enter an integer number: \00"
@.str.1 = [4 x i8] c"%ld\00"
@.str.2 = [21 x i8] c"Enter repeatitions: \00"
@.str.3 = [22 x i8] c"Fibonacci(%ld) = %ld\0A\00"
@.str.4 = [21 x i8] c"Calculation time %f\0A\00"
@CLOCKS_PER_SEC = global double 0.000000e+00
define i32 @main() {
%1 = alloca i64
%2 = alloca i64
%3 = bitcast i64* %1 to i8*
%4 = bitcast i64* %2 to i8*
%5 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([26 x i8], [26 x i8]* @.str, i64 0, i64 0))
%6 = call i32 @scanf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i64* %1)
%7 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([21 x i8], [21 x i8]* @.str.2, i64 0, i64 0))
%8 = call i32 @scanf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i64* %2)
%9 = call i64 (...) @clock()
%10 = load i64, i64* %2
%11 = add nsw i64 %10, -1
store i64 %11, i64* %2
%12 = icmp sgt i64 %10, 0
br i1 %12, label %13, label %19
13: ; preds = %0, %13
%14 = load i64, i64* %1
%15 = call i64 @fibonacci(i64 %14)
%16 = load i64, i64* %2
%17 = add nsw i64 %16, -1
store i64 %17, i64* %2
%18 = icmp sgt i64 %16, 0
br i1 %18, label %13, label %19
19: ; preds = %13, %0
%20 = phi i64 [ undef, %0 ], [ %15, %13 ]
%21 = call i64 (...) @clock()
%22 = load i64, i64* %1
%23 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([22 x i8], [22 x i8]* @.str.3, i64 0, i64 0), i64 %22, i64 %20)
%24 = sub nsw i64 %21, %9
%25 = sitofp i64 %24 to double
%26 = load double, double* @CLOCKS_PER_SEC
%27 = fdiv double %25, %26
%28 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([21 x i8], [21 x i8]* @.str.4, i64 0, i64 0), double %27)
ret i32 0
}