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

/* Variables and functions */
int /*<<< orphan*/ fclose(int /*<<< orphan*/ *);
int /*<<< orphan*/ feof(int /*<<< orphan*/ *);
int /*<<< orphan*/ fgets(char *, int, int /*<<< orphan*/ *);
int /*<<< orphan*/ *fopen(char const *, char *);
int parse_line(char *, void const *, void *);
int /*<<< orphan*/ truncate_nl(char *);
int conf_parse(const char *filename, const void *table, void *userdata) {
  FILE *f;
  int err = 0;
  if (!filename) {
    return -1;
  }
  f = fopen(filename, "r");
  if (!f) {
    return -1;
  }
  while (!err && !feof(f)) {
    char l[2048];
    if (!fgets(l, sizeof(l), f))
      break;
    truncate_nl(l);
    err = parse_line(l, table, userdata);
  }
  if (!feof(f))
    err = -1;
  fclose(f);
  return err;
}


x86 assembly (clang, -O0):
<conf_parse>:
push   %rbp
mov    %rsp,%rbp
sub    $0x840,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
mov    %rdx,-0x20(%rbp)
movl   $0x0,-0x2c(%rbp)
cmpq   $0x0,-0x10(%rbp)
jne    1195 <conf_parse+0x35>
movl   $0xffffffff,-0x4(%rbp)
jmp    1274 <conf_parse+0x114>
mov    -0x10(%rbp),%rdi
lea    0xe60(%rip),%rsi
call   1080 <fopen@plt>
mov    %rax,-0x28(%rbp)
cmpq   $0x0,-0x28(%rbp)
jne    11c0 <conf_parse+0x60>
movl   $0xffffffff,-0x4(%rbp)
jmp    1274 <conf_parse+0x114>
jmp    11c5 <conf_parse+0x65>
xor    %eax,%eax
cmpl   $0x0,-0x2c(%rbp)
mov    %al,-0x831(%rbp)
jne    11ee <conf_parse+0x8e>
mov    -0x28(%rbp),%rdi
call   1050 <feof@plt>
cmp    $0x0,%eax
setne  %al
xor    $0xff,%al
mov    %al,-0x831(%rbp)
mov    -0x831(%rbp),%al
test   $0x1,%al
jne    1201 <conf_parse+0xa1>
jmp    124c <conf_parse+0xec>
lea    -0x830(%rbp),%rdi
mov    -0x28(%rbp),%rdx
mov    $0x800,%esi
call   1040 <fgets@plt>
cmp    $0x0,%eax
jne    1224 <conf_parse+0xc4>
jmp    124c <conf_parse+0xec>
lea    -0x830(%rbp),%rdi
call   1070 <truncate_nl@plt>
lea    -0x830(%rbp),%rdi
mov    -0x18(%rbp),%rsi
mov    -0x20(%rbp),%rdx
call   1060 <parse_line@plt>
mov    %eax,-0x2c(%rbp)
jmp    11c5 <conf_parse+0x65>
mov    -0x28(%rbp),%rdi
call   1050 <feof@plt>
cmp    $0x0,%eax
jne    1265 <conf_parse+0x105>
movl   $0xffffffff,-0x2c(%rbp)
mov    -0x28(%rbp),%rdi
call   1030 <fclose@plt>
mov    -0x2c(%rbp),%eax
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x840,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<conf_parse>:
push   %rbp
push   %r15
push   %r14
push   %r12
push   %rbx
sub    $0x800,%rsp
mov    $0xffffffff,%r12d
test   %rdi,%rdi
je     11f7 <conf_parse+0x97>
mov    %rdx,%r14
mov    %rsi,%r15
lea    0xe79(%rip),%rsi
call   1080 <fopen@plt>
test   %rax,%rax
je     11f7 <conf_parse+0x97>
mov    %rax,%rbx
mov    %rsp,%r12
nopw   0x0(%rax,%rax,1)
mov    %rbx,%rdi
call   1050 <feof@plt>
xor    %ebp,%ebp
test   %eax,%eax
jne    11de <conf_parse+0x7e>
mov    %r12,%rdi
mov    $0x800,%esi
mov    %rbx,%rdx
call   1040 <fgets@plt>
test   %eax,%eax
je     11de <conf_parse+0x7e>
mov    %r12,%rdi
call   1070 <truncate_nl@plt>
mov    %r12,%rdi
mov    %r15,%rsi
mov    %r14,%rdx
call   1060 <parse_line@plt>
test   %eax,%eax
je     11a0 <conf_parse+0x40>
mov    %eax,%ebp
mov    %rbx,%rdi
call   1050 <feof@plt>
cmp    $0x1,%eax
sbb    %r12d,%r12d
or     %ebp,%r12d
mov    %rbx,%rdi
call   1030 <fclose@plt>
mov    %r12d,%eax
add    $0x800,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [2 x i8] c"r\00"
define i32 @conf_parse(i8* %0, i8* %1, i8* %2) {
%4 = alloca i32
%5 = alloca i8*
%6 = alloca i8*
%7 = alloca i8*
%8 = alloca i32*
%9 = alloca i32
%10 = alloca [2048 x i8]
store i8* %0, i8** %5
store i8* %1, i8** %6
store i8* %2, i8** %7
store i32 0, i32* %9
%11 = load i8*, i8** %5
%12 = icmp ne i8* %11, null
br i1 %12, label %14, label %13
13: ; preds = %3
store i32 -1, i32* %4
br label %53
14: ; preds = %3
%15 = load i8*, i8** %5
%16 = call i32* @fopen(i8* %15, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
store i32* %16, i32** %8
%17 = load i32*, i32** %8
%18 = icmp ne i32* %17, null
br i1 %18, label %20, label %19
19: ; preds = %14
store i32 -1, i32* %4
br label %53
20: ; preds = %14
br label %21
21: ; preds = %37, %20
%22 = load i32, i32* %9
%23 = icmp ne i32 %22, 0
br i1 %23, label %29, label %24
24: ; preds = %21
%25 = load i32*, i32** %8
%26 = call i32 @feof(i32* %25)
%27 = icmp ne i32 %26, 0
%28 = xor i1 %27, true
br label %29
29: ; preds = %24, %21
%30 = phi i1 [ false, %21 ], [ %28, %24 ]
br i1 %30, label %31, label %44
31: ; preds = %29
%32 = getelementptr inbounds [2048 x i8], [2048 x i8]* %10, i64 0, i64 0
%33 = load i32*, i32** %8
%34 = call i32 @fgets(i8* %32, i32 2048, i32* %33)
%35 = icmp ne i32 %34, 0
br i1 %35, label %37, label %36
36: ; preds = %31
br label %44
37: ; preds = %31
%38 = getelementptr inbounds [2048 x i8], [2048 x i8]* %10, i64 0, i64 0
%39 = call i32 @truncate_nl(i8* %38)
%40 = getelementptr inbounds [2048 x i8], [2048 x i8]* %10, i64 0, i64 0
%41 = load i8*, i8** %6
%42 = load i8*, i8** %7
%43 = call i32 @parse_line(i8* %40, i8* %41, i8* %42)
store i32 %43, i32* %9
br label %21
44: ; preds = %36, %29
%45 = load i32*, i32** %8
%46 = call i32 @feof(i32* %45)
%47 = icmp ne i32 %46, 0
br i1 %47, label %49, label %48
48: ; preds = %44
store i32 -1, i32* %9
br label %49
49: ; preds = %48, %44
%50 = load i32*, i32** %8
%51 = call i32 @fclose(i32* %50)
%52 = load i32, i32* %9
store i32 %52, i32* %4
br label %53
53: ; preds = %49, %19, %13
%54 = load i32, i32* %4
ret i32 %54
}

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