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

/* Variables and functions */
int /*<<< orphan*/ exit(int);
int /*<<< orphan*/ fclose(int /*<<< orphan*/ *);
scalar_t__ fgets(char *, int, int /*<<< orphan*/ *);
int /*<<< orphan*/ *fopen(char const *, char *);
int /*<<< orphan*/ free(char *);
void *malloc(int);
int /*<<< orphan*/ printf(char *);
scalar_t__ strtoll(char *, int /*<<< orphan*/ *, int);
int64_t *getNumbers(const char *path) {
  FILE *file;
  if (!(file = fopen(path, "r"))) {
    printf("Couldn't open file\n");
    exit(1);
  }
  int64_t *nums = malloc(100 * sizeof(int64_t));
  char *line = malloc((50 + 2) * sizeof(char));
  for (int i = 0; fgets(line, 50 + 2, file); i++) {
    line[14] = '\0';
    nums[i] = (int64_t)strtoll(line, NULL, 10);
  }
  fclose(file);
  free(line);
  return nums;
}


x86 assembly (clang, -O0):
<getNumbers>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x8(%rbp)
mov    -0x8(%rbp),%rdi
lea    0xe69(%rip),%rsi
call   1090 <fopen@plt>
mov    %rax,-0x10(%rbp)
cmp    $0x0,%rax
jne    11c0 <getNumbers+0x40>
lea    0xe51(%rip),%rdi
call   1050 <printf@plt>
mov    $0x1,%edi
call   10a0 <exit@plt>
mov    $0x320,%edi
call   1080 <malloc@plt>
mov    %rax,-0x18(%rbp)
mov    $0x34,%edi
call   1080 <malloc@plt>
mov    %rax,-0x20(%rbp)
movl   $0x0,-0x24(%rbp)
mov    -0x20(%rbp),%rdi
mov    -0x10(%rbp),%rdx
mov    $0x34,%esi
call   1060 <fgets@plt>
cmp    $0x0,%rax
je     1236 <getNumbers+0xb6>
mov    -0x20(%rbp),%rax
movb   $0x0,0xe(%rax)
mov    -0x20(%rbp),%rdi
xor    %eax,%eax
mov    %eax,%esi
mov    $0xa,%edx
call   1070 <strtoll@plt>
mov    %rax,%rdx
mov    -0x18(%rbp),%rax
movslq -0x24(%rbp),%rcx
mov    %rdx,(%rax,%rcx,8)
mov    -0x24(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x24(%rbp)
jmp    11e3 <getNumbers+0x63>
mov    -0x10(%rbp),%rdi
call   1040 <fclose@plt>
mov    -0x20(%rbp),%rdi
call   1030 <free@plt>
mov    -0x18(%rbp),%rax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<getNumbers>:
push   %r15
push   %r14
push   %r12
push   %rbx
push   %rax
lea    0xe71(%rip),%rsi
call   1090 <fopen@plt>
test   %rax,%rax
je     1230 <getNumbers+0xb0>
mov    %rax,%r15
mov    $0x320,%edi
call   1080 <malloc@plt>
mov    %rax,%r14
mov    $0x34,%edi
call   1080 <malloc@plt>
mov    %rax,%r12
mov    %rax,%rdi
mov    $0x34,%esi
mov    %r15,%rdx
call   1060 <fgets@plt>
test   %rax,%rax
je     1211 <getNumbers+0x91>
mov    %r14,%rbx
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax)
movb   $0x0,0xe(%r12)
mov    %r12,%rdi
xor    %esi,%esi
mov    $0xa,%edx
call   1070 <strtoll@plt>
mov    %rax,(%rbx)
mov    %r12,%rdi
mov    $0x34,%esi
mov    %r15,%rdx
call   1060 <fgets@plt>
add    $0x8,%rbx
test   %rax,%rax
jne    11e0 <getNumbers+0x60>
mov    %r15,%rdi
call   1050 <fclose@plt>
mov    %r12,%rdi
call   1030 <free@plt>
mov    %r14,%rax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
ret
lea    0xdcb(%rip),%rdi
call   1040 <puts@plt>
mov    $0x1,%edi
call   10a0 <exit@plt>

LLVM IR (-O0):
@.str = [2 x i8] c"r\00"
@.str.1 = [20 x i8] c"Couldn't open file\0A\00"
define i64* @getNumbers(i8* %0) {
%2 = alloca i8*
%3 = alloca i32*
%4 = alloca i64*
%5 = alloca i8*
%6 = alloca i32
store i8* %0, i8** %2
%7 = load i8*, i8** %2
%8 = call i32* @fopen(i8* %7, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
store i32* %8, i32** %3
%9 = icmp ne i32* %8, null
br i1 %9, label %13, label %10
10: ; preds = %1
%11 = call i32 @printf(i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.1, i64 0, i64 0))
%12 = call i32 @exit(i32 1)
unreachable
13: ; preds = %1
%14 = call i8* @malloc(i32 800)
%15 = bitcast i8* %14 to i64*
store i64* %15, i64** %4
%16 = call i8* @malloc(i32 52)
store i8* %16, i8** %5
store i32 0, i32* %6
br label %17
17: ; preds = %31, %13
%18 = load i8*, i8** %5
%19 = load i32*, i32** %3
%20 = call i64 @fgets(i8* %18, i32 52, i32* %19)
%21 = icmp ne i64 %20, 0
br i1 %21, label %22, label %34
22: ; preds = %17
%23 = load i8*, i8** %5
%24 = getelementptr inbounds i8, i8* %23, i64 14
store i8 0, i8* %24
%25 = load i8*, i8** %5
%26 = call i64 @strtoll(i8* %25, i32* null, i32 10)
%27 = load i64*, i64** %4
%28 = load i32, i32* %6
%29 = sext i32 %28 to i64
%30 = getelementptr inbounds i64, i64* %27, i64 %29
store i64 %26, i64* %30
br label %31
31: ; preds = %22
%32 = load i32, i32* %6
%33 = add nsw i32 %32, 1
store i32 %33, i32* %6
br label %17
34: ; preds = %17
%35 = load i32*, i32** %3
%36 = call i32 @fclose(i32* %35)
%37 = load i8*, i8** %5
%38 = call i32 @free(i8* %37)
%39 = load i64*, i64** %4
ret i64* %39
}

LLVM IR (-O2):
@.str = [2 x i8] c"r\00"
@str = [19 x i8] c"Couldn't open file\00"
define noalias i64* @getNumbers(i8* nocapture %0) {
%2 = tail call i32* @fopen(i8* %0, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
%3 = icmp eq i32* %2, null
br i1 %3, label %4, label %7
4: ; preds = %1
%5 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([19 x i8], [19 x i8]* @str, i64 0, i64 0))
%6 = tail call i32 @exit(i32 1)
unreachable
7: ; preds = %1
%8 = tail call dereferenceable_or_null(800) i8* @malloc(i32 800)
%9 = bitcast i8* %8 to i64*
%10 = tail call dereferenceable_or_null(52) i8* @malloc(i32 52)
%11 = tail call i64 @fgets(i8* %10, i32 52, i32* %2)
%12 = icmp eq i64 %11, 0
br i1 %12, label %15, label %13
13: ; preds = %7
%14 = getelementptr inbounds i8, i8* %10, i64 14
br label %18
15: ; preds = %18, %7
%16 = tail call i32 @fclose(i32* %2)
%17 = tail call i32 @free(i8* %10)
ret i64* %9
18: ; preds = %13, %18
%19 = phi i64 [ 0, %13 ], [ %22, %18 ]
store i8 0, i8* %14
%20 = tail call i64 @strtoll(i8* nocapture %10, i32* null, i32 10)
%21 = getelementptr inbounds i64, i64* %9, i64 %19
store i64 %20, i64* %21
%22 = add nuw i64 %19, 1
%23 = tail call i64 @fgets(i8* %10, i32 52, i32* %2)
%24 = icmp eq i64 %23, 0
br i1 %24, label %15, label %18
}