#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 *aml_array_int_1d_new(int, int /*<<< orphan*/);
int /*<<< orphan*/ fscanf(int /*<<< orphan*/ *, char *, int *);
int *aml_array_int_1d_load(FILE *file, int s1) {
  int i;
  int *arr = aml_array_int_1d_new(s1, 0);
  for (i = 0; i < s1; i++)
    fscanf(file, "%d", &arr[i]);
  return arr;
}


x86 assembly (clang, -O0):
<aml_array_int_1d_load>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
mov    -0xc(%rbp),%edi
xor    %esi,%esi
call   1030 <aml_array_int_1d_new@plt>
mov    %rax,-0x18(%rbp)
movl   $0x0,-0x10(%rbp)
mov    -0x10(%rbp),%eax
cmp    -0xc(%rbp),%eax
jge    117d <aml_array_int_1d_load+0x5d>
mov    -0x8(%rbp),%rdi
mov    -0x18(%rbp),%rdx
movslq -0x10(%rbp),%rax
shl    $0x2,%rax
add    %rax,%rdx
lea    0xe96(%rip),%rsi
call   1040 <fscanf@plt>
mov    -0x10(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x10(%rbp)
jmp    1144 <aml_array_int_1d_load+0x24>
mov    -0x18(%rbp),%rax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<aml_array_int_1d_load>:
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
mov    %esi,%ebx
mov    %rdi,%r12
mov    %esi,%edi
xor    %esi,%esi
call   1030 <aml_array_int_1d_new@plt>
mov    %rax,%r14
test   %ebx,%ebx
jle    1168 <aml_array_int_1d_load+0x48>
mov    %ebx,%r13d
lea    0xeb8(%rip),%r15
mov    %r14,%rbx
nopl   0x0(%rax,%rax,1)
mov    %r12,%rdi
mov    %r15,%rsi
mov    %rbx,%rdx
call   1040 <fscanf@plt>
add    $0x4,%rbx
add    $0xffffffffffffffff,%r13
jne    1150 <aml_array_int_1d_load+0x30>
mov    %r14,%rax
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
ret

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

LLVM IR (-O2):
@.str = [3 x i8] c"%d\00"
define i32* @aml_array_int_1d_load(i32* nocapture %0, i32 %1) {
%3 = tail call i32* @aml_array_int_1d_new(i32 %1, i32 0)
%4 = icmp sgt i32 %1, 0
br i1 %4, label %5, label %13
5: ; preds = %2
%6 = zext i32 %1 to i64
br label %7
7: ; preds = %5, %7
%8 = phi i64 [ 0, %5 ], [ %11, %7 ]
%9 = getelementptr inbounds i32, i32* %3, i64 %8
%10 = tail call i32 @fscanf(i32* %0, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32* %9)
%11 = add nuw nsw i64 %8, 1
%12 = icmp eq i64 %11, %6
br i1 %12, label %13, label %7
13: ; preds = %7, %2
ret i32* %3
}