#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;
scalar_t__ fscanf(int /*<<< orphan*/ *, char *, int *);
void readArrayFile(FILE *stream, int arr[], int size) {
  int i, read;
  for (i = 0; i < size; ++i) {
    if (fscanf(stream, "%d", &read) == EOF)
      break;
    arr[i] = read;
  }
}


x86 assembly (clang, -O0):
<readArrayFile>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %edx,-0x14(%rbp)
movl   $0x0,-0x18(%rbp)
mov    -0x18(%rbp),%eax
cmp    -0x14(%rbp),%eax
jge    117b <readArrayFile+0x6b>
mov    -0x8(%rbp),%rdi
lea    0xebf(%rip),%rsi
lea    -0x1c(%rbp),%rdx
call   1030 <fscanf@plt>
mov    0x2e97(%rip),%rcx
cmp    (%rcx),%rax
jne    115f <readArrayFile+0x4f>
jmp    117b <readArrayFile+0x6b>
mov    -0x1c(%rbp),%edx
mov    -0x10(%rbp),%rax
movslq -0x18(%rbp),%rcx
mov    %edx,(%rax,%rcx,4)
mov    -0x18(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x18(%rbp)
jmp    112a <readArrayFile+0x1a>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<readArrayFile>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
test   %edx,%edx
jle    1168 <readArrayFile+0x58>
mov    %rsi,%r14
mov    %rdi,%r13
mov    %edx,%ebx
xor    %ebp,%ebp
lea    0x4(%rsp),%r12
mov    0x2eb3(%rip),%r15
cs nopw 0x0(%rax,%rax,1)
nop
mov    %r13,%rdi
lea    0xeb6(%rip),%rsi
mov    %r12,%rdx
call   1030 <fscanf@plt>
cmp    (%r15),%rax
je     1168 <readArrayFile+0x58>
mov    0x4(%rsp),%eax
mov    %eax,(%r14,%rbp,4)
add    $0x1,%rbp
cmp    %rbp,%rbx
jne    1140 <readArrayFile+0x30>
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

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

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