#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*/ IniLine;
typedef int /*<<< orphan*/ FILE;

/* Variables and functions */
int /*<<< orphan*/ ProcessIniLine(unsigned char *);
int /*<<< orphan*/ fclose(int /*<<< orphan*/ *);
int /*<<< orphan*/ *fgets(char *, int, int /*<<< orphan*/ *);
int /*<<< orphan*/ *fopen(char *, char *);
int DL_ReadIniFile(char *filename) {
  FILE *fh;
  unsigned char IniLine[1000 + 1];
  if (filename == NULL)
    return -1;
  fh = fopen(filename, "r");
  if (fh == NULL)
    return -1;
  while (fgets((char *)IniLine, sizeof(IniLine), fh) != NULL) {
    ProcessIniLine(IniLine);
  }
  fclose(fh);
  return 0;
}


x86 assembly (clang, -O0):
<DL_ReadIniFile>:
push   %rbp
mov    %rsp,%rbp
sub    $0x410,%rsp
mov    %rdi,-0x10(%rbp)
cmpq   $0x0,-0x10(%rbp)
jne    1166 <DL_ReadIniFile+0x26>
movl   $0xffffffff,-0x4(%rbp)
jmp    11d6 <DL_ReadIniFile+0x96>
mov    -0x10(%rbp),%rdi
lea    0xe8f(%rip),%rsi
call   1050 <fopen@plt>
mov    %rax,-0x18(%rbp)
cmpq   $0x0,-0x18(%rbp)
jne    1191 <DL_ReadIniFile+0x51>
movl   $0xffffffff,-0x4(%rbp)
jmp    11d6 <DL_ReadIniFile+0x96>
jmp    1196 <DL_ReadIniFile+0x56>
lea    -0x410(%rbp),%rdi
mov    -0x18(%rbp),%rdx
mov    $0x3e9,%esi
call   1040 <fgets@plt>
cmp    $0x0,%rax
je     11c6 <DL_ReadIniFile+0x86>
lea    -0x410(%rbp),%rdi
call   1060 <ProcessIniLine@plt>
jmp    1196 <DL_ReadIniFile+0x56>
mov    -0x18(%rbp),%rdi
call   1030 <fclose@plt>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x410,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<DL_ReadIniFile>:
push   %rbp
push   %rbx
sub    $0x3f8,%rsp
mov    $0xffffffff,%ebp
test   %rdi,%rdi
je     11a7 <DL_ReadIniFile+0x67>
lea    0xea6(%rip),%rsi
call   1050 <fopen@plt>
test   %rax,%rax
je     11a7 <DL_ReadIniFile+0x67>
mov    %rax,%rbx
mov    %rsp,%rdi
mov    $0x3e9,%esi
mov    %rax,%rdx
call   1040 <fgets@plt>
test   %rax,%rax
je     119d <DL_ReadIniFile+0x5d>
mov    %rsp,%rbp
nop
mov    %rbp,%rdi
call   1060 <ProcessIniLine@plt>
mov    %rbp,%rdi
mov    $0x3e9,%esi
mov    %rbx,%rdx
call   1040 <fgets@plt>
test   %rax,%rax
jne    1180 <DL_ReadIniFile+0x40>
mov    %rbx,%rdi
call   1030 <fclose@plt>
xor    %ebp,%ebp
mov    %ebp,%eax
add    $0x3f8,%rsp
pop    %rbx
pop    %rbp
ret

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

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