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

/* Variables and functions */
long long atoi(char *);
int /*<<< orphan*/ exit(int);
int /*<<< orphan*/ fclose(int /*<<< orphan*/ *);
scalar_t__ fgets(char *, int, int /*<<< orphan*/ *);
int fib(int, long long *, int *);
int /*<<< orphan*/ *fopen(char *, char *);
int /*<<< orphan*/ printf(char *, ...);
int /*<<< orphan*/ usage();
int main(int argc, char *argv[]) {
  if (argc < 2) {
    printf("Too few arguments...\n");
    usage();
    return -1;
  }
  FILE *cache;
  char value[128];
  long long cache_array[64];
  int i = 0;
  if ((cache = fopen(argv[1], "r")) == NULL) {
    printf("Cache not opened, exiting.\n");
    fclose(cache);
    exit(1);
  }
  while (fgets(value, 128, cache)) {
    cache_array[i] = atoi(value);
    i++;
  }
  i--;
  fclose(cache);
  printf("%i\n", fib(46, cache_array, &i));
  long long sum = 0;
  for (int j = 0; j <= 50; j++) {
    int val = cache_array[j];
    if (val % 2 == 0 && val <= 4000000000) {
      sum += val;
      printf("cache_array[%i]=%i\n", j, cache_array[j]);
    }
  }
  printf("The result is obviously: %i\n", sum);
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x2c0,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
cmpl   $0x2,-0x8(%rbp)
jge    11c4 <main+0x44>
lea    0xe56(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    $0x0,%al
call   1060 <usage@plt>
movl   $0xffffffff,-0x4(%rbp)
jmp    1370 <main+0x1f0>
movl   $0x0,-0x2a4(%rbp)
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
lea    0xe39(%rip),%rsi
call   1080 <fopen@plt>
mov    %rax,-0x18(%rbp)
cmp    $0x0,%rax
jne    1211 <main+0x91>
lea    0xe21(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    -0x18(%rbp),%rdi
call   1030 <fclose@plt>
mov    $0x1,%edi
call   10a0 <exit@plt>
jmp    1216 <main+0x96>
lea    -0xa0(%rbp),%rdi
mov    -0x18(%rbp),%rdx
mov    $0x80,%esi
call   1050 <fgets@plt>
cmp    $0x0,%rax
je     1267 <main+0xe7>
lea    -0xa0(%rbp),%rdi
call   1090 <atoi@plt>
mov    %rax,%rcx
movslq -0x2a4(%rbp),%rax
mov    %rcx,-0x2a0(%rbp,%rax,8)
ff
mov    -0x2a4(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x2a4(%rbp)
jmp    1216 <main+0x96>
mov    -0x2a4(%rbp),%eax
add    $0xffffffff,%eax
mov    %eax,-0x2a4(%rbp)
mov    -0x18(%rbp),%rdi
call   1030 <fclose@plt>
lea    -0x2a0(%rbp),%rsi
mov    $0x2e,%edi
lea    -0x2a4(%rbp),%rdx
call   1070 <fib@plt>
mov    %eax,%esi
lea    0xdc1(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
movq   $0x0,-0x2b0(%rbp)
movl   $0x0,-0x2b4(%rbp)
cmpl   $0x32,-0x2b4(%rbp)
jg     135b <main+0x1db>
movslq -0x2b4(%rbp),%rax
mov    -0x2a0(%rbp,%rax,8),%rax
ff
mov    %eax,-0x2b8(%rbp)
mov    -0x2b8(%rbp),%eax
mov    $0x2,%ecx
cltd
idiv   %ecx
cmp    $0x0,%edx
jne    1342 <main+0x1c2>
movslq -0x2b8(%rbp),%rax
mov    $0xee6b2800,%ecx
cmp    %rcx,%rax
jg     1342 <main+0x1c2>
movslq -0x2b8(%rbp),%rax
add    -0x2b0(%rbp),%rax
mov    %rax,-0x2b0(%rbp)
mov    -0x2b4(%rbp),%esi
movslq -0x2b4(%rbp),%rax
mov    -0x2a0(%rbp,%rax,8),%rdx
ff
lea    0xcf9(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
jmp    1347 <main+0x1c7>
mov    -0x2b4(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x2b4(%rbp)
jmp    12bc <main+0x13c>
mov    -0x2b0(%rbp),%rsi
lea    0xcdf(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    -0x4(%rbp),%eax
add    $0x2c0,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %rbx
sub    $0x298,%rsp
cmp    $0x1,%edi
jg     11bf <main+0x2f>
lea    0xea5(%rip),%rdi
call   1030 <puts@plt>
xor    %eax,%eax
call   1070 <usage@plt>
mov    $0xffffffff,%ebx
jmp    12be <main+0x12e>
mov    0x8(%rsi),%rdi
lea    0xe36(%rip),%rsi
call   1090 <fopen@plt>
test   %rax,%rax
je     12ce <main+0x13e>
mov    %rax,%r14
lea    0x10(%rsp),%rdi
mov    $0x80,%esi
mov    %rax,%rdx
call   1060 <fgets@plt>
mov    $0xffffffff,%ebp
test   %rax,%rax
je     1237 <main+0xa7>
lea    0x90(%rsp),%rbx
lea    0x10(%rsp),%r15
cs nopw 0x0(%rax,%rax,1)
xchg   %ax,%ax
mov    %r15,%rdi
call   10a0 <atoi@plt>
mov    %rax,(%rbx)
mov    %r15,%rdi
mov    $0x80,%esi
mov    %r14,%rdx
call   1060 <fgets@plt>
add    $0x1,%ebp
add    $0x8,%rbx
test   %rax,%rax
jne    1210 <main+0x80>
mov    %ebp,0xc(%rsp)
mov    %r14,%rdi
call   1040 <fclose@plt>
lea    0x90(%rsp),%rsi
lea    0xc(%rsp),%rdx
mov    $0x2e,%edi
call   1080 <fib@plt>
lea    0xdce(%rip),%rdi
mov    %eax,%esi
xor    %eax,%eax
call   1050 <printf@plt>
lea    0xd91(%rip),%r14
xor    %ebx,%ebx
xor    %r15d,%r15d
jmp    128a <main+0xfa>
nopl   0x0(%rax,%rax,1)
add    $0x1,%rbx
cmp    $0x33,%rbx
je     12ab <main+0x11b>
mov    0x90(%rsp,%rbx,8),%rdx
test   $0x1,%dl
jne    1280 <main+0xf0>
movslq %edx,%rax
add    %rax,%r15
mov    %r14,%rdi
mov    %ebx,%esi
xor    %eax,%eax
call   1050 <printf@plt>
jmp    1280 <main+0xf0>
lea    0xd64(%rip),%rdi
xor    %ebx,%ebx
mov    %r15,%rsi
xor    %eax,%eax
call   1050 <printf@plt>
mov    %ebx,%eax
add    $0x298,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret
lea    0xd5e(%rip),%rdi
call   1030 <puts@plt>
xor    %edi,%edi
call   1040 <fclose@plt>
mov    $0x1,%edi
call   10b0 <exit@plt>

LLVM IR (-O0):
@.str = [22 x i8] c"Too few arguments...\0A\00"
@.str.1 = [2 x i8] c"r\00"
@.str.2 = [28 x i8] c"Cache not opened, exiting.\0A\00"
@.str.3 = [4 x i8] c"%i\0A\00"
@.str.4 = [20 x i8] c"cache_array[%i]=%i\0A\00"
@.str.5 = [29 x i8] c"The result is obviously: %i\0A\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i32*
%7 = alloca [128 x i8]
%8 = alloca [64 x i64]
%9 = alloca i32
%10 = alloca i64
%11 = alloca i32
%12 = alloca i32
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%13 = load i32, i32* %4
%14 = icmp slt i32 %13, 2
br i1 %14, label %15, label %18
15: ; preds = %2
%16 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str, i64 0, i64 0))
%17 = call i32 (...) @usage()
store i32 -1, i32* %3
br label %85
18: ; preds = %2
store i32 0, i32* %9
%19 = load i8**, i8*** %5
%20 = getelementptr inbounds i8*, i8** %19, i64 1
%21 = load i8*, i8** %20
%22 = call i32* @fopen(i8* %21, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
store i32* %22, i32** %6
%23 = icmp eq i32* %22, null
br i1 %23, label %24, label %29
24: ; preds = %18
%25 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.str.2, i64 0, i64 0))
%26 = load i32*, i32** %6
%27 = call i32 @fclose(i32* %26)
%28 = call i32 @exit(i32 1)
unreachable
29: ; preds = %18
br label %30
30: ; preds = %35, %29
%31 = getelementptr inbounds [128 x i8], [128 x i8]* %7, i64 0, i64 0
%32 = load i32*, i32** %6
%33 = call i64 @fgets(i8* %31, i32 128, i32* %32)
%34 = icmp ne i64 %33, 0
br i1 %34, label %35, label %43
35: ; preds = %30
%36 = getelementptr inbounds [128 x i8], [128 x i8]* %7, i64 0, i64 0
%37 = call i64 @atoi(i8* %36)
%38 = load i32, i32* %9
%39 = sext i32 %38 to i64
%40 = getelementptr inbounds [64 x i64], [64 x i64]* %8, i64 0, i64 %39
store i64 %37, i64* %40
%41 = load i32, i32* %9
%42 = add nsw i32 %41, 1
store i32 %42, i32* %9
br label %30
43: ; preds = %30
%44 = load i32, i32* %9
%45 = add nsw i32 %44, -1
store i32 %45, i32* %9
%46 = load i32*, i32** %6
%47 = call i32 @fclose(i32* %46)
%48 = getelementptr inbounds [64 x i64], [64 x i64]* %8, i64 0, i64 0
%49 = call i32 @fib(i32 46, i64* %48, i32* %9)
%50 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.3, i64 0, i64 0), i32 %49)
store i64 0, i64* %10
store i32 0, i32* %11
br label %51
51: ; preds = %79, %43
%52 = load i32, i32* %11
%53 = icmp sle i32 %52, 50
br i1 %53, label %54, label %82
54: ; preds = %51
%55 = load i32, i32* %11
%56 = sext i32 %55 to i64
%57 = getelementptr inbounds [64 x i64], [64 x i64]* %8, i64 0, i64 %56
%58 = load i64, i64* %57
%59 = trunc i64 %58 to i32
store i32 %59, i32* %12
%60 = load i32, i32* %12
%61 = srem i32 %60, 2
%62 = icmp eq i32 %61, 0
br i1 %62, label %63, label %78
63: ; preds = %54
%64 = load i32, i32* %12
%65 = sext i32 %64 to i64
%66 = icmp sle i64 %65, 4000000000
br i1 %66, label %67, label %78
67: ; preds = %63
%68 = load i32, i32* %12
%69 = sext i32 %68 to i64
%70 = load i64, i64* %10
%71 = add nsw i64 %70, %69
store i64 %71, i64* %10
%72 = load i32, i32* %11
%73 = load i32, i32* %11
%74 = sext i32 %73 to i64
%75 = getelementptr inbounds [64 x i64], [64 x i64]* %8, i64 0, i64 %74
%76 = load i64, i64* %75
%77 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.4, i64 0, i64 0), i32 %72, i64 %76)
br label %78
78: ; preds = %67, %63, %54
br label %79
79: ; preds = %78
%80 = load i32, i32* %11
%81 = add nsw i32 %80, 1
store i32 %81, i32* %11
br label %51
82: ; preds = %51
%83 = load i64, i64* %10
%84 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([29 x i8], [29 x i8]* @.str.5, i64 0, i64 0), i64 %83)
br label %85
85: ; preds = %82, %15
%86 = load i32, i32* %3
ret i32 %86
}

LLVM IR (-O2):
@.str.1 = [2 x i8] c"r\00"
@.str.3 = [4 x i8] c"%i\0A\00"
@.str.4 = [20 x i8] c"cache_array[%i]=%i\0A\00"
@.str.5 = [29 x i8] c"The result is obviously: %i\0A\00"
@str = [27 x i8] c"Cache not opened, exiting.\00"
@str.6 = [21 x i8] c"Too few arguments...\00"
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = alloca [128 x i8]
%4 = alloca [64 x i64]
%5 = alloca i32
%6 = icmp slt i32 %0, 2
br i1 %6, label %7, label %10
7: ; preds = %2
%8 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([21 x i8], [21 x i8]* @str.6, i64 0, i64 0))
%9 = tail call i32 (...) @usage()
br label %58
10: ; preds = %2
%11 = getelementptr inbounds [128 x i8], [128 x i8]* %3, i64 0, i64 0
%12 = bitcast [64 x i64]* %4 to i8*
%13 = bitcast i32* %5 to i8*
%14 = getelementptr inbounds i8*, i8** %1, i64 1
%15 = load i8*, i8** %14
%16 = tail call i32* @fopen(i8* %15, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
%17 = icmp eq i32* %16, null
br i1 %17, label %21, label %18
18: ; preds = %10
%19 = call i64 @fgets(i8* %11, i32 128, i32* %16)
%20 = icmp eq i64 %19, 0
br i1 %20, label %33, label %25
21: ; preds = %10
%22 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([27 x i8], [27 x i8]* @str, i64 0, i64 0))
%23 = tail call i32 @fclose(i32* null)
%24 = tail call i32 @exit(i32 1)
unreachable
25: ; preds = %18, %25
%26 = phi i32 [ %30, %25 ], [ 0, %18 ]
%27 = call i64 @atoi(i8* %11)
%28 = zext i32 %26 to i64
%29 = getelementptr inbounds [64 x i64], [64 x i64]* %4, i64 0, i64 %28
store i64 %27, i64* %29
%30 = add nuw nsw i32 %26, 1
%31 = call i64 @fgets(i8* %11, i32 128, i32* %16)
%32 = icmp eq i64 %31, 0
br i1 %32, label %33, label %25
33: ; preds = %25, %18
%34 = phi i32 [ -1, %18 ], [ %26, %25 ]
store i32 %34, i32* %5
%35 = call i32 @fclose(i32* %16)
%36 = getelementptr inbounds [64 x i64], [64 x i64]* %4, i64 0, i64 0
%37 = call i32 @fib(i32 46, i64* %36, i32* %5)
%38 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str.3, i64 0, i64 0), i32 %37)
br label %41
39: ; preds = %54
%40 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([29 x i8], [29 x i8]* @.str.5, i64 0, i64 0), i64 %55)
br label %58
41: ; preds = %33, %54
%42 = phi i64 [ 0, %33 ], [ %56, %54 ]
%43 = phi i64 [ 0, %33 ], [ %55, %54 ]
%44 = getelementptr inbounds [64 x i64], [64 x i64]* %4, i64 0, i64 %42
%45 = load i64, i64* %44
%46 = and i64 %45, 1
%47 = icmp eq i64 %46, 0
br i1 %47, label %48, label %54
48: ; preds = %41
%49 = shl i64 %45, 32
%50 = ashr exact i64 %49, 32
%51 = add nsw i64 %50, %43
%52 = trunc i64 %42 to i32
%53 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([20 x i8], [20 x i8]* @.str.4, i64 0, i64 0), i32 %52, i64 %45)
br label %54
54: ; preds = %48, %41
%55 = phi i64 [ %51, %48 ], [ %43, %41 ]
%56 = add nuw nsw i64 %42, 1
%57 = icmp eq i64 %56, 51
br i1 %57, label %39, label %41
58: ; preds = %39, %7
%59 = phi i32 [ -1, %7 ], [ 0, %39 ]
ret i32 %59
}