#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*/ assert(char const *);
int /*<<< orphan*/ fclose(int /*<<< orphan*/ *);
int /*<<< orphan*/ *fopen(char const *, char *);
int /*<<< orphan*/ fread(char *, int, long, int /*<<< orphan*/ *);
int /*<<< orphan*/ fseek(int /*<<< orphan*/ *, long, int /*<<< orphan*/);
long ftell(int /*<<< orphan*/ *);
scalar_t__ malloc(size_t);
char *_load_file(const char *path) {
  FILE *fp = 0;
  char *result = 0;
  long curpos = 0;
  long l = 0;
  do {
    ((void)(path));
    assert(path);
  } while (0);
  fp = fopen(path, "rb");
  if (fp) {
    curpos = ftell(fp);
    fseek(fp, 0L, SEEK_END);
    l = ftell(fp);
    fseek(fp, curpos, SEEK_SET);
    result = (char *)malloc((size_t)(l + 1));
    do {
      ((void)(result));
      assert(result);
    } while (0);
    fread(result, 1, l, fp);
    fclose(fp);
    result[l] = '\0';
  }
  return result;
}


x86 assembly (clang, -O0):
<_load_file>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x8(%rbp)
movq   $0x0,-0x10(%rbp)
movq   $0x0,-0x18(%rbp)
movq   $0x0,-0x20(%rbp)
movq   $0x0,-0x28(%rbp)
mov    -0x8(%rbp),%rdi
call   1050 <assert@plt>
mov    -0x8(%rbp),%rdi
lea    0xe50(%rip),%rsi
call   1090 <fopen@plt>
mov    %rax,-0x10(%rbp)
cmpq   $0x0,-0x10(%rbp)
je     124f <_load_file+0xdf>
mov    -0x10(%rbp),%rdi
call   1060 <ftell@plt>
mov    %rax,-0x20(%rbp)
mov    -0x10(%rbp),%rdi
mov    0x2e0c(%rip),%rax
mov    (%rax),%edx
xor    %eax,%eax
mov    %eax,%esi
call   1080 <fseek@plt>
mov    -0x10(%rbp),%rdi
call   1060 <ftell@plt>
mov    %rax,-0x28(%rbp)
mov    -0x10(%rbp),%rdi
mov    -0x20(%rbp),%rsi
mov    0x2dd5(%rip),%rax
mov    (%rax),%edx
call   1080 <fseek@plt>
mov    -0x28(%rbp),%rdi
add    $0x1,%rdi
call   1070 <malloc@plt>
mov    %rax,-0x18(%rbp)
mov    -0x18(%rbp),%rdi
call   1050 <assert@plt>
mov    -0x18(%rbp),%rdi
mov    -0x28(%rbp),%rdx
mov    -0x10(%rbp),%rcx
mov    $0x1,%esi
call   1030 <fread@plt>
mov    -0x10(%rbp),%rdi
call   1040 <fclose@plt>
mov    -0x18(%rbp),%rax
mov    -0x28(%rbp),%rcx
movb   $0x0,(%rax,%rcx,1)
mov    -0x18(%rbp),%rax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<_load_file>:
push   %r15
push   %r14
push   %rbx
mov    %rdi,%rbx
call   1050 <assert@plt>
lea    0xe7c(%rip),%rsi
mov    %rbx,%rdi
call   1090 <fopen@plt>
test   %rax,%rax
je     1207 <_load_file+0x97>
mov    %rax,%r15
mov    %rax,%rdi
call   1060 <ftell@plt>
mov    %rax,%rbx
mov    0x2e42(%rip),%rax
mov    (%rax),%edx
mov    %r15,%rdi
xor    %esi,%esi
call   1080 <fseek@plt>
mov    %r15,%rdi
call   1060 <ftell@plt>
mov    %rax,%r14
mov    0x2e14(%rip),%rax
mov    (%rax),%edx
mov    %r15,%rdi
mov    %rbx,%rsi
call   1080 <fseek@plt>
lea    0x1(%r14),%rdi
call   1070 <malloc@plt>
mov    %rax,%rbx
mov    %rax,%rdi
call   1050 <assert@plt>
mov    %rbx,%rdi
mov    $0x1,%esi
mov    %r14,%rdx
mov    %r15,%rcx
call   1030 <fread@plt>
mov    %r15,%rdi
call   1040 <fclose@plt>
movb   $0x0,(%rbx,%r14,1)
jmp    1209 <_load_file+0x99>
xor    %ebx,%ebx
mov    %rbx,%rax
pop    %rbx
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@.str = [3 x i8] c"rb\00"
@SEEK_END = global i32 0
@SEEK_SET = global i32 0
define i8* @_load_file(i8* %0) {
%2 = alloca i8*
%3 = alloca i32*
%4 = alloca i8*
%5 = alloca i64
%6 = alloca i64
store i8* %0, i8** %2
store i32* null, i32** %3
store i8* null, i8** %4
store i64 0, i64* %5
store i64 0, i64* %6
br label %7
7: ; preds = %1
%8 = load i8*, i8** %2
%9 = load i8*, i8** %2
%10 = call i32 @assert(i8* %9)
br label %11
11: ; preds = %7
%12 = load i8*, i8** %2
%13 = call i32* @fopen(i8* %12, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0))
store i32* %13, i32** %3
%14 = load i32*, i32** %3
%15 = icmp ne i32* %14, null
br i1 %15, label %16, label %46
16: ; preds = %11
%17 = load i32*, i32** %3
%18 = call i64 @ftell(i32* %17)
store i64 %18, i64* %5
%19 = load i32*, i32** %3
%20 = load i32, i32* @SEEK_END
%21 = call i32 @fseek(i32* %19, i64 0, i32 %20)
%22 = load i32*, i32** %3
%23 = call i64 @ftell(i32* %22)
store i64 %23, i64* %6
%24 = load i32*, i32** %3
%25 = load i64, i64* %5
%26 = load i32, i32* @SEEK_SET
%27 = call i32 @fseek(i32* %24, i64 %25, i32 %26)
%28 = load i64, i64* %6
%29 = add nsw i64 %28, 1
%30 = call i64 @malloc(i64 %29)
%31 = inttoptr i64 %30 to i8*
store i8* %31, i8** %4
br label %32
32: ; preds = %16
%33 = load i8*, i8** %4
%34 = load i8*, i8** %4
%35 = call i32 @assert(i8* %34)
br label %36
36: ; preds = %32
%37 = load i8*, i8** %4
%38 = load i64, i64* %6
%39 = load i32*, i32** %3
%40 = call i32 @fread(i8* %37, i32 1, i64 %38, i32* %39)
%41 = load i32*, i32** %3
%42 = call i32 @fclose(i32* %41)
%43 = load i8*, i8** %4
%44 = load i64, i64* %6
%45 = getelementptr inbounds i8, i8* %43, i64 %44
store i8 0, i8* %45
br label %46
46: ; preds = %36, %11
%47 = load i8*, i8** %4
ret i8* %47
}

LLVM IR (-O2):
@.str = [3 x i8] c"rb\00"
@SEEK_END = global i32 0
@SEEK_SET = global i32 0
define i8* @_load_file(i8* %0) {
%2 = tail call i32 @assert(i8* %0)
%3 = tail call i32* @fopen(i8* %0, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0))
%4 = icmp eq i32* %3, null
br i1 %4, label %19, label %5
5: ; preds = %1
%6 = tail call i64 @ftell(i32* %3)
%7 = load i32, i32* @SEEK_END
%8 = tail call i32 @fseek(i32* %3, i64 0, i32 %7)
%9 = tail call i64 @ftell(i32* %3)
%10 = load i32, i32* @SEEK_SET
%11 = tail call i32 @fseek(i32* %3, i64 %6, i32 %10)
%12 = add nsw i64 %9, 1
%13 = tail call i64 @malloc(i64 %12)
%14 = inttoptr i64 %13 to i8*
%15 = tail call i32 @assert(i8* %14)
%16 = tail call i32 @fread(i8* %14, i32 1, i64 %9, i32* %3)
%17 = tail call i32 @fclose(i32* %3)
%18 = getelementptr inbounds i8, i8* %14, i64 %9
store i8 0, i8* %18
br label %19
19: ; preds = %5, %1
%20 = phi i8* [ %14, %5 ], [ null, %1 ]
ret i8* %20
}