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

/* Variables and functions */
int /*<<< orphan*/ cfgAddOption(char *, char *);
int /*<<< orphan*/ cfgReset();
int /*<<< orphan*/ fclose(int /*<<< orphan*/ *);
scalar_t__ fgets(char *, int, int /*<<< orphan*/ *);
int /*<<< orphan*/ *fopen(char *, char *);
int strlen(char *);
int cfgReadFile(char *pszFile) {
  int i = 0;
  FILE *f = fopen(pszFile, "r");
  char szBuffer[512];
  cfgReset();
  if (f != NULL) {
    while (fgets(szBuffer, sizeof(szBuffer), f)) {
      szBuffer[strlen(szBuffer) - 1] = 0;
      if (*szBuffer && *szBuffer != ';' && *szBuffer != '#') {
        char *pszSplit = szBuffer;
        while (*pszSplit && *pszSplit != '=') {
          ++pszSplit;
        }
        if (*pszSplit) {
          *pszSplit = 0;
          ++pszSplit;
          if (*pszSplit) {
            cfgAddOption(szBuffer, pszSplit);
            ++i;
          }
        }
      }
    }
    fclose(f);
  }
  return (i);
}


x86 assembly (clang, -O0):
<cfgReadFile>:
push   %rbp
mov    %rsp,%rbp
sub    $0x230,%rsp
mov    %rdi,-0x8(%rbp)
movl   $0x0,-0xc(%rbp)
mov    -0x8(%rbp),%rdi
lea    0xe7f(%rip),%rsi
call   1080 <fopen@plt>
mov    %rax,-0x18(%rbp)
mov    $0x0,%al
call   1030 <cfgReset@plt>
cmpq   $0x0,-0x18(%rbp)
je     12e2 <cfgReadFile+0x182>
jmp    11a1 <cfgReadFile+0x41>
lea    -0x220(%rbp),%rdi
mov    -0x18(%rbp),%rdx
mov    $0x200,%esi
call   1070 <fgets@plt>
cmp    $0x0,%rax
je     12d9 <cfgReadFile+0x179>
lea    -0x220(%rbp),%rdi
call   1060 <strlen@plt>
sub    $0x1,%eax
cltq
movb   $0x0,-0x220(%rbp,%rax,1)
movsbl -0x220(%rbp),%eax
cmp    $0x0,%eax
je     12d4 <cfgReadFile+0x174>
movsbl -0x220(%rbp),%eax
cmp    $0x3b,%eax
je     12d4 <cfgReadFile+0x174>
movsbl -0x220(%rbp),%eax
cmp    $0x23,%eax
je     12d4 <cfgReadFile+0x174>
lea    -0x220(%rbp),%rax
mov    %rax,-0x228(%rbp)
mov    -0x228(%rbp),%rax
movsbl (%rax),%ecx
xor    %eax,%eax
cmp    $0x0,%ecx
mov    %al,-0x229(%rbp)
je     1248 <cfgReadFile+0xe8>
mov    -0x228(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x3d,%eax
setne  %al
mov    %al,-0x229(%rbp)
mov    -0x229(%rbp),%al
test   $0x1,%al
jne    125b <cfgReadFile+0xfb>
jmp    1272 <cfgReadFile+0x112>
mov    -0x228(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x228(%rbp)
jmp    1217 <cfgReadFile+0xb7>
mov    -0x228(%rbp),%rax
cmpb   $0x0,(%rax)
je     12cf <cfgReadFile+0x16f>
mov    -0x228(%rbp),%rax
movb   $0x0,(%rax)
mov    -0x228(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x228(%rbp)
mov    -0x228(%rbp),%rax
cmpb   $0x0,(%rax)
je     12ca <cfgReadFile+0x16a>
lea    -0x220(%rbp),%rdi
mov    -0x228(%rbp),%rsi
call   1040 <cfgAddOption@plt>
mov    -0xc(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xc(%rbp)
jmp    12cf <cfgReadFile+0x16f>
jmp    12d4 <cfgReadFile+0x174>
jmp    11a1 <cfgReadFile+0x41>
mov    -0x18(%rbp),%rdi
call   1050 <fclose@plt>
mov    -0xc(%rbp),%eax
add    $0x230,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<cfgReadFile>:
push   %rbp
push   %r15
push   %r14
push   %r12
push   %rbx
sub    $0x200,%rsp
lea    0xe8a(%rip),%rsi
call   1080 <fopen@plt>
mov    %rax,%rbx
xor    %r14d,%r14d
xor    %eax,%eax
call   1030 <cfgReset@plt>
test   %rbx,%rbx
je     1240 <cfgReadFile+0xe0>
mov    %rsp,%rbp
mov    %rbp,%rdi
mov    $0x200,%esi
mov    %rbx,%rdx
call   1070 <fgets@plt>
xor    %r14d,%r14d
test   %rax,%rax
je     1238 <cfgReadFile+0xd8>
lea    0x1(%rsp),%r15
movabs $0x800000800000001,%r12
jmp    11e5 <cfgReadFile+0x85>
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax,%rax,1)
mov    %rbp,%rdi
mov    $0x200,%esi
mov    %rbx,%rdx
call   1070 <fgets@plt>
test   %rax,%rax
je     1238 <cfgReadFile+0xd8>
mov    %rbp,%rdi
call   1060 <strlen@plt>
cltq
movb   $0x0,-0x1(%rax,%rbp,1)
movzbl (%rsp),%eax
cmp    $0x3b,%rax
ja     1204 <cfgReadFile+0xa4>
bt     %rax,%r12
jb     11d0 <cfgReadFile+0x70>
mov    %r15,%rsi
test   %al,%al
je     11d0 <cfgReadFile+0x70>
nopl   0x0(%rax,%rax,1)
cmp    $0x3d,%al
je     1221 <cfgReadFile+0xc1>
movzbl (%rsi),%eax
add    $0x1,%rsi
test   %al,%al
jne    1210 <cfgReadFile+0xb0>
jmp    11d0 <cfgReadFile+0x70>
movb   $0x0,-0x1(%rsi)
cmpb   $0x0,(%rsi)
je     11d0 <cfgReadFile+0x70>
mov    %rbp,%rdi
call   1040 <cfgAddOption@plt>
add    $0x1,%r14d
jmp    11d0 <cfgReadFile+0x70>
mov    %rbx,%rdi
call   1050 <fclose@plt>
mov    %r14d,%eax
add    $0x200,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [2 x i8] c"r\00"
define i32 @cfgReadFile(i8* %0) {
%2 = alloca i8*
%3 = alloca i32
%4 = alloca i32*
%5 = alloca [512 x i8]
%6 = alloca i8*
store i8* %0, i8** %2
store i32 0, i32* %3
%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** %4
%9 = call i32 (...) @cfgReset()
%10 = load i32*, i32** %4
%11 = icmp ne i32* %10, null
br i1 %11, label %12, label %78
12: ; preds = %1
br label %13
13: ; preds = %74, %12
%14 = getelementptr inbounds [512 x i8], [512 x i8]* %5, i64 0, i64 0
%15 = load i32*, i32** %4
%16 = call i64 @fgets(i8* %14, i32 512, i32* %15)
%17 = icmp ne i64 %16, 0
br i1 %17, label %18, label %75
18: ; preds = %13
%19 = getelementptr inbounds [512 x i8], [512 x i8]* %5, i64 0, i64 0
%20 = call i32 @strlen(i8* %19)
%21 = sub nsw i32 %20, 1
%22 = sext i32 %21 to i64
%23 = getelementptr inbounds [512 x i8], [512 x i8]* %5, i64 0, i64 %22
store i8 0, i8* %23
%24 = getelementptr inbounds [512 x i8], [512 x i8]* %5, i64 0, i64 0
%25 = load i8, i8* %24
%26 = sext i8 %25 to i32
%27 = icmp ne i32 %26, 0
br i1 %27, label %28, label %74
28: ; preds = %18
%29 = getelementptr inbounds [512 x i8], [512 x i8]* %5, i64 0, i64 0
%30 = load i8, i8* %29
%31 = sext i8 %30 to i32
%32 = icmp ne i32 %31, 59
br i1 %32, label %33, label %74
33: ; preds = %28
%34 = getelementptr inbounds [512 x i8], [512 x i8]* %5, i64 0, i64 0
%35 = load i8, i8* %34
%36 = sext i8 %35 to i32
%37 = icmp ne i32 %36, 35
br i1 %37, label %38, label %74
38: ; preds = %33
%39 = getelementptr inbounds [512 x i8], [512 x i8]* %5, i64 0, i64 0
store i8* %39, i8** %6
br label %40
40: ; preds = %52, %38
%41 = load i8*, i8** %6
%42 = load i8, i8* %41
%43 = sext i8 %42 to i32
%44 = icmp ne i32 %43, 0
br i1 %44, label %45, label %50
45: ; preds = %40
%46 = load i8*, i8** %6
%47 = load i8, i8* %46
%48 = sext i8 %47 to i32
%49 = icmp ne i32 %48, 61
br label %50
50: ; preds = %45, %40
%51 = phi i1 [ false, %40 ], [ %49, %45 ]
br i1 %51, label %52, label %55
52: ; preds = %50
%53 = load i8*, i8** %6
%54 = getelementptr inbounds i8, i8* %53, i32 1
store i8* %54, i8** %6
br label %40
55: ; preds = %50
%56 = load i8*, i8** %6
%57 = load i8, i8* %56
%58 = icmp ne i8 %57, 0
br i1 %58, label %59, label %73
59: ; preds = %55
%60 = load i8*, i8** %6
store i8 0, i8* %60
%61 = load i8*, i8** %6
%62 = getelementptr inbounds i8, i8* %61, i32 1
store i8* %62, i8** %6
%63 = load i8*, i8** %6
%64 = load i8, i8* %63
%65 = icmp ne i8 %64, 0
br i1 %65, label %66, label %72
66: ; preds = %59
%67 = getelementptr inbounds [512 x i8], [512 x i8]* %5, i64 0, i64 0
%68 = load i8*, i8** %6
%69 = call i32 @cfgAddOption(i8* %67, i8* %68)
%70 = load i32, i32* %3
%71 = add nsw i32 %70, 1
store i32 %71, i32* %3
br label %72
72: ; preds = %66, %59
br label %73
73: ; preds = %72, %55
br label %74
74: ; preds = %73, %33, %28, %18
br label %13
75: ; preds = %13
%76 = load i32*, i32** %4
%77 = call i32 @fclose(i32* %76)
br label %78
78: ; preds = %75, %1
%79 = load i32, i32* %3
ret i32 %79
}

LLVM IR (-O2):
@.str = [2 x i8] c"r\00"
define i32 @cfgReadFile(i8* nocapture %0) {
%2 = alloca [512 x i8]
%3 = tail call i32* @fopen(i8* %0, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
%4 = getelementptr inbounds [512 x i8], [512 x i8]* %2, i64 0, i64 0
%5 = tail call i32 (...) @cfgReset()
%6 = icmp eq i32* %3, null
br i1 %6, label %37, label %7
7: ; preds = %1
%8 = call i64 @fgets(i8* %4, i32 512, i32* %3)
%9 = icmp eq i64 %8, 0
br i1 %9, label %34, label %10
10: ; preds = %7, %30
%11 = phi i32 [ %31, %30 ], [ 0, %7 ]
%12 = call i32 @strlen(i8* %4)
%13 = add nsw i32 %12, -1
%14 = sext i32 %13 to i64
%15 = getelementptr inbounds [512 x i8], [512 x i8]* %2, i64 0, i64 %14
store i8 0, i8* %15
%16 = load i8, i8* %4
switch i8 %16, label %17 [
i8 59, label %30
i8 35, label %30
i8 0, label %30
]
17: ; preds = %10, %20
%18 = phi i8 [ %22, %20 ], [ %16, %10 ]
%19 = phi i8* [ %21, %20 ], [ %4, %10 ]
switch i8 %18, label %20 [
i8 0, label %30
i8 61, label %23
]
20: ; preds = %17
%21 = getelementptr inbounds i8, i8* %19, i64 1
%22 = load i8, i8* %21
br label %17
23: ; preds = %17
store i8 0, i8* %19
%24 = getelementptr inbounds i8, i8* %19, i64 1
%25 = load i8, i8* %24
%26 = icmp eq i8 %25, 0
br i1 %26, label %30, label %27
27: ; preds = %23
%28 = call i32 @cfgAddOption(i8* %4, i8* %24)
%29 = add nsw i32 %11, 1
br label %30
30: ; preds = %17, %27, %23, %10, %10, %10
%31 = phi i32 [ %11, %10 ], [ %11, %10 ], [ %11, %10 ], [ %29, %27 ], [ %11, %23 ], [ %11, %17 ]
%32 = call i64 @fgets(i8* %4, i32 512, i32* %3)
%33 = icmp eq i64 %32, 0
br i1 %33, label %34, label %10
34: ; preds = %30, %7
%35 = phi i32 [ 0, %7 ], [ %31, %30 ]
%36 = call i32 @fclose(i32* %3)
br label %37
37: ; preds = %34, %1
%38 = phi i32 [ %35, %34 ], [ 0, %1 ]
ret i32 %38
}