#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 *);
int ini_parse_file(int /*<<< orphan*/ *,
                   int (*)(void *, char const *, char const *, char const *,
                           char const *),
                   void *, char const *);
int ini_parse(const char *filename,
              int (*handler)(void *, const char *, const char *, const char *,
                             const char *),
              void *user, const char *tx_section) {
  FILE *file;
  int error;
  file = fopen(filename, "r");
  if (!file)
    return -1;
  error = ini_parse_file(file, handler, user, tx_section);
  fclose(file);
  return error;
}


x86 assembly (clang, -O0):
<ini_parse>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
mov    %rdx,-0x20(%rbp)
mov    %rcx,-0x28(%rbp)
mov    -0x10(%rbp),%rdi
lea    0xead(%rip),%rsi
call   1040 <fopen@plt>
mov    %rax,-0x30(%rbp)
cmpq   $0x0,-0x30(%rbp)
jne    1173 <ini_parse+0x43>
movl   $0xffffffff,-0x4(%rbp)
jmp    119a <ini_parse+0x6a>
mov    -0x30(%rbp),%rdi
mov    -0x18(%rbp),%rsi
mov    -0x20(%rbp),%rdx
mov    -0x28(%rbp),%rcx
call   1050 <ini_parse_file@plt>
mov    %eax,-0x34(%rbp)
mov    -0x30(%rbp),%rdi
call   1030 <fclose@plt>
mov    -0x34(%rbp),%eax
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<ini_parse>:
push   %rbp
push   %r15
push   %r14
push   %r12
push   %rbx
mov    %rcx,%r14
mov    %rdx,%r15
mov    %rsi,%r12
lea    0xeb8(%rip),%rsi
call   1040 <fopen@plt>
test   %rax,%rax
je     1174 <ini_parse+0x44>
mov    %rax,%rbx
mov    %rax,%rdi
mov    %r12,%rsi
mov    %r15,%rdx
mov    %r14,%rcx
call   1050 <ini_parse_file@plt>
mov    %eax,%ebp
mov    %rbx,%rdi
call   1030 <fclose@plt>
mov    %ebp,%eax
jmp    1179 <ini_parse+0x49>
mov    $0xffffffff,%eax
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
ret

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

LLVM IR (-O2):
@.str = [2 x i8] c"r\00"
define i32 @ini_parse(i8* nocapture %0, i32 (i8*, i8*, i8*, i8*, i8*)* %1, i8* %2, i8* %3) {
%5 = tail call i32* @fopen(i8* %0, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
%6 = icmp eq i32* %5, null
br i1 %6, label %10, label %7
7: ; preds = %4
%8 = tail call i32 @ini_parse_file(i32* %5, i32 (i8*, i8*, i8*, i8*, i8*)* %1, i8* %2, i8* %3)
%9 = tail call i32 @fclose(i32* %5)
br label %10
10: ; preds = %4, %7
%11 = phi i32 [ %8, %7 ], [ -1, %4 ]
ret i32 %11
}