#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 /*<<< orphan*/ *fopen(char *, char *);
scalar_t__ fscanf(int /*<<< orphan*/ *, char *, int *);
int readFile(char *filename, int *nums) {
  int num, tmp, i;
  FILE *f;
  f = fopen(filename, "r");
  for (i = 0; fscanf(f, "%d", &tmp) != EOF; i++) {
    nums[i] = tmp;
  }
  return i;
}


x86 assembly (clang, -O0):
<readFile>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    -0x8(%rbp),%rdi
lea    0xec5(%rip),%rsi
call   1040 <fopen@plt>
mov    %rax,-0x28(%rbp)
movl   $0x0,-0x1c(%rbp)
mov    -0x28(%rbp),%rdi
lea    0xeac(%rip),%rsi
lea    -0x18(%rbp),%rdx
call   1030 <fscanf@plt>
mov    0x2e82(%rip),%rcx
cmp    (%rcx),%rax
je     118b <readFile+0x6b>
mov    -0x18(%rbp),%edx
mov    -0x10(%rbp),%rax
movslq -0x1c(%rbp),%rcx
mov    %edx,(%rax,%rcx,4)
mov    -0x1c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x1c(%rbp)
jmp    114b <readFile+0x2b>
mov    -0x1c(%rbp),%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<readFile>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
mov    %rsi,%r14
lea    0xecb(%rip),%rsi
call   1040 <fopen@plt>
mov    %rax,%r15
lea    0xebe(%rip),%rsi
lea    0x4(%rsp),%rdx
mov    %rax,%rdi
call   1030 <fscanf@plt>
mov    0x2e90(%rip),%rbp
xor    %ebx,%ebx
cmp    0x0(%rbp),%rax
je     1190 <readFile+0x70>
xor    %ebx,%ebx
lea    0xe99(%rip),%r12
lea    0x4(%rsp),%r13
xchg   %ax,%ax
mov    0x4(%rsp),%eax
mov    %eax,(%r14,%rbx,4)
add    $0x1,%rbx
mov    %r15,%rdi
mov    %r12,%rsi
mov    %r13,%rdx
call   1030 <fscanf@plt>
cmp    0x0(%rbp),%rax
jne    1170 <readFile+0x50>
mov    %ebx,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

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

LLVM IR (-O2):
@.str = [2 x i8] c"r\00"
@.str.1 = [3 x i8] c"%d\00"
@EOF = global i64 0
define i32 @readFile(i8* nocapture %0, i32* nocapture writeonly %1) {
%3 = alloca i32
%4 = bitcast i32* %3 to i8*
%5 = tail call i32* @fopen(i8* %0, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
%6 = call i64 @fscanf(i32* %5, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %3)
%7 = load i64, i64* @EOF
%8 = icmp eq i64 %6, %7
br i1 %8, label %19, label %9
9: ; preds = %2, %9
%10 = phi i64 [ %13, %9 ], [ 0, %2 ]
%11 = load i32, i32* %3
%12 = getelementptr inbounds i32, i32* %1, i64 %10
store i32 %11, i32* %12
%13 = add nuw i64 %10, 1
%14 = call i64 @fscanf(i32* %5, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %3)
%15 = load i64, i64* @EOF
%16 = icmp eq i64 %14, %15
br i1 %16, label %17, label %9
17: ; preds = %9
%18 = trunc i64 %13 to i32
br label %19
19: ; preds = %17, %2
%20 = phi i32 [ 0, %2 ], [ %18, %17 ]
ret i32 %20
}