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

/* Variables and functions */
int /*<<< orphan*/ exit(int);
int /*<<< orphan*/ fclose(int /*<<< orphan*/ *);
int /*<<< orphan*/ feof(int /*<<< orphan*/ *);
int /*<<< orphan*/ fflush(int /*<<< orphan*/);
int /*<<< orphan*/ *fgets(char *, int, int /*<<< orphan*/ *);
int /*<<< orphan*/ *fopen(char *, char *);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *, char *);
int /*<<< orphan*/ memset(char *, int /*<<< orphan*/, int);
int /*<<< orphan*/ parse_line(char *, int);
int /*<<< orphan*/ stderr;
scalar_t__ strlen(char *);
int parse_config(char *conf_file_name) {
  char line_buf[1024];
  FILE *fp = fopen(conf_file_name, "r");
  if (fp == NULL) {
    fprintf(stderr, "open %s failed!\n", conf_file_name);
    fflush(stderr);
    exit(-1);
  }
  while (!feof(fp)) {
    memset(line_buf, 0, sizeof(line_buf));
    if (fgets(line_buf, sizeof(line_buf) - 1, fp) == NULL) {
      continue;
    }
    if (strlen(line_buf) > 0) {
      parse_line(line_buf, sizeof(line_buf));
    }
  }
  fclose(fp);
  return 0;
}


x86 assembly (clang, -O0):
<parse_config>:
push   %rbp
mov    %rsp,%rbp
sub    $0x420,%rsp
mov    %rdi,-0x8(%rbp)
mov    -0x8(%rbp),%rdi
lea    0xe46(%rip),%rsi
call   10b0 <fopen@plt>
mov    %rax,-0x418(%rbp)
cmpq   $0x0,-0x418(%rbp)
jne    1205 <parse_config+0x65>
mov    0x2e05(%rip),%rax
mov    (%rax),%edi
mov    -0x8(%rbp),%rdx
lea    0xe1a(%rip),%rsi
call   1070 <fprintf@plt>
mov    0x2dec(%rip),%rax
mov    (%rax),%edi
call   10a0 <fflush@plt>
mov    $0xffffffff,%edi
call   10c0 <exit@plt>
jmp    120a <parse_config+0x6a>
mov    -0x418(%rbp),%rdi
call   1080 <feof@plt>
cmp    $0x0,%eax
setne  %al
xor    $0xff,%al
test   $0x1,%al
jne    122b <parse_config+0x8b>
jmp    1291 <parse_config+0xf1>
lea    -0x410(%rbp),%rdi
xor    %esi,%esi
mov    $0x400,%edx
call   1050 <memset@plt>
lea    -0x410(%rbp),%rdi
mov    -0x418(%rbp),%rdx
mov    $0x3ff,%esi
call   1060 <fgets@plt>
cmp    $0x0,%rax
jne    1265 <parse_config+0xc5>
jmp    120a <parse_config+0x6a>
lea    -0x410(%rbp),%rdi
call   1040 <strlen@plt>
cmp    $0x0,%rax
jle    128c <parse_config+0xec>
lea    -0x410(%rbp),%rdi
mov    $0x400,%esi
call   1090 <parse_line@plt>
jmp    120a <parse_config+0x6a>
mov    -0x418(%rbp),%rdi
call   1030 <fclose@plt>
xor    %eax,%eax
add    $0x420,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<parse_config>:
push   %r14
push   %rbx
sub    $0x408,%rsp
mov    %rdi,%r14
lea    0xe4c(%rip),%rsi
call   10b0 <fopen@plt>
test   %rax,%rax
je     123c <parse_config+0x9c>
mov    %rax,%rbx
mov    %rax,%rdi
call   1080 <feof@plt>
test   %eax,%eax
je     11e2 <parse_config+0x42>
mov    %rbx,%rdi
call   1030 <fclose@plt>
xor    %eax,%eax
add    $0x408,%rsp
pop    %rbx
pop    %r14
ret
mov    %rsp,%r14
jmp    11fc <parse_config+0x5c>
nopw   0x0(%rax,%rax,1)
mov    %rbx,%rdi
call   1080 <feof@plt>
test   %eax,%eax
jne    11cd <parse_config+0x2d>
mov    %r14,%rdi
xor    %esi,%esi
mov    $0x400,%edx
call   1050 <memset@plt>
mov    %r14,%rdi
mov    $0x3ff,%esi
mov    %rbx,%rdx
call   1060 <fgets@plt>
test   %rax,%rax
je     11f0 <parse_config+0x50>
mov    %r14,%rdi
call   1040 <strlen@plt>
test   %rax,%rax
jle    11f0 <parse_config+0x50>
mov    %r14,%rdi
mov    $0x400,%esi
call   1090 <parse_line@plt>
jmp    11f0 <parse_config+0x50>
mov    0x2d9d(%rip),%rbx
mov    (%rbx),%edi
lea    0xdb6(%rip),%rsi
mov    %r14,%rdx
call   1070 <fprintf@plt>
mov    (%rbx),%edi
call   10a0 <fflush@plt>
mov    $0xffffffff,%edi
call   10c0 <exit@plt>

LLVM IR (-O0):
@.str = [2 x i8] c"r\00"
@stderr = global i32 0
@.str.1 = [17 x i8] c"open %s failed!\0A\00"
define i32 @parse_config(i8* %0) {
%2 = alloca i8*
%3 = alloca [1024 x i8]
%4 = alloca i32*
store i8* %0, i8** %2
%5 = load i8*, i8** %2
%6 = call i32* @fopen(i8* %5, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
store i32* %6, i32** %4
%7 = load i32*, i32** %4
%8 = icmp eq i32* %7, null
br i1 %8, label %9, label %16
9: ; preds = %1
%10 = load i32, i32* @stderr
%11 = load i8*, i8** %2
%12 = call i32 @fprintf(i32 %10, i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.1, i64 0, i64 0), i8* %11)
%13 = load i32, i32* @stderr
%14 = call i32 @fflush(i32 %13)
%15 = call i32 @exit(i32 -1)
unreachable
16: ; preds = %1
br label %17
17: ; preds = %37, %29, %16
%18 = load i32*, i32** %4
%19 = call i32 @feof(i32* %18)
%20 = icmp ne i32 %19, 0
%21 = xor i1 %20, true
br i1 %21, label %22, label %38
22: ; preds = %17
%23 = getelementptr inbounds [1024 x i8], [1024 x i8]* %3, i64 0, i64 0
%24 = call i32 @memset(i8* %23, i32 0, i32 1024)
%25 = getelementptr inbounds [1024 x i8], [1024 x i8]* %3, i64 0, i64 0
%26 = load i32*, i32** %4
%27 = call i32* @fgets(i8* %25, i32 1023, i32* %26)
%28 = icmp eq i32* %27, null
br i1 %28, label %29, label %30
29: ; preds = %22
br label %17
30: ; preds = %22
%31 = getelementptr inbounds [1024 x i8], [1024 x i8]* %3, i64 0, i64 0
%32 = call i64 @strlen(i8* %31)
%33 = icmp sgt i64 %32, 0
br i1 %33, label %34, label %37
34: ; preds = %30
%35 = getelementptr inbounds [1024 x i8], [1024 x i8]* %3, i64 0, i64 0
%36 = call i32 @parse_line(i8* %35, i32 1024)
br label %37
37: ; preds = %34, %30
br label %17
38: ; preds = %17
%39 = load i32*, i32** %4
%40 = call i32 @fclose(i32* %39)
ret i32 0
}

LLVM IR (-O2):
@.str = [2 x i8] c"r\00"
@stderr = global i32 0
@.str.1 = [17 x i8] c"open %s failed!\0A\00"
define i32 @parse_config(i8* %0) {
%2 = alloca [1024 x i8]
%3 = getelementptr inbounds [1024 x i8], [1024 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 %9, label %6
6: ; preds = %1
%7 = call i32 @feof(i32* %4)
%8 = icmp eq i32 %7, 0
br i1 %8, label %15, label %27
9: ; preds = %1
%10 = load i32, i32* @stderr
%11 = tail call i32 @fprintf(i32 %10, i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.1, i64 0, i64 0), i8* %0)
%12 = load i32, i32* @stderr
%13 = tail call i32 @fflush(i32 %12)
%14 = tail call i32 @exit(i32 -1)
unreachable
15: ; preds = %6, %24
%16 = call i32 @memset(i8* %3, i32 0, i32 1024)
%17 = call i32* @fgets(i8* %3, i32 1023, i32* %4)
%18 = icmp eq i32* %17, null
br i1 %18, label %24, label %19
19: ; preds = %15
%20 = call i64 @strlen(i8* %3)
%21 = icmp sgt i64 %20, 0
br i1 %21, label %22, label %24
22: ; preds = %19
%23 = call i32 @parse_line(i8* %3, i32 1024)
br label %24
24: ; preds = %19, %22, %15
%25 = call i32 @feof(i32* %4)
%26 = icmp eq i32 %25, 0
br i1 %26, label %15, label %27
27: ; preds = %24, %6
%28 = call i32 @fclose(i32* %4)
ret i32 0
}