#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 */
scalar_t__ EOF;
int /*<<< orphan*/ assert(int);
int /*<<< orphan*/ fclose(int /*<<< orphan*/ *);
char fgetc(int /*<<< orphan*/ *);
int /*<<< orphan*/ *fopen(char const *, char *);
int load_ini_file(const char *file, char *buf, int *file_size) {
  FILE *in = NULL;
  int i = 0;
  *file_size = 0;
  assert(file != NULL);
  assert(buf != NULL);
  in = fopen(file, "r");
  if (NULL == in) {
    return 0;
  }
  buf[i] = fgetc(in);
  while (buf[i] != (char)EOF) {
    i++;
    assert(i < 1024 * 16);
    buf[i] = fgetc(in);
  }
  buf[i] = '\0';
  *file_size = i;
  fclose(in);
  return 1;
}


x86 assembly (clang, -O0):
<load_ini_file>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
mov    %rdx,-0x20(%rbp)
movq   $0x0,-0x28(%rbp)
movl   $0x0,-0x2c(%rbp)
mov    -0x20(%rbp),%rax
movl   $0x0,(%rax)
cmpq   $0x0,-0x10(%rbp)
setne  %al
and    $0x1,%al
movzbl %al,%edi
call   1050 <assert@plt>
cmpq   $0x0,-0x18(%rbp)
setne  %al
and    $0x1,%al
movzbl %al,%edi
call   1050 <assert@plt>
mov    -0x10(%rbp),%rdi
lea    0xe64(%rip),%rsi
call   1060 <fopen@plt>
mov    %rax,-0x28(%rbp)
xor    %eax,%eax
cmp    -0x28(%rbp),%rax
jne    11bd <load_ini_file+0x7d>
movl   $0x0,-0x4(%rbp)
jmp    1251 <load_ini_file+0x111>
mov    -0x28(%rbp),%rdi
call   1040 <fgetc@plt>
mov    %al,%dl
mov    -0x18(%rbp),%rax
movslq -0x2c(%rbp),%rcx
mov    %dl,(%rax,%rcx,1)
mov    -0x18(%rbp),%rax
movslq -0x2c(%rbp),%rcx
movsbl (%rax,%rcx,1),%eax
mov    0x2e02(%rip),%rcx
mov    (%rcx),%rcx
movsbl %cl,%ecx
cmp    %ecx,%eax
je     122c <load_ini_file+0xec>
mov    -0x2c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x2c(%rbp)
cmpl   $0x4000,-0x2c(%rbp)
setl   %al
and    $0x1,%al
movzbl %al,%edi
call   1050 <assert@plt>
mov    -0x28(%rbp),%rdi
call   1040 <fgetc@plt>
mov    %al,%dl
mov    -0x18(%rbp),%rax
movslq -0x2c(%rbp),%rcx
mov    %dl,(%rax,%rcx,1)
jmp    11d3 <load_ini_file+0x93>
mov    -0x18(%rbp),%rax
movslq -0x2c(%rbp),%rcx
movb   $0x0,(%rax,%rcx,1)
mov    -0x2c(%rbp),%ecx
mov    -0x20(%rbp),%rax
mov    %ecx,(%rax)
mov    -0x28(%rbp),%rdi
call   1030 <fclose@plt>
movl   $0x1,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<load_ini_file>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
mov    %rdx,%r14
mov    %rsi,%r15
mov    %rdi,%rbx
movl   $0x0,(%rdx)
xor    %edi,%edi
test   %rbx,%rbx
setne  %dil
call   1050 <assert@plt>
xor    %edi,%edi
test   %r15,%r15
setne  %dil
call   1050 <assert@plt>
lea    0xe83(%rip),%rsi
mov    %rbx,%rdi
call   1060 <fopen@plt>
test   %rax,%rax
je     11fb <load_ini_file+0xbb>
mov    %rax,%r12
mov    %rax,%rdi
call   1040 <fgetc@plt>
mov    %al,(%r15)
movsbl %al,%eax
mov    0x2e46(%rip),%r13
movsbl 0x0(%r13),%ecx
xor    %ebx,%ebx
cmp    %eax,%ecx
je     11e2 <load_ini_file+0xa2>
xor    %ebx,%ebx
nop
mov    %rbx,%rbp
add    $0x1,%rbx
xor    %edi,%edi
cmp    $0x3fff,%rbp
setb   %dil
call   1050 <assert@plt>
mov    %r12,%rdi
call   1040 <fgetc@plt>
mov    %al,0x1(%r15,%rbp,1)
movsbl %al,%eax
movsbl 0x0(%r13),%ecx
cmp    %eax,%ecx
jne    11b0 <load_ini_file+0x70>
mov    %ebx,%eax
movb   $0x0,(%r15,%rax,1)
mov    %ebx,(%r14)
mov    %r12,%rdi
call   1030 <fclose@plt>
mov    $0x1,%eax
jmp    11fd <load_ini_file+0xbd>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [2 x i8] c"r\00"
@EOF = global i64 0
define i32 @load_ini_file(i8* %0, i8* %1, i32* %2) {
%4 = alloca i32
%5 = alloca i8*
%6 = alloca i8*
%7 = alloca i32*
%8 = alloca i32*
%9 = alloca i32
store i8* %0, i8** %5
store i8* %1, i8** %6
store i32* %2, i32** %7
store i32* null, i32** %8
store i32 0, i32* %9
%10 = load i32*, i32** %7
store i32 0, i32* %10
%11 = load i8*, i8** %5
%12 = icmp ne i8* %11, null
%13 = zext i1 %12 to i32
%14 = call i32 @assert(i32 %13)
%15 = load i8*, i8** %6
%16 = icmp ne i8* %15, null
%17 = zext i1 %16 to i32
%18 = call i32 @assert(i32 %17)
%19 = load i8*, i8** %5
%20 = call i32* @fopen(i8* %19, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
store i32* %20, i32** %8
%21 = load i32*, i32** %8
%22 = icmp eq i32* null, %21
br i1 %22, label %23, label %24
23: ; preds = %3
store i32 0, i32* %4
br label %64
24: ; preds = %3
%25 = load i32*, i32** %8
%26 = call signext i8 @fgetc(i32* %25)
%27 = load i8*, i8** %6
%28 = load i32, i32* %9
%29 = sext i32 %28 to i64
%30 = getelementptr inbounds i8, i8* %27, i64 %29
store i8 %26, i8* %30
br label %31
31: ; preds = %42, %24
%32 = load i8*, i8** %6
%33 = load i32, i32* %9
%34 = sext i32 %33 to i64
%35 = getelementptr inbounds i8, i8* %32, i64 %34
%36 = load i8, i8* %35
%37 = sext i8 %36 to i32
%38 = load i64, i64* @EOF
%39 = trunc i64 %38 to i8
%40 = sext i8 %39 to i32
%41 = icmp ne i32 %37, %40
br i1 %41, label %42, label %55
42: ; preds = %31
%43 = load i32, i32* %9
%44 = add nsw i32 %43, 1
store i32 %44, i32* %9
%45 = load i32, i32* %9
%46 = icmp slt i32 %45, 16384
%47 = zext i1 %46 to i32
%48 = call i32 @assert(i32 %47)
%49 = load i32*, i32** %8
%50 = call signext i8 @fgetc(i32* %49)
%51 = load i8*, i8** %6
%52 = load i32, i32* %9
%53 = sext i32 %52 to i64
%54 = getelementptr inbounds i8, i8* %51, i64 %53
store i8 %50, i8* %54
br label %31
55: ; preds = %31
%56 = load i8*, i8** %6
%57 = load i32, i32* %9
%58 = sext i32 %57 to i64
%59 = getelementptr inbounds i8, i8* %56, i64 %58
store i8 0, i8* %59
%60 = load i32, i32* %9
%61 = load i32*, i32** %7
store i32 %60, i32* %61
%62 = load i32*, i32** %8
%63 = call i32 @fclose(i32* %62)
store i32 1, i32* %4
br label %64
64: ; preds = %55, %23
%65 = load i32, i32* %4
ret i32 %65
}

LLVM IR (-O2):
@.str = [2 x i8] c"r\00"
@EOF = global i64 0
define i32 @load_ini_file(i8* %0, i8* %1, i32* nocapture writeonly %2) {
store i32 0, i32* %2
%4 = icmp ne i8* %0, null
%5 = zext i1 %4 to i32
%6 = tail call i32 @assert(i32 %5)
%7 = icmp ne i8* %1, null
%8 = zext i1 %7 to i32
%9 = tail call i32 @assert(i32 %8)
%10 = tail call i32* @fopen(i8* %0, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
%11 = icmp eq i32* %10, null
br i1 %11, label %41, label %12
12: ; preds = %3
%13 = tail call signext i8 @fgetc(i32* %10)
store i8 %13, i8* %1
%14 = sext i8 %13 to i32
%15 = load i64, i64* @EOF
%16 = trunc i64 %15 to i32
%17 = shl i32 %16, 24
%18 = ashr exact i32 %17, 24
%19 = icmp eq i32 %18, %14
br i1 %19, label %36, label %20
20: ; preds = %12, %20
%21 = phi i64 [ %22, %20 ], [ 0, %12 ]
%22 = add nuw i64 %21, 1
%23 = icmp ult i64 %21, 16383
%24 = zext i1 %23 to i32
%25 = tail call i32 @assert(i32 %24)
%26 = tail call signext i8 @fgetc(i32* %10)
%27 = getelementptr inbounds i8, i8* %1, i64 %22
store i8 %26, i8* %27
%28 = sext i8 %26 to i32
%29 = load i64, i64* @EOF
%30 = trunc i64 %29 to i32
%31 = shl i32 %30, 24
%32 = ashr exact i32 %31, 24
%33 = icmp eq i32 %32, %28
br i1 %33, label %34, label %20
34: ; preds = %20
%35 = trunc i64 %22 to i32
br label %36
36: ; preds = %34, %12
%37 = phi i32 [ 0, %12 ], [ %35, %34 ]
%38 = zext i32 %37 to i64
%39 = getelementptr inbounds i8, i8* %1, i64 %38
store i8 0, i8* %39
store i32 %37, i32* %2
%40 = tail call i32 @fclose(i32* %10)
br label %41
41: ; preds = %3, %36
%42 = phi i32 [ 1, %36 ], [ 0, %3 ]
ret i32 %42
}