#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 */
int atoi(char *);
int /*<<< orphan*/ fclose(int /*<<< orphan*/ *);
int /*<<< orphan*/ *fgets(char *, int, int /*<<< orphan*/ *);
int /*<<< orphan*/ *fopen(char *, char *);
void fill_arr(int *ar, char *filename) {
  FILE *fd;
  long long int i = 0;
  char number[50];
  if ((fd = fopen(filename, "r")) != NULL) {
    while (fgets(number, 50, fd) != NULL) {
      ar[i++] = atoi(number);
    }
    fclose(fd);
  }
}


x86 assembly (clang, -O0):
<fill_arr>:
push   %rbp
mov    %rsp,%rbp
sub    $0x60,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
movq   $0x0,-0x20(%rbp)
mov    -0x10(%rbp),%rdi
lea    0xe9d(%rip),%rsi
call   1050 <fopen@plt>
mov    %rax,-0x18(%rbp)
cmp    $0x0,%rax
je     11c6 <fill_arr+0x86>
jmp    117b <fill_arr+0x3b>
lea    -0x60(%rbp),%rdi
mov    -0x18(%rbp),%rdx
mov    $0x32,%esi
call   1040 <fgets@plt>
cmp    $0x0,%rax
je     11bd <fill_arr+0x7d>
lea    -0x60(%rbp),%rdi
call   1060 <atoi@plt>
mov    %eax,%edx
mov    -0x8(%rbp),%rax
mov    -0x20(%rbp),%rcx
mov    %rcx,%rsi
add    $0x1,%rsi
mov    %rsi,-0x20(%rbp)
mov    %edx,(%rax,%rcx,4)
jmp    117b <fill_arr+0x3b>
mov    -0x18(%rbp),%rdi
call   1030 <fclose@plt>
add    $0x60,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<fill_arr>:
push   %r15
push   %r14
push   %rbx
sub    $0x40,%rsp
mov    %rsi,%rax
mov    %rdi,%rbx
lea    0xeaa(%rip),%rsi
mov    %rax,%rdi
call   1050 <fopen@plt>
test   %rax,%rax
je     11ab <fill_arr+0x6b>
mov    %rax,%r14
mov    %rsp,%rdi
mov    $0x32,%esi
mov    %rax,%rdx
call   1040 <fgets@plt>
test   %rax,%rax
je     11a3 <fill_arr+0x63>
mov    %rsp,%r15
xchg   %ax,%ax
mov    %r15,%rdi
call   1060 <atoi@plt>
mov    %eax,(%rbx)
mov    %r15,%rdi
mov    $0x32,%esi
mov    %r14,%rdx
call   1040 <fgets@plt>
add    $0x4,%rbx
test   %rax,%rax
jne    1180 <fill_arr+0x40>
mov    %r14,%rdi
call   1030 <fclose@plt>
add    $0x40,%rsp
pop    %rbx
pop    %r14
pop    %r15
ret

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

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