#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__ hecmw_read_bin_value(unsigned char *, int, int /*<<< orphan*/ *);
int hecmw_read_bin_int_arr(int *x, int n, FILE *fp) {
  long xx;
  int i;
  for (i = 0; i < n; i++, x++) {
    if (hecmw_read_bin_value((unsigned char *)&xx, sizeof(long), fp) != 0) {
      return -1;
    }
    *x = xx;
  }
  return 0;
}


x86 assembly (clang, -O0):
<hecmw_read_bin_int_arr>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x10(%rbp)
mov    %esi,-0x14(%rbp)
mov    %rdx,-0x20(%rbp)
movl   $0x0,-0x2c(%rbp)
mov    -0x2c(%rbp),%eax
cmp    -0x14(%rbp),%eax
jge    1184 <hecmw_read_bin_int_arr+0x74>
lea    -0x28(%rbp),%rdi
mov    -0x20(%rbp),%rdx
mov    $0x8,%esi
call   1030 <hecmw_read_bin_value@plt>
cmp    $0x0,%rax
je     115e <hecmw_read_bin_int_arr+0x4e>
movl   $0xffffffff,-0x4(%rbp)
jmp    118b <hecmw_read_bin_int_arr+0x7b>
mov    -0x28(%rbp),%rax
mov    %eax,%ecx
mov    -0x10(%rbp),%rax
mov    %ecx,(%rax)
mov    -0x2c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x2c(%rbp)
mov    -0x10(%rbp),%rax
add    $0x4,%rax
mov    %rax,-0x10(%rbp)
jmp    112a <hecmw_read_bin_int_arr+0x1a>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<hecmw_read_bin_int_arr>:
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x10,%rsp
test   %esi,%esi
jle    1166 <hecmw_read_bin_int_arr+0x56>
mov    %rdx,%r14
mov    %rdi,%r12
mov    %esi,%r13d
xor    %ebx,%ebx
lea    0x8(%rsp),%r15
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax,%rax,1)
mov    %r15,%rdi
mov    $0x8,%esi
mov    %r14,%rdx
call   1030 <hecmw_read_bin_value@plt>
test   %rax,%rax
jne    116a <hecmw_read_bin_int_arr+0x5a>
mov    0x8(%rsp),%eax
mov    %eax,(%r12,%rbx,4)
add    $0x1,%rbx
cmp    %ebx,%r13d
jne    1140 <hecmw_read_bin_int_arr+0x30>
xor    %eax,%eax
jmp    116f <hecmw_read_bin_int_arr+0x5f>
mov    $0xffffffff,%eax
add    $0x10,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
define i32 @hecmw_read_bin_int_arr(i32* %0, i32 %1, i32* %2) {
%4 = alloca i32
%5 = alloca i32*
%6 = alloca i32
%7 = alloca i32*
%8 = alloca i64
%9 = alloca i32
store i32* %0, i32** %5
store i32 %1, i32* %6
store i32* %2, i32** %7
store i32 0, i32* %9
br label %10
10: ; preds = %24, %3
%11 = load i32, i32* %9
%12 = load i32, i32* %6
%13 = icmp slt i32 %11, %12
br i1 %13, label %14, label %29
14: ; preds = %10
%15 = bitcast i64* %8 to i8*
%16 = load i32*, i32** %7
%17 = call i64 @hecmw_read_bin_value(i8* %15, i32 8, i32* %16)
%18 = icmp ne i64 %17, 0
br i1 %18, label %19, label %20
19: ; preds = %14
store i32 -1, i32* %4
br label %30
20: ; preds = %14
%21 = load i64, i64* %8
%22 = trunc i64 %21 to i32
%23 = load i32*, i32** %5
store i32 %22, i32* %23
br label %24
24: ; preds = %20
%25 = load i32, i32* %9
%26 = add nsw i32 %25, 1
store i32 %26, i32* %9
%27 = load i32*, i32** %5
%28 = getelementptr inbounds i32, i32* %27, i32 1
store i32* %28, i32** %5
br label %10
29: ; preds = %10
store i32 0, i32* %4
br label %30
30: ; preds = %29, %19
%31 = load i32, i32* %4
ret i32 %31
}

LLVM IR (-O2):
define i32 @hecmw_read_bin_int_arr(i32* nocapture writeonly %0, i32 %1, i32* %2) {
%4 = alloca i64
%5 = bitcast i64* %4 to i8*
%6 = icmp sgt i32 %1, 0
br i1 %6, label %7, label %18
7: ; preds = %3, %12
%8 = phi i32 [ %15, %12 ], [ 0, %3 ]
%9 = phi i32* [ %16, %12 ], [ %0, %3 ]
%10 = call i64 @hecmw_read_bin_value(i8* %5, i32 8, i32* %2)
%11 = icmp eq i64 %10, 0
br i1 %11, label %12, label %18
12: ; preds = %7
%13 = load i64, i64* %4
%14 = trunc i64 %13 to i32
store i32 %14, i32* %9
%15 = add nuw nsw i32 %8, 1
%16 = getelementptr inbounds i32, i32* %9, i64 1
%17 = icmp eq i32 %15, %1
br i1 %17, label %18, label %7
18: ; preds = %7, %12, %3
%19 = phi i32 [ 0, %3 ], [ 0, %12 ], [ -1, %7 ]
ret i32 %19
}