#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 */
char *Trims(char *);
int /*<<< orphan*/ assert(int /*<<< orphan*/);
int /*<<< orphan*/ fclose(int /*<<< orphan*/ *);
int /*<<< orphan*/ feof(int /*<<< orphan*/ *);
int /*<<< orphan*/ fgets(char *, int, int /*<<< orphan*/ *);
int /*<<< orphan*/ *fopen(char *, char *);
int /*<<< orphan*/ setenv(char *, char *, int);
char *strcat(char *, char *);
int /*<<< orphan*/ strcmp(char *, char *);
int strlen(char *);
char *strtok(char *, char *);
void conf_init(char *path) {
  FILE *fp;
  char *p, *right_val, *left_val;
  char buf[100], bufs[100];
  fp = fopen(path, "r");
  assert((fp != NULL));
  while (!feof(fp)) {
    fgets(buf, 2, fp);
    if (!strcmp(buf, "#")) {
      fgets(buf, 100, fp);
    } else if (!strcmp(buf, "[")) {
      fgets(buf, 100, fp);
    } else {
      fgets(bufs, 100, fp);
      if (bufs[strlen(bufs) - 1] == '\n')
        bufs[strlen(bufs) - 1] = ' ';
      p = strcat(buf, bufs);
      left_val = strtok(p, "=");
      right_val = strtok(NULL, "=");
      left_val = Trims(left_val);
      right_val = Trims(right_val);
      if (left_val == NULL)
        continue;
      if (right_val == NULL)
        setenv(left_val, "", 1);
      else
        setenv(left_val, right_val, 1);
    }
  }
  fclose(fp);
}


x86 assembly (clang, -O0):
<conf_init>:
push   %rbp
mov    %rsp,%rbp
sub    $0x100,%rsp
mov    %rdi,-0x8(%rbp)
mov    -0x8(%rbp),%rdi
lea    0xe36(%rip),%rsi
call   10a0 <fopen@plt>
mov    %rax,-0x10(%rbp)
cmpq   $0x0,-0x10(%rbp)
setne  %al
and    $0x1,%al
movzbl %al,%edi
call   1080 <assert@plt>
mov    -0x10(%rbp),%rdi
call   1090 <feof@plt>
cmp    $0x0,%eax
setne  %al
xor    $0xff,%al
test   $0x1,%al
jne    1203 <conf_init+0x53>
jmp    1383 <conf_init+0x1d3>
lea    -0x90(%rbp),%rdi
mov    -0x10(%rbp),%rdx
mov    $0x2,%esi
call   1060 <fgets@plt>
lea    -0x90(%rbp),%rdi
lea    0xddc(%rip),%rsi
call   1070 <strcmp@plt>
cmp    $0x0,%eax
jne    124e <conf_init+0x9e>
lea    -0x90(%rbp),%rdi
mov    -0x10(%rbp),%rdx
mov    $0x64,%esi
call   1060 <fgets@plt>
jmp    137e <conf_init+0x1ce>
lea    -0x90(%rbp),%rdi
lea    0xda8(%rip),%rsi
call   1070 <strcmp@plt>
cmp    $0x0,%eax
jne    1284 <conf_init+0xd4>
lea    -0x90(%rbp),%rdi
mov    -0x10(%rbp),%rdx
mov    $0x64,%esi
call   1060 <fgets@plt>
jmp    1379 <conf_init+0x1c9>
lea    -0x100(%rbp),%rdi
mov    -0x10(%rbp),%rdx
mov    $0x64,%esi
call   1060 <fgets@plt>
lea    -0x100(%rbp),%rdi
call   1050 <strlen@plt>
sub    $0x1,%eax
cltq
movsbl -0x100(%rbp,%rax,1),%eax
ff
cmp    $0xa,%eax
jne    12d4 <conf_init+0x124>
lea    -0x100(%rbp),%rdi
call   1050 <strlen@plt>
sub    $0x1,%eax
cltq
movb   $0x20,-0x100(%rbp,%rax,1)
20
lea    -0x90(%rbp),%rdi
lea    -0x100(%rbp),%rsi
call   10d0 <strcat@plt>
mov    %rax,-0x18(%rbp)
mov    -0x18(%rbp),%rdi
lea    0xd10(%rip),%rsi
call   10b0 <strtok@plt>
mov    %rax,-0x28(%rbp)
xor    %eax,%eax
mov    %eax,%edi
lea    0xcfc(%rip),%rsi
call   10b0 <strtok@plt>
mov    %rax,-0x20(%rbp)
mov    -0x28(%rbp),%rdi
call   10c0 <Trims@plt>
mov    %rax,-0x28(%rbp)
mov    -0x20(%rbp),%rdi
call   10c0 <Trims@plt>
mov    %rax,-0x20(%rbp)
cmpq   $0x0,-0x28(%rbp)
jne    133d <conf_init+0x18d>
jmp    11e5 <conf_init+0x35>
cmpq   $0x0,-0x20(%rbp)
jne    1362 <conf_init+0x1b2>
mov    -0x28(%rbp),%rdi
lea    0xcb0(%rip),%rsi
mov    $0x1,%edx
call   1030 <setenv@plt>
jmp    1374 <conf_init+0x1c4>
mov    -0x28(%rbp),%rdi
mov    -0x20(%rbp),%rsi
mov    $0x1,%edx
call   1030 <setenv@plt>
jmp    1379 <conf_init+0x1c9>
jmp    137e <conf_init+0x1ce>
jmp    11e5 <conf_init+0x35>
mov    -0x10(%rbp),%rdi
call   1040 <fclose@plt>
add    $0x100,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<conf_init>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0xd8,%rsp
lea    0xe48(%rip),%rsi
call   1090 <fopen@plt>
mov    %rax,%rbx
xor    %edi,%edi
test   %rax,%rax
setne  %dil
call   1070 <assert@plt>
mov    %rbx,%rdi
call   1080 <feof@plt>
test   %eax,%eax
je     11f4 <conf_init+0x54>
mov    %rbx,%rdi
call   1040 <fclose@plt>
add    $0xd8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret
mov    %rsp,%r14
lea    0x70(%rsp),%r15
lea    0xdff(%rip),%r12
jmp    122c <conf_init+0x8c>
cs nopw 0x0(%rax,%rax,1)
nop
mov    %r14,%rdi
mov    $0x64,%esi
mov    %rbx,%rdx
call   1060 <fgets@plt>
mov    %rbx,%rdi
call   1080 <feof@plt>
test   %eax,%eax
jne    11da <conf_init+0x3a>
mov    %r14,%rdi
mov    $0x2,%esi
mov    %rbx,%rdx
call   1060 <fgets@plt>
movzwl (%rsp),%eax
cmp    $0x5b,%ax
je     1210 <conf_init+0x70>
cmp    $0x23,%ax
je     1210 <conf_init+0x70>
mov    %r15,%rdi
mov    $0x64,%esi
mov    %rbx,%rdx
call   1060 <fgets@plt>
mov    %r15,%rdi
call   1050 <strlen@plt>
cltq
cmpb   $0xa,-0x1(%rax,%r15,1)
jne    127e <conf_init+0xde>
mov    %r15,%rdi
call   1050 <strlen@plt>
cltq
movb   $0x20,-0x1(%rax,%r15,1)
mov    %r14,%rdi
mov    %r15,%rsi
call   10c0 <strcat@plt>
mov    %r14,%rdi
mov    %r12,%rsi
call   10a0 <strtok@plt>
mov    %rax,%rbp
xor    %edi,%edi
mov    %r12,%rsi
call   10a0 <strtok@plt>
mov    %rax,%r13
mov    %rbp,%rdi
call   10b0 <Trims@plt>
mov    %rax,%rbp
mov    %r13,%rdi
call   10b0 <Trims@plt>
test   %rbp,%rbp
je     1220 <conf_init+0x80>
mov    %rbp,%rdi
test   %rax,%rax
je     12cd <conf_init+0x12d>
mov    %rax,%rsi
jmp    12d4 <conf_init+0x134>
lea    0xd2f(%rip),%rsi
mov    $0x1,%edx
call   1030 <setenv@plt>
jmp    1220 <conf_init+0x80>

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

LLVM IR (-O2):
@.str = [2 x i8] c"r\00"
@.str.3 = [2 x i8] c"=\00"
@.str.4 = [1 x i8] zeroinitializer
define void @conf_init(i8* nocapture %0) {
%2 = alloca [100 x i8]
%3 = alloca [100 x i8]
%4 = getelementptr inbounds [100 x i8], [100 x i8]* %2, i64 0, i64 0
%5 = getelementptr inbounds [100 x i8], [100 x i8]* %3, i64 0, i64 0
%6 = tail call i32* @fopen(i8* %0, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
%7 = icmp ne i32* %6, null
%8 = zext i1 %7 to i32
%9 = tail call i32 @assert(i32 %8)
%10 = call i32 @feof(i32* %6)
%11 = icmp eq i32 %10, 0
br i1 %11, label %12, label %50
12: ; preds = %1
%13 = bitcast [100 x i8]* %2 to i16*
br label %14
14: ; preds = %12, %47
%15 = call i32 @fgets(i8* %4, i32 2, i32* %6)
%16 = load i16, i16* %13
switch i16 %16, label %21 [
i16 35, label %17
i16 91, label %19
]
17: ; preds = %14
%18 = call i32 @fgets(i8* %4, i32 100, i32* %6)
br label %47
19: ; preds = %14
%20 = call i32 @fgets(i8* %4, i32 100, i32* %6)
br label %47
21: ; preds = %14
%22 = call i32 @fgets(i8* %5, i32 100, i32* %6)
%23 = call i32 @strlen(i8* %5)
%24 = add nsw i32 %23, -1
%25 = sext i32 %24 to i64
%26 = getelementptr inbounds [100 x i8], [100 x i8]* %3, i64 0, i64 %25
%27 = load i8, i8* %26
%28 = icmp eq i8 %27, 10
br i1 %28, label %29, label %34
29: ; preds = %21
%30 = call i32 @strlen(i8* %5)
%31 = add nsw i32 %30, -1
%32 = sext i32 %31 to i64
%33 = getelementptr inbounds [100 x i8], [100 x i8]* %3, i64 0, i64 %32
store i8 32, i8* %33
br label %34
34: ; preds = %29, %21
%35 = call i8* @strcat(i8* %4, i8* %5)
%36 = call i8* @strtok(i8* %4, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.3, i64 0, i64 0))
%37 = call i8* @strtok(i8* null, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.3, i64 0, i64 0))
%38 = call i8* @Trims(i8* %36)
%39 = call i8* @Trims(i8* %37)
%40 = icmp eq i8* %38, null
br i1 %40, label %47, label %41
41: ; preds = %34
%42 = icmp eq i8* %39, null
br i1 %42, label %43, label %45
43: ; preds = %41
%44 = call i32 @setenv(i8* %38, i8* getelementptr inbounds ([1 x i8], [1 x i8]* @.str.4, i64 0, i64 0), i32 1)
br label %47
45: ; preds = %41
%46 = call i32 @setenv(i8* %38, i8* %39, i32 1)
br label %47
47: ; preds = %17, %43, %45, %19, %34
%48 = call i32 @feof(i32* %6)
%49 = icmp eq i32 %48, 0
br i1 %49, label %14, label %50
50: ; preds = %47, %1
%51 = call i32 @fclose(i32* %6)
ret void
}