#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 */
struct cfg_section {
  int dummy;
};
struct cfg_domain {
  int dummy;
};
typedef int /*<<< orphan*/ FILE;

/* Variables and functions */
struct cfg_domain *cfg_get_domain(char *);
struct cfg_section *cfg_get_section(struct cfg_domain *, char *);
int /*<<< orphan*/ cfg_set_entry(struct cfg_section *, char *, char *);
int /*<<< orphan*/ fclose(int /*<<< orphan*/ *);
int /*<<< orphan*/ *fgets(char *, int, int /*<<< orphan*/ *);
int /*<<< orphan*/ *fopen(char *, char *);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *, char *, int);
int /*<<< orphan*/ free(char *);
char *malloc(int);
int sscanf(char *, char *, char *, ...);
int /*<<< orphan*/ stderr;
int /*<<< orphan*/ strcpy(char *, char *);
int strlen(char *);
char *strrchr(char *, char);
int cfg_parse_file(char *dname, char *filename) {
  struct cfg_domain *domain = NULL;
  struct cfg_section *section = NULL;
  char line[256], tag[64], value[192];
  FILE *fp;
  int nr;
  if (NULL == (fp = fopen(filename, "r")))
    return -1;
  nr = 0;
  domain = cfg_get_domain(dname);
  while (NULL != fgets(line, 255, fp)) {
    nr++;
    if (1 == sscanf(line, "# include \"%[^\"]\"", value)) {
      char *h, *inc;
      inc = malloc(strlen(filename) + strlen(value));
      strcpy(inc, filename);
      h = strrchr(inc, '/');
      if (h)
        h++;
      else
        h = inc;
      strcpy(h, value);
      cfg_parse_file(dname, inc);
      free(inc);
      continue;
    }
    if (line[0] == '\n' || line[0] == '#' || line[0] == '%')
      continue;
    if (1 == sscanf(line, "[%99[^]]]", value)) {
      section = cfg_get_section(domain, value);
    } else if (2 == sscanf(line, " %63[^= ] = %191[^\n]", tag, value)) {
      if (NULL == section) {
        fprintf(stderr, "%s:%d: error: no section\n", filename, nr);
      } else {
        char *c = value + strlen(value) - 1;
        while (c > value && (*c == ' ' || *c == '\t'))
          *(c--) = 0;
        cfg_set_entry(section, tag, value);
      }
    } else {
      fprintf(stderr, "%s:%d: syntax error\n", filename, nr);
    }
  }
  fclose(fp);
  return 0;
}


x86 assembly (clang, -O0):
<cfg_parse_file>:
push   %rbp
mov    %rsp,%rbp
sub    $0x270,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
movq   $0x0,-0x20(%rbp)
movq   $0x0,-0x28(%rbp)
mov    -0x18(%rbp),%rdi
lea    0xdf2(%rip),%rsi
call   1100 <fopen@plt>
mov    %rax,%rcx
mov    %rcx,-0x238(%rbp)
xor    %eax,%eax
cmp    %rcx,%rax
jne    1234 <cfg_parse_file+0x54>
movl   $0xffffffff,-0x4(%rbp)
jmp    155c <cfg_parse_file+0x37c>
movl   $0x0,-0x23c(%rbp)
mov    -0x10(%rbp),%rdi
call   10f0 <cfg_get_domain@plt>
mov    %rax,-0x20(%rbp)
lea    -0x130(%rbp),%rdi
mov    -0x238(%rbp),%rdx
mov    $0xff,%esi
call   1090 <fgets@plt>
mov    %rax,%rcx
xor    %eax,%eax
cmp    %rcx,%rax
je     1549 <cfg_parse_file+0x369>
mov    -0x23c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x23c(%rbp)
lea    -0x130(%rbp),%rdi
lea    -0x230(%rbp),%rdx
lea    0xd6d(%rip),%rsi
mov    $0x0,%al
call   10e0 <sscanf@plt>
mov    %eax,%ecx
mov    $0x1,%eax
cmp    %ecx,%eax
jne    1369 <cfg_parse_file+0x189>
mov    -0x18(%rbp),%rdi
call   1060 <strlen@plt>
mov    %eax,-0x25c(%rbp)
lea    -0x230(%rbp),%rdi
call   1060 <strlen@plt>
mov    -0x25c(%rbp),%edi
add    %eax,%edi
call   10d0 <malloc@plt>
mov    %rax,-0x250(%rbp)
mov    -0x250(%rbp),%rdi
mov    -0x18(%rbp),%rsi
call   1040 <strcpy@plt>
mov    -0x250(%rbp),%rdi
mov    $0x2f,%esi
call   1080 <strrchr@plt>
mov    %rax,-0x248(%rbp)
cmpq   $0x0,-0x248(%rbp)
je     1327 <cfg_parse_file+0x147>
mov    -0x248(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x248(%rbp)
jmp    1335 <cfg_parse_file+0x155>
mov    -0x250(%rbp),%rax
mov    %rax,-0x248(%rbp)
mov    -0x248(%rbp),%rdi
lea    -0x230(%rbp),%rsi
call   1040 <strcpy@plt>
mov    -0x10(%rbp),%rdi
mov    -0x250(%rbp),%rsi
call   10a0 <cfg_parse_file@plt>
mov    -0x250(%rbp),%rdi
call   1030 <free@plt>
jmp    124b <cfg_parse_file+0x6b>
movsbl -0x130(%rbp),%eax
cmp    $0xa,%eax
je     1399 <cfg_parse_file+0x1b9>
movsbl -0x130(%rbp),%eax
cmp    $0x23,%eax
je     1399 <cfg_parse_file+0x1b9>
movsbl -0x130(%rbp),%eax
cmp    $0x25,%eax
jne    139e <cfg_parse_file+0x1be>
jmp    124b <cfg_parse_file+0x6b>
lea    -0x130(%rbp),%rdi
lea    -0x230(%rbp),%rdx
lea    0xc61(%rip),%rsi
mov    $0x0,%al
call   10e0 <sscanf@plt>
mov    %eax,%ecx
mov    $0x1,%eax
cmp    %ecx,%eax
jne    13e2 <cfg_parse_file+0x202>
mov    -0x20(%rbp),%rdi
lea    -0x230(%rbp),%rsi
call   1070 <cfg_get_section@plt>
mov    %rax,-0x28(%rbp)
jmp    1544 <cfg_parse_file+0x364>
lea    -0x130(%rbp),%rdi
lea    -0x170(%rbp),%rdx
lea    -0x230(%rbp),%rcx
lea    0xc20(%rip),%rsi
mov    $0x0,%al
call   10e0 <sscanf@plt>
mov    %eax,%ecx
mov    $0x2,%eax
cmp    %ecx,%eax
jne    1520 <cfg_parse_file+0x340>
xor    %eax,%eax
cmp    -0x28(%rbp),%rax
jne    1444 <cfg_parse_file+0x264>
mov    0x2bb9(%rip),%rax
mov    (%rax),%edi
mov    -0x18(%rbp),%rdx
mov    -0x23c(%rbp),%ecx
lea    0xbf9(%rip),%rsi
call   10c0 <fprintf@plt>
jmp    151b <cfg_parse_file+0x33b>
lea    -0x230(%rbp),%rax
mov    %rax,-0x268(%rbp)
lea    -0x230(%rbp),%rdi
call   1060 <strlen@plt>
mov    %eax,%ecx
mov    -0x268(%rbp),%rax
movslq %ecx,%rcx
add    %rcx,%rax
add    $0xffffffffffffffff,%rax
mov    %rax,-0x258(%rbp)
mov    -0x258(%rbp),%rcx
lea    -0x230(%rbp),%rdx
xor    %eax,%eax
cmp    %rdx,%rcx
mov    %al,-0x269(%rbp)
jbe    14d4 <cfg_parse_file+0x2f4>
mov    -0x258(%rbp),%rax
movsbl (%rax),%ecx
mov    $0x1,%al
cmp    $0x20,%ecx
mov    %al,-0x26a(%rbp)
je     14c8 <cfg_parse_file+0x2e8>
mov    -0x258(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x9,%eax
sete   %al
mov    %al,-0x26a(%rbp)
mov    -0x26a(%rbp),%al
mov    %al,-0x269(%rbp)
mov    -0x269(%rbp),%al
test   $0x1,%al
jne    14e7 <cfg_parse_file+0x307>
jmp    1504 <cfg_parse_file+0x324>
mov    -0x258(%rbp),%rax
mov    %rax,%rcx
add    $0xffffffffffffffff,%rcx
mov    %rcx,-0x258(%rbp)
movb   $0x0,(%rax)
jmp    1478 <cfg_parse_file+0x298>
mov    -0x28(%rbp),%rdi
lea    -0x170(%rbp),%rsi
lea    -0x230(%rbp),%rdx
call   10b0 <cfg_set_entry@plt>
jmp    153f <cfg_parse_file+0x35f>
mov    0x2ab9(%rip),%rax
mov    (%rax),%edi
mov    -0x18(%rbp),%rdx
mov    -0x23c(%rbp),%ecx
lea    0xb13(%rip),%rsi
call   10c0 <fprintf@plt>
jmp    1544 <cfg_parse_file+0x364>
jmp    124b <cfg_parse_file+0x6b>
mov    -0x238(%rbp),%rdi
call   1050 <fclose@plt>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x270,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<cfg_parse_file>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x238,%rsp
mov    %rsi,%rax
mov    %rdi,0x18(%rsp)
lea    0xe00(%rip),%rsi
mov    %rax,0x10(%rsp)
mov    %rax,%rdi
call   1100 <fopen@plt>
test   %rax,%rax
je     142e <cfg_parse_file+0x24e>
mov    %rax,%r14
mov    0x18(%rsp),%rdi
call   10f0 <cfg_get_domain@plt>
mov    %rax,0x20(%rsp)
lea    0x70(%rsp),%rdi
mov    $0xff,%esi
mov    %r14,%rdx
call   1090 <fgets@plt>
test   %rax,%rax
je     1422 <cfg_parse_file+0x242>
lea    0x70(%rsp),%r12
lea    0x170(%rsp),%rbx
xor    %r13d,%r13d
xor    %eax,%eax
mov    %rax,0x8(%rsp)
mov    %r14,0x28(%rsp)
mov    0x10(%rsp),%r15
add    $0x1,%r13d
jmp    12f6 <cfg_parse_file+0x116>
nopl   (%rax)
mov    %r15,%rdi
call   1060 <strlen@plt>
mov    %eax,%r14d
mov    %rbx,%rdi
call   1060 <strlen@plt>
add    %eax,%r14d
mov    %r14d,%edi
mov    0x18(%rsp),%r14
call   10d0 <malloc@plt>
mov    %rax,%rbp
mov    %rax,%rdi
mov    %r15,%rsi
call   1040 <strcpy@plt>
mov    %rbp,%rdi
mov    $0x2f,%esi
call   1080 <strrchr@plt>
lea    0x1(%rax),%rdi
test   %rax,%rax
cmove  %rbp,%rdi
mov    %rbx,%rsi
call   1040 <strcpy@plt>
mov    %r14,%rdi
mov    0x28(%rsp),%r14
mov    %rbp,%rsi
call   10a0 <cfg_parse_file@plt>
mov    %rbp,%rdi
call   1030 <free@plt>
mov    %r12,%rdi
mov    $0xff,%esi
mov    %r14,%rdx
call   1090 <fgets@plt>
add    $0x1,%r13d
test   %rax,%rax
je     1422 <cfg_parse_file+0x242>
mov    %r12,%rdi
lea    0xd02(%rip),%rsi
mov    %rbx,%rdx
xor    %eax,%eax
call   10e0 <sscanf@plt>
cmp    $0x1,%eax
je     1270 <cfg_parse_file+0x90>
movzbl 0x70(%rsp),%eax
cmp    $0x25,%rax
ja     132e <cfg_parse_file+0x14e>
movabs $0x2800000400,%rcx
bt     %rax,%rcx
jb     12d9 <cfg_parse_file+0xf9>
mov    %r12,%rdi
lea    0xcdc(%rip),%rsi
mov    %rbx,%rdx
xor    %eax,%eax
call   10e0 <sscanf@plt>
cmp    $0x1,%eax
jne    135e <cfg_parse_file+0x17e>
mov    0x20(%rsp),%rdi
mov    %rbx,%rsi
call   1070 <cfg_get_section@plt>
mov    %rax,0x8(%rsp)
jmp    13e3 <cfg_parse_file+0x203>
mov    %r12,%rdi
lea    0xcb6(%rip),%rsi
lea    0x30(%rsp),%rdx
mov    %rbx,%rcx
xor    %eax,%eax
call   10e0 <sscanf@plt>
cmp    $0x2,%eax
jne    13c6 <cfg_parse_file+0x1e6>
cmpq   $0x0,0x8(%rsp)
je     13fe <cfg_parse_file+0x21e>
mov    %rbx,%rdi
call   1060 <strlen@plt>
cltq
add    %rsp,%rax
add    $0x16f,%rax
jmp    13a0 <cfg_parse_file+0x1c0>
movb   $0x0,(%rax)
add    $0xffffffffffffffff,%rax
cmp    %rbx,%rax
jbe    13b2 <cfg_parse_file+0x1d2>
movzbl (%rax),%ecx
cmp    $0x20,%cl
je     1399 <cfg_parse_file+0x1b9>
cmp    $0x9,%cl
je     1399 <cfg_parse_file+0x1b9>
mov    0x8(%rsp),%rdi
lea    0x30(%rsp),%rsi
mov    %rbx,%rdx
call   10b0 <cfg_set_entry@plt>
jmp    13e3 <cfg_parse_file+0x203>
mov    0x2c13(%rip),%rax
mov    (%rax),%edi
lea    0xc77(%rip),%rsi
mov    0x10(%rsp),%rdx
mov    %r13d,%ecx
call   10c0 <fprintf@plt>
mov    %r12,%rdi
mov    $0xff,%esi
mov    %r14,%rdx
call   1090 <fgets@plt>
test   %rax,%rax
jne    1264 <cfg_parse_file+0x84>
jmp    1422 <cfg_parse_file+0x242>
mov    0x2bdb(%rip),%rax
mov    (%rax),%edi
lea    0xc25(%rip),%rsi
mov    0x10(%rsp),%rdx
mov    %r13d,%ecx
call   10c0 <fprintf@plt>
xor    %eax,%eax
jmp    1354 <cfg_parse_file+0x174>
mov    %r14,%rdi
call   1050 <fclose@plt>
xor    %eax,%eax
jmp    1433 <cfg_parse_file+0x253>
mov    $0xffffffff,%eax
add    $0x238,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
%struct.cfg_domain = type { i32 }
%struct.cfg_section = type { i32 }
@.str = [2 x i8] c"r\00"
@.str.1 = [18 x i8] c"# include \22%[^\22]\22\00"
@.str.2 = [10 x i8] c"[%99[^]]]\00"
@.str.3 = [21 x i8] c" %63[^= ] = %191[^\0A]\00"
@stderr = global i32 0
@.str.4 = [26 x i8] c"%s:%d: error: no section\0A\00"
@.str.5 = [21 x i8] c"%s:%d: syntax error\0A\00"
define i32 @cfg_parse_file(i8* %0, i8* %1) {
%3 = alloca i32
%4 = alloca i8*
%5 = alloca i8*
%6 = alloca %struct.cfg_domain*
%7 = alloca %struct.cfg_section*
%8 = alloca [256 x i8]
%9 = alloca [64 x i8]
%10 = alloca [192 x i8]
%11 = alloca i32*
%12 = alloca i32
%13 = alloca i8*
%14 = alloca i8*
%15 = alloca i8*
store i8* %0, i8** %4
store i8* %1, i8** %5
store %struct.cfg_domain* null, %struct.cfg_domain** %6
store %struct.cfg_section* null, %struct.cfg_section** %7
%16 = load i8*, i8** %5
%17 = call i32* @fopen(i8* %16, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
store i32* %17, i32** %11
%18 = icmp eq i32* null, %17
br i1 %18, label %19, label %20
19: ; preds = %2
store i32 -1, i32* %3
br label %146
20: ; preds = %2
store i32 0, i32* %12
%21 = load i8*, i8** %4
%22 = call %struct.cfg_domain* @cfg_get_domain(i8* %21)
store %struct.cfg_domain* %22, %struct.cfg_domain** %6
br label %23
23: ; preds = %142, %78, %54, %20
%24 = getelementptr inbounds [256 x i8], [256 x i8]* %8, i64 0, i64 0
%25 = load i32*, i32** %11
%26 = call i32* @fgets(i8* %24, i32 255, i32* %25)
%27 = icmp ne i32* null, %26
br i1 %27, label %28, label %143
28: ; preds = %23
%29 = load i32, i32* %12
%30 = add nsw i32 %29, 1
store i32 %30, i32* %12
%31 = getelementptr inbounds [256 x i8], [256 x i8]* %8, i64 0, i64 0
%32 = getelementptr inbounds [192 x i8], [192 x i8]* %10, i64 0, i64 0
%33 = call i32 (i8*, i8*, i8*, ...) @sscanf(i8* %31, i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.1, i64 0, i64 0), i8* %32)
%34 = icmp eq i32 1, %33
br i1 %34, label %35, label %63
35: ; preds = %28
%36 = load i8*, i8** %5
%37 = call i32 @strlen(i8* %36)
%38 = getelementptr inbounds [192 x i8], [192 x i8]* %10, i64 0, i64 0
%39 = call i32 @strlen(i8* %38)
%40 = add nsw i32 %37, %39
%41 = call i8* @malloc(i32 %40)
store i8* %41, i8** %14
%42 = load i8*, i8** %14
%43 = load i8*, i8** %5
%44 = call i32 @strcpy(i8* %42, i8* %43)
%45 = load i8*, i8** %14
%46 = call i8* @strrchr(i8* %45, i8 signext 47)
store i8* %46, i8** %13
%47 = load i8*, i8** %13
%48 = icmp ne i8* %47, null
br i1 %48, label %49, label %52
49: ; preds = %35
%50 = load i8*, i8** %13
%51 = getelementptr inbounds i8, i8* %50, i32 1
store i8* %51, i8** %13
br label %54
52: ; preds = %35
%53 = load i8*, i8** %14
store i8* %53, i8** %13
br label %54
54: ; preds = %52, %49
%55 = load i8*, i8** %13
%56 = getelementptr inbounds [192 x i8], [192 x i8]* %10, i64 0, i64 0
%57 = call i32 @strcpy(i8* %55, i8* %56)
%58 = load i8*, i8** %4
%59 = load i8*, i8** %14
%60 = call i32 @cfg_parse_file(i8* %58, i8* %59)
%61 = load i8*, i8** %14
%62 = call i32 @free(i8* %61)
br label %23
63: ; preds = %28
%64 = getelementptr inbounds [256 x i8], [256 x i8]* %8, i64 0, i64 0
%65 = load i8, i8* %64
%66 = sext i8 %65 to i32
%67 = icmp eq i32 %66, 10
br i1 %67, label %78, label %68
68: ; preds = %63
%69 = getelementptr inbounds [256 x i8], [256 x i8]* %8, i64 0, i64 0
%70 = load i8, i8* %69
%71 = sext i8 %70 to i32
%72 = icmp eq i32 %71, 35
br i1 %72, label %78, label %73
73: ; preds = %68
%74 = getelementptr inbounds [256 x i8], [256 x i8]* %8, i64 0, i64 0
%75 = load i8, i8* %74
%76 = sext i8 %75 to i32
%77 = icmp eq i32 %76, 37
br i1 %77, label %78, label %79
78: ; preds = %73, %68, %63
br label %23
79: ; preds = %73
%80 = getelementptr inbounds [256 x i8], [256 x i8]* %8, i64 0, i64 0
%81 = getelementptr inbounds [192 x i8], [192 x i8]* %10, i64 0, i64 0
%82 = call i32 (i8*, i8*, i8*, ...) @sscanf(i8* %80, i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.2, i64 0, i64 0), i8* %81)
%83 = icmp eq i32 1, %82
br i1 %83, label %84, label %88
84: ; preds = %79
%85 = load %struct.cfg_domain*, %struct.cfg_domain** %6
%86 = getelementptr inbounds [192 x i8], [192 x i8]* %10, i64 0, i64 0
%87 = call %struct.cfg_section* @cfg_get_section(%struct.cfg_domain* %85, i8* %86)
store %struct.cfg_section* %87, %struct.cfg_section** %7
br label %142
88: ; preds = %79
%89 = getelementptr inbounds [256 x i8], [256 x i8]* %8, i64 0, i64 0
%90 = getelementptr inbounds [64 x i8], [64 x i8]* %9, i64 0, i64 0
%91 = getelementptr inbounds [192 x i8], [192 x i8]* %10, i64 0, i64 0
%92 = call i32 (i8*, i8*, i8*, ...) @sscanf(i8* %89, i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.3, i64 0, i64 0), i8* %90, i8* %91)
%93 = icmp eq i32 2, %92
br i1 %93, label %94, label %136
94: ; preds = %88
%95 = load %struct.cfg_section*, %struct.cfg_section** %7
%96 = icmp eq %struct.cfg_section* null, %95
br i1 %96, label %97, label %102
97: ; preds = %94
%98 = load i32, i32* @stderr
%99 = load i8*, i8** %5
%100 = load i32, i32* %12
%101 = call i32 @fprintf(i32 %98, i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str.4, i64 0, i64 0), i8* %99, i32 %100)
br label %135
102: ; preds = %94
%103 = getelementptr inbounds [192 x i8], [192 x i8]* %10, i64 0, i64 0
%104 = getelementptr inbounds [192 x i8], [192 x i8]* %10, i64 0, i64 0
%105 = call i32 @strlen(i8* %104)
%106 = sext i32 %105 to i64
%107 = getelementptr inbounds i8, i8* %103, i64 %106
%108 = getelementptr inbounds i8, i8* %107, i64 -1
store i8* %108, i8** %15
br label %109
109: ; preds = %127, %102
%110 = load i8*, i8** %15
%111 = getelementptr inbounds [192 x i8], [192 x i8]* %10, i64 0, i64 0
%112 = icmp ugt i8* %110, %111
br i1 %112, label %113, label %125
113: ; preds = %109
%114 = load i8*, i8** %15
%115 = load i8, i8* %114
%116 = sext i8 %115 to i32
%117 = icmp eq i32 %116, 32
br i1 %117, label %123, label %118
118: ; preds = %113
%119 = load i8*, i8** %15
%120 = load i8, i8* %119
%121 = sext i8 %120 to i32
%122 = icmp eq i32 %121, 9
br label %123
123: ; preds = %118, %113
%124 = phi i1 [ true, %113 ], [ %122, %118 ]
br label %125
125: ; preds = %123, %109
%126 = phi i1 [ false, %109 ], [ %124, %123 ]
br i1 %126, label %127, label %130
127: ; preds = %125
%128 = load i8*, i8** %15
%129 = getelementptr inbounds i8, i8* %128, i32 -1
store i8* %129, i8** %15
store i8 0, i8* %128
br label %109
130: ; preds = %125
%131 = load %struct.cfg_section*, %struct.cfg_section** %7
%132 = getelementptr inbounds [64 x i8], [64 x i8]* %9, i64 0, i64 0
%133 = getelementptr inbounds [192 x i8], [192 x i8]* %10, i64 0, i64 0
%134 = call i32 @cfg_set_entry(%struct.cfg_section* %131, i8* %132, i8* %133)
br label %135
135: ; preds = %130, %97
br label %141
136: ; preds = %88
%137 = load i32, i32* @stderr
%138 = load i8*, i8** %5
%139 = load i32, i32* %12
%140 = call i32 @fprintf(i32 %137, i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.5, i64 0, i64 0), i8* %138, i32 %139)
br label %141
141: ; preds = %136, %135
br label %142
142: ; preds = %141, %84
br label %23
143: ; preds = %23
%144 = load i32*, i32** %11
%145 = call i32 @fclose(i32* %144)
store i32 0, i32* %3
br label %146
146: ; preds = %143, %19
%147 = load i32, i32* %3
ret i32 %147
}

LLVM IR (-O2):
%struct.cfg_domain = type { i32 }
%struct.cfg_section = type { i32 }
@.str = [2 x i8] c"r\00"
@.str.1 = [18 x i8] c"# include \22%[^\22]\22\00"
@.str.2 = [10 x i8] c"[%99[^]]]\00"
@.str.3 = [21 x i8] c" %63[^= ] = %191[^\0A]\00"
@stderr = global i32 0
@.str.4 = [26 x i8] c"%s:%d: error: no section\0A\00"
@.str.5 = [21 x i8] c"%s:%d: syntax error\0A\00"
define i32 @cfg_parse_file(i8* %0, i8* %1) {
%3 = alloca [256 x i8]
%4 = alloca [64 x i8]
%5 = alloca [192 x i8]
%6 = getelementptr inbounds [256 x i8], [256 x i8]* %3, i64 0, i64 0
%7 = getelementptr inbounds [64 x i8], [64 x i8]* %4, i64 0, i64 0
%8 = getelementptr inbounds [192 x i8], [192 x i8]* %5, i64 0, i64 0
%9 = tail call i32* @fopen(i8* %1, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
%10 = icmp eq i32* %9, null
br i1 %10, label %77, label %11
11: ; preds = %2
%12 = tail call %struct.cfg_domain* @cfg_get_domain(i8* %0)
%13 = call i32* @fgets(i8* %6, i32 255, i32* %9)
%14 = icmp eq i32* %13, null
br i1 %14, label %75, label %15
15: ; preds = %11, %71
%16 = phi i32 [ %20, %71 ], [ 0, %11 ]
%17 = phi %struct.cfg_section* [ %72, %71 ], [ null, %11 ]
br label %18
18: ; preds = %15, %36
%19 = phi i32 [ %16, %15 ], [ %20, %36 ]
%20 = add nsw i32 %19, 1
%21 = call i32 (i8*, i8*, i8*, ...) @sscanf(i8* %6, i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.1, i64 0, i64 0), i8* %8)
%22 = icmp eq i32 %21, 1
br i1 %22, label %23, label %39
23: ; preds = %18
%24 = call i32 @strlen(i8* %1)
%25 = call i32 @strlen(i8* %8)
%26 = add nsw i32 %25, %24
%27 = call i8* @malloc(i32 %26)
%28 = call i32 @strcpy(i8* %27, i8* %1)
%29 = call i8* @strrchr(i8* dereferenceable(1) %27, i8 signext 47)
%30 = icmp eq i8* %29, null
%31 = getelementptr inbounds i8, i8* %29, i64 1
%32 = select i1 %30, i8* %27, i8* %31
%33 = call i32 @strcpy(i8* %32, i8* %8)
%34 = call i32 @cfg_parse_file(i8* %0, i8* %27)
%35 = call i32 @free(i8* %27)
br label %36
36: ; preds = %23, %39, %39, %39
%37 = call i32* @fgets(i8* %6, i32 255, i32* %9)
%38 = icmp eq i32* %37, null
br i1 %38, label %75, label %18
39: ; preds = %18
%40 = load i8, i8* %6
switch i8 %40, label %41 [
i8 37, label %36
i8 35, label %36
i8 10, label %36
]
41: ; preds = %39
%42 = call i32 (i8*, i8*, i8*, ...) @sscanf(i8* %6, i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.2, i64 0, i64 0), i8* %8)
%43 = icmp eq i32 %42, 1
br i1 %43, label %44, label %46
44: ; preds = %41
%45 = call %struct.cfg_section* @cfg_get_section(%struct.cfg_domain* %12, i8* %8)
br label %71
46: ; preds = %41
%47 = call i32 (i8*, i8*, i8*, ...) @sscanf(i8* %6, i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.3, i64 0, i64 0), i8* %7, i8* %8)
%48 = icmp eq i32 %47, 2
br i1 %48, label %49, label %68
49: ; preds = %46
%50 = icmp eq %struct.cfg_section* %17, null
br i1 %50, label %51, label %54
51: ; preds = %49
%52 = load i32, i32* @stderr
%53 = call i32 @fprintf(i32 %52, i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str.4, i64 0, i64 0), i8* %1, i32 %20)
br label %71
54: ; preds = %49
%55 = call i32 @strlen(i8* %8)
%56 = sext i32 %55 to i64
%57 = getelementptr inbounds [192 x i8], [192 x i8]* %5, i64 0, i64 %56
%58 = getelementptr inbounds i8, i8* %57, i64 -1
%59 = icmp ugt i8* %58, %8
br i1 %59, label %60, label %66
60: ; preds = %54, %63
%61 = phi i8* [ %64, %63 ], [ %58, %54 ]
%62 = load i8, i8* %61
switch i8 %62, label %66 [
i8 32, label %63
i8 9, label %63
]
63: ; preds = %60, %60
store i8 0, i8* %61
%64 = getelementptr inbounds i8, i8* %61, i64 -1
%65 = icmp ugt i8* %64, %8
br i1 %65, label %60, label %66
66: ; preds = %63, %60, %54
%67 = call i32 @cfg_set_entry(%struct.cfg_section* %17, i8* %7, i8* %8)
br label %71
68: ; preds = %46
%69 = load i32, i32* @stderr
%70 = call i32 @fprintf(i32 %69, i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.5, i64 0, i64 0), i8* %1, i32 %20)
br label %71
71: ; preds = %68, %66, %51, %44
%72 = phi %struct.cfg_section* [ %45, %44 ], [ null, %51 ], [ %17, %66 ], [ %17, %68 ]
%73 = call i32* @fgets(i8* %6, i32 255, i32* %9)
%74 = icmp eq i32* %73, null
br i1 %74, label %75, label %15
75: ; preds = %71, %36, %11
%76 = call i32 @fclose(i32* %9)
br label %77
77: ; preds = %2, %75
%78 = phi i32 [ 0, %75 ], [ -1, %2 ]
ret i32 %78
}