#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*/ FILE;

/* Variables and functions */
int /*<<< orphan*/ configadd(char *, char *);
int /*<<< orphan*/ exit(int);
int /*<<< orphan*/ fclose(int /*<<< orphan*/ *);
scalar_t__ fgets(char *, int, int /*<<< orphan*/ *);
int /*<<< orphan*/ *fopen(char const *, char *);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *, char const *, ...);
int /*<<< orphan*/ stderr;
char *strchr(char *, char);
int /*<<< orphan*/ strcpy(char *, char *);
int /*<<< orphan*/ strtolower(char *);
int /*<<< orphan*/ trim(char *);
void ConfigFile(const char *configFile) {
  FILE *fp = fopen(configFile, "r");
  if (fp == NULL) {
    fprintf(stderr, "Config file %s not found\n", configFile);
    return;
  }
  char linebuf[16384];
  int linenum = 0;
  while (fgets(linebuf, 16384, fp)) {
    linenum++;
    trim(linebuf);
    if ((linebuf[0] == '\0') || (linebuf[0] == '#'))
      continue;
    char *eqpos = strchr(linebuf, '=');
    if (eqpos != NULL) {
      char cfg_varname[1024];
      char cfg_value[8192];
      *eqpos = '\0';
      strcpy(cfg_varname, linebuf);
      trim(cfg_varname);
      strtolower(cfg_varname);
      strcpy(cfg_value, eqpos + 1);
      trim(cfg_value);
      configadd(cfg_varname, cfg_value);
    } else {
      fprintf(stderr, "Error in config file %s line %d:\n   = not found.\n",
              configFile, linenum);
      exit(1);
    }
  }
  fclose(fp);
}


x86 assembly (clang, -O0):
<ConfigFile>:
push   %rbp
mov    %rsp,%rbp
sub    $0x6420,%rsp
mov    %rdi,-0x8(%rbp)
mov    -0x8(%rbp),%rdi
lea    0xe46(%rip),%rsi
call   10a0 <fopen@plt>
mov    %rax,-0x10(%rbp)
cmpq   $0x0,-0x10(%rbp)
jne    11ee <ConfigFile+0x4e>
mov    0x2e0b(%rip),%rax
mov    (%rax),%edi
mov    -0x8(%rbp),%rdx
lea    0xe20(%rip),%rsi
mov    $0x0,%al
call   1090 <fprintf@plt>
jmp    1326 <ConfigFile+0x186>
movl   $0x0,-0x4014(%rbp)
lea    -0x4010(%rbp),%rdi
mov    -0x10(%rbp),%rdx
mov    $0x4000,%esi
call   1080 <fgets@plt>
cmp    $0x0,%rax
je     131d <ConfigFile+0x17d>
mov    -0x4014(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x4014(%rbp)
lea    -0x4010(%rbp),%rdi
call   1070 <trim@plt>
movsbl -0x4010(%rbp),%eax
cmp    $0x0,%eax
je     1252 <ConfigFile+0xb2>
movsbl -0x4010(%rbp),%eax
cmp    $0x23,%eax
jne    1257 <ConfigFile+0xb7>
jmp    11f8 <ConfigFile+0x58>
lea    -0x4010(%rbp),%rdi
mov    $0x3d,%esi
call   1060 <strchr@plt>
mov    %rax,-0x4020(%rbp)
cmpq   $0x0,-0x4020(%rbp)
je     12ed <ConfigFile+0x14d>
mov    -0x4020(%rbp),%rax
movb   $0x0,(%rax)
lea    -0x4420(%rbp),%rdi
lea    -0x4010(%rbp),%rsi
call   1030 <strcpy@plt>
lea    -0x4420(%rbp),%rdi
call   1070 <trim@plt>
lea    -0x4420(%rbp),%rdi
call   1050 <strtolower@plt>
lea    -0x6420(%rbp),%rdi
mov    -0x4020(%rbp),%rsi
add    $0x1,%rsi
call   1030 <strcpy@plt>
lea    -0x6420(%rbp),%rdi
call   1070 <trim@plt>
lea    -0x4420(%rbp),%rdi
lea    -0x6420(%rbp),%rsi
call   10c0 <configadd@plt>
jmp    1318 <ConfigFile+0x178>
mov    0x2cec(%rip),%rax
mov    (%rax),%edi
mov    -0x8(%rbp),%rdx
mov    -0x4014(%rbp),%ecx
lea    0xd15(%rip),%rsi
mov    $0x0,%al
call   1090 <fprintf@plt>
mov    $0x1,%edi
call   10b0 <exit@plt>
jmp    11f8 <ConfigFile+0x58>
mov    -0x10(%rbp),%rdi
call   1040 <fclose@plt>
add    $0x6420,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<ConfigFile>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x6418,%rsp
mov    %rdi,%rbx
lea    0xe45(%rip),%rsi
call   10a0 <fopen@plt>
test   %rax,%rax
je     12b8 <ConfigFile+0x118>
mov    %rax,%r15
mov    %rbx,0x8(%rsp)
lea    0x410(%rsp),%rdi
mov    $0x4000,%esi
mov    %rax,%rdx
call   1080 <fgets@plt>
test   %rax,%rax
je     129e <ConfigFile+0xfe>
mov    $0x1,%ebp
lea    0x410(%rsp),%rbx
lea    0x10(%rsp),%r12
lea    0x4410(%rsp),%r13
jmp    1228 <ConfigFile+0x88>
nopl   0x0(%rax,%rax,1)
mov    %rbx,%rdi
mov    $0x4000,%esi
mov    %r15,%rdx
call   1080 <fgets@plt>
add    $0x1,%ebp
test   %rax,%rax
je     129e <ConfigFile+0xfe>
mov    %rbx,%rdi
call   1070 <trim@plt>
movzbl 0x410(%rsp),%eax
test   %al,%al
je     1210 <ConfigFile+0x70>
cmp    $0x23,%al
je     1210 <ConfigFile+0x70>
mov    %rbx,%rdi
mov    $0x3d,%esi
call   1060 <strchr@plt>
test   %rax,%rax
je     12e3 <ConfigFile+0x143>
mov    %rax,%r14
movb   $0x0,(%rax)
mov    %r12,%rdi
mov    %rbx,%rsi
call   1030 <strcpy@plt>
mov    %r12,%rdi
call   1070 <trim@plt>
mov    %r12,%rdi
call   1050 <strtolower@plt>
add    $0x1,%r14
mov    %r13,%rdi
mov    %r14,%rsi
call   1030 <strcpy@plt>
mov    %r13,%rdi
call   1070 <trim@plt>
mov    %r12,%rdi
mov    %r13,%rsi
call   10c0 <configadd@plt>
jmp    1210 <ConfigFile+0x70>
mov    %r15,%rdi
call   1040 <fclose@plt>
add    $0x6418,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret
mov    0x2d21(%rip),%rax
mov    (%rax),%edi
lea    0xd3a(%rip),%rsi
mov    %rbx,%rdx
xor    %eax,%eax
add    $0x6418,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
jmp    1090 <fprintf@plt>
mov    0x2cf6(%rip),%rax
mov    (%rax),%edi
lea    0xd29(%rip),%rsi
mov    0x8(%rsp),%rdx
mov    %ebp,%ecx
xor    %eax,%eax
call   1090 <fprintf@plt>
mov    $0x1,%edi
call   10b0 <exit@plt>

LLVM IR (-O0):
@.str = [2 x i8] c"r\00"
@stderr = global i32 0
@.str.1 = [26 x i8] c"Config file %s not found\0A\00"
@.str.2 = [50 x i8] c"Error in config file %s line %d:\0A = not found.\0A\00"
define void @ConfigFile(i8* %0) {
%2 = alloca i8*
%3 = alloca i32*
%4 = alloca [16384 x i8]
%5 = alloca i32
%6 = alloca i8*
%7 = alloca [1024 x i8]
%8 = alloca [8192 x i8]
store i8* %0, i8** %2
%9 = load i8*, i8** %2
%10 = call i32* @fopen(i8* %9, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
store i32* %10, i32** %3
%11 = load i32*, i32** %3
%12 = icmp eq i32* %11, null
br i1 %12, label %13, label %17
13: ; preds = %1
%14 = load i32, i32* @stderr
%15 = load i8*, i8** %2
%16 = call i32 (i32, i8*, i8*, ...) @fprintf(i32 %14, i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str.1, i64 0, i64 0), i8* %15)
br label %71
17: ; preds = %1
store i32 0, i32* %5
br label %18
18: ; preds = %67, %37, %17
%19 = getelementptr inbounds [16384 x i8], [16384 x i8]* %4, i64 0, i64 0
%20 = load i32*, i32** %3
%21 = call i64 @fgets(i8* %19, i32 16384, i32* %20)
%22 = icmp ne i64 %21, 0
br i1 %22, label %23, label %68
23: ; preds = %18
%24 = load i32, i32* %5
%25 = add nsw i32 %24, 1
store i32 %25, i32* %5
%26 = getelementptr inbounds [16384 x i8], [16384 x i8]* %4, i64 0, i64 0
%27 = call i32 @trim(i8* %26)
%28 = getelementptr inbounds [16384 x i8], [16384 x i8]* %4, i64 0, i64 0
%29 = load i8, i8* %28
%30 = sext i8 %29 to i32
%31 = icmp eq i32 %30, 0
br i1 %31, label %37, label %32
32: ; preds = %23
%33 = getelementptr inbounds [16384 x i8], [16384 x i8]* %4, i64 0, i64 0
%34 = load i8, i8* %33
%35 = sext i8 %34 to i32
%36 = icmp eq i32 %35, 35
br i1 %36, label %37, label %38
37: ; preds = %32, %23
br label %18
38: ; preds = %32
%39 = getelementptr inbounds [16384 x i8], [16384 x i8]* %4, i64 0, i64 0
%40 = call i8* @strchr(i8* %39, i8 signext 61)
store i8* %40, i8** %6
%41 = load i8*, i8** %6
%42 = icmp ne i8* %41, null
br i1 %42, label %43, label %61
43: ; preds = %38
%44 = load i8*, i8** %6
store i8 0, i8* %44
%45 = getelementptr inbounds [1024 x i8], [1024 x i8]* %7, i64 0, i64 0
%46 = getelementptr inbounds [16384 x i8], [16384 x i8]* %4, i64 0, i64 0
%47 = call i32 @strcpy(i8* %45, i8* %46)
%48 = getelementptr inbounds [1024 x i8], [1024 x i8]* %7, i64 0, i64 0
%49 = call i32 @trim(i8* %48)
%50 = getelementptr inbounds [1024 x i8], [1024 x i8]* %7, i64 0, i64 0
%51 = call i32 @strtolower(i8* %50)
%52 = getelementptr inbounds [8192 x i8], [8192 x i8]* %8, i64 0, i64 0
%53 = load i8*, i8** %6
%54 = getelementptr inbounds i8, i8* %53, i64 1
%55 = call i32 @strcpy(i8* %52, i8* %54)
%56 = getelementptr inbounds [8192 x i8], [8192 x i8]* %8, i64 0, i64 0
%57 = call i32 @trim(i8* %56)
%58 = getelementptr inbounds [1024 x i8], [1024 x i8]* %7, i64 0, i64 0
%59 = getelementptr inbounds [8192 x i8], [8192 x i8]* %8, i64 0, i64 0
%60 = call i32 @configadd(i8* %58, i8* %59)
br label %67
61: ; preds = %38
%62 = load i32, i32* @stderr
%63 = load i8*, i8** %2
%64 = load i32, i32* %5
%65 = call i32 (i32, i8*, i8*, ...) @fprintf(i32 %62, i8* getelementptr inbounds ([50 x i8], [50 x i8]* @.str.2, i64 0, i64 0), i8* %63, i32 %64)
%66 = call i32 @exit(i32 1)
unreachable
67: ; preds = %43
br label %18
68: ; preds = %18
%69 = load i32*, i32** %3
%70 = call i32 @fclose(i32* %69)
br label %71
71: ; preds = %68, %13
ret void
}

LLVM IR (-O2):
@.str = [2 x i8] c"r\00"
@stderr = global i32 0
@.str.1 = [26 x i8] c"Config file %s not found\0A\00"
@.str.2 = [50 x i8] c"Error in config file %s line %d:\0A = not found.\0A\00"
define void @ConfigFile(i8* %0) {
%2 = alloca [16384 x i8]
%3 = alloca [1024 x i8]
%4 = alloca [8192 x i8]
%5 = tail call i32* @fopen(i8* %0, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
%6 = icmp eq i32* %5, null
br i1 %6, label %7, label %10
7: ; preds = %1
%8 = load i32, i32* @stderr
%9 = tail call i32 (i32, i8*, i8*, ...) @fprintf(i32 %8, i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str.1, i64 0, i64 0), i8* %0)
br label %42
10: ; preds = %1
%11 = getelementptr inbounds [16384 x i8], [16384 x i8]* %2, i64 0, i64 0
%12 = call i64 @fgets(i8* %11, i32 16384, i32* %5)
%13 = icmp eq i64 %12, 0
br i1 %13, label %40, label %14
14: ; preds = %10
%15 = getelementptr inbounds [1024 x i8], [1024 x i8]* %3, i64 0, i64 0
%16 = getelementptr inbounds [8192 x i8], [8192 x i8]* %4, i64 0, i64 0
br label %17
17: ; preds = %14, %33
%18 = phi i32 [ 0, %14 ], [ %19, %33 ]
%19 = add nuw nsw i32 %18, 1
%20 = call i32 @trim(i8* %11)
%21 = load i8, i8* %11
switch i8 %21, label %22 [
i8 35, label %33
i8 0, label %33
]
22: ; preds = %17
%23 = call i8* @strchr(i8* %11, i8 signext 61)
%24 = icmp eq i8* %23, null
br i1 %24, label %36, label %25
25: ; preds = %22
store i8 0, i8* %23
%26 = call i32 @strcpy(i8* %15, i8* %11)
%27 = call i32 @trim(i8* %15)
%28 = call i32 @strtolower(i8* %15)
%29 = getelementptr inbounds i8, i8* %23, i64 1
%30 = call i32 @strcpy(i8* %16, i8* %29)
%31 = call i32 @trim(i8* %16)
%32 = call i32 @configadd(i8* %15, i8* %16)
br label %33
33: ; preds = %25, %17, %17
%34 = call i64 @fgets(i8* %11, i32 16384, i32* %5)
%35 = icmp eq i64 %34, 0
br i1 %35, label %40, label %17
36: ; preds = %22
%37 = load i32, i32* @stderr
%38 = call i32 (i32, i8*, i8*, ...) @fprintf(i32 %37, i8* getelementptr inbounds ([50 x i8], [50 x i8]* @.str.2, i64 0, i64 0), i8* %0, i32 %19)
%39 = call i32 @exit(i32 1)
unreachable
40: ; preds = %33, %10
%41 = call i32 @fclose(i32* %5)
br label %42
42: ; preds = %40, %7
ret void
}