#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(int);
scalar_t__ calloc(int, size_t);
int /*<<< orphan*/ fclose(int /*<<< orphan*/ *);
int /*<<< orphan*/ *fopen(char const *, char *);
size_t fread(char *, int, size_t, int /*<<< orphan*/ *);
int /*<<< orphan*/ fseek(int /*<<< orphan*/ *, int /*<<< orphan*/,
                         int /*<<< orphan*/);
int /*<<< orphan*/ ftell(int /*<<< orphan*/ *);
char *load_file(const char *path, size_t *size) {
  FILE *fp = fopen(path, "r");
  assert(fp != 0);
  fseek(fp, 0, SEEK_END);
  size_t len = (size_t)ftell(fp);
  fseek(fp, 0, SEEK_SET);
  char *json = (char *)calloc(1, len + 1);
  size_t readed = fread(json, 1, len, fp);
  assert(len == readed);
  json[len] = '\0';
  fclose(fp);
  *size = len;
  return json;
  (void)readed;
}


x86 assembly (clang, -O0):
<load_file>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    -0x8(%rbp),%rdi
lea    0xe75(%rip),%rsi
call   1090 <fopen@plt>
mov    %rax,-0x18(%rbp)
cmpq   $0x0,-0x18(%rbp)
setne  %al
and    $0x1,%al
movzbl %al,%edi
call   1060 <assert@plt>
mov    -0x18(%rbp),%rdi
mov    0x2e37(%rip),%rax
mov    (%rax),%edx
xor    %esi,%esi
call   1080 <fseek@plt>
mov    -0x18(%rbp),%rdi
call   1070 <ftell@plt>
cltq
mov    %rax,-0x20(%rbp)
mov    -0x18(%rbp),%rdi
mov    0x2e04(%rip),%rax
mov    (%rax),%edx
xor    %esi,%esi
call   1080 <fseek@plt>
mov    -0x20(%rbp),%rsi
add    $0x1,%rsi
mov    $0x1,%edi
call   1050 <calloc@plt>
mov    %rax,-0x28(%rbp)
mov    -0x28(%rbp),%rdi
mov    -0x20(%rbp),%rdx
mov    -0x18(%rbp),%rcx
mov    $0x1,%esi
call   1030 <fread@plt>
mov    %rax,-0x30(%rbp)
mov    -0x20(%rbp),%rax
cmp    -0x30(%rbp),%rax
sete   %al
and    $0x1,%al
movzbl %al,%edi
call   1060 <assert@plt>
mov    -0x28(%rbp),%rax
mov    -0x20(%rbp),%rcx
movb   $0x0,(%rax,%rcx,1)
mov    -0x18(%rbp),%rdi
call   1040 <fclose@plt>
mov    -0x20(%rbp),%rcx
mov    -0x10(%rbp),%rax
mov    %rcx,(%rax)
mov    -0x28(%rbp),%rax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<load_file>:
push   %r15
push   %r14
push   %r12
push   %rbx
push   %rax
mov    %rsi,%r14
lea    0xe7e(%rip),%rsi
call   1090 <fopen@plt>
mov    %rax,%r15
xor    %edi,%edi
test   %rax,%rax
setne  %dil
call   1060 <assert@plt>
mov    0x2e49(%rip),%rax
mov    (%rax),%edx
mov    %r15,%rdi
xor    %esi,%esi
call   1080 <fseek@plt>
mov    %r15,%rdi
call   1070 <ftell@plt>
movslq %eax,%rbx
mov    0x2e1b(%rip),%rax
mov    (%rax),%edx
mov    %r15,%rdi
xor    %esi,%esi
call   1080 <fseek@plt>
lea    0x1(%rbx),%rsi
mov    $0x1,%edi
call   1050 <calloc@plt>
mov    %rax,%r12
mov    %rax,%rdi
mov    $0x1,%esi
mov    %rbx,%rdx
mov    %r15,%rcx
call   1030 <fread@plt>
xor    %edi,%edi
cmp    %rbx,%rax
sete   %dil
call   1060 <assert@plt>
movb   $0x0,(%r12,%rbx,1)
mov    %r15,%rdi
call   1040 <fclose@plt>
mov    %rbx,(%r14)
mov    %r12,%rax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
ret

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

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