#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 /*<<< orphan*/ SEEK_END;
int /*<<< orphan*/ SEEK_SET;
int /*<<< orphan*/ fail(char *);
int /*<<< orphan*/ fclose(int /*<<< orphan*/ *);
int /*<<< orphan*/ *fopen(char const *, char *);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *, ...);
int fread(void *, long, int, int /*<<< orphan*/ *);
scalar_t__ fseek(int /*<<< orphan*/ *, long, int /*<<< orphan*/);
long ftell(int /*<<< orphan*/ *);
void *malloc(long);
int /*<<< orphan*/ stderr;
void load_binary_data(const char *fname, void **ptr, bool verbose) {
  FILE *f;
  *ptr = 0;
  if (!fname) {
    fprintf(stderr,
            "load: warning: no data file specified (did you use slr?)\n");
    return;
  }
  if (verbose)
    fprintf(stderr, "# load: loading data from %s...\n", fname);
  do {
    if (!(f = fopen(fname, "rb")))
      fail("fopen");
  } while (0);
  ;
  do {
    if (!(fseek(f, 0L, SEEK_END) == 0))
      fail("fseek");
  } while (0);
  ;
  long sz = ftell(f);
  do {
    if (!(sz >= 0))
      fail("ftell");
  } while (0);
  ;
  if (sz > 0) {
    void *p;
    do {
      if (!(p = malloc(sz + sizeof(double))))
        fail("malloc");
    } while (0);
    ;
    fseek(f, 0L, SEEK_SET);
    do {
      if (!(fread(p, sz, 1, f) == 1))
        fail("fread");
    } while (0);
    ;
    *ptr = p;
    if (verbose)
      fprintf(stderr, "# load: %ld bytes loaded at %p\n", sz, p);
  }
  fclose(f);
}


x86 assembly (clang, -O0):
<load_binary_data>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %edx,-0x14(%rbp)
mov    -0x10(%rbp),%rax
movq   $0x0,(%rax)
cmpq   $0x0,-0x8(%rbp)
jne    11c5 <load_binary_data+0x45>
mov    0x2e28(%rip),%rax
mov    (%rax),%edi
lea    0xe47(%rip),%rsi
mov    $0x0,%al
call   1060 <fprintf@plt>
jmp    1341 <load_binary_data+0x1c1>
cmpl   $0x0,-0x14(%rbp)
je     11ea <load_binary_data+0x6a>
mov    0x2e02(%rip),%rax
mov    (%rax),%edi
mov    -0x8(%rbp),%rdx
lea    0xe57(%rip),%rsi
mov    $0x0,%al
call   1060 <fprintf@plt>
jmp    11ef <load_binary_data+0x6f>
mov    -0x8(%rbp),%rdi
lea    0xe61(%rip),%rsi
call   10a0 <fopen@plt>
mov    %rax,-0x20(%rbp)
cmp    $0x0,%rax
jne    1219 <load_binary_data+0x99>
lea    0xe4a(%rip),%rdi
call   1040 <fail@plt>
jmp    121e <load_binary_data+0x9e>
jmp    1223 <load_binary_data+0xa3>
mov    -0x20(%rbp),%rdi
mov    0x2dba(%rip),%rax
mov    (%rax),%edx
xor    %eax,%eax
mov    %eax,%esi
call   1090 <fseek@plt>
cmp    $0x0,%rax
je     124f <load_binary_data+0xcf>
lea    0xe1a(%rip),%rdi
call   1040 <fail@plt>
jmp    1254 <load_binary_data+0xd4>
mov    -0x20(%rbp),%rdi
call   1070 <ftell@plt>
mov    %rax,-0x28(%rbp)
cmpq   $0x0,-0x28(%rbp)
jge    1278 <load_binary_data+0xf8>
lea    0xdf7(%rip),%rdi
call   1040 <fail@plt>
jmp    127d <load_binary_data+0xfd>
cmpq   $0x0,-0x28(%rbp)
jle    1338 <load_binary_data+0x1b8>
jmp    128d <load_binary_data+0x10d>
mov    -0x28(%rbp),%rdi
add    $0x8,%rdi
call   1080 <malloc@plt>
mov    %rax,-0x30(%rbp)
cmp    $0x0,%rax
jne    12b4 <load_binary_data+0x134>
lea    0xdc1(%rip),%rdi
call   1040 <fail@plt>
jmp    12b9 <load_binary_data+0x139>
mov    -0x20(%rbp),%rdi
mov    0x2d0c(%rip),%rax
mov    (%rax),%edx
xor    %eax,%eax
mov    %eax,%esi
call   1090 <fseek@plt>
mov    -0x30(%rbp),%rdi
mov    -0x28(%rbp),%rsi
mov    -0x20(%rbp),%rcx
mov    $0x1,%edx
call   1030 <fread@plt>
cmp    $0x1,%eax
je     12fa <load_binary_data+0x17a>
lea    0xd82(%rip),%rdi
call   1040 <fail@plt>
jmp    12ff <load_binary_data+0x17f>
mov    -0x30(%rbp),%rcx
mov    -0x10(%rbp),%rax
mov    %rcx,(%rax)
cmpl   $0x0,-0x14(%rbp)
je     1333 <load_binary_data+0x1b3>
mov    0x2cbd(%rip),%rax
mov    (%rax),%edi
mov    -0x28(%rbp),%rdx
mov    -0x30(%rbp),%rcx
lea    0xd51(%rip),%rsi
mov    $0x0,%al
call   1060 <fprintf@plt>
jmp    1338 <load_binary_data+0x1b8>
mov    -0x20(%rbp),%rdi
call   1050 <fclose@plt>
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<load_binary_data>:
push   %rbp
push   %r15
push   %r14
push   %r12
push   %rbx
movq   $0x0,(%rsi)
test   %rdi,%rdi
je     129e <load_binary_data+0x11e>
mov    %edx,%r14d
mov    %rsi,%r15
mov    %rdi,%rbx
test   %edx,%edx
je     11bf <load_binary_data+0x3f>
mov    0x2e2c(%rip),%rax
mov    (%rax),%edi
lea    0xe85(%rip),%rsi
mov    %rbx,%rdx
xor    %eax,%eax
call   1060 <fprintf@plt>
lea    0xe95(%rip),%rsi
mov    %rbx,%rdi
call   10a0 <fopen@plt>
mov    %rax,%rbp
test   %rax,%rax
jne    11e2 <load_binary_data+0x62>
lea    0xe81(%rip),%rdi
call   1040 <fail@plt>
mov    0x2dff(%rip),%rax
mov    (%rax),%edx
mov    %rbp,%rdi
xor    %esi,%esi
call   1090 <fseek@plt>
test   %rax,%rax
je     1206 <load_binary_data+0x86>
lea    0xe63(%rip),%rdi
call   1040 <fail@plt>
mov    %rbp,%rdi
call   1070 <ftell@plt>
test   %rax,%rax
js     12bd <load_binary_data+0x13d>
je     12c9 <load_binary_data+0x149>
mov    %rax,%rbx
mov    %rax,%rdi
add    $0x8,%rdi
call   1080 <malloc@plt>
mov    %rax,%r12
test   %rax,%rax
jne    1240 <load_binary_data+0xc0>
lea    0xe35(%rip),%rdi
call   1040 <fail@plt>
mov    0x2d89(%rip),%rax
mov    (%rax),%edx
mov    %rbp,%rdi
xor    %esi,%esi
call   1090 <fseek@plt>
mov    %r12,%rdi
mov    %rbx,%rsi
mov    $0x1,%edx
mov    %rbp,%rcx
call   1030 <fread@plt>
cmp    $0x1,%eax
je     1277 <load_binary_data+0xf7>
lea    0xe05(%rip),%rdi
call   1040 <fail@plt>
mov    %r12,(%r15)
test   %r14d,%r14d
je     12c9 <load_binary_data+0x149>
mov    0x2d52(%rip),%rax
mov    (%rax),%edi
lea    0xdee(%rip),%rsi
mov    %rbx,%rdx
mov    %r12,%rcx
xor    %eax,%eax
call   1060 <fprintf@plt>
jmp    12c9 <load_binary_data+0x149>
mov    0x2d33(%rip),%rax
mov    (%rax),%edi
lea    0xd52(%rip),%rsi
xor    %eax,%eax
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
jmp    1060 <fprintf@plt>
lea    0xda6(%rip),%rdi
call   1040 <fail@plt>
mov    %rbp,%rdi
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
jmp    1050 <fclose@plt>

LLVM IR (-O0):
@stderr = global i32 0
@.str = [58 x i8] c"load: warning: no data file specified (did you use slr?)\0A\00"
@.str.1 = [33 x i8] c"# load: loading data from %s...\0A\00"
@.str.2 = [3 x i8] c"rb\00"
@.str.3 = [6 x i8] c"fopen\00"
@SEEK_END = global i32 0
@.str.4 = [6 x i8] c"fseek\00"
@.str.5 = [6 x i8] c"ftell\00"
@.str.6 = [7 x i8] c"malloc\00"
@SEEK_SET = global i32 0
@.str.7 = [6 x i8] c"fread\00"
@.str.8 = [32 x i8] c"# load: %ld bytes loaded at %p\0A\00"
define void @load_binary_data(i8* %0, i8** %1, i32 %2) {
%4 = alloca i8*
%5 = alloca i8**
%6 = alloca i32
%7 = alloca i32*
%8 = alloca i64
%9 = alloca i8*
store i8* %0, i8** %4
store i8** %1, i8*** %5
store i32 %2, i32* %6
%10 = load i8**, i8*** %5
store i8* null, i8** %10
%11 = load i8*, i8** %4
%12 = icmp ne i8* %11, null
br i1 %12, label %16, label %13
13: ; preds = %3
%14 = load i32, i32* @stderr
%15 = call i32 (i32, i8*, ...) @fprintf(i32 %14, i8* getelementptr inbounds ([58 x i8], [58 x i8]* @.str, i64 0, i64 0))
br label %88
16: ; preds = %3
%17 = load i32, i32* %6
%18 = icmp ne i32 %17, 0
br i1 %18, label %19, label %23
19: ; preds = %16
%20 = load i32, i32* @stderr
%21 = load i8*, i8** %4
%22 = call i32 (i32, i8*, ...) @fprintf(i32 %20, i8* getelementptr inbounds ([33 x i8], [33 x i8]* @.str.1, i64 0, i64 0), i8* %21)
br label %23
23: ; preds = %19, %16
br label %24
24: ; preds = %23
%25 = load i8*, i8** %4
%26 = call i32* @fopen(i8* %25, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0))
store i32* %26, i32** %7
%27 = icmp ne i32* %26, null
br i1 %27, label %30, label %28
28: ; preds = %24
%29 = call i32 @fail(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.3, i64 0, i64 0))
br label %30
30: ; preds = %28, %24
br label %31
31: ; preds = %30
br label %32
32: ; preds = %31
%33 = load i32*, i32** %7
%34 = load i32, i32* @SEEK_END
%35 = call i64 @fseek(i32* %33, i64 0, i32 %34)
%36 = icmp eq i64 %35, 0
br i1 %36, label %39, label %37
37: ; preds = %32
%38 = call i32 @fail(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.4, i64 0, i64 0))
br label %39
39: ; preds = %37, %32
br label %40
40: ; preds = %39
%41 = load i32*, i32** %7
%42 = call i64 @ftell(i32* %41)
store i64 %42, i64* %8
br label %43
43: ; preds = %40
%44 = load i64, i64* %8
%45 = icmp sge i64 %44, 0
br i1 %45, label %48, label %46
46: ; preds = %43
%47 = call i32 @fail(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.5, i64 0, i64 0))
br label %48
48: ; preds = %46, %43
br label %49
49: ; preds = %48
%50 = load i64, i64* %8
%51 = icmp sgt i64 %50, 0
br i1 %51, label %52, label %85
52: ; preds = %49
br label %53
53: ; preds = %52
%54 = load i64, i64* %8
%55 = add i64 %54, 8
%56 = call i8* @malloc(i64 %55)
store i8* %56, i8** %9
%57 = icmp ne i8* %56, null
br i1 %57, label %60, label %58
58: ; preds = %53
%59 = call i32 @fail(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.6, i64 0, i64 0))
br label %60
60: ; preds = %58, %53
br label %61
61: ; preds = %60
%62 = load i32*, i32** %7
%63 = load i32, i32* @SEEK_SET
%64 = call i64 @fseek(i32* %62, i64 0, i32 %63)
br label %65
65: ; preds = %61
%66 = load i8*, i8** %9
%67 = load i64, i64* %8
%68 = load i32*, i32** %7
%69 = call i32 @fread(i8* %66, i64 %67, i32 1, i32* %68)
%70 = icmp eq i32 %69, 1
br i1 %70, label %73, label %71
71: ; preds = %65
%72 = call i32 @fail(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.7, i64 0, i64 0))
br label %73
73: ; preds = %71, %65
br label %74
74: ; preds = %73
%75 = load i8*, i8** %9
%76 = load i8**, i8*** %5
store i8* %75, i8** %76
%77 = load i32, i32* %6
%78 = icmp ne i32 %77, 0
br i1 %78, label %79, label %84
79: ; preds = %74
%80 = load i32, i32* @stderr
%81 = load i64, i64* %8
%82 = load i8*, i8** %9
%83 = call i32 (i32, i8*, ...) @fprintf(i32 %80, i8* getelementptr inbounds ([32 x i8], [32 x i8]* @.str.8, i64 0, i64 0), i64 %81, i8* %82)
br label %84
84: ; preds = %79, %74
br label %85
85: ; preds = %84, %49
%86 = load i32*, i32** %7
%87 = call i32 @fclose(i32* %86)
br label %88
88: ; preds = %85, %13
ret void
}

LLVM IR (-O2):
@stderr = global i32 0
@.str = [58 x i8] c"load: warning: no data file specified (did you use slr?)\0A\00"
@.str.1 = [33 x i8] c"# load: loading data from %s...\0A\00"
@.str.2 = [3 x i8] c"rb\00"
@.str.3 = [6 x i8] c"fopen\00"
@SEEK_END = global i32 0
@.str.4 = [6 x i8] c"fseek\00"
@.str.5 = [6 x i8] c"ftell\00"
@.str.6 = [7 x i8] c"malloc\00"
@SEEK_SET = global i32 0
@.str.7 = [6 x i8] c"fread\00"
@.str.8 = [32 x i8] c"# load: %ld bytes loaded at %p\0A\00"
define void @load_binary_data(i8* %0, i8** nocapture writeonly %1, i32 %2) {
store i8* null, i8** %1
%4 = icmp eq i8* %0, null
br i1 %4, label %5, label %8
5: ; preds = %3
%6 = load i32, i32* @stderr
%7 = tail call i32 (i32, i8*, ...) @fprintf(i32 %6, i8* getelementptr inbounds ([58 x i8], [58 x i8]* @.str, i64 0, i64 0))
br label %50
8: ; preds = %3
%9 = icmp eq i32 %2, 0
br i1 %9, label %13, label %10
10: ; preds = %8
%11 = load i32, i32* @stderr
%12 = tail call i32 (i32, i8*, ...) @fprintf(i32 %11, i8* getelementptr inbounds ([33 x i8], [33 x i8]* @.str.1, i64 0, i64 0), i8* %0)
br label %13
13: ; preds = %8, %10
%14 = tail call i32* @fopen(i8* %0, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0))
%15 = icmp eq i32* %14, null
br i1 %15, label %16, label %18
16: ; preds = %13
%17 = tail call i32 @fail(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.3, i64 0, i64 0))
br label %18
18: ; preds = %13, %16
%19 = load i32, i32* @SEEK_END
%20 = tail call i64 @fseek(i32* %14, i64 0, i32 %19)
%21 = icmp eq i64 %20, 0
br i1 %21, label %24, label %22
22: ; preds = %18
%23 = tail call i32 @fail(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.4, i64 0, i64 0))
br label %24
24: ; preds = %22, %18
%25 = tail call i64 @ftell(i32* %14)
%26 = icmp sgt i64 %25, -1
br i1 %26, label %29, label %27
27: ; preds = %24
%28 = tail call i32 @fail(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.5, i64 0, i64 0))
br label %48
29: ; preds = %24
%30 = icmp eq i64 %25, 0
br i1 %30, label %48, label %31
31: ; preds = %29
%32 = add nuw i64 %25, 8
%33 = tail call i8* @malloc(i64 %32)
%34 = icmp eq i8* %33, null
br i1 %34, label %35, label %37
35: ; preds = %31
%36 = tail call i32 @fail(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.6, i64 0, i64 0))
br label %37
37: ; preds = %35, %31
%38 = load i32, i32* @SEEK_SET
%39 = tail call i64 @fseek(i32* %14, i64 0, i32 %38)
%40 = tail call i32 @fread(i8* %33, i64 %25, i32 1, i32* %14)
%41 = icmp eq i32 %40, 1
br i1 %41, label %44, label %42
42: ; preds = %37
%43 = tail call i32 @fail(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.7, i64 0, i64 0))
br label %44
44: ; preds = %42, %37
store i8* %33, i8** %1
br i1 %9, label %48, label %45
45: ; preds = %44
%46 = load i32, i32* @stderr
%47 = tail call i32 (i32, i8*, ...) @fprintf(i32 %46, i8* getelementptr inbounds ([32 x i8], [32 x i8]* @.str.8, i64 0, i64 0), i64 %25, i8* %33)
br label %48
48: ; preds = %27, %44, %45, %29
%49 = tail call i32 @fclose(i32* %14)
br label %50
50: ; preds = %48, %5
ret void
}