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


x86 assembly (clang, -O0):
<load_ini_file>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
movl   $0x0,-0x1c(%rbp)
movq   $0x0,-0x28(%rbp)
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    0xe72(%rip),%rsi
call   1060 <fopen@plt>
mov    %rax,-0x28(%rbp)
xor    %eax,%eax
cmp    -0x28(%rbp),%rax
jne    11af <load_ini_file+0x6f>
movl   $0xffffffff,-0x4(%rbp)
jmp    121b <load_ini_file+0xdb>
jmp    11b4 <load_ini_file+0x74>
mov    -0x28(%rbp),%rdi
call   1040 <fgetc@plt>
mov    -0x18(%rbp),%rcx
movslq -0x1c(%rbp),%rdx
mov    %al,(%rcx,%rdx,1)
movsbl %al,%eax
mov    0x2e16(%rip),%rcx
movsbl (%rcx),%ecx
cmp    %ecx,%eax
je     11ff <load_ini_file+0xbf>
mov    -0x1c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x1c(%rbp)
cmpl   $0x1fa0,-0x1c(%rbp)
setl   %al
and    $0x1,%al
movzbl %al,%edi
call   1050 <assert@plt>
jmp    11b4 <load_ini_file+0x74>
mov    -0x18(%rbp),%rax
movslq -0x1c(%rbp),%rcx
movb   $0x0,(%rax,%rcx,1)
mov    -0x28(%rbp),%rdi
call   1030 <fclose@plt>
movl   $0x0,-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    %rsi,%r14
mov    %rdi,%rbx
xor    %edi,%edi
test   %rbx,%rbx
setne  %dil
call   1050 <assert@plt>
xor    %edi,%edi
test   %r14,%r14
setne  %dil
call   1050 <assert@plt>
lea    0xe8c(%rip),%rsi
mov    %rbx,%rdi
call   1060 <fopen@plt>
test   %rax,%rax
je     11a3 <load_ini_file+0x63>
mov    %rax,%r13
mov    %rax,%rdi
call   1040 <fgetc@plt>
mov    %al,(%r14)
mov    0x2e52(%rip),%r12
xor    %r15d,%r15d
cmp    (%r12),%al
jne    11ab <load_ini_file+0x6b>
xor    %eax,%eax
jmp    11de <load_ini_file+0x9e>
mov    $0xffffffff,%r15d
jmp    11eb <load_ini_file+0xab>
xor    %ebx,%ebx
nopl   (%rax)
mov    %rbx,%rbp
add    $0x1,%rbx
xor    %edi,%edi
cmp    $0x1f9f,%rbp
setb   %dil
call   1050 <assert@plt>
mov    %r13,%rdi
call   1040 <fgetc@plt>
mov    %al,0x1(%r14,%rbp,1)
cmp    (%r12),%al
jne    11b0 <load_ini_file+0x70>
mov    %ebx,%eax
movb   $0x0,(%r14,%rax,1)
mov    %r13,%rdi
call   1030 <fclose@plt>
mov    %r15d,%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 i8 0
define i32 @load_ini_file(i8* %0, i8* %1) {
%3 = alloca i32
%4 = alloca i8*
%5 = alloca i8*
%6 = alloca i32
%7 = alloca i32*
store i8* %0, i8** %4
store i8* %1, i8** %5
store i32 0, i32* %6
store i32* null, i32** %7
%8 = load i8*, i8** %4
%9 = icmp ne i8* %8, null
%10 = zext i1 %9 to i32
%11 = call i32 @assert(i32 %10)
%12 = load i8*, i8** %5
%13 = icmp ne i8* %12, null
%14 = zext i1 %13 to i32
%15 = call i32 @assert(i32 %14)
%16 = load i8*, i8** %4
%17 = call i32* @fopen(i8* %16, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
store i32* %17, i32** %7
%18 = load i32*, i32** %7
%19 = icmp eq i32* null, %18
br i1 %19, label %20, label %21
20: ; preds = %2
store i32 -1, i32* %3
br label %47
21: ; preds = %2
br label %22
22: ; preds = %33, %21
%23 = load i32*, i32** %7
%24 = call signext i8 @fgetc(i32* %23)
%25 = load i8*, i8** %5
%26 = load i32, i32* %6
%27 = sext i32 %26 to i64
%28 = getelementptr inbounds i8, i8* %25, i64 %27
store i8 %24, i8* %28
%29 = sext i8 %24 to i32
%30 = load i8, i8* @EOF
%31 = sext i8 %30 to i32
%32 = icmp ne i32 %29, %31
br i1 %32, label %33, label %40
33: ; preds = %22
%34 = load i32, i32* %6
%35 = add nsw i32 %34, 1
store i32 %35, i32* %6
%36 = load i32, i32* %6
%37 = icmp slt i32 %36, 8096
%38 = zext i1 %37 to i32
%39 = call i32 @assert(i32 %38)
br label %22
40: ; preds = %22
%41 = load i8*, i8** %5
%42 = load i32, i32* %6
%43 = sext i32 %42 to i64
%44 = getelementptr inbounds i8, i8* %41, i64 %43
store i8 0, i8* %44
%45 = load i32*, i32** %7
%46 = call i32 @fclose(i32* %45)
store i32 0, i32* %3
br label %47
47: ; preds = %40, %20
%48 = load i32, i32* %3
ret i32 %48
}

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