#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;
typedef int /*<<< orphan*/ FILE;

/* Variables and functions */
scalar_t__ clock();
int /*<<< orphan*/ fclose(int /*<<< orphan*/ *);
int /*<<< orphan*/ fibo(int);
int /*<<< orphan*/ *fopen(char *, char *);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/ *, char *, int, ...);
int main(void) {
  clock_t start, diff;
  start = clock();
  FILE *file;
  file = fopen("fiboc.txt", "w+");
  int counter = 0;
  for (counter; counter < 1500; counter++) {
    fprintf(file, "number%d =%lld\n", counter + 1, fibo(counter));
  }
  diff = clock() - start;
  fprintf(file, "Time is equal=%ld\n", (diff));
  fclose(file);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
movl   $0x0,-0x4(%rbp)
mov    $0x0,%al
call   1030 <clock@plt>
mov    %rax,-0x10(%rbp)
lea    0xe8f(%rip),%rdi
lea    0xe92(%rip),%rsi
call   1070 <fopen@plt>
mov    %rax,-0x20(%rbp)
movl   $0x0,-0x24(%rbp)
cmpl   $0x5dc,-0x24(%rbp)
jge    11d3 <main+0x83>
mov    -0x20(%rbp),%rax
mov    %rax,-0x30(%rbp)
mov    -0x24(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x28(%rbp)
mov    -0x24(%rbp),%edi
call   1060 <fibo@plt>
mov    -0x30(%rbp),%rdi
mov    -0x28(%rbp),%edx
mov    %eax,%ecx
lea    0xe4f(%rip),%rsi
mov    $0x0,%al
call   1050 <fprintf@plt>
mov    -0x24(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x24(%rbp)
jmp    1188 <main+0x38>
mov    $0x0,%al
call   1030 <clock@plt>
sub    -0x10(%rbp),%rax
mov    %rax,-0x18(%rbp)
mov    -0x20(%rbp),%rdi
mov    -0x18(%rbp),%rax
mov    %eax,%edx
lea    0xe2a(%rip),%rsi
mov    $0x0,%al
call   1050 <fprintf@plt>
mov    -0x20(%rbp),%rdi
call   1040 <fclose@plt>
xor    %eax,%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %rbx
push   %rax
xor    %eax,%eax
call   1030 <clock@plt>
mov    %rax,%r14
lea    0xe98(%rip),%rdi
lea    0xe9b(%rip),%rsi
call   1070 <fopen@plt>
mov    %rax,%rbx
lea    0xe8f(%rip),%r15
xor    %edi,%edi
lea    0x1(%rdi),%ebp
call   1060 <fibo@plt>
mov    %rbx,%rdi
mov    %r15,%rsi
mov    %ebp,%edx
mov    %eax,%ecx
xor    %eax,%eax
call   1050 <fprintf@plt>
mov    %ebp,%edi
cmp    $0x5dc,%ebp
jne    1180 <main+0x30>
xor    %eax,%eax
call   1030 <clock@plt>
sub    %r14d,%eax
lea    0xe69(%rip),%rsi
mov    %rbx,%rdi
mov    %eax,%edx
xor    %eax,%eax
call   1050 <fprintf@plt>
mov    %rbx,%rdi
call   1040 <fclose@plt>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [10 x i8] c"fiboc.txt\00"
@.str.1 = [3 x i8] c"w+\00"
@.str.2 = [16 x i8] c"number%d =%lld\0A\00"
@.str.3 = [19 x i8] c"Time is equal=%ld\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i64
%3 = alloca i64
%4 = alloca i32*
%5 = alloca i32
store i32 0, i32* %1
%6 = call i64 (...) @clock()
store i64 %6, i64* %2
%7 = call i32* @fopen(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0))
store i32* %7, i32** %4
store i32 0, i32* %5
%8 = load i32, i32* %5
br label %9
9: ; preds = %19, %0
%10 = load i32, i32* %5
%11 = icmp slt i32 %10, 1500
br i1 %11, label %12, label %22
12: ; preds = %9
%13 = load i32*, i32** %4
%14 = load i32, i32* %5
%15 = add nsw i32 %14, 1
%16 = load i32, i32* %5
%17 = call i32 @fibo(i32 %16)
%18 = call i32 (i32*, i8*, i32, ...) @fprintf(i32* %13, i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.2, i64 0, i64 0), i32 %15, i32 %17)
br label %19
19: ; preds = %12
%20 = load i32, i32* %5
%21 = add nsw i32 %20, 1
store i32 %21, i32* %5
br label %9
22: ; preds = %9
%23 = call i64 (...) @clock()
%24 = load i64, i64* %2
%25 = sub nsw i64 %23, %24
store i64 %25, i64* %3
%26 = load i32*, i32** %4
%27 = load i64, i64* %3
%28 = trunc i64 %27 to i32
%29 = call i32 (i32*, i8*, i32, ...) @fprintf(i32* %26, i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.3, i64 0, i64 0), i32 %28)
%30 = load i32*, i32** %4
%31 = call i32 @fclose(i32* %30)
ret i32 0
}

LLVM IR (-O2):
@.str = [10 x i8] c"fiboc.txt\00"
@.str.1 = [3 x i8] c"w+\00"
@.str.2 = [16 x i8] c"number%d =%lld\0A\00"
@.str.3 = [19 x i8] c"Time is equal=%ld\0A\00"
define i32 @main() {
%1 = tail call i64 (...) @clock()
%2 = tail call i32* @fopen(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0))
br label %3
3: ; preds = %0, %3
%4 = phi i32 [ 0, %0 ], [ %5, %3 ]
%5 = add nuw nsw i32 %4, 1
%6 = tail call i32 @fibo(i32 %4)
%7 = tail call i32 (i32*, i8*, i32, ...) @fprintf(i32* %2, i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.2, i64 0, i64 0), i32 %5, i32 %6)
%8 = icmp eq i32 %5, 1500
br i1 %8, label %9, label %3
9: ; preds = %3
%10 = tail call i64 (...) @clock()
%11 = sub nsw i64 %10, %1
%12 = trunc i64 %11 to i32
%13 = tail call i32 (i32*, i8*, i32, ...) @fprintf(i32* %2, i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.3, i64 0, i64 0), i32 %12)
%14 = tail call i32 @fclose(i32* %2)
ret i32 0
}