#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 */
size_t fread(float *, int, int, int /*<<< orphan*/ *);
int /*<<< orphan*/ memset(float *, int /*<<< orphan*/, int);
void read_curveset(FILE *f, float *curve, uint32_t *hist) {
  size_t r = fread(curve, 1, sizeof(float) * 3 * 0x10000, f);
  if (r != sizeof(float) * 3 * 0x10000) {
    memset(curve, 0, sizeof(float) * 3 * 0x10000);
  } else {
    r = fread(hist, 1, sizeof(uint32_t) * 3 * 0x10000, f);
    if (r != sizeof(uint32_t) * 3 * 0x10000) {
      memset(curve, 0, sizeof(float) * 3 * 0x10000);
      memset(hist, 0, sizeof(uint32_t) * 3 * 0x10000);
    }
  }
}


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    %rax,-0x20(%rbp)
cmpq   $0xc0000,-0x20(%rbp)
je     1172 <read_curveset+0x52>
mov    -0x10(%rbp),%rdi
xor    %esi,%esi
mov    $0xc0000,%edx
call   1040 <memset@plt>
jmp    11c0 <read_curveset+0xa0>
mov    -0x18(%rbp),%rdi
mov    -0x8(%rbp),%rcx
mov    $0x1,%esi
mov    $0xc0000,%edx
call   1030 <fread@plt>
mov    %rax,-0x20(%rbp)
cmpq   $0xc0000,-0x20(%rbp)
je     11bb <read_curveset+0x9b>
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    11c0 <read_curveset+0xa0>
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,%rax
jne    116e <read_curveset+0x4e>
mov    %r14,%rdi
mov    $0x1,%esi
mov    $0xc0000,%edx
mov    %rbx,%rcx
call   1030 <fread@plt>
cmp    $0xc0000,%rax
jne    1173 <read_curveset+0x53>
pop    %rbx
pop    %r14
pop    %r15
ret
mov    %r15,%r14
jmp    1182 <read_curveset+0x62>
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 i64
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 i64 @fread(float* %8, i32 1, i32 786432, i32* %9)
store i64 %10, i64* %7
%11 = load i64, i64* %7
%12 = icmp ne i64 %11, 786432
br i1 %12, label %13, label %16
13: ; preds = %3
%14 = load float*, float** %5
%15 = call i32 @memset(float* %14, i32 0, i32 786432)
br label %28
16: ; preds = %3
%17 = load float*, float** %6
%18 = load i32*, i32** %4
%19 = call i64 @fread(float* %17, i32 1, i32 786432, i32* %18)
store i64 %19, i64* %7
%20 = load i64, i64* %7
%21 = icmp ne i64 %20, 786432
br i1 %21, label %22, label %27
22: ; preds = %16
%23 = load float*, float** %5
%24 = call i32 @memset(float* %23, i32 0, i32 786432)
%25 = load float*, float** %6
%26 = call i32 @memset(float* %25, i32 0, i32 786432)
br label %27
27: ; preds = %22, %16
br label %28
28: ; preds = %27, %13
ret void
}

LLVM IR (-O2):
define void @read_curveset(i32* nocapture %0, float* %1, float* %2) {
%4 = tail call i64 @fread(float* %1, i32 1, i32 786432, i32* %0)
%5 = icmp eq i64 %4, 786432
br i1 %5, label %6, label %11
6: ; preds = %3
%7 = tail call i64 @fread(float* %2, i32 1, i32 786432, i32* %0)
%8 = icmp eq i64 %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
}