#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;
    long alloc_sz = sz + sizeof(double);
    do {
      if (!(p = malloc(alloc_sz + 64)))
        fail("malloc");
    } while (0);
    ;
    if ((uintptr_t)p % 64 != 0)
      p = (char *)p + (64 - (uintptr_t)p % 64);
    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    $0x40,%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    1375 <load_binary_data+0x1f5>
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    136c <load_binary_data+0x1ec>
mov    -0x28(%rbp),%rax
add    $0x8,%rax
mov    %rax,-0x38(%rbp)
mov    -0x38(%rbp),%rdi
add    $0x40,%rdi
call   1080 <malloc@plt>
mov    %rax,-0x30(%rbp)
cmp    $0x0,%rax
jne    12bb <load_binary_data+0x13b>
lea    0xdba(%rip),%rdi
call   1040 <fail@plt>
jmp    12c0 <load_binary_data+0x140>
mov    -0x30(%rbp),%rax
and    $0x3f,%rax
cmp    $0x0,%rax
je     12ed <load_binary_data+0x16d>
mov    -0x30(%rbp),%rax
mov    -0x30(%rbp),%rdx
and    $0x3f,%rdx
mov    $0x40,%ecx
sub    %rdx,%rcx
add    %rcx,%rax
mov    %rax,-0x30(%rbp)
mov    -0x20(%rbp),%rdi
mov    0x2cd8(%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     132e <load_binary_data+0x1ae>
lea    0xd4e(%rip),%rdi
call   1040 <fail@plt>
jmp    1333 <load_binary_data+0x1b3>
mov    -0x30(%rbp),%rcx
mov    -0x10(%rbp),%rax
mov    %rcx,(%rax)
cmpl   $0x0,-0x14(%rbp)
je     1367 <load_binary_data+0x1e7>
mov    0x2c89(%rip),%rax
mov    (%rax),%edi
mov    -0x28(%rbp),%rdx
mov    -0x30(%rbp),%rcx
lea    0xd1d(%rip),%rsi
mov    $0x0,%al
call   1060 <fprintf@plt>
jmp    136c <load_binary_data+0x1ec>
mov    -0x20(%rbp),%rdi
call   1050 <fclose@plt>
add    $0x40,%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     12b5 <load_binary_data+0x135>
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     12d4 <load_binary_data+0x154>
je     12e0 <load_binary_data+0x160>
mov    %rax,%r12
mov    %rax,%rdi
add    $0x48,%rdi
call   1080 <malloc@plt>
mov    %rax,%rbx
test   %rax,%rax
jne    1240 <load_binary_data+0xc0>
lea    0xe35(%rip),%rdi
call   1040 <fail@plt>
mov    %ebx,%eax
and    $0x3f,%eax
mov    $0x40,%ecx
sub    %rax,%rcx
test   %rax,%rax
cmove  %rax,%rcx
add    %rcx,%rbx
mov    0x2d72(%rip),%rax
mov    (%rax),%edx
mov    %rbp,%rdi
xor    %esi,%esi
call   1090 <fseek@plt>
mov    %rbx,%rdi
mov    %r12,%rsi
mov    $0x1,%edx
mov    %rbp,%rcx
call   1030 <fread@plt>
cmp    $0x1,%eax
je     128e <load_binary_data+0x10e>
lea    0xdee(%rip),%rdi
call   1040 <fail@plt>
mov    %rbx,(%r15)
test   %r14d,%r14d
je     12e0 <load_binary_data+0x160>
mov    0x2d3b(%rip),%rax
mov    (%rax),%edi
lea    0xdd7(%rip),%rsi
mov    %r12,%rdx
mov    %rbx,%rcx
xor    %eax,%eax
call   1060 <fprintf@plt>
jmp    12e0 <load_binary_data+0x160>
mov    0x2d1c(%rip),%rax
mov    (%rax),%edi
lea    0xd3b(%rip),%rsi
xor    %eax,%eax
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
jmp    1060 <fprintf@plt>
lea    0xd8f(%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*
%10 = alloca i64
store i8* %0, i8** %4
store i8** %1, i8*** %5
store i32 %2, i32* %6
%11 = load i8**, i8*** %5
store i8* null, i8** %11
%12 = load i8*, i8** %4
%13 = icmp ne i8* %12, null
br i1 %13, label %17, label %14
14: ; preds = %3
%15 = load i32, i32* @stderr
%16 = call i32 (i32, i8*, ...) @fprintf(i32 %15, i8* getelementptr inbounds ([58 x i8], [58 x i8]* @.str, i64 0, i64 0))
br label %103
17: ; preds = %3
%18 = load i32, i32* %6
%19 = icmp ne i32 %18, 0
br i1 %19, label %20, label %24
20: ; preds = %17
%21 = load i32, i32* @stderr
%22 = load i8*, i8** %4
%23 = call i32 (i32, i8*, ...) @fprintf(i32 %21, i8* getelementptr inbounds ([33 x i8], [33 x i8]* @.str.1, i64 0, i64 0), i8* %22)
br label %24
24: ; preds = %20, %17
br label %25
25: ; preds = %24
%26 = load i8*, i8** %4
%27 = call i32* @fopen(i8* %26, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0))
store i32* %27, i32** %7
%28 = icmp ne i32* %27, null
br i1 %28, label %31, label %29
29: ; preds = %25
%30 = call i32 @fail(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.3, i64 0, i64 0))
br label %31
31: ; preds = %29, %25
br label %32
32: ; preds = %31
br label %33
33: ; preds = %32
%34 = load i32*, i32** %7
%35 = load i32, i32* @SEEK_END
%36 = call i64 @fseek(i32* %34, i64 0, i32 %35)
%37 = icmp eq i64 %36, 0
br i1 %37, label %40, label %38
38: ; preds = %33
%39 = call i32 @fail(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.4, i64 0, i64 0))
br label %40
40: ; preds = %38, %33
br label %41
41: ; preds = %40
%42 = load i32*, i32** %7
%43 = call i64 @ftell(i32* %42)
store i64 %43, i64* %8
br label %44
44: ; preds = %41
%45 = load i64, i64* %8
%46 = icmp sge i64 %45, 0
br i1 %46, label %49, label %47
47: ; preds = %44
%48 = call i32 @fail(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.5, i64 0, i64 0))
br label %49
49: ; preds = %47, %44
br label %50
50: ; preds = %49
%51 = load i64, i64* %8
%52 = icmp sgt i64 %51, 0
br i1 %52, label %53, label %100
53: ; preds = %50
%54 = load i64, i64* %8
%55 = add i64 %54, 8
store i64 %55, i64* %10
br label %56
56: ; preds = %53
%57 = load i64, i64* %10
%58 = add nsw i64 %57, 64
%59 = call i8* @malloc(i64 %58)
store i8* %59, i8** %9
%60 = icmp ne i8* %59, null
br i1 %60, label %63, label %61
61: ; preds = %56
%62 = call i32 @fail(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.6, i64 0, i64 0))
br label %63
63: ; preds = %61, %56
br label %64
64: ; preds = %63
%65 = load i8*, i8** %9
%66 = ptrtoint i8* %65 to i64
%67 = urem i64 %66, 64
%68 = icmp ne i64 %67, 0
br i1 %68, label %69, label %76
69: ; preds = %64
%70 = load i8*, i8** %9
%71 = load i8*, i8** %9
%72 = ptrtoint i8* %71 to i64
%73 = urem i64 %72, 64
%74 = sub i64 64, %73
%75 = getelementptr inbounds i8, i8* %70, i64 %74
store i8* %75, i8** %9
br label %76
76: ; preds = %69, %64
%77 = load i32*, i32** %7
%78 = load i32, i32* @SEEK_SET
%79 = call i64 @fseek(i32* %77, i64 0, i32 %78)
br label %80
80: ; preds = %76
%81 = load i8*, i8** %9
%82 = load i64, i64* %8
%83 = load i32*, i32** %7
%84 = call i32 @fread(i8* %81, i64 %82, i32 1, i32* %83)
%85 = icmp eq i32 %84, 1
br i1 %85, label %88, label %86
86: ; preds = %80
%87 = call i32 @fail(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.7, i64 0, i64 0))
br label %88
88: ; preds = %86, %80
br label %89
89: ; preds = %88
%90 = load i8*, i8** %9
%91 = load i8**, i8*** %5
store i8* %90, i8** %91
%92 = load i32, i32* %6
%93 = icmp ne i32 %92, 0
br i1 %93, label %94, label %99
94: ; preds = %89
%95 = load i32, i32* @stderr
%96 = load i64, i64* %8
%97 = load i8*, i8** %9
%98 = call i32 (i32, i8*, ...) @fprintf(i32 %95, i8* getelementptr inbounds ([32 x i8], [32 x i8]* @.str.8, i64 0, i64 0), i64 %96, i8* %97)
br label %99
99: ; preds = %94, %89
br label %100
100: ; preds = %99, %50
%101 = load i32*, i32** %7
%102 = call i32 @fclose(i32* %101)
br label %103
103: ; preds = %100, %14
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 %56
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 %54
29: ; preds = %24
%30 = icmp eq i64 %25, 0
br i1 %30, label %54, label %31
31: ; preds = %29
%32 = add nuw i64 %25, 72
%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 = ptrtoint i8* %33 to i64
%39 = and i64 %38, 63
%40 = icmp eq i64 %39, 0
%41 = sub nuw nsw i64 64, %39
%42 = select i1 %40, i64 0, i64 %41
%43 = getelementptr i8, i8* %33, i64 %42
%44 = load i32, i32* @SEEK_SET
%45 = tail call i64 @fseek(i32* %14, i64 0, i32 %44)
%46 = tail call i32 @fread(i8* %43, i64 %25, i32 1, i32* %14)
%47 = icmp eq i32 %46, 1
br i1 %47, label %50, label %48
48: ; preds = %37
%49 = tail call i32 @fail(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.7, i64 0, i64 0))
br label %50
50: ; preds = %48, %37
store i8* %43, i8** %1
br i1 %9, label %54, label %51
51: ; preds = %50
%52 = load i32, i32* @stderr
%53 = tail call i32 (i32, i8*, ...) @fprintf(i32 %52, i8* getelementptr inbounds ([32 x i8], [32 x i8]* @.str.8, i64 0, i64 0), i64 %25, i8* %43)
br label %54
54: ; preds = %27, %50, %51, %29
%55 = tail call i32 @fclose(i32* %14)
br label %56
56: ; preds = %54, %5
ret void
}