#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*/ errno;
int /*<<< orphan*/ exit(int);
int /*<<< orphan*/ fclose(int /*<<< orphan*/ *);
int /*<<< orphan*/ *fopen(char const *, char *);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *, char const *, char *);
size_t const fread(char *, int, size_t const, int /*<<< orphan*/ *);
int /*<<< orphan*/ stderr;
char *strerror(int /*<<< orphan*/);
int get_file_content(const char *path, const size_t size, char *o) {
  FILE *fd = fopen(path, "r");
  if (fd == NULL) {
    fprintf(stderr, "Error openning %s: %s\n", path, strerror(errno));
    exit(-1);
  }
  if (fread(o, 1, size, fd) != size) {
    fprintf(stderr, "Error reading %s: %s\n", path, strerror(errno));
    exit(1);
  }
  fclose(fd);
  return 0;
}


x86 assembly (clang, -O0):
<get_file_content>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
mov    -0x8(%rbp),%rdi
lea    0xe81(%rip),%rsi
call   1060 <fopen@plt>
mov    %rax,-0x20(%rbp)
cmpq   $0x0,-0x20(%rbp)
jne    11d5 <get_file_content+0x75>
mov    0x2e46(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x2c(%rbp)
mov    -0x8(%rbp),%rax
mov    %rax,-0x28(%rbp)
mov    0x2e2a(%rip),%rax
mov    (%rax),%edi
call   1080 <strerror@plt>
mov    -0x2c(%rbp),%edi
mov    -0x28(%rbp),%rdx
mov    %rax,%rcx
lea    0xe3c(%rip),%rsi
call   1050 <fprintf@plt>
mov    $0xffffffff,%edi
call   1070 <exit@plt>
mov    -0x18(%rbp),%rdi
mov    -0x10(%rbp),%rdx
mov    -0x20(%rbp),%rcx
mov    $0x1,%esi
call   1030 <fread@plt>
cmp    -0x10(%rbp),%rax
je     1237 <get_file_content+0xd7>
mov    0x2de4(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x3c(%rbp)
mov    -0x8(%rbp),%rax
mov    %rax,-0x38(%rbp)
mov    0x2dc8(%rip),%rax
mov    (%rax),%edi
call   1080 <strerror@plt>
mov    -0x3c(%rbp),%edi
mov    -0x38(%rbp),%rdx
mov    %rax,%rcx
lea    0xdf1(%rip),%rsi
call   1050 <fprintf@plt>
mov    $0x1,%edi
call   1070 <exit@plt>
mov    -0x20(%rbp),%rdi
call   1040 <fclose@plt>
xor    %eax,%eax
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<get_file_content>:
push   %r15
push   %r14
push   %r12
push   %rbx
push   %rax
mov    %rdx,%r12
mov    %rsi,%r15
mov    %rdi,%r14
lea    0xe88(%rip),%rsi
call   1060 <fopen@plt>
test   %rax,%rax
je     11b3 <get_file_content+0x53>
mov    %rax,%rbx
mov    %r12,%rdi
mov    $0x1,%esi
mov    %r15,%rdx
mov    %rax,%rcx
call   1030 <fread@plt>
cmp    %r15,%rax
jne    11e8 <get_file_content+0x88>
mov    %rbx,%rdi
call   1040 <fclose@plt>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
ret
mov    0x2e26(%rip),%rax
mov    (%rax),%ebx
mov    0x2e15(%rip),%rax
mov    (%rax),%edi
call   1080 <strerror@plt>
lea    0xe31(%rip),%rsi
mov    %ebx,%edi
mov    %r14,%rdx
mov    %rax,%rcx
call   1050 <fprintf@plt>
mov    $0xffffffff,%edi
call   1070 <exit@plt>
mov    0x2df1(%rip),%rax
mov    (%rax),%ebx
mov    0x2de0(%rip),%rax
mov    (%rax),%edi
call   1080 <strerror@plt>
lea    0xe13(%rip),%rsi
mov    %ebx,%edi
mov    %r14,%rdx
mov    %rax,%rcx
call   1050 <fprintf@plt>
mov    $0x1,%edi
call   1070 <exit@plt>

LLVM IR (-O0):
@.str = [2 x i8] c"r\00"
@stderr = global i32 0
@.str.1 = [23 x i8] c"Error openning %s: %s\0A\00"
@errno = global i32 0
@.str.2 = [22 x i8] c"Error reading %s: %s\0A\00"
define i32 @get_file_content(i8* %0, i64 %1, i8* %2) {
%4 = alloca i8*
%5 = alloca i64
%6 = alloca i8*
%7 = alloca i32*
store i8* %0, i8** %4
store i64 %1, i64* %5
store i8* %2, i8** %6
%8 = load i8*, i8** %4
%9 = call i32* @fopen(i8* %8, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
store i32* %9, i32** %7
%10 = load i32*, i32** %7
%11 = icmp eq i32* %10, null
br i1 %11, label %12, label %19
12: ; preds = %3
%13 = load i32, i32* @stderr
%14 = load i8*, i8** %4
%15 = load i32, i32* @errno
%16 = call i8* @strerror(i32 %15)
%17 = call i32 @fprintf(i32 %13, i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.1, i64 0, i64 0), i8* %14, i8* %16)
%18 = call i32 @exit(i32 -1)
unreachable
19: ; preds = %3
%20 = load i8*, i8** %6
%21 = load i64, i64* %5
%22 = load i32*, i32** %7
%23 = call i64 @fread(i8* %20, i32 1, i64 %21, i32* %22)
%24 = load i64, i64* %5
%25 = icmp ne i64 %23, %24
br i1 %25, label %26, label %33
26: ; preds = %19
%27 = load i32, i32* @stderr
%28 = load i8*, i8** %4
%29 = load i32, i32* @errno
%30 = call i8* @strerror(i32 %29)
%31 = call i32 @fprintf(i32 %27, i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.2, i64 0, i64 0), i8* %28, i8* %30)
%32 = call i32 @exit(i32 1)
unreachable
33: ; preds = %19
%34 = load i32*, i32** %7
%35 = call i32 @fclose(i32* %34)
ret i32 0
}

LLVM IR (-O2):
@.str = [2 x i8] c"r\00"
@stderr = global i32 0
@.str.1 = [23 x i8] c"Error openning %s: %s\0A\00"
@errno = global i32 0
@.str.2 = [22 x i8] c"Error reading %s: %s\0A\00"
define i32 @get_file_content(i8* %0, i64 %1, i8* nocapture %2) {
%4 = tail call i32* @fopen(i8* %0, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
%5 = icmp eq i32* %4, null
br i1 %5, label %6, label %12
6: ; preds = %3
%7 = load i32, i32* @stderr
%8 = load i32, i32* @errno
%9 = tail call i8* @strerror(i32 %8)
%10 = tail call i32 @fprintf(i32 %7, i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.1, i64 0, i64 0), i8* %0, i8* %9)
%11 = tail call i32 @exit(i32 -1)
unreachable
12: ; preds = %3
%13 = tail call i64 @fread(i8* %2, i32 1, i64 %1, i32* %4)
%14 = icmp eq i64 %13, %1
br i1 %14, label %21, label %15
15: ; preds = %12
%16 = load i32, i32* @stderr
%17 = load i32, i32* @errno
%18 = tail call i8* @strerror(i32 %17)
%19 = tail call i32 @fprintf(i32 %16, i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.2, i64 0, i64 0), i8* %0, i8* %18)
%20 = tail call i32 @exit(i32 1)
unreachable
21: ; preds = %12
%22 = tail call i32 @fclose(i32* %4)
ret i32 0
}