#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 char FILE;

/* Variables and functions */
int /*<<< orphan*/ SEEK_END;
int /*<<< orphan*/ assert(char *);
char *calloc(int, int);
int /*<<< orphan*/ fclose(char *);
char *fopen(char *, char *);
int fread(char *, int, int, char *);
int /*<<< orphan*/ fseek(char *, long, int /*<<< orphan*/);
int ftell(char *);
int /*<<< orphan*/ rewind(char *);
void ReadFile(char filename[], char **s) {
  FILE *f = fopen(filename, "r");
  assert(f);
  fseek(f, 0L, SEEK_END);
  int size = ftell(f);
  rewind(f);
  *s = calloc(size + 2, sizeof(char));
  assert(*s);
  int status = fread(*s, sizeof(char), size, f);
  fclose(f);
}


x86 assembly (clang, -O0):
<ReadFile>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    -0x8(%rbp),%rdi
lea    0xe65(%rip),%rsi
call   10a0 <fopen@plt>
mov    %rax,-0x18(%rbp)
mov    -0x18(%rbp),%rdi
call   1070 <assert@plt>
mov    -0x18(%rbp),%rdi
mov    0x2e30(%rip),%rax
mov    (%rax),%edx
xor    %eax,%eax
mov    %eax,%esi
call   1090 <fseek@plt>
mov    -0x18(%rbp),%rdi
call   1080 <ftell@plt>
mov    %eax,-0x1c(%rbp)
mov    -0x18(%rbp),%rdi
call   1050 <rewind@plt>
mov    -0x1c(%rbp),%edi
add    $0x2,%edi
mov    $0x1,%esi
call   1060 <calloc@plt>
mov    %rax,%rcx
mov    -0x10(%rbp),%rax
mov    %rcx,(%rax)
mov    -0x10(%rbp),%rax
mov    (%rax),%rdi
call   1070 <assert@plt>
mov    -0x10(%rbp),%rax
mov    (%rax),%rdi
mov    -0x1c(%rbp),%edx
mov    -0x18(%rbp),%rcx
mov    $0x1,%esi
call   1030 <fread@plt>
mov    %eax,-0x20(%rbp)
mov    -0x18(%rbp),%rdi
call   1040 <fclose@plt>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<ReadFile>:
push   %r15
push   %r14
push   %rbx
mov    %rsi,%r14
lea    0xe71(%rip),%rsi
call   10a0 <fopen@plt>
mov    %rax,%rbx
mov    %rax,%rdi
call   1070 <assert@plt>
mov    0x2e42(%rip),%rax
mov    (%rax),%edx
mov    %rbx,%rdi
xor    %esi,%esi
call   1090 <fseek@plt>
mov    %rbx,%rdi
call   1080 <ftell@plt>
mov    %eax,%r15d
mov    %rbx,%rdi
call   1050 <rewind@plt>
lea    0x2(%r15),%edi
mov    $0x1,%esi
call   1060 <calloc@plt>
mov    %rax,(%r14)
mov    %rax,%rdi
call   1070 <assert@plt>
mov    (%r14),%rdi
mov    $0x1,%esi
mov    %r15d,%edx
mov    %rbx,%rcx
call   1030 <fread@plt>
mov    %rbx,%rdi
pop    %rbx
pop    %r14
pop    %r15
jmp    1040 <fclose@plt>

LLVM IR (-O0):
@.str = [2 x i8] c"r\00"
@SEEK_END = global i32 0
define void @ReadFile(i8* %0, i8** %1) {
%3 = alloca i8*
%4 = alloca i8**
%5 = alloca i8*
%6 = alloca i32
%7 = alloca i32
store i8* %0, i8** %3
store i8** %1, i8*** %4
%8 = load i8*, i8** %3
%9 = call i8* @fopen(i8* %8, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
store i8* %9, i8** %5
%10 = load i8*, i8** %5
%11 = call i32 @assert(i8* %10)
%12 = load i8*, i8** %5
%13 = load i32, i32* @SEEK_END
%14 = call i32 @fseek(i8* %12, i64 0, i32 %13)
%15 = load i8*, i8** %5
%16 = call i32 @ftell(i8* %15)
store i32 %16, i32* %6
%17 = load i8*, i8** %5
%18 = call i32 @rewind(i8* %17)
%19 = load i32, i32* %6
%20 = add nsw i32 %19, 2
%21 = call i8* @calloc(i32 %20, i32 1)
%22 = load i8**, i8*** %4
store i8* %21, i8** %22
%23 = load i8**, i8*** %4
%24 = load i8*, i8** %23
%25 = call i32 @assert(i8* %24)
%26 = load i8**, i8*** %4
%27 = load i8*, i8** %26
%28 = load i32, i32* %6
%29 = load i8*, i8** %5
%30 = call i32 @fread(i8* %27, i32 1, i32 %28, i8* %29)
store i32 %30, i32* %7
%31 = load i8*, i8** %5
%32 = call i32 @fclose(i8* %31)
ret void
}

LLVM IR (-O2):
@.str = [2 x i8] c"r\00"
@SEEK_END = global i32 0
define void @ReadFile(i8* nocapture %0, i8** nocapture %1) {
%3 = tail call i8* @fopen(i8* %0, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
%4 = tail call i32 @assert(i8* %3)
%5 = load i32, i32* @SEEK_END
%6 = tail call i32 @fseek(i8* %3, i64 0, i32 %5)
%7 = tail call i32 @ftell(i8* %3)
%8 = tail call i32 @rewind(i8* %3)
%9 = add nsw i32 %7, 2
%10 = tail call i8* @calloc(i32 %9, i32 1)
store i8* %10, i8** %1
%11 = tail call i32 @assert(i8* %10)
%12 = load i8*, i8** %1
%13 = tail call i32 @fread(i8* %12, i32 1, i32 %7, i8* %3)
%14 = tail call i32 @fclose(i8* %3)
ret void
}