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

/* Variables and functions */
int /*<<< orphan*/ REG_NOSUB;
int /*<<< orphan*/ R_OK;
scalar_t__ access(char const *, int /*<<< orphan*/);
int /*<<< orphan*/ fclose(int /*<<< orphan*/ *);
scalar_t__ fgets(char *, int, int /*<<< orphan*/ *);
int /*<<< orphan*/ *fopen(char const *, char *);
scalar_t__ isspace(char);
int /*<<< orphan*/ printf(char *, int);
int /*<<< orphan*/ readLine(char *, int /*<<< orphan*/ *);
int regcomp(int /*<<< orphan*/ *, char *, int /*<<< orphan*/);
int /*<<< orphan*/ regfree(int /*<<< orphan*/ *);
int strlen(char *);
void readConfig() {
  const char name[] = "a2web.conf";
  if (access(name, R_OK))
    return;
  char buf[256];
  FILE *f = fopen(name, "r");
  if (!f)
    return;
  regex_t reg;
  int i = regcomp(&reg, "^[[:alpha:][:space:]]*=[[:print:]]*$", REG_NOSUB);
  if (i)
    printf("Failed to compile regex, %d\n", i);
  while (fgets(buf, 256, f)) {
    char *ptr = buf;
    while (isspace(*ptr))
      ptr++;
    if (*ptr == '#')
      continue;
    if (strlen(ptr) < 2)
      continue;
    for (i = 0; ptr[i]; i++)
      if (ptr[i] == '\n')
        ptr[i] = '\0';
    readLine(ptr, &reg);
  }
  regfree(&reg);
  fclose(f);
}


x86 assembly (clang, -O0):
<readConfig>:
push   %rbp
mov    %rsp,%rbp
sub    $0x130,%rsp
mov    0xe4e(%rip),%rax
mov    %rax,-0xb(%rbp)
mov    0xe4b(%rip),%ax
mov    %ax,-0x3(%rbp)
mov    0xe43(%rip),%al
mov    %al,-0x1(%rbp)
lea    -0xb(%rbp),%rdi
mov    0x2e03(%rip),%rax
mov    (%rax),%esi
call   10b0 <access@plt>
cmp    $0x0,%rax
je     11eb <readConfig+0x4b>
jmp    1385 <readConfig+0x1e5>
lea    -0xb(%rbp),%rdi
lea    0xe15(%rip),%rsi
call   10c0 <fopen@plt>
mov    %rax,-0x118(%rbp)
cmpq   $0x0,-0x118(%rbp)
jne    1215 <readConfig+0x75>
jmp    1385 <readConfig+0x1e5>
mov    0x2dc4(%rip),%rax
mov    (%rax),%edx
lea    -0x11c(%rbp),%rdi
lea    0xde1(%rip),%rsi
call   1080 <regcomp@plt>
mov    %eax,-0x120(%rbp)
cmpl   $0x0,-0x120(%rbp)
je     1256 <readConfig+0xb6>
mov    -0x120(%rbp),%esi
lea    0xde1(%rip),%rdi
call   1060 <printf@plt>
jmp    125b <readConfig+0xbb>
lea    -0x110(%rbp),%rdi
mov    -0x118(%rbp),%rdx
mov    $0x100,%esi
call   1090 <fgets@plt>
cmp    $0x0,%rax
je     136d <readConfig+0x1cd>
lea    -0x110(%rbp),%rax
mov    %rax,-0x128(%rbp)
mov    -0x128(%rbp),%rax
movsbl (%rax),%edi
call   1070 <isspace@plt>
cmp    $0x0,%rax
je     12bb <readConfig+0x11b>
mov    -0x128(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x128(%rbp)
jmp    128b <readConfig+0xeb>
mov    -0x128(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x23,%eax
jne    12d3 <readConfig+0x133>
jmp    125b <readConfig+0xbb>
mov    -0x128(%rbp),%rdi
call   1050 <strlen@plt>
cmp    $0x2,%eax
jge    12ed <readConfig+0x14d>
jmp    125b <readConfig+0xbb>
movl   $0x0,-0x120(%rbp)
mov    -0x128(%rbp),%rax
movslq -0x120(%rbp),%rcx
cmpb   $0x0,(%rax,%rcx,1)
je     1355 <readConfig+0x1b5>
mov    -0x128(%rbp),%rax
movslq -0x120(%rbp),%rcx
movsbl (%rax,%rcx,1),%eax
cmp    $0xa,%eax
jne    133c <readConfig+0x19c>
mov    -0x128(%rbp),%rax
movslq -0x120(%rbp),%rcx
movb   $0x0,(%rax,%rcx,1)
jmp    1341 <readConfig+0x1a1>
mov    -0x120(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x120(%rbp)
jmp    12f7 <readConfig+0x157>
mov    -0x128(%rbp),%rdi
lea    -0x11c(%rbp),%rsi
call   10a0 <readLine@plt>
jmp    125b <readConfig+0xbb>
lea    -0x11c(%rbp),%rdi
call   1040 <regfree@plt>
mov    -0x118(%rbp),%rdi
call   1030 <fclose@plt>
add    $0x130,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<readConfig>:
push   %r15
push   %r14
push   %r12
push   %rbx
sub    $0x128,%rsp
movabs $0x6f632e6265773261,%rax
2e 63 6f
mov    %rax,0x10(%rsp)
movl   $0x666e6f,0x17(%rsp)
mov    0x2e0c(%rip),%rax
mov    (%rax),%esi
lea    0x10(%rsp),%rdi
call   10b0 <access@plt>
test   %rax,%rax
jne    12e2 <readConfig+0x142>
lea    0xe23(%rip),%rsi
lea    0x10(%rsp),%rdi
call   10c0 <fopen@plt>
test   %rax,%rax
je     12e2 <readConfig+0x142>
mov    %rax,%r14
mov    0x2ddb(%rip),%rax
mov    (%rax),%edx
lea    0xdff(%rip),%rsi
lea    0xc(%rsp),%rdi
call   1080 <regcomp@plt>
test   %eax,%eax
je     122a <readConfig+0x8a>
lea    0xe0f(%rip),%rdi
mov    %eax,%esi
call   1060 <printf@plt>
lea    0x20(%rsp),%r12
mov    %r12,%rdi
mov    $0x100,%esi
mov    %r14,%rdx
call   1090 <fgets@plt>
test   %rax,%rax
je     12d0 <readConfig+0x130>
lea    0xc(%rsp),%r15
mov    %r12,%rcx
jmp    1278 <readConfig+0xd8>
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax)
mov    %r12,%rdi
mov    $0x100,%esi
mov    %r14,%rdx
call   1090 <fgets@plt>
mov    %r12,%rcx
test   %rax,%rax
je     12d0 <readConfig+0x130>
mov    %rcx,%rbx
movsbl (%rcx),%edi
call   1070 <isspace@plt>
lea    0x1(%rbx),%rcx
test   %rax,%rax
jne    1278 <readConfig+0xd8>
cmpb   $0x23,(%rbx)
je     1260 <readConfig+0xc0>
mov    %rbx,%rdi
call   1050 <strlen@plt>
cmp    $0x2,%eax
jl     1260 <readConfig+0xc0>
mov    %rbx,%rax
jmp    12b7 <readConfig+0x117>
cs nopw 0x0(%rax,%rax,1)
nopl   (%rax)
movb   $0x0,(%rax)
add    $0x1,%rax
movzbl (%rax),%ecx
cmp    $0xa,%cl
je     12b0 <readConfig+0x110>
test   %cl,%cl
jne    12b3 <readConfig+0x113>
mov    %rbx,%rdi
mov    %r15,%rsi
call   10a0 <readLine@plt>
jmp    1260 <readConfig+0xc0>
lea    0xc(%rsp),%rdi
call   1040 <regfree@plt>
mov    %r14,%rdi
call   1030 <fclose@plt>
add    $0x128,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@__const.readConfig.name = [11 x i8] c"a2web.conf\00"
@R_OK = global i32 0
@.str = [2 x i8] c"r\00"
@.str.1 = [37 x i8] c"^[[:alpha:][:space:]]*=[[:print:]]*$\00"
@REG_NOSUB = global i32 0
@.str.2 = [29 x i8] c"Failed to compile regex, %d\0A\00"
define void @readConfig() {
%1 = alloca [11 x i8]
%2 = alloca [256 x i8]
%3 = alloca i32*
%4 = alloca i32
%5 = alloca i32
%6 = alloca i8*
%7 = bitcast [11 x i8]* %1 to i8*
%8 = getelementptr inbounds [11 x i8], [11 x i8]* %1, i64 0, i64 0
%9 = load i32, i32* @R_OK
%10 = call i64 @access(i8* %8, i32 %9)
%11 = icmp ne i64 %10, 0
br i1 %11, label %12, label %13
12: ; preds = %0
br label %86
13: ; preds = %0
%14 = getelementptr inbounds [11 x i8], [11 x i8]* %1, i64 0, i64 0
%15 = call i32* @fopen(i8* %14, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
store i32* %15, i32** %3
%16 = load i32*, i32** %3
%17 = icmp ne i32* %16, null
br i1 %17, label %19, label %18
18: ; preds = %13
br label %86
19: ; preds = %13
%20 = load i32, i32* @REG_NOSUB
%21 = call i32 @regcomp(i32* %4, i8* getelementptr inbounds ([37 x i8], [37 x i8]* @.str.1, i64 0, i64 0), i32 %20)
store i32 %21, i32* %5
%22 = load i32, i32* %5
%23 = icmp ne i32 %22, 0
br i1 %23, label %24, label %27
24: ; preds = %19
%25 = load i32, i32* %5
%26 = call i32 @printf(i8* getelementptr inbounds ([29 x i8], [29 x i8]* @.str.2, i64 0, i64 0), i32 %25)
br label %27
27: ; preds = %24, %19
br label %28
28: ; preds = %79, %53, %48, %27
%29 = getelementptr inbounds [256 x i8], [256 x i8]* %2, i64 0, i64 0
%30 = load i32*, i32** %3
%31 = call i64 @fgets(i8* %29, i32 256, i32* %30)
%32 = icmp ne i64 %31, 0
br i1 %32, label %33, label %82
33: ; preds = %28
%34 = getelementptr inbounds [256 x i8], [256 x i8]* %2, i64 0, i64 0
store i8* %34, i8** %6
br label %35
35: ; preds = %40, %33
%36 = load i8*, i8** %6
%37 = load i8, i8* %36
%38 = call i64 @isspace(i8 signext %37)
%39 = icmp ne i64 %38, 0
br i1 %39, label %40, label %43
40: ; preds = %35
%41 = load i8*, i8** %6
%42 = getelementptr inbounds i8, i8* %41, i32 1
store i8* %42, i8** %6
br label %35
43: ; preds = %35
%44 = load i8*, i8** %6
%45 = load i8, i8* %44
%46 = sext i8 %45 to i32
%47 = icmp eq i32 %46, 35
br i1 %47, label %48, label %49
48: ; preds = %43
br label %28
49: ; preds = %43
%50 = load i8*, i8** %6
%51 = call i32 @strlen(i8* %50)
%52 = icmp slt i32 %51, 2
br i1 %52, label %53, label %54
53: ; preds = %49
br label %28
54: ; preds = %49
store i32 0, i32* %5
br label %55
55: ; preds = %76, %54
%56 = load i8*, i8** %6
%57 = load i32, i32* %5
%58 = sext i32 %57 to i64
%59 = getelementptr inbounds i8, i8* %56, i64 %58
%60 = load i8, i8* %59
%61 = icmp ne i8 %60, 0
br i1 %61, label %62, label %79
62: ; preds = %55
%63 = load i8*, i8** %6
%64 = load i32, i32* %5
%65 = sext i32 %64 to i64
%66 = getelementptr inbounds i8, i8* %63, i64 %65
%67 = load i8, i8* %66
%68 = sext i8 %67 to i32
%69 = icmp eq i32 %68, 10
br i1 %69, label %70, label %75
70: ; preds = %62
%71 = load i8*, i8** %6
%72 = load i32, i32* %5
%73 = sext i32 %72 to i64
%74 = getelementptr inbounds i8, i8* %71, i64 %73
store i8 0, i8* %74
br label %75
75: ; preds = %70, %62
br label %76
76: ; preds = %75
%77 = load i32, i32* %5
%78 = add nsw i32 %77, 1
store i32 %78, i32* %5
br label %55
79: ; preds = %55
%80 = load i8*, i8** %6
%81 = call i32 @readLine(i8* %80, i32* %4)
br label %28
82: ; preds = %28
%83 = call i32 @regfree(i32* %4)
%84 = load i32*, i32** %3
%85 = call i32 @fclose(i32* %84)
br label %86
86: ; preds = %82, %18, %12
ret void
}

LLVM IR (-O2):
@__const.readConfig.name = [11 x i8] c"a2web.conf\00"
@R_OK = global i32 0
@.str = [2 x i8] c"r\00"
@.str.1 = [37 x i8] c"^[[:alpha:][:space:]]*=[[:print:]]*$\00"
@REG_NOSUB = global i32 0
@.str.2 = [29 x i8] c"Failed to compile regex, %d\0A\00"
define void @readConfig() {
%1 = alloca [11 x i8]
%2 = alloca [256 x i8]
%3 = alloca i32
%4 = getelementptr inbounds [11 x i8], [11 x i8]* %1, i64 0, i64 0
%5 = load i32, i32* @R_OK
%6 = call i64 @access(i8* %4, i32 %5)
%7 = icmp eq i64 %6, 0
br i1 %7, label %8, label %52
8: ; preds = %0
%9 = getelementptr inbounds [256 x i8], [256 x i8]* %2, i64 0, i64 0
%10 = call i32* @fopen(i8* %4, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
%11 = icmp eq i32* %10, null
br i1 %11, label %51, label %12
12: ; preds = %8
%13 = bitcast i32* %3 to i8*
%14 = load i32, i32* @REG_NOSUB
%15 = call i32 @regcomp(i32* %3, i8* getelementptr inbounds ([37 x i8], [37 x i8]* @.str.1, i64 0, i64 0), i32 %14)
%16 = icmp eq i32 %15, 0
br i1 %16, label %19, label %17
17: ; preds = %12
%18 = call i32 @printf(i8* getelementptr inbounds ([29 x i8], [29 x i8]* @.str.2, i64 0, i64 0), i32 %15)
br label %19
19: ; preds = %17, %12
%20 = call i64 @fgets(i8* %9, i32 256, i32* %10)
%21 = icmp eq i64 %20, 0
br i1 %21, label %48, label %22
22: ; preds = %19, %28
%23 = phi i8* [ %29, %28 ], [ %9, %19 ]
%24 = load i8, i8* %23
%25 = call i64 @isspace(i8 signext %24)
%26 = icmp eq i64 %25, 0
%27 = getelementptr inbounds i8, i8* %23, i64 1
br i1 %26, label %30, label %28
28: ; preds = %22, %45
%29 = phi i8* [ %27, %22 ], [ %9, %45 ]
br label %22
30: ; preds = %22
%31 = load i8, i8* %23
%32 = icmp eq i8 %31, 35
br i1 %32, label %45, label %33
33: ; preds = %30
%34 = call i32 @strlen(i8* %23)
%35 = icmp slt i32 %34, 2
br i1 %35, label %45, label %36
36: ; preds = %33, %41
%37 = phi i64 [ %42, %41 ], [ 0, %33 ]
%38 = getelementptr inbounds i8, i8* %23, i64 %37
%39 = load i8, i8* %38
switch i8 %39, label %41 [
i8 0, label %43
i8 10, label %40
]
40: ; preds = %36
store i8 0, i8* %38
br label %41
41: ; preds = %36, %40
%42 = add nuw i64 %37, 1
br label %36
43: ; preds = %36
%44 = call i32 @readLine(i8* %23, i32* %3)
br label %45
45: ; preds = %33, %30, %43
%46 = call i64 @fgets(i8* %9, i32 256, i32* %10)
%47 = icmp eq i64 %46, 0
br i1 %47, label %48, label %28
48: ; preds = %45, %19
%49 = call i32 @regfree(i32* %3)
%50 = call i32 @fclose(i32* %10)
br label %51
51: ; preds = %8, %48
br label %52
52: ; preds = %0, %51
ret void
}