#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 */
unsigned long long atoll(char *);
int /*<<< orphan*/ fgets(char *, int, int /*<<< orphan*/ *);
int /*<<< orphan*/ *fopen(char *, char *);
void read_file(unsigned long long *arr, int size, char *path) {
  FILE *fp = fopen(path, "r");
  char tmp[255];
  unsigned long i;
  for (i = 0; i < size; i++) {
    fgets(tmp, 255, fp);
    *(arr + i) = atoll(tmp);
  }
  return;
}


x86 assembly (clang, -O0):
<read_file>:
push   %rbp
mov    %rsp,%rbp
sub    $0x130,%rsp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
mov    %rdx,-0x18(%rbp)
mov    -0x18(%rbp),%rdi
lea    0xeaf(%rip),%rsi
call   1050 <fopen@plt>
mov    %rax,-0x20(%rbp)
movq   $0x0,-0x128(%rbp)
mov    -0x128(%rbp),%rax
movslq -0xc(%rbp),%rcx
cmp    %rcx,%rax
jae    11c3 <read_file+0x93>
lea    -0x120(%rbp),%rdi
mov    -0x20(%rbp),%rdx
mov    $0xff,%esi
call   1030 <fgets@plt>
lea    -0x120(%rbp),%rdi
call   1040 <atoll@plt>
mov    %rax,%rdx
mov    -0x8(%rbp),%rax
mov    -0x128(%rbp),%rcx
mov    %rdx,(%rax,%rcx,8)
mov    -0x128(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x128(%rbp)
jmp    1165 <read_file+0x35>
add    $0x130,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<read_file>:
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x100,%rsp
mov    %esi,%ebx
mov    %rdi,%r14
lea    0xeb4(%rip),%rsi
mov    %rdx,%rdi
call   1050 <fopen@plt>
test   %ebx,%ebx
je     1195 <read_file+0x65>
mov    %rax,%r15
movslq %ebx,%r12
xor    %ebx,%ebx
mov    %rsp,%r13
cs nopw 0x0(%rax,%rax,1)
nopl   (%rax)
mov    %r13,%rdi
mov    $0xff,%esi
mov    %r15,%rdx
call   1030 <fgets@plt>
mov    %r13,%rdi
call   1040 <atoll@plt>
mov    %rax,(%r14,%rbx,8)
add    $0x1,%rbx
cmp    %rbx,%r12
jne    1170 <read_file+0x40>
add    $0x100,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@.str = [2 x i8] c"r\00"
define void @read_file(i64* %0, i32 %1, i8* %2) {
%4 = alloca i64*
%5 = alloca i32
%6 = alloca i8*
%7 = alloca i32*
%8 = alloca [255 x i8]
%9 = alloca i64
store i64* %0, i64** %4
store i32 %1, i32* %5
store i8* %2, i8** %6
%10 = load i8*, i8** %6
%11 = call i32* @fopen(i8* %10, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
store i32* %11, i32** %7
store i64 0, i64* %9
br label %12
12: ; preds = %26, %3
%13 = load i64, i64* %9
%14 = load i32, i32* %5
%15 = sext i32 %14 to i64
%16 = icmp ult i64 %13, %15
br i1 %16, label %17, label %29
17: ; preds = %12
%18 = getelementptr inbounds [255 x i8], [255 x i8]* %8, i64 0, i64 0
%19 = load i32*, i32** %7
%20 = call i32 @fgets(i8* %18, i32 255, i32* %19)
%21 = getelementptr inbounds [255 x i8], [255 x i8]* %8, i64 0, i64 0
%22 = call i64 @atoll(i8* %21)
%23 = load i64*, i64** %4
%24 = load i64, i64* %9
%25 = getelementptr inbounds i64, i64* %23, i64 %24
store i64 %22, i64* %25
br label %26
26: ; preds = %17
%27 = load i64, i64* %9
%28 = add i64 %27, 1
store i64 %28, i64* %9
br label %12
29: ; preds = %12
ret void
}

LLVM IR (-O2):
@.str = [2 x i8] c"r\00"
define void @read_file(i64* nocapture writeonly %0, i32 %1, i8* nocapture %2) {
%4 = alloca [255 x i8]
%5 = tail call i32* @fopen(i8* %2, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
%6 = getelementptr inbounds [255 x i8], [255 x i8]* %4, i64 0, i64 0
%7 = icmp eq i32 %1, 0
br i1 %7, label %17, label %8
8: ; preds = %3
%9 = sext i32 %1 to i64
br label %10
10: ; preds = %8, %10
%11 = phi i64 [ %15, %10 ], [ 0, %8 ]
%12 = call i32 @fgets(i8* %6, i32 255, i32* %5)
%13 = call i64 @atoll(i8* %6)
%14 = getelementptr inbounds i64, i64* %0, i64 %11
store i64 %13, i64* %14
%15 = add nuw i64 %11, 1
%16 = icmp eq i64 %15, %9
br i1 %16, label %17, label %10
17: ; preds = %10, %3
ret void
}