#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_double_arr(double *x, int n, FILE *fp) {
  int i;
  for (i = 0; i < n; i++, x++) {
    if (hecmw_read_bin_value((unsigned char *)x, sizeof(double), fp) != 0)
      return -1;
  }
  return 0;
}


x86 assembly (clang, -O0):
<hecmw_read_bin_double_arr>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x10(%rbp)
mov    %esi,-0x14(%rbp)
mov    %rdx,-0x20(%rbp)
movl   $0x0,-0x24(%rbp)
mov    -0x24(%rbp),%eax
cmp    -0x14(%rbp),%eax
jge    117d <hecmw_read_bin_double_arr+0x6d>
mov    -0x10(%rbp),%rdi
mov    -0x20(%rbp),%rdx
mov    $0x8,%esi
call   1030 <hecmw_read_bin_value@plt>
cmp    $0x0,%rax
je     115e <hecmw_read_bin_double_arr+0x4e>
movl   $0xffffffff,-0x4(%rbp)
jmp    1184 <hecmw_read_bin_double_arr+0x74>
jmp    1163 <hecmw_read_bin_double_arr+0x53>
mov    -0x24(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x24(%rbp)
mov    -0x10(%rbp),%rax
add    $0x8,%rax
mov    %rax,-0x10(%rbp)
jmp    112a <hecmw_read_bin_double_arr+0x1a>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<hecmw_read_bin_double_arr>:
push   %rbp
push   %r15
push   %r14
push   %rbx
push   %rax
xor    %r14d,%r14d
test   %esi,%esi
jle    1156 <hecmw_read_bin_double_arr+0x46>
mov    %rdx,%r15
mov    %esi,%ebp
mov    %rdi,%rbx
cs nopw 0x0(%rax,%rax,1)
mov    %rbx,%rdi
mov    $0x8,%esi
mov    %r15,%rdx
call   1030 <hecmw_read_bin_value@plt>
test   %rax,%rax
jne    1150 <hecmw_read_bin_double_arr+0x40>
add    $0x8,%rbx
add    $0xffffffff,%ebp
jne    1130 <hecmw_read_bin_double_arr+0x20>
jmp    1156 <hecmw_read_bin_double_arr+0x46>
mov    $0xffffffff,%r14d
mov    %r14d,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
define i32 @hecmw_read_bin_double_arr(double* %0, i32 %1, i32* %2) {
%4 = alloca i32
%5 = alloca double*
%6 = alloca i32
%7 = alloca i32*
%8 = alloca i32
store double* %0, double** %5
store i32 %1, i32* %6
store i32* %2, i32** %7
store i32 0, i32* %8
br label %9
9: ; preds = %21, %3
%10 = load i32, i32* %8
%11 = load i32, i32* %6
%12 = icmp slt i32 %10, %11
br i1 %12, label %13, label %26
13: ; preds = %9
%14 = load double*, double** %5
%15 = bitcast double* %14 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 = %13
store i32 -1, i32* %4
br label %27
20: ; preds = %13
br label %21
21: ; preds = %20
%22 = load i32, i32* %8
%23 = add nsw i32 %22, 1
store i32 %23, i32* %8
%24 = load double*, double** %5
%25 = getelementptr inbounds double, double* %24, i32 1
store double* %25, double** %5
br label %9
26: ; preds = %9
store i32 0, i32* %4
br label %27
27: ; preds = %26, %19
%28 = load i32, i32* %4
ret i32 %28
}

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