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

/* Variables and functions */
int /*<<< orphan*/ fclose(int /*<<< orphan*/ *);
int /*<<< orphan*/ *fgets(char *, int, int /*<<< orphan*/ *);
int /*<<< orphan*/ *fopen(char const *, char *);
scalar_t__ parse_config_line(char *);
int config_load(const char *filename) {
  char line[512];
  FILE *fp;
  fp = fopen(filename, "r");
  if (!fp)
    return -1;
  while (fgets(line, sizeof(line), fp) != NULL) {
    if (parse_config_line(line) != 0) {
      fclose(fp);
      return -1;
    }
  }
  fclose(fp);
  return 0;
}


x86 assembly (clang, -O0):
<config_load>:
push   %rbp
mov    %rsp,%rbp
sub    $0x220,%rsp
mov    %rdi,-0x10(%rbp)
mov    -0x10(%rbp),%rdi
lea    0xea6(%rip),%rsi
call   1060 <fopen@plt>
mov    %rax,-0x218(%rbp)
cmpq   $0x0,-0x218(%rbp)
jne    1180 <config_load+0x40>
movl   $0xffffffff,-0x4(%rbp)
jmp    11ed <config_load+0xad>
jmp    1185 <config_load+0x45>
lea    -0x210(%rbp),%rdi
mov    -0x218(%rbp),%rdx
mov    $0x200,%esi
call   1040 <fgets@plt>
cmp    $0x0,%rax
je     11da <config_load+0x9a>
lea    -0x210(%rbp),%rdi
call   1050 <parse_config_line@plt>
cmp    $0x0,%rax
je     11d5 <config_load+0x95>
mov    -0x218(%rbp),%rdi
call   1030 <fclose@plt>
movl   $0xffffffff,-0x4(%rbp)
jmp    11ed <config_load+0xad>
jmp    1185 <config_load+0x45>
mov    -0x218(%rbp),%rdi
call   1030 <fclose@plt>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x220,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<config_load>:
push   %r14
push   %rbx
sub    $0x208,%rsp
lea    0xeaf(%rip),%rsi
call   1060 <fopen@plt>
test   %rax,%rax
je     1199 <config_load+0x59>
mov    %rax,%r14
mov    %rsp,%rbx
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax,%rax,1)
mov    %rbx,%rdi
mov    $0x200,%esi
mov    %r14,%rdx
call   1040 <fgets@plt>
test   %rax,%rax
je     11a0 <config_load+0x60>
mov    %rbx,%rdi
call   1050 <parse_config_line@plt>
test   %rax,%rax
je     1170 <config_load+0x30>
mov    $0xffffffff,%ebx
jmp    11a2 <config_load+0x62>
mov    $0xffffffff,%ebx
jmp    11aa <config_load+0x6a>
xor    %ebx,%ebx
mov    %r14,%rdi
call   1030 <fclose@plt>
mov    %ebx,%eax
add    $0x208,%rsp
pop    %rbx
pop    %r14
ret

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

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