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

/* Variables and functions */
int /*<<< orphan*/ delGaps(char *);
int errno;
int /*<<< orphan*/ fclose(int /*<<< orphan*/ *);
int /*<<< orphan*/ *fopen(char const *, char *);
int /*<<< orphan*/ free(char *);
int /*<<< orphan*/ getline(char **, size_t *, int /*<<< orphan*/ *);
int /*<<< orphan*/ mapFree(char **);
int mapPush(char ***, char *, char *);
int sscanf(char *, char *, char **, char **);
char **readConfig(const char *path) {
  int safe_errno = errno;
  FILE *fp = fopen(path, "r");
  if (fp == NULL) {
    errno = safe_errno;
    return NULL;
  }
  char **rval = NULL;
  char *line = NULL;
  size_t len = 0;
  ssize_t read = 0;
  while (0 < (read = getline(&line, &len, fp))) {
    delGaps(line);
    char *value = NULL;
    char *key = NULL;
    if (2 == sscanf(line, "%m[^=]=%ms", &key, &value)) {
      if (key == NULL || key[0] == '#') {
        free(value);
        free(key);
        continue;
      }
      if (-1 == mapPush(&rval, key, value)) {
        free(value);
        free(key);
        mapFree(rval);
        rval = NULL;
        break;
      }
    }
    free(value);
    free(key);
  }
  free(line);
  fclose(fp);
  return rval;
}


x86 assembly (clang, -O0):
<readConfig>:
push   %rbp
mov    %rsp,%rbp
sub    $0x50,%rsp
mov    %rdi,-0x10(%rbp)
mov    0x2e4d(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x14(%rbp)
mov    -0x10(%rbp),%rdi
lea    0xe5d(%rip),%rsi
call   1090 <fopen@plt>
mov    %rax,-0x20(%rbp)
cmpq   $0x0,-0x20(%rbp)
jne    11d0 <readConfig+0x50>
mov    -0x14(%rbp),%ecx
mov    0x2e1f(%rip),%rax
mov    %ecx,(%rax)
movq   $0x0,-0x8(%rbp)
jmp    12ff <readConfig+0x17f>
movq   $0x0,-0x28(%rbp)
movq   $0x0,-0x30(%rbp)
movq   $0x0,-0x38(%rbp)
movl   $0x0,-0x3c(%rbp)
mov    -0x20(%rbp),%rdx
lea    -0x30(%rbp),%rdi
lea    -0x38(%rbp),%rsi
call   10a0 <getline@plt>
mov    %eax,%ecx
mov    %ecx,-0x3c(%rbp)
xor    %eax,%eax
cmp    %ecx,%eax
jge    12e5 <readConfig+0x165>
mov    -0x30(%rbp),%rdi
call   1050 <delGaps@plt>
movq   $0x0,-0x48(%rbp)
movq   $0x0,-0x50(%rbp)
mov    -0x30(%rbp),%rdi
lea    0xdcf(%rip),%rsi
lea    -0x50(%rbp),%rdx
lea    -0x48(%rbp),%rcx
call   1080 <sscanf@plt>
mov    %eax,%ecx
mov    $0x2,%eax
cmp    %ecx,%eax
jne    12ce <readConfig+0x14e>
cmpq   $0x0,-0x50(%rbp)
je     126a <readConfig+0xea>
mov    -0x50(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x23,%eax
jne    1281 <readConfig+0x101>
mov    -0x48(%rbp),%rdi
call   1030 <free@plt>
mov    -0x50(%rbp),%rdi
call   1030 <free@plt>
jmp    11ef <readConfig+0x6f>
mov    -0x50(%rbp),%rsi
mov    -0x48(%rbp),%rdx
lea    -0x28(%rbp),%rdi
call   1060 <mapPush@plt>
mov    %eax,%ecx
mov    $0xffffffff,%eax
cmp    %ecx,%eax
jne    12c9 <readConfig+0x149>
mov    -0x48(%rbp),%rdi
call   1030 <free@plt>
mov    -0x50(%rbp),%rdi
call   1030 <free@plt>
mov    -0x28(%rbp),%rdi
call   1070 <mapFree@plt>
movq   $0x0,-0x28(%rbp)
jmp    12e5 <readConfig+0x165>
jmp    12ce <readConfig+0x14e>
mov    -0x48(%rbp),%rdi
call   1030 <free@plt>
mov    -0x50(%rbp),%rdi
call   1030 <free@plt>
jmp    11ef <readConfig+0x6f>
mov    -0x30(%rbp),%rdi
call   1030 <free@plt>
mov    -0x20(%rbp),%rdi
call   1040 <fclose@plt>
mov    -0x28(%rbp),%rax
mov    %rax,-0x8(%rbp)
mov    -0x8(%rbp),%rax
add    $0x50,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<readConfig>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x28,%rsp
mov    0x2e4b(%rip),%r14
mov    (%r14),%ebp
lea    0xe61(%rip),%rsi
call   1090 <fopen@plt>
test   %rax,%rax
je     12ba <readConfig+0x13a>
mov    %rax,%rbx
movq   $0x0,0x18(%rsp)
movq   $0x0,(%rsp)
movq   $0x0,0x20(%rsp)
mov    %rsp,%rdi
lea    0x20(%rsp),%rsi
mov    %rax,%rdx
call   10a0 <getline@plt>
test   %eax,%eax
jle    12a2 <readConfig+0x122>
lea    0xe19(%rip),%r14
lea    0x8(%rsp),%r15
lea    0x10(%rsp),%r12
mov    %rsp,%rbp
lea    0x20(%rsp),%r13
jmp    1226 <readConfig+0xa6>
nopl   (%rax)
mov    0x10(%rsp),%rdi
call   1030 <free@plt>
mov    0x8(%rsp),%rdi
call   1030 <free@plt>
mov    %rbp,%rdi
mov    %r13,%rsi
mov    %rbx,%rdx
call   10a0 <getline@plt>
test   %eax,%eax
jle    12a2 <readConfig+0x122>
mov    (%rsp),%rdi
call   1050 <delGaps@plt>
movq   $0x0,0x10(%rsp)
movq   $0x0,0x8(%rsp)
mov    (%rsp),%rdi
mov    %r14,%rsi
mov    %r15,%rdx
mov    %r12,%rcx
call   1080 <sscanf@plt>
cmp    $0x2,%eax
jne    1200 <readConfig+0x80>
mov    0x8(%rsp),%rsi
test   %rsi,%rsi
je     1200 <readConfig+0x80>
cmpb   $0x23,(%rsi)
je     1200 <readConfig+0x80>
mov    0x10(%rsp),%rdx
lea    0x18(%rsp),%rdi
call   1060 <mapPush@plt>
cmp    $0xffffffff,%eax
jne    1200 <readConfig+0x80>
mov    0x10(%rsp),%rdi
call   1030 <free@plt>
mov    0x8(%rsp),%rdi
call   1030 <free@plt>
mov    0x18(%rsp),%rdi
call   1070 <mapFree@plt>
movq   $0x0,0x18(%rsp)
mov    (%rsp),%rdi
call   1030 <free@plt>
mov    %rbx,%rdi
call   1040 <fclose@plt>
mov    0x18(%rsp),%rax
jmp    12bf <readConfig+0x13f>
mov    %ebp,(%r14)
xor    %eax,%eax
add    $0x28,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@errno = global i32 0
@.str = [2 x i8] c"r\00"
@.str.1 = [11 x i8] c"%m[^=]=%ms\00"
define i8** @readConfig(i8* %0) {
%2 = alloca i8**
%3 = alloca i8*
%4 = alloca i32
%5 = alloca i32*
%6 = alloca i8**
%7 = alloca i8*
%8 = alloca i64
%9 = alloca i32
%10 = alloca i8*
%11 = alloca i8*
store i8* %0, i8** %3
%12 = load i32, i32* @errno
store i32 %12, i32* %4
%13 = load i8*, i8** %3
%14 = call i32* @fopen(i8* %13, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
store i32* %14, i32** %5
%15 = load i32*, i32** %5
%16 = icmp eq i32* %15, null
br i1 %16, label %17, label %19
17: ; preds = %1
%18 = load i32, i32* %4
store i32 %18, i32* @errno
store i8** null, i8*** %2
br label %68
19: ; preds = %1
store i8** null, i8*** %6
store i8* null, i8** %7
store i64 0, i64* %8
store i32 0, i32* %9
br label %20
20: ; preds = %57, %39, %19
%21 = load i32*, i32** %5
%22 = call i32 @getline(i8** %7, i64* %8, i32* %21)
store i32 %22, i32* %9
%23 = icmp slt i32 0, %22
br i1 %23, label %24, label %62
24: ; preds = %20
%25 = load i8*, i8** %7
%26 = call i32 @delGaps(i8* %25)
store i8* null, i8** %10
store i8* null, i8** %11
%27 = load i8*, i8** %7
%28 = call i32 @sscanf(i8* %27, i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.1, i64 0, i64 0), i8** %11, i8** %10)
%29 = icmp eq i32 2, %28
br i1 %29, label %30, label %57
30: ; preds = %24
%31 = load i8*, i8** %11
%32 = icmp eq i8* %31, null
br i1 %32, label %39, label %33
33: ; preds = %30
%34 = load i8*, i8** %11
%35 = getelementptr inbounds i8, i8* %34, i64 0
%36 = load i8, i8* %35
%37 = sext i8 %36 to i32
%38 = icmp eq i32 %37, 35
br i1 %38, label %39, label %44
39: ; preds = %33, %30
%40 = load i8*, i8** %10
%41 = call i32 @free(i8* %40)
%42 = load i8*, i8** %11
%43 = call i32 @free(i8* %42)
br label %20
44: ; preds = %33
%45 = load i8*, i8** %11
%46 = load i8*, i8** %10
%47 = call i32 @mapPush(i8*** %6, i8* %45, i8* %46)
%48 = icmp eq i32 -1, %47
br i1 %48, label %49, label %56
49: ; preds = %44
%50 = load i8*, i8** %10
%51 = call i32 @free(i8* %50)
%52 = load i8*, i8** %11
%53 = call i32 @free(i8* %52)
%54 = load i8**, i8*** %6
%55 = call i32 @mapFree(i8** %54)
store i8** null, i8*** %6
br label %62
56: ; preds = %44
br label %57
57: ; preds = %56, %24
%58 = load i8*, i8** %10
%59 = call i32 @free(i8* %58)
%60 = load i8*, i8** %11
%61 = call i32 @free(i8* %60)
br label %20
62: ; preds = %49, %20
%63 = load i8*, i8** %7
%64 = call i32 @free(i8* %63)
%65 = load i32*, i32** %5
%66 = call i32 @fclose(i32* %65)
%67 = load i8**, i8*** %6
store i8** %67, i8*** %2
br label %68
68: ; preds = %62, %17
%69 = load i8**, i8*** %2
ret i8** %69
}

LLVM IR (-O2):
@errno = global i32 0
@.str = [2 x i8] c"r\00"
@.str.1 = [11 x i8] c"%m[^=]=%ms\00"
define i8** @readConfig(i8* nocapture %0) {
%2 = alloca i8**
%3 = alloca i8*
%4 = alloca i64
%5 = alloca i8*
%6 = alloca i8*
%7 = load i32, i32* @errno
%8 = tail call i32* @fopen(i8* %0, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
%9 = icmp eq i32* %8, null
br i1 %9, label %10, label %11
10: ; preds = %1
store i32 %7, i32* @errno
br label %55
11: ; preds = %1
%12 = bitcast i8*** %2 to i8*
store i8** null, i8*** %2
%13 = bitcast i8** %3 to i8*
store i8* null, i8** %3
%14 = bitcast i64* %4 to i8*
store i64 0, i64* %4
%15 = call i32 @getline(i8** %3, i64* %4, i32* %8)
%16 = icmp sgt i32 %15, 0
br i1 %16, label %17, label %50
17: ; preds = %11
%18 = bitcast i8** %5 to i8*
%19 = bitcast i8** %6 to i8*
br label %20
20: ; preds = %17, %43
%21 = load i8*, i8** %3
%22 = call i32 @delGaps(i8* %21)
store i8* null, i8** %5
store i8* null, i8** %6
%23 = load i8*, i8** %3
%24 = call i32 @sscanf(i8* %23, i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.1, i64 0, i64 0), i8** %6, i8** %5)
%25 = icmp eq i32 %24, 2
br i1 %25, label %26, label %43
26: ; preds = %20
%27 = load i8*, i8** %6
%28 = icmp eq i8* %27, null
br i1 %28, label %43, label %29
29: ; preds = %26
%30 = load i8, i8* %27
%31 = icmp eq i8 %30, 35
br i1 %31, label %43, label %32
32: ; preds = %29
%33 = load i8*, i8** %5
%34 = call i32 @mapPush(i8*** %2, i8* %27, i8* %33)
%35 = icmp eq i32 %34, -1
br i1 %35, label %36, label %43
36: ; preds = %32
%37 = load i8*, i8** %5
%38 = call i32 @free(i8* %37)
%39 = load i8*, i8** %6
%40 = call i32 @free(i8* %39)
%41 = load i8**, i8*** %2
%42 = call i32 @mapFree(i8** %41)
store i8** null, i8*** %2
br label %50
43: ; preds = %20, %32, %26, %29
%44 = load i8*, i8** %5
%45 = call i32 @free(i8* %44)
%46 = load i8*, i8** %6
%47 = call i32 @free(i8* %46)
%48 = call i32 @getline(i8** %3, i64* %4, i32* %8)
%49 = icmp sgt i32 %48, 0
br i1 %49, label %20, label %50
50: ; preds = %43, %11, %36
%51 = load i8*, i8** %3
%52 = call i32 @free(i8* %51)
%53 = call i32 @fclose(i32* %8)
%54 = load i8**, i8*** %2
br label %55
55: ; preds = %50, %10
%56 = phi i8** [ null, %10 ], [ %54, %50 ]
ret i8** %56
}