#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 uint8_t;
typedef int int64_t;
typedef int /*<<< orphan*/ FILE;

/* Variables and functions */
scalar_t__ EOF;
int /*<<< orphan*/ clearerr(int /*<<< orphan*/ *);
int /*<<< orphan*/ errno;
scalar_t__ fclose(int /*<<< orphan*/ *);
scalar_t__ feof(int /*<<< orphan*/ *);
scalar_t__ ferror(int /*<<< orphan*/ *);
scalar_t__ file_get_size(char const *, int *);
int /*<<< orphan*/ *fopen(char const *, char *);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *, ...);
size_t fread(char *, int, int, int /*<<< orphan*/ *);
int /*<<< orphan*/ free(char *);
scalar_t__ malloc(size_t);
int /*<<< orphan*/ stderr;
char *strerror(int /*<<< orphan*/);
uint8_t file_get_contents(const char *filename, char **contents) {
  int64_t size = 0;
  size_t size_to_read = 0;
  size_t read_size = 0;
  FILE *f = NULL;
  if (file_get_size(filename, &size))
    return 1;
  size_to_read = sizeof(char) * size;
  *contents = (char *)malloc(size_to_read + sizeof(char));
  if (*contents == NULL) {
    fprintf(stderr, "Error: %s\n", strerror(errno));
    fprintf(stderr, " -> Memory allocation failed for file contents.\n");
    fprintf(stderr, " -> File: %s\n", filename);
    return 1;
  }
  (*contents)[size] = '\0';
  f = fopen(filename, "r");
  if (f == NULL) {
    fprintf(stderr, "Error: %s\n", strerror(errno));
    fprintf(stderr, " -> Failed to open file.\n");
    fprintf(stderr, " -> File: %s\n", filename);
    free(*contents);
    *contents = NULL;
    return 1;
  }
  read_size = fread(*contents, sizeof(char), size, f);
  if (read_size < size_to_read) {
    fprintf(stderr, "Error: Data size read from file less than expected.\n");
    fprintf(stderr, " -> Expected: %ld\n", (int64_t)size_to_read);
    fprintf(stderr, " -> Actual: %ld\n", (int64_t)read_size);
    fprintf(stderr, " -> File: %s\n", filename);
    if (ferror(f)) {
      fprintf(stderr, "Error: Unknown error when reading from file.\n");
      fprintf(stderr, " -> File: %s\n", filename);
      clearerr(f);
    }
    if (feof(f)) {
      fprintf(stderr, "Error: Premature end-of-file.\n");
      fprintf(stderr, " -> File: %s\n", filename);
    }
    if (fclose(f) == EOF) {
      fprintf(stderr, "Error: %s\n", strerror(errno));
      fprintf(stderr, " -> Failed to close file.\n");
      fprintf(stderr, " -> File: %s\n", filename);
    }
    free(*contents);
    *contents = NULL;
    return 1;
  }
  if (fclose(f) == EOF) {
    fprintf(stderr, "Error: %s\n", strerror(errno));
    fprintf(stderr, " -> Failed to close file.\n");
    fprintf(stderr, " -> File: %s\n", filename);
    free(*contents);
    *contents = NULL;
    return 1;
  }
  return 0;
}


x86 assembly (clang, -O0):
<file_get_contents>:
push   %rbp
mov    %rsp,%rbp
sub    $0x50,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
movl   $0x0,-0x1c(%rbp)
movq   $0x0,-0x28(%rbp)
movq   $0x0,-0x30(%rbp)
movq   $0x0,-0x38(%rbp)
mov    -0x10(%rbp),%rdi
lea    -0x1c(%rbp),%rsi
call   1040 <file_get_size@plt>
cmp    $0x0,%rax
je     1202 <file_get_contents+0x52>
movl   $0x1,-0x4(%rbp)
jmp    15b8 <file_get_contents+0x408>
movslq -0x1c(%rbp),%rax
shl    $0x0,%rax
mov    %rax,-0x28(%rbp)
mov    -0x28(%rbp),%rdi
add    $0x1,%rdi
call   10b0 <malloc@plt>
mov    %rax,%rcx
mov    -0x18(%rbp),%rax
mov    %rcx,(%rax)
mov    -0x18(%rbp),%rax
cmpq   $0x0,(%rax)
jne    129f <file_get_contents+0xef>
mov    0x2d9e(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x3c(%rbp)
mov    0x2d8a(%rip),%rax
mov    (%rax),%edi
call   10d0 <strerror@plt>
mov    -0x3c(%rbp),%edi
mov    %rax,%rdx
lea    0xda6(%rip),%rsi
mov    $0x0,%al
call   1080 <fprintf@plt>
mov    0x2d70(%rip),%rax
mov    (%rax),%edi
lea    0xd9a(%rip),%rsi
mov    $0x0,%al
call   1080 <fprintf@plt>
mov    0x2d59(%rip),%rax
mov    (%rax),%edi
mov    -0x10(%rbp),%rdx
lea    0xdb0(%rip),%rsi
mov    $0x0,%al
call   1080 <fprintf@plt>
movl   $0x1,-0x4(%rbp)
jmp    15b8 <file_get_contents+0x408>
mov    -0x18(%rbp),%rax
mov    (%rax),%rax
movslq -0x1c(%rbp),%rcx
movb   $0x0,(%rax,%rcx,1)
mov    -0x10(%rbp),%rdi
lea    0xd91(%rip),%rsi
call   10c0 <fopen@plt>
mov    %rax,-0x38(%rbp)
cmpq   $0x0,-0x38(%rbp)
jne    1350 <file_get_contents+0x1a0>
mov    0x2d04(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x40(%rbp)
mov    0x2cf0(%rip),%rax
mov    (%rax),%edi
call   10d0 <strerror@plt>
mov    -0x40(%rbp),%edi
mov    %rax,%rdx
lea    0xd0c(%rip),%rsi
mov    $0x0,%al
call   1080 <fprintf@plt>
mov    0x2cd6(%rip),%rax
mov    (%rax),%edi
lea    0xd41(%rip),%rsi
mov    $0x0,%al
call   1080 <fprintf@plt>
mov    0x2cbf(%rip),%rax
mov    (%rax),%edi
mov    -0x10(%rbp),%rdx
lea    0xd16(%rip),%rsi
mov    $0x0,%al
call   1080 <fprintf@plt>
mov    -0x18(%rbp),%rax
mov    (%rax),%rdi
call   1030 <free@plt>
mov    -0x18(%rbp),%rax
movq   $0x0,(%rax)
movl   $0x1,-0x4(%rbp)
jmp    15b8 <file_get_contents+0x408>
mov    -0x18(%rbp),%rax
mov    (%rax),%rdi
mov    -0x1c(%rbp),%edx
mov    -0x38(%rbp),%rcx
mov    $0x1,%esi
call   1060 <fread@plt>
mov    %rax,-0x30(%rbp)
mov    -0x30(%rbp),%rax
cmp    -0x28(%rbp),%rax
jae    1515 <file_get_contents+0x365>
mov    0x2c57(%rip),%rax
mov    (%rax),%edi
lea    0xcdc(%rip),%rsi
mov    $0x0,%al
call   1080 <fprintf@plt>
mov    0x2c40(%rip),%rax
mov    (%rax),%edi
mov    -0x28(%rbp),%rax
mov    %eax,%edx
lea    0xcf4(%rip),%rsi
mov    $0x0,%al
call   1080 <fprintf@plt>
mov    0x2c23(%rip),%rax
mov    (%rax),%edi
mov    -0x30(%rbp),%rax
mov    %eax,%edx
lea    0xcea(%rip),%rsi
mov    $0x0,%al
call   1080 <fprintf@plt>
mov    0x2c06(%rip),%rax
mov    (%rax),%edi
mov    -0x10(%rbp),%rdx
lea    0xc5d(%rip),%rsi
mov    $0x0,%al
call   1080 <fprintf@plt>
mov    -0x38(%rbp),%rdi
call   1050 <ferror@plt>
cmp    $0x0,%rax
je     1434 <file_get_contents+0x284>
mov    0x2bd8(%rip),%rax
mov    (%rax),%edi
lea    0xcb6(%rip),%rsi
mov    $0x0,%al
call   1080 <fprintf@plt>
mov    0x2bc1(%rip),%rax
mov    (%rax),%edi
mov    -0x10(%rbp),%rdx
lea    0xc18(%rip),%rsi
mov    $0x0,%al
call   1080 <fprintf@plt>
mov    -0x38(%rbp),%rdi
call   10a0 <clearerr@plt>
mov    -0x38(%rbp),%rdi
call   1090 <feof@plt>
cmp    $0x0,%rax
je     1479 <file_get_contents+0x2c9>
mov    0x2b8a(%rip),%rax
mov    (%rax),%edi
lea    0xc96(%rip),%rsi
mov    $0x0,%al
call   1080 <fprintf@plt>
mov    0x2b73(%rip),%rax
mov    (%rax),%edi
mov    -0x10(%rbp),%rdx
lea    0xbca(%rip),%rsi
mov    $0x0,%al
call   1080 <fprintf@plt>
mov    -0x38(%rbp),%rdi
call   1070 <fclose@plt>
mov    0x2b5f(%rip),%rcx
cmp    (%rcx),%rax
jne    14f2 <file_get_contents+0x342>
mov    0x2b3f(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x44(%rbp)
mov    0x2b2b(%rip),%rax
mov    (%rax),%edi
call   10d0 <strerror@plt>
mov    -0x44(%rbp),%edi
mov    %rax,%rdx
lea    0xb47(%rip),%rsi
mov    $0x0,%al
call   1080 <fprintf@plt>
mov    0x2b11(%rip),%rax
mov    (%rax),%edi
lea    0xc3c(%rip),%rsi
mov    $0x0,%al
call   1080 <fprintf@plt>
mov    0x2afa(%rip),%rax
mov    (%rax),%edi
mov    -0x10(%rbp),%rdx
lea    0xb51(%rip),%rsi
mov    $0x0,%al
call   1080 <fprintf@plt>
mov    -0x18(%rbp),%rax
mov    (%rax),%rdi
call   1030 <free@plt>
mov    -0x18(%rbp),%rax
movq   $0x0,(%rax)
movl   $0x1,-0x4(%rbp)
jmp    15b8 <file_get_contents+0x408>
mov    -0x38(%rbp),%rdi
call   1070 <fclose@plt>
mov    0x2ac3(%rip),%rcx
cmp    (%rcx),%rax
jne    15b1 <file_get_contents+0x401>
mov    0x2aa3(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x48(%rbp)
mov    0x2a8f(%rip),%rax
mov    (%rax),%edi
call   10d0 <strerror@plt>
mov    -0x48(%rbp),%edi
mov    %rax,%rdx
lea    0xaab(%rip),%rsi
mov    $0x0,%al
call   1080 <fprintf@plt>
mov    0x2a75(%rip),%rax
mov    (%rax),%edi
lea    0xba0(%rip),%rsi
mov    $0x0,%al
call   1080 <fprintf@plt>
mov    0x2a5e(%rip),%rax
mov    (%rax),%edi
mov    -0x10(%rbp),%rdx
lea    0xab5(%rip),%rsi
mov    $0x0,%al
call   1080 <fprintf@plt>
mov    -0x18(%rbp),%rax
mov    (%rax),%rdi
call   1030 <free@plt>
mov    -0x18(%rbp),%rax
movq   $0x0,(%rax)
movl   $0x1,-0x4(%rbp)
jmp    15b8 <file_get_contents+0x408>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x50,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<file_get_contents>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
mov    %rsi,%r14
mov    %rdi,%r12
movl   $0x0,0x4(%rsp)
lea    0x4(%rsp),%rsi
call   1040 <file_get_size@plt>
mov    $0x1,%ebp
test   %rax,%rax
je     11ee <file_get_contents+0x3e>
mov    %ebp,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret
movslq 0x4(%rsp),%rbx
lea    0x1(%rbx),%rdi
call   10b0 <malloc@plt>
mov    %rax,(%r14)
test   %rax,%rax
je     136a <file_get_contents+0x1ba>
movslq 0x4(%rsp),%rcx
movb   $0x0,(%rax,%rcx,1)
lea    0xe32(%rip),%rsi
mov    %r12,%rdi
call   10c0 <fopen@plt>
test   %rax,%rax
je     13bf <file_get_contents+0x20f>
mov    %rax,%r15
mov    (%r14),%rdi
mov    0x4(%rsp),%edx
mov    $0x1,%esi
mov    %rax,%rcx
call   1060 <fread@plt>
cmp    %rbx,%rax
jae    1423 <file_get_contents+0x273>
mov    %rax,%rbp
mov    0x2d85(%rip),%r13
mov    0x0(%r13),%edi
lea    0xe08(%rip),%rsi
xor    %eax,%eax
call   1080 <fprintf@plt>
mov    0x0(%r13),%edi
lea    0xe2b(%rip),%rsi
mov    %ebx,%edx
xor    %eax,%eax
call   1080 <fprintf@plt>
mov    0x0(%r13),%edi
lea    0xe2a(%rip),%rsi
mov    %ebp,%edx
xor    %eax,%eax
call   1080 <fprintf@plt>
mov    0x0(%r13),%edi
lea    0xda4(%rip),%rsi
mov    %r12,%rdx
xor    %eax,%eax
call   1080 <fprintf@plt>
mov    %r15,%rdi
call   1050 <ferror@plt>
test   %rax,%rax
je     12de <file_get_contents+0x12e>
mov    0x0(%r13),%edi
lea    0xe05(%rip),%rsi
xor    %eax,%eax
call   1080 <fprintf@plt>
mov    0x0(%r13),%edi
lea    0xd70(%rip),%rsi
mov    %r12,%rdx
xor    %eax,%eax
call   1080 <fprintf@plt>
mov    %r15,%rdi
call   10a0 <clearerr@plt>
mov    %r15,%rdi
call   1090 <feof@plt>
test   %rax,%rax
je     1312 <file_get_contents+0x162>
mov    0x0(%r13),%edi
lea    0xdf7(%rip),%rsi
xor    %eax,%eax
call   1080 <fprintf@plt>
mov    0x0(%r13),%edi
lea    0xd34(%rip),%rsi
mov    %r12,%rdx
xor    %eax,%eax
call   1080 <fprintf@plt>
mov    %r15,%rdi
call   1070 <fclose@plt>
mov    0x2cc7(%rip),%rcx
cmp    (%rcx),%rax
jne    148d <file_get_contents+0x2dd>
mov    0x0(%r13),%ebx
mov    0x2c9b(%rip),%rax
mov    (%rax),%edi
call   10d0 <strerror@plt>
lea    0xcbd(%rip),%rsi
mov    %ebx,%edi
mov    %rax,%rdx
xor    %eax,%eax
call   1080 <fprintf@plt>
mov    0x0(%r13),%edi
lea    0xdb2(%rip),%rsi
xor    %eax,%eax
call   1080 <fprintf@plt>
mov    0x0(%r13),%edi
jmp    147c <file_get_contents+0x2cc>
mov    0x2c67(%rip),%r14
mov    (%r14),%ebx
mov    0x2c55(%rip),%rax
mov    (%rax),%edi
call   10d0 <strerror@plt>
lea    0xc77(%rip),%rsi
mov    %ebx,%edi
mov    %rax,%rdx
xor    %eax,%eax
call   1080 <fprintf@plt>
mov    (%r14),%edi
lea    0xc6c(%rip),%rsi
xor    %eax,%eax
call   1080 <fprintf@plt>
mov    (%r14),%edi
lea    0xc8c(%rip),%rsi
mov    %r12,%rdx
xor    %eax,%eax
call   1080 <fprintf@plt>
jmp    11dd <file_get_contents+0x2d>
mov    0x2c12(%rip),%r15
mov    (%r15),%ebx
mov    0x2c00(%rip),%rax
mov    (%rax),%edi
call   10d0 <strerror@plt>
lea    0xc22(%rip),%rsi
mov    %ebx,%edi
mov    %rax,%rdx
xor    %eax,%eax
call   1080 <fprintf@plt>
mov    (%r15),%edi
lea    0xc58(%rip),%rsi
xor    %eax,%eax
call   1080 <fprintf@plt>
mov    (%r15),%edi
lea    0xc37(%rip),%rsi
mov    %r12,%rdx
xor    %eax,%eax
call   1080 <fprintf@plt>
mov    (%r14),%rdi
call   1030 <free@plt>
movq   $0x0,(%r14)
jmp    11dd <file_get_contents+0x2d>
mov    %r15,%rdi
call   1070 <fclose@plt>
mov    0x2bb6(%rip),%rcx
xor    %ebp,%ebp
cmp    (%rcx),%rax
jne    11dd <file_get_contents+0x2d>
mov    0x2b94(%rip),%rbp
mov    0x0(%rbp),%ebx
mov    0x2b82(%rip),%rax
mov    (%rax),%edi
call   10d0 <strerror@plt>
lea    0xba4(%rip),%rsi
mov    %ebx,%edi
mov    %rax,%rdx
xor    %eax,%eax
call   1080 <fprintf@plt>
mov    0x0(%rbp),%edi
lea    0xc9a(%rip),%rsi
xor    %eax,%eax
call   1080 <fprintf@plt>
mov    0x0(%rbp),%edi
lea    0xbb9(%rip),%rsi
mov    %r12,%rdx
xor    %eax,%eax
call   1080 <fprintf@plt>
mov    (%r14),%rdi
call   1030 <free@plt>
movq   $0x0,(%r14)
mov    $0x1,%ebp
jmp    11dd <file_get_contents+0x2d>

LLVM IR (-O0):
@stderr = global i32 0
@.str = [11 x i8] c"Error: %s\0A\00"
@errno = global i32 0
@.str.1 = [49 x i8] c" -> Memory allocation failed for file contents.\0A\00"
@.str.2 = [14 x i8] c" -> File: %s\0A\00"
@.str.3 = [2 x i8] c"r\00"
@.str.4 = [26 x i8] c" -> Failed to open file.\0A\00"
@.str.5 = [53 x i8] c"Error: Data size read from file less than expected.\0A\00"
@.str.6 = [19 x i8] c" -> Expected: %ld\0A\00"
@.str.7 = [17 x i8] c" -> Actual: %ld\0A\00"
@.str.8 = [46 x i8] c"Error: Unknown error when reading from file.\0A\00"
@.str.9 = [31 x i8] c"Error: Premature end-of-file.\0A\00"
@EOF = global i64 0
@.str.10 = [27 x i8] c" -> Failed to close file.\0A\00"
define i32 @file_get_contents(i8* %0, i8** %1) {
%3 = alloca i32
%4 = alloca i8*
%5 = alloca i8**
%6 = alloca i32
%7 = alloca i64
%8 = alloca i64
%9 = alloca i32*
store i8* %0, i8** %4
store i8** %1, i8*** %5
store i32 0, i32* %6
store i64 0, i64* %7
store i64 0, i64* %8
store i32* null, i32** %9
%10 = load i8*, i8** %4
%11 = call i64 @file_get_size(i8* %10, i32* %6)
%12 = icmp ne i64 %11, 0
br i1 %12, label %13, label %14
13: ; preds = %2
store i32 1, i32* %3
br label %144
14: ; preds = %2
%15 = load i32, i32* %6
%16 = sext i32 %15 to i64
%17 = mul i64 1, %16
store i64 %17, i64* %7
%18 = load i64, i64* %7
%19 = add i64 %18, 1
%20 = call i64 @malloc(i64 %19)
%21 = inttoptr i64 %20 to i8*
%22 = load i8**, i8*** %5
store i8* %21, i8** %22
%23 = load i8**, i8*** %5
%24 = load i8*, i8** %23
%25 = icmp eq i8* %24, null
br i1 %25, label %26, label %36
26: ; preds = %14
%27 = load i32, i32* @stderr
%28 = load i32, i32* @errno
%29 = call i8* @strerror(i32 %28)
%30 = call i32 (i32, i8*, ...) @fprintf(i32 %27, i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str, i64 0, i64 0), i8* %29)
%31 = load i32, i32* @stderr
%32 = call i32 (i32, i8*, ...) @fprintf(i32 %31, i8* getelementptr inbounds ([49 x i8], [49 x i8]* @.str.1, i64 0, i64 0))
%33 = load i32, i32* @stderr
%34 = load i8*, i8** %4
%35 = call i32 (i32, i8*, ...) @fprintf(i32 %33, i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.2, i64 0, i64 0), i8* %34)
store i32 1, i32* %3
br label %144
36: ; preds = %14
%37 = load i8**, i8*** %5
%38 = load i8*, i8** %37
%39 = load i32, i32* %6
%40 = sext i32 %39 to i64
%41 = getelementptr inbounds i8, i8* %38, i64 %40
store i8 0, i8* %41
%42 = load i8*, i8** %4
%43 = call i32* @fopen(i8* %42, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.3, i64 0, i64 0))
store i32* %43, i32** %9
%44 = load i32*, i32** %9
%45 = icmp eq i32* %44, null
br i1 %45, label %46, label %60
46: ; preds = %36
%47 = load i32, i32* @stderr
%48 = load i32, i32* @errno
%49 = call i8* @strerror(i32 %48)
%50 = call i32 (i32, i8*, ...) @fprintf(i32 %47, i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str, i64 0, i64 0), i8* %49)
%51 = load i32, i32* @stderr
%52 = call i32 (i32, i8*, ...) @fprintf(i32 %51, i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str.4, i64 0, i64 0))
%53 = load i32, i32* @stderr
%54 = load i8*, i8** %4
%55 = call i32 (i32, i8*, ...) @fprintf(i32 %53, i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.2, i64 0, i64 0), i8* %54)
%56 = load i8**, i8*** %5
%57 = load i8*, i8** %56
%58 = call i32 @free(i8* %57)
%59 = load i8**, i8*** %5
store i8* null, i8** %59
store i32 1, i32* %3
br label %144
60: ; preds = %36
%61 = load i8**, i8*** %5
%62 = load i8*, i8** %61
%63 = load i32, i32* %6
%64 = load i32*, i32** %9
%65 = call i64 @fread(i8* %62, i32 1, i32 %63, i32* %64)
store i64 %65, i64* %8
%66 = load i64, i64* %8
%67 = load i64, i64* %7
%68 = icmp ult i64 %66, %67
br i1 %68, label %69, label %124
69: ; preds = %60
%70 = load i32, i32* @stderr
%71 = call i32 (i32, i8*, ...) @fprintf(i32 %70, i8* getelementptr inbounds ([53 x i8], [53 x i8]* @.str.5, i64 0, i64 0))
%72 = load i32, i32* @stderr
%73 = load i64, i64* %7
%74 = trunc i64 %73 to i32
%75 = call i32 (i32, i8*, ...) @fprintf(i32 %72, i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.6, i64 0, i64 0), i32 %74)
%76 = load i32, i32* @stderr
%77 = load i64, i64* %8
%78 = trunc i64 %77 to i32
%79 = call i32 (i32, i8*, ...) @fprintf(i32 %76, i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.7, i64 0, i64 0), i32 %78)
%80 = load i32, i32* @stderr
%81 = load i8*, i8** %4
%82 = call i32 (i32, i8*, ...) @fprintf(i32 %80, i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.2, i64 0, i64 0), i8* %81)
%83 = load i32*, i32** %9
%84 = call i64 @ferror(i32* %83)
%85 = icmp ne i64 %84, 0
br i1 %85, label %86, label %94
86: ; preds = %69
%87 = load i32, i32* @stderr
%88 = call i32 (i32, i8*, ...) @fprintf(i32 %87, i8* getelementptr inbounds ([46 x i8], [46 x i8]* @.str.8, i64 0, i64 0))
%89 = load i32, i32* @stderr
%90 = load i8*, i8** %4
%91 = call i32 (i32, i8*, ...) @fprintf(i32 %89, i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.2, i64 0, i64 0), i8* %90)
%92 = load i32*, i32** %9
%93 = call i32 @clearerr(i32* %92)
br label %94
94: ; preds = %86, %69
%95 = load i32*, i32** %9
%96 = call i64 @feof(i32* %95)
%97 = icmp ne i64 %96, 0
br i1 %97, label %98, label %104
98: ; preds = %94
%99 = load i32, i32* @stderr
%100 = call i32 (i32, i8*, ...) @fprintf(i32 %99, i8* getelementptr inbounds ([31 x i8], [31 x i8]* @.str.9, i64 0, i64 0))
%101 = load i32, i32* @stderr
%102 = load i8*, i8** %4
%103 = call i32 (i32, i8*, ...) @fprintf(i32 %101, i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.2, i64 0, i64 0), i8* %102)
br label %104
104: ; preds = %98, %94
%105 = load i32*, i32** %9
%106 = call i64 @fclose(i32* %105)
%107 = load i64, i64* @EOF
%108 = icmp eq i64 %106, %107
br i1 %108, label %109, label %119
109: ; preds = %104
%110 = load i32, i32* @stderr
%111 = load i32, i32* @errno
%112 = call i8* @strerror(i32 %111)
%113 = call i32 (i32, i8*, ...) @fprintf(i32 %110, i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str, i64 0, i64 0), i8* %112)
%114 = load i32, i32* @stderr
%115 = call i32 (i32, i8*, ...) @fprintf(i32 %114, i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str.10, i64 0, i64 0))
%116 = load i32, i32* @stderr
%117 = load i8*, i8** %4
%118 = call i32 (i32, i8*, ...) @fprintf(i32 %116, i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.2, i64 0, i64 0), i8* %117)
br label %119
119: ; preds = %109, %104
%120 = load i8**, i8*** %5
%121 = load i8*, i8** %120
%122 = call i32 @free(i8* %121)
%123 = load i8**, i8*** %5
store i8* null, i8** %123
store i32 1, i32* %3
br label %144
124: ; preds = %60
%125 = load i32*, i32** %9
%126 = call i64 @fclose(i32* %125)
%127 = load i64, i64* @EOF
%128 = icmp eq i64 %126, %127
br i1 %128, label %129, label %143
129: ; preds = %124
%130 = load i32, i32* @stderr
%131 = load i32, i32* @errno
%132 = call i8* @strerror(i32 %131)
%133 = call i32 (i32, i8*, ...) @fprintf(i32 %130, i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str, i64 0, i64 0), i8* %132)
%134 = load i32, i32* @stderr
%135 = call i32 (i32, i8*, ...) @fprintf(i32 %134, i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str.10, i64 0, i64 0))
%136 = load i32, i32* @stderr
%137 = load i8*, i8** %4
%138 = call i32 (i32, i8*, ...) @fprintf(i32 %136, i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.2, i64 0, i64 0), i8* %137)
%139 = load i8**, i8*** %5
%140 = load i8*, i8** %139
%141 = call i32 @free(i8* %140)
%142 = load i8**, i8*** %5
store i8* null, i8** %142
store i32 1, i32* %3
br label %144
143: ; preds = %124
store i32 0, i32* %3
br label %144
144: ; preds = %143, %129, %119, %46, %26, %13
%145 = load i32, i32* %3
ret i32 %145
}

LLVM IR (-O2):
@stderr = global i32 0
@.str = [11 x i8] c"Error: %s\0A\00"
@errno = global i32 0
@.str.1 = [49 x i8] c" -> Memory allocation failed for file contents.\0A\00"
@.str.2 = [14 x i8] c" -> File: %s\0A\00"
@.str.3 = [2 x i8] c"r\00"
@.str.4 = [26 x i8] c" -> Failed to open file.\0A\00"
@.str.5 = [53 x i8] c"Error: Data size read from file less than expected.\0A\00"
@.str.6 = [19 x i8] c" -> Expected: %ld\0A\00"
@.str.7 = [17 x i8] c" -> Actual: %ld\0A\00"
@.str.8 = [46 x i8] c"Error: Unknown error when reading from file.\0A\00"
@.str.9 = [31 x i8] c"Error: Premature end-of-file.\0A\00"
@EOF = global i64 0
@.str.10 = [27 x i8] c" -> Failed to close file.\0A\00"
define i32 @file_get_contents(i8* %0, i8** nocapture %1) {
%3 = alloca i32
%4 = bitcast i32* %3 to i8*
store i32 0, i32* %3
%5 = call i64 @file_get_size(i8* %0, i32* %3)
%6 = icmp eq i64 %5, 0
br i1 %6, label %7, label %102
7: ; preds = %2
%8 = load i32, i32* %3
%9 = sext i32 %8 to i64
%10 = add nsw i64 %9, 1
%11 = call i64 @malloc(i64 %10)
%12 = inttoptr i64 %11 to i8*
store i8* %12, i8** %1
%13 = icmp eq i64 %11, 0
br i1 %13, label %14, label %23
14: ; preds = %7
%15 = load i32, i32* @stderr
%16 = load i32, i32* @errno
%17 = call i8* @strerror(i32 %16)
%18 = call i32 (i32, i8*, ...) @fprintf(i32 %15, i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str, i64 0, i64 0), i8* %17)
%19 = load i32, i32* @stderr
%20 = call i32 (i32, i8*, ...) @fprintf(i32 %19, i8* getelementptr inbounds ([49 x i8], [49 x i8]* @.str.1, i64 0, i64 0))
%21 = load i32, i32* @stderr
%22 = call i32 (i32, i8*, ...) @fprintf(i32 %21, i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.2, i64 0, i64 0), i8* %0)
br label %102
23: ; preds = %7
%24 = load i32, i32* %3
%25 = sext i32 %24 to i64
%26 = getelementptr inbounds i8, i8* %12, i64 %25
store i8 0, i8* %26
%27 = call i32* @fopen(i8* %0, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.3, i64 0, i64 0))
%28 = icmp eq i32* %27, null
br i1 %28, label %29, label %40
29: ; preds = %23
%30 = load i32, i32* @stderr
%31 = load i32, i32* @errno
%32 = call i8* @strerror(i32 %31)
%33 = call i32 (i32, i8*, ...) @fprintf(i32 %30, i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str, i64 0, i64 0), i8* %32)
%34 = load i32, i32* @stderr
%35 = call i32 (i32, i8*, ...) @fprintf(i32 %34, i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str.4, i64 0, i64 0))
%36 = load i32, i32* @stderr
%37 = call i32 (i32, i8*, ...) @fprintf(i32 %36, i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.2, i64 0, i64 0), i8* %0)
%38 = load i8*, i8** %1
%39 = call i32 @free(i8* %38)
store i8* null, i8** %1
br label %102
40: ; preds = %23
%41 = load i8*, i8** %1
%42 = load i32, i32* %3
%43 = call i64 @fread(i8* %41, i32 1, i32 %42, i32* %27)
%44 = icmp ult i64 %43, %9
br i1 %44, label %45, label %87
45: ; preds = %40
%46 = load i32, i32* @stderr
%47 = call i32 (i32, i8*, ...) @fprintf(i32 %46, i8* getelementptr inbounds ([53 x i8], [53 x i8]* @.str.5, i64 0, i64 0))
%48 = load i32, i32* @stderr
%49 = call i32 (i32, i8*, ...) @fprintf(i32 %48, i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.6, i64 0, i64 0), i32 %8)
%50 = load i32, i32* @stderr
%51 = trunc i64 %43 to i32
%52 = call i32 (i32, i8*, ...) @fprintf(i32 %50, i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.7, i64 0, i64 0), i32 %51)
%53 = load i32, i32* @stderr
%54 = call i32 (i32, i8*, ...) @fprintf(i32 %53, i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.2, i64 0, i64 0), i8* %0)
%55 = call i64 @ferror(i32* %27)
%56 = icmp eq i64 %55, 0
br i1 %56, label %63, label %57
57: ; preds = %45
%58 = load i32, i32* @stderr
%59 = call i32 (i32, i8*, ...) @fprintf(i32 %58, i8* getelementptr inbounds ([46 x i8], [46 x i8]* @.str.8, i64 0, i64 0))
%60 = load i32, i32* @stderr
%61 = call i32 (i32, i8*, ...) @fprintf(i32 %60, i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.2, i64 0, i64 0), i8* %0)
%62 = call i32 @clearerr(i32* %27)
br label %63
63: ; preds = %57, %45
%64 = call i64 @feof(i32* %27)
%65 = icmp eq i64 %64, 0
br i1 %65, label %71, label %66
66: ; preds = %63
%67 = load i32, i32* @stderr
%68 = call i32 (i32, i8*, ...) @fprintf(i32 %67, i8* getelementptr inbounds ([31 x i8], [31 x i8]* @.str.9, i64 0, i64 0))
%69 = load i32, i32* @stderr
%70 = call i32 (i32, i8*, ...) @fprintf(i32 %69, i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.2, i64 0, i64 0), i8* %0)
br label %71
71: ; preds = %66, %63
%72 = call i64 @fclose(i32* %27)
%73 = load i64, i64* @EOF
%74 = icmp eq i64 %72, %73
br i1 %74, label %75, label %84
75: ; preds = %71
%76 = load i32, i32* @stderr
%77 = load i32, i32* @errno
%78 = call i8* @strerror(i32 %77)
%79 = call i32 (i32, i8*, ...) @fprintf(i32 %76, i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str, i64 0, i64 0), i8* %78)
%80 = load i32, i32* @stderr
%81 = call i32 (i32, i8*, ...) @fprintf(i32 %80, i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str.10, i64 0, i64 0))
%82 = load i32, i32* @stderr
%83 = call i32 (i32, i8*, ...) @fprintf(i32 %82, i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.2, i64 0, i64 0), i8* %0)
br label %84
84: ; preds = %75, %71
%85 = load i8*, i8** %1
%86 = call i32 @free(i8* %85)
store i8* null, i8** %1
br label %102
87: ; preds = %40
%88 = call i64 @fclose(i32* %27)
%89 = load i64, i64* @EOF
%90 = icmp eq i64 %88, %89
br i1 %90, label %91, label %102
91: ; preds = %87
%92 = load i32, i32* @stderr
%93 = load i32, i32* @errno
%94 = call i8* @strerror(i32 %93)
%95 = call i32 (i32, i8*, ...) @fprintf(i32 %92, i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str, i64 0, i64 0), i8* %94)
%96 = load i32, i32* @stderr
%97 = call i32 (i32, i8*, ...) @fprintf(i32 %96, i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str.10, i64 0, i64 0))
%98 = load i32, i32* @stderr
%99 = call i32 (i32, i8*, ...) @fprintf(i32 %98, i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.2, i64 0, i64 0), i8* %0)
%100 = load i8*, i8** %1
%101 = call i32 @free(i8* %100)
store i8* null, i8** %1
br label %102
102: ; preds = %87, %2, %91, %84, %29, %14
%103 = phi i32 [ 1, %14 ], [ 1, %29 ], [ 1, %84 ], [ 1, %91 ], [ 1, %2 ], [ 0, %87 ]
ret i32 %103
}