#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 float uint32_t;
typedef int /*<<< orphan*/ FILE;

/* Variables and functions */
int fread(float *, int, int, int /*<<< orphan*/ *);
int /*<<< orphan*/ memset(float *, int /*<<< orphan*/, int);
void read_curveset(FILE *f, float *curve, uint32_t *hist) {
  int r = fread(curve, 1, 3 * 0x10000 * sizeof(float), f);
  if (r != 3 * 0x10000 * sizeof(float)) {
    memset(curve, 0, 3 * 0x10000 * sizeof(float));
  } else {
    r = fread(hist, 1, 3 * 0x10000 * sizeof(uint32_t), f);
    if (r != 3 * 0x10000 * sizeof(uint32_t)) {
      memset(curve, 0, 3 * 0x10000 * sizeof(float));
      memset(hist, 0, 3 * 0x10000 * sizeof(uint32_t));
    }
  }
}


x86 assembly (clang, -O0):
<read_curveset>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
mov    -0x10(%rbp),%rdi
mov    -0x8(%rbp),%rcx
mov    $0x1,%esi
mov    $0xc0000,%edx
call   1030 <fread@plt>
mov    %eax,-0x1c(%rbp)
movslq -0x1c(%rbp),%rax
cmp    $0xc0000,%rax
je     1173 <read_curveset+0x53>
mov    -0x10(%rbp),%rdi
xor    %esi,%esi
mov    $0xc0000,%edx
call   1040 <memset@plt>
jmp    11c2 <read_curveset+0xa2>
mov    -0x18(%rbp),%rdi
mov    -0x8(%rbp),%rcx
mov    $0x1,%esi
mov    $0xc0000,%edx
call   1030 <fread@plt>
mov    %eax,-0x1c(%rbp)
movslq -0x1c(%rbp),%rax
cmp    $0xc0000,%rax
je     11bd <read_curveset+0x9d>
mov    -0x10(%rbp),%rdi
xor    %esi,%esi
mov    $0xc0000,%edx
call   1040 <memset@plt>
mov    -0x18(%rbp),%rdi
xor    %esi,%esi
mov    $0xc0000,%edx
call   1040 <memset@plt>
jmp    11c2 <read_curveset+0xa2>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<read_curveset>:
push   %r15
push   %r14
push   %rbx
mov    %rdx,%r14
mov    %rsi,%r15
mov    %rdi,%rbx
mov    %rsi,%rdi
mov    $0x1,%esi
mov    $0xc0000,%edx
mov    %rbx,%rcx
call   1030 <fread@plt>
cmp    $0xc0000,%eax
jne    116c <read_curveset+0x4c>
mov    %r14,%rdi
mov    $0x1,%esi
mov    $0xc0000,%edx
mov    %rbx,%rcx
call   1030 <fread@plt>
cmp    $0xc0000,%eax
jne    1171 <read_curveset+0x51>
pop    %rbx
pop    %r14
pop    %r15
ret
mov    %r15,%r14
jmp    1180 <read_curveset+0x60>
mov    %r15,%rdi
xor    %esi,%esi
mov    $0xc0000,%edx
call   1040 <memset@plt>
mov    %r14,%rdi
xor    %esi,%esi
mov    $0xc0000,%edx
pop    %rbx
pop    %r14
pop    %r15
jmp    1040 <memset@plt>

LLVM IR (-O0):
define void @read_curveset(i32* %0, float* %1, float* %2) {
%4 = alloca i32*
%5 = alloca float*
%6 = alloca float*
%7 = alloca i32
store i32* %0, i32** %4
store float* %1, float** %5
store float* %2, float** %6
%8 = load float*, float** %5
%9 = load i32*, i32** %4
%10 = call i32 @fread(float* %8, i32 1, i32 786432, i32* %9)
store i32 %10, i32* %7
%11 = load i32, i32* %7
%12 = sext i32 %11 to i64
%13 = icmp ne i64 %12, 786432
br i1 %13, label %14, label %17
14: ; preds = %3
%15 = load float*, float** %5
%16 = call i32 @memset(float* %15, i32 0, i32 786432)
br label %30
17: ; preds = %3
%18 = load float*, float** %6
%19 = load i32*, i32** %4
%20 = call i32 @fread(float* %18, i32 1, i32 786432, i32* %19)
store i32 %20, i32* %7
%21 = load i32, i32* %7
%22 = sext i32 %21 to i64
%23 = icmp ne i64 %22, 786432
br i1 %23, label %24, label %29
24: ; preds = %17
%25 = load float*, float** %5
%26 = call i32 @memset(float* %25, i32 0, i32 786432)
%27 = load float*, float** %6
%28 = call i32 @memset(float* %27, i32 0, i32 786432)
br label %29
29: ; preds = %24, %17
br label %30
30: ; preds = %29, %14
ret void
}

LLVM IR (-O2):
define void @read_curveset(i32* nocapture %0, float* %1, float* %2) {
%4 = tail call i32 @fread(float* %1, i32 1, i32 786432, i32* %0)
%5 = icmp eq i32 %4, 786432
br i1 %5, label %6, label %11
6: ; preds = %3
%7 = tail call i32 @fread(float* %2, i32 1, i32 786432, i32* %0)
%8 = icmp eq i32 %7, 786432
br i1 %8, label %14, label %9
9: ; preds = %6
%10 = tail call i32 @memset(float* %1, i32 0, i32 786432)
br label %11
11: ; preds = %3, %9
%12 = phi float* [ %2, %9 ], [ %1, %3 ]
%13 = tail call i32 @memset(float* %12, i32 0, i32 786432)
br label %14
14: ; preds = %11, %6
ret void
}