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

/* Variables and functions */
int /*<<< orphan*/ fclose(int /*<<< orphan*/ *);
char *fgets(char *, int, int /*<<< orphan*/ *);
int /*<<< orphan*/ *fopen(char const *, char *);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *, int, char const *,
                           char *);
int parse_config_item(char *, char *, int /*<<< orphan*/);
int /*<<< orphan*/ stderr;
int strlen(char *);
void load_config_file(const char *filename) {
  FILE *fp;
  char option[256];
  int line = 0;
  char *p;
  fp = fopen(filename, "r");
  if (!fp)
    return;
  while (fgets(option, sizeof(option), fp) == option) {
    line++;
    if (option[0])
      option[strlen(option) - 1] = '\0';
    if (option[0] == '#')
      continue;
    p = option;
    while (*p != '\0') {
      if (*p == ' ') {
        *p = '\0';
        p++;
        while (*p == ' ')
          p++;
        break;
      }
      p++;
    }
    if (parse_config_item(option, p, 0) == -1)
      fprintf(stderr, "Didn't understand line %d in file %s [%s]\n", line,
              filename, option);
  }
  fclose(fp);
}


x86 assembly (clang, -O0):
<load_config_file>:
push   %rbp
mov    %rsp,%rbp
sub    $0x120,%rsp
mov    %rdi,-0x8(%rbp)
movl   $0x0,-0x114(%rbp)
mov    -0x8(%rbp),%rdi
lea    0xe7c(%rip),%rsi
call   1070 <fopen@plt>
mov    %rax,-0x10(%rbp)
cmpq   $0x0,-0x10(%rbp)
jne    119d <load_config_file+0x3d>
jmp    12f9 <load_config_file+0x199>
jmp    11a2 <load_config_file+0x42>
lea    -0x110(%rbp),%rdi
mov    -0x10(%rbp),%rdx
mov    $0x100,%esi
call   1050 <fgets@plt>
lea    -0x110(%rbp),%rcx
cmp    %rcx,%rax
jne    12f0 <load_config_file+0x190>
mov    -0x114(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x114(%rbp)
cmpb   $0x0,-0x110(%rbp)
je     11fc <load_config_file+0x9c>
lea    -0x110(%rbp),%rdi
call   1040 <strlen@plt>
sub    $0x1,%eax
cltq
movb   $0x0,-0x110(%rbp,%rax,1)
movsbl -0x110(%rbp),%eax
cmp    $0x23,%eax
jne    1211 <load_config_file+0xb1>
jmp    11a2 <load_config_file+0x42>
lea    -0x110(%rbp),%rax
mov    %rax,-0x120(%rbp)
mov    -0x120(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x0,%eax
je     12a7 <load_config_file+0x147>
mov    -0x120(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x20,%eax
jne    1290 <load_config_file+0x130>
mov    -0x120(%rbp),%rax
movb   $0x0,(%rax)
mov    -0x120(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x120(%rbp)
mov    -0x120(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x20,%eax
jne    128b <load_config_file+0x12b>
mov    -0x120(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x120(%rbp)
jmp    1261 <load_config_file+0x101>
jmp    12a7 <load_config_file+0x147>
mov    -0x120(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x120(%rbp)
jmp    121f <load_config_file+0xbf>
lea    -0x110(%rbp),%rdi
mov    -0x120(%rbp),%rsi
xor    %edx,%edx
call   1080 <parse_config_item@plt>
cmp    $0xffffffff,%eax
jne    12eb <load_config_file+0x18b>
mov    0x2d14(%rip),%rax
mov    (%rax),%edi
mov    -0x114(%rbp),%edx
mov    -0x8(%rbp),%rcx
lea    -0x110(%rbp),%r8
lea    0xd1c(%rip),%rsi
call   1060 <fprintf@plt>
jmp    11a2 <load_config_file+0x42>
mov    -0x10(%rbp),%rdi
call   1030 <fclose@plt>
add    $0x120,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<load_config_file>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x108,%rsp
mov    %rdi,%r14
lea    0xe85(%rip),%rsi
call   1070 <fopen@plt>
test   %rax,%rax
je     11a8 <load_config_file+0x48>
mov    %rax,%r15
mov    %rsp,%rbx
mov    %rbx,%rdi
mov    $0x100,%esi
mov    %rax,%rdx
call   1050 <fgets@plt>
cmp    %rbx,%rax
je     11ba <load_config_file+0x5a>
mov    %r15,%rdi
call   1030 <fclose@plt>
add    $0x108,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret
xor    %ebp,%ebp
mov    0x2e1d(%rip),%r13
lea    0xe38(%rip),%r12
jmp    11e5 <load_config_file+0x85>
nopl   0x0(%rax)
mov    %rbx,%rdi
mov    $0x100,%esi
mov    %r15,%rdx
call   1050 <fgets@plt>
cmp    %rbx,%rax
jne    11a0 <load_config_file+0x40>
add    $0x1,%ebp
cmpb   $0x0,(%rsp)
je     1210 <load_config_file+0xb0>
mov    %rbx,%rdi
call   1040 <strlen@plt>
cltq
movb   $0x0,-0x1(%rax,%rbx,1)
mov    (%rsp),%cl
cmp    $0x23,%cl
je     11d0 <load_config_file+0x70>
jmp    1212 <load_config_file+0xb2>
nopw   0x0(%rax,%rax,1)
xor    %ecx,%ecx
mov    %rbx,%rax
test   %cl,%cl
je     1231 <load_config_file+0xd1>
nopl   0x0(%rax)
cmp    $0x20,%cl
je     1240 <load_config_file+0xe0>
movzbl 0x1(%rax),%ecx
add    $0x1,%rax
test   %cl,%cl
jne    1220 <load_config_file+0xc0>
mov    %rax,%rsi
jmp    125d <load_config_file+0xfd>
cs nopw 0x0(%rax,%rax,1)
movb   $0x0,(%rax)
cs nopw 0x0(%rax,%rax,1)
nopl   (%rax)
lea    0x1(%rax),%rsi
cmpb   $0x20,0x1(%rax)
mov    %rsi,%rax
je     1250 <load_config_file+0xf0>
mov    %rbx,%rdi
xor    %edx,%edx
call   1080 <parse_config_item@plt>
cmp    $0xffffffff,%eax
jne    11d0 <load_config_file+0x70>
mov    0x0(%r13),%edi
mov    %r12,%rsi
mov    %ebp,%edx
mov    %r14,%rcx
mov    %rbx,%r8
call   1060 <fprintf@plt>
jmp    11d0 <load_config_file+0x70>

LLVM IR (-O0):
@.str = [2 x i8] c"r\00"
@stderr = global i32 0
@.str.1 = [43 x i8] c"Didn't understand line %d in file %s [%s]\0A\00"
define void @load_config_file(i8* %0) {
%2 = alloca i8*
%3 = alloca i32*
%4 = alloca [256 x i8]
%5 = alloca i32
%6 = alloca i8*
store i8* %0, i8** %2
store i32 0, i32* %5
%7 = load i8*, i8** %2
%8 = call i32* @fopen(i8* %7, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
store i32* %8, i32** %3
%9 = load i32*, i32** %3
%10 = icmp ne i32* %9, null
br i1 %10, label %12, label %11
11: ; preds = %1
br label %80
12: ; preds = %1
br label %13
13: ; preds = %76, %36, %12
%14 = getelementptr inbounds [256 x i8], [256 x i8]* %4, i64 0, i64 0
%15 = load i32*, i32** %3
%16 = call i8* @fgets(i8* %14, i32 256, i32* %15)
%17 = getelementptr inbounds [256 x i8], [256 x i8]* %4, i64 0, i64 0
%18 = icmp eq i8* %16, %17
br i1 %18, label %19, label %77
19: ; preds = %13
%20 = load i32, i32* %5
%21 = add nsw i32 %20, 1
store i32 %21, i32* %5
%22 = getelementptr inbounds [256 x i8], [256 x i8]* %4, i64 0, i64 0
%23 = load i8, i8* %22
%24 = icmp ne i8 %23, 0
br i1 %24, label %25, label %31
25: ; preds = %19
%26 = getelementptr inbounds [256 x i8], [256 x i8]* %4, i64 0, i64 0
%27 = call i32 @strlen(i8* %26)
%28 = sub nsw i32 %27, 1
%29 = sext i32 %28 to i64
%30 = getelementptr inbounds [256 x i8], [256 x i8]* %4, i64 0, i64 %29
store i8 0, i8* %30
br label %31
31: ; preds = %25, %19
%32 = getelementptr inbounds [256 x i8], [256 x i8]* %4, i64 0, i64 0
%33 = load i8, i8* %32
%34 = sext i8 %33 to i32
%35 = icmp eq i32 %34, 35
br i1 %35, label %36, label %37
36: ; preds = %31
br label %13
37: ; preds = %31
%38 = getelementptr inbounds [256 x i8], [256 x i8]* %4, i64 0, i64 0
store i8* %38, i8** %6
br label %39
39: ; preds = %62, %37
%40 = load i8*, i8** %6
%41 = load i8, i8* %40
%42 = sext i8 %41 to i32
%43 = icmp ne i32 %42, 0
br i1 %43, label %44, label %65
44: ; preds = %39
%45 = load i8*, i8** %6
%46 = load i8, i8* %45
%47 = sext i8 %46 to i32
%48 = icmp eq i32 %47, 32
br i1 %48, label %49, label %62
49: ; preds = %44
%50 = load i8*, i8** %6
store i8 0, i8* %50
%51 = load i8*, i8** %6
%52 = getelementptr inbounds i8, i8* %51, i32 1
store i8* %52, i8** %6
br label %53
53: ; preds = %58, %49
%54 = load i8*, i8** %6
%55 = load i8, i8* %54
%56 = sext i8 %55 to i32
%57 = icmp eq i32 %56, 32
br i1 %57, label %58, label %61
58: ; preds = %53
%59 = load i8*, i8** %6
%60 = getelementptr inbounds i8, i8* %59, i32 1
store i8* %60, i8** %6
br label %53
61: ; preds = %53
br label %65
62: ; preds = %44
%63 = load i8*, i8** %6
%64 = getelementptr inbounds i8, i8* %63, i32 1
store i8* %64, i8** %6
br label %39
65: ; preds = %61, %39
%66 = getelementptr inbounds [256 x i8], [256 x i8]* %4, i64 0, i64 0
%67 = load i8*, i8** %6
%68 = call i32 @parse_config_item(i8* %66, i8* %67, i32 0)
%69 = icmp eq i32 %68, -1
br i1 %69, label %70, label %76
70: ; preds = %65
%71 = load i32, i32* @stderr
%72 = load i32, i32* %5
%73 = load i8*, i8** %2
%74 = getelementptr inbounds [256 x i8], [256 x i8]* %4, i64 0, i64 0
%75 = call i32 @fprintf(i32 %71, i8* getelementptr inbounds ([43 x i8], [43 x i8]* @.str.1, i64 0, i64 0), i32 %72, i8* %73, i8* %74)
br label %76
76: ; preds = %70, %65
br label %13
77: ; preds = %13
%78 = load i32*, i32** %3
%79 = call i32 @fclose(i32* %78)
br label %80
80: ; preds = %77, %11
ret void
}

LLVM IR (-O2):
@.str = [2 x i8] c"r\00"
@stderr = global i32 0
@.str.1 = [43 x i8] c"Didn't understand line %d in file %s [%s]\0A\00"
define void @load_config_file(i8* %0) {
%2 = alloca [256 x i8]
%3 = getelementptr inbounds [256 x i8], [256 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 %47, label %6
6: ; preds = %1
%7 = call i8* @fgets(i8* %3, i32 256, i32* %4)
%8 = icmp eq i8* %7, %3
br i1 %8, label %9, label %45
9: ; preds = %6, %42
%10 = phi i32 [ %11, %42 ], [ 0, %6 ]
%11 = add nuw nsw i32 %10, 1
%12 = load i8, i8* %3
%13 = icmp eq i8 %12, 0
br i1 %13, label %21, label %14
14: ; preds = %9
%15 = call i32 @strlen(i8* %3)
%16 = add nsw i32 %15, -1
%17 = sext i32 %16 to i64
%18 = getelementptr inbounds [256 x i8], [256 x i8]* %2, i64 0, i64 %17
store i8 0, i8* %18
%19 = load i8, i8* %3
%20 = icmp eq i8 %19, 35
br i1 %20, label %42, label %21
21: ; preds = %9, %14
%22 = phi i8 [ 0, %9 ], [ %19, %14 ]
br label %23
23: ; preds = %21, %32
%24 = phi i8 [ %34, %32 ], [ %22, %21 ]
%25 = phi i8* [ %33, %32 ], [ %3, %21 ]
switch i8 %24, label %32 [
i8 0, label %35
i8 32, label %26
]
26: ; preds = %23
store i8 0, i8* %25
br label %27
27: ; preds = %27, %26
%28 = phi i8* [ %25, %26 ], [ %29, %27 ]
%29 = getelementptr inbounds i8, i8* %28, i64 1
%30 = load i8, i8* %29
%31 = icmp eq i8 %30, 32
br i1 %31, label %27, label %35
32: ; preds = %23
%33 = getelementptr inbounds i8, i8* %25, i64 1
%34 = load i8, i8* %33
br label %23
35: ; preds = %23, %27
%36 = phi i8* [ %29, %27 ], [ %25, %23 ]
%37 = call i32 @parse_config_item(i8* %3, i8* %36, i32 0)
%38 = icmp eq i32 %37, -1
br i1 %38, label %39, label %42
39: ; preds = %35
%40 = load i32, i32* @stderr
%41 = call i32 @fprintf(i32 %40, i8* getelementptr inbounds ([43 x i8], [43 x i8]* @.str.1, i64 0, i64 0), i32 %11, i8* %0, i8* %3)
br label %42
42: ; preds = %35, %39, %14
%43 = call i8* @fgets(i8* %3, i32 256, i32* %4)
%44 = icmp eq i8* %43, %3
br i1 %44, label %9, label %45
45: ; preds = %42, %6
%46 = call i32 @fclose(i32* %4)
br label %47
47: ; preds = %1, %45
ret void
}