#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*/ fclose(int /*<<< orphan*/ *);
int /*<<< orphan*/ *fopen(char const *, char *);
unsigned long fread(char *, int, unsigned long, int /*<<< orphan*/ *);
int get_file_content(const char *filename, char *content,
                     unsigned long *max_content_size) {
  if (!filename || !content || !max_content_size || *max_content_size == 0) {
    return 0;
  }
  FILE *f = fopen(filename, "r");
  if (!f) {
    return 0;
  }
  *max_content_size = fread(content, sizeof(char), *max_content_size, f);
  fclose(f);
  return 1;
}


x86 assembly (clang, -O0):
<get_file_content>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
mov    %rdx,-0x20(%rbp)
cmpq   $0x0,-0x10(%rbp)
je     1173 <get_file_content+0x43>
cmpq   $0x0,-0x18(%rbp)
je     1173 <get_file_content+0x43>
cmpq   $0x0,-0x20(%rbp)
je     1173 <get_file_content+0x43>
mov    -0x20(%rbp),%rax
cmpq   $0x0,(%rax)
jne    117f <get_file_content+0x4f>
movl   $0x0,-0x4(%rbp)
jmp    11dd <get_file_content+0xad>
mov    -0x10(%rbp),%rdi
lea    0xe76(%rip),%rsi
call   1050 <fopen@plt>
mov    %rax,-0x28(%rbp)
cmpq   $0x0,-0x28(%rbp)
jne    11aa <get_file_content+0x7a>
movl   $0x0,-0x4(%rbp)
jmp    11dd <get_file_content+0xad>
mov    -0x18(%rbp),%rdi
mov    -0x20(%rbp),%rax
mov    (%rax),%rdx
mov    -0x28(%rbp),%rcx
mov    $0x1,%esi
call   1030 <fread@plt>
mov    %rax,%rcx
mov    -0x20(%rbp),%rax
mov    %rcx,(%rax)
mov    -0x28(%rbp),%rdi
call   1040 <fclose@plt>
movl   $0x1,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<get_file_content>:
push   %rbp
push   %r15
push   %r14
push   %rbx
push   %rax
xor    %r14d,%r14d
test   %rdi,%rdi
je     118d <get_file_content+0x5d>
mov    %rsi,%rbp
test   %rsi,%rsi
je     118d <get_file_content+0x5d>
mov    %rdx,%rbx
test   %rdx,%rdx
je     118d <get_file_content+0x5d>
cmpq   $0x0,(%rbx)
je     118d <get_file_content+0x5d>
lea    0xea4(%rip),%rsi
call   1050 <fopen@plt>
test   %rax,%rax
je     118d <get_file_content+0x5d>
mov    %rax,%r15
mov    (%rbx),%rdx
mov    $0x1,%r14d
mov    %rbp,%rdi
mov    $0x1,%esi
mov    %rax,%rcx
call   1030 <fread@plt>
mov    %rax,(%rbx)
mov    %r15,%rdi
call   1040 <fclose@plt>
mov    %r14d,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret

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

LLVM IR (-O2):
@.str = [2 x i8] c"r\00"
define i32 @get_file_content(i8* %0, i8* %1, i64* %2) {
%4 = icmp ne i8* %0, null
%5 = icmp ne i8* %1, null
%6 = and i1 %4, %5
%7 = icmp ne i64* %2, null
%8 = and i1 %6, %7
br i1 %8, label %9, label %19
9: ; preds = %3
%10 = load i64, i64* %2
%11 = icmp eq i64 %10, 0
br i1 %11, label %19, label %12
12: ; preds = %9
%13 = tail call i32* @fopen(i8* %0, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
%14 = icmp eq i32* %13, null
br i1 %14, label %19, label %15
15: ; preds = %12
%16 = load i64, i64* %2
%17 = tail call i64 @fread(i8* %1, i32 1, i64 %16, i32* %13)
store i64 %17, i64* %2
%18 = tail call i32 @fclose(i32* %13)
br label %19
19: ; preds = %15, %12, %3, %9
%20 = phi i32 [ 0, %9 ], [ 0, %3 ], [ 1, %15 ], [ 0, %12 ]
ret i32 %20
}