#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 */
scalar_t__ EOF;
int atoi(char *);
int /*<<< orphan*/ fclose(int /*<<< orphan*/ *);
int /*<<< orphan*/ *fopen(char *, char *);
scalar_t__ fscanf(int /*<<< orphan*/ *, char *, char *);
void readNumbersFromFile(int size, int *numbers) {
  int i = 0;
  char filename[] = "../../numbers/numbers.txt";
  char str[1000];
  FILE *file;
  file = fopen(filename, "r");
  if (file) {
    while (i < size && fscanf(file, "%s", str) != EOF) {
      numbers[i] = atoi(str);
      i++;
    }
    fclose(file);
  }
}


x86 assembly (clang, -O0):
<readNumbersFromFile>:
push   %rbp
mov    %rsp,%rbp
sub    $0x430,%rsp
mov    %edi,-0x4(%rbp)
mov    %rsi,-0x10(%rbp)
movl   $0x0,-0x14(%rbp)
mov    0xea0(%rip),%rax
mov    %rax,-0x30(%rbp)
mov    0xe9d(%rip),%rax
mov    %rax,-0x28(%rbp)
mov    0xe9a(%rip),%rax
mov    %rax,-0x20(%rbp)
mov    0xe97(%rip),%ax
mov    %ax,-0x18(%rbp)
lea    -0x30(%rbp),%rdi
lea    0xe8a(%rip),%rsi
call   1050 <fopen@plt>
mov    %rax,-0x428(%rbp)
cmpq   $0x0,-0x428(%rbp)
je     1236 <readNumbersFromFile+0xf6>
jmp    11af <readNumbersFromFile+0x6f>
mov    -0x14(%rbp),%ecx
xor    %eax,%eax
cmp    -0x4(%rbp),%ecx
mov    %al,-0x429(%rbp)
jge    11f0 <readNumbersFromFile+0xb0>
mov    -0x428(%rbp),%rdi
lea    -0x420(%rbp),%rdx
lea    0xe44(%rip),%rsi
call   1040 <fscanf@plt>
mov    0x2e04(%rip),%rcx
cmp    (%rcx),%rax
setne  %al
mov    %al,-0x429(%rbp)
mov    -0x429(%rbp),%al
test   $0x1,%al
jne    1203 <readNumbersFromFile+0xc3>
jmp    122a <readNumbersFromFile+0xea>
lea    -0x420(%rbp),%rdi
call   1060 <atoi@plt>
mov    %eax,%edx
mov    -0x10(%rbp),%rax
movslq -0x14(%rbp),%rcx
mov    %edx,(%rax,%rcx,4)
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    11af <readNumbersFromFile+0x6f>
mov    -0x428(%rbp),%rdi
call   1030 <fclose@plt>
add    $0x430,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<readNumbersFromFile>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x408,%rsp
mov    %rsi,%r14
mov    %edi,%ebp
movups 0xead(%rip),%xmm0
movups %xmm0,0xa(%rsp)
movaps 0xe97(%rip),%xmm0
movaps %xmm0,(%rsp)
lea    0xea6(%rip),%rsi
mov    %rsp,%rdi
call   1050 <fopen@plt>
test   %rax,%rax
je     11d4 <readNumbersFromFile+0x94>
mov    %rax,%rbx
test   %ebp,%ebp
jle    11cc <readNumbersFromFile+0x8c>
mov    %ebp,%r13d
xor    %ebp,%ebp
lea    0x20(%rsp),%r12
mov    0x2e4f(%rip),%r15
nopl   0x0(%rax)
mov    %rbx,%rdi
lea    0xe72(%rip),%rsi
mov    %r12,%rdx
call   1040 <fscanf@plt>
cmp    (%r15),%rax
je     11cc <readNumbersFromFile+0x8c>
mov    %r12,%rdi
call   1060 <atoi@plt>
mov    %eax,(%r14,%rbp,4)
add    $0x1,%rbp
cmp    %rbp,%r13
jne    11a0 <readNumbersFromFile+0x60>
mov    %rbx,%rdi
call   1030 <fclose@plt>
add    $0x408,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@__const.readNumbersFromFile.filename = [26 x i8] c"../../numbers/numbers.txt\00"
@.str = [2 x i8] c"r\00"
@.str.1 = [3 x i8] c"%s\00"
@EOF = global i64 0
define void @readNumbersFromFile(i32 %0, i32* %1) {
%3 = alloca i32
%4 = alloca i32*
%5 = alloca i32
%6 = alloca [26 x i8]
%7 = alloca [1000 x i8]
%8 = alloca i32*
store i32 %0, i32* %3
store i32* %1, i32** %4
store i32 0, i32* %5
%9 = bitcast [26 x i8]* %6 to i8*
%10 = getelementptr inbounds [26 x i8], [26 x i8]* %6, i64 0, i64 0
%11 = call i32* @fopen(i8* %10, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
store i32* %11, i32** %8
%12 = load i32*, i32** %8
%13 = icmp ne i32* %12, null
br i1 %13, label %14, label %39
14: ; preds = %2
br label %15
15: ; preds = %27, %14
%16 = load i32, i32* %5
%17 = load i32, i32* %3
%18 = icmp slt i32 %16, %17
br i1 %18, label %19, label %25
19: ; preds = %15
%20 = load i32*, i32** %8
%21 = getelementptr inbounds [1000 x i8], [1000 x i8]* %7, i64 0, i64 0
%22 = call i64 @fscanf(i32* %20, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i8* %21)
%23 = load i64, i64* @EOF
%24 = icmp ne i64 %22, %23
br label %25
25: ; preds = %19, %15
%26 = phi i1 [ false, %15 ], [ %24, %19 ]
br i1 %26, label %27, label %36
27: ; preds = %25
%28 = getelementptr inbounds [1000 x i8], [1000 x i8]* %7, i64 0, i64 0
%29 = call i32 @atoi(i8* %28)
%30 = load i32*, i32** %4
%31 = load i32, i32* %5
%32 = sext i32 %31 to i64
%33 = getelementptr inbounds i32, i32* %30, i64 %32
store i32 %29, i32* %33
%34 = load i32, i32* %5
%35 = add nsw i32 %34, 1
store i32 %35, i32* %5
br label %15
36: ; preds = %25
%37 = load i32*, i32** %8
%38 = call i32 @fclose(i32* %37)
br label %39
39: ; preds = %36, %2
ret void
}

LLVM IR (-O2):
@__const.readNumbersFromFile.filename = [26 x i8] c"../../numbers/numbers.txt\00"
@.str = [2 x i8] c"r\00"
@.str.1 = [3 x i8] c"%s\00"
@EOF = global i64 0
define void @readNumbersFromFile(i32 %0, i32* nocapture writeonly %1) {
%3 = alloca [26 x i8]
%4 = alloca [1000 x i8]
%5 = getelementptr inbounds [26 x i8], [26 x i8]* %3, i64 0, i64 0
%6 = getelementptr inbounds [1000 x i8], [1000 x i8]* %4, i64 0, i64 0
%7 = call i32* @fopen(i8* %5, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
%8 = icmp eq i32* %7, null
br i1 %8, label %25, label %9
9: ; preds = %2
%10 = icmp sgt i32 %0, 0
br i1 %10, label %11, label %23
11: ; preds = %9
%12 = zext i32 %0 to i64
br label %13
13: ; preds = %11, %18
%14 = phi i64 [ 0, %11 ], [ %21, %18 ]
%15 = call i64 @fscanf(i32* %7, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i8* %6)
%16 = load i64, i64* @EOF
%17 = icmp eq i64 %15, %16
br i1 %17, label %23, label %18
18: ; preds = %13
%19 = call i32 @atoi(i8* %6)
%20 = getelementptr inbounds i32, i32* %1, i64 %14
store i32 %19, i32* %20
%21 = add nuw nsw i64 %14, 1
%22 = icmp eq i64 %21, %12
br i1 %22, label %23, label %13
23: ; preds = %13, %18, %9
%24 = call i32 @fclose(i32* %7)
br label %25
25: ; preds = %23, %2
ret void
}