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

/* Variables and functions */
int /*<<< orphan*/ O_RDONLY;
int /*<<< orphan*/ exit(int);
int /*<<< orphan*/ memset(char *, int /*<<< orphan*/, int);
int open(char *, int /*<<< orphan*/);
int /*<<< orphan*/ perror(char *);
int /*<<< orphan*/ printf(char *, ...);
int readLine(int, char *, int);
int /*<<< orphan*/ strcat(char *, char *);
int /*<<< orphan*/ strcpy(char *, char *);
int strlen(char *);
int /*<<< orphan*/ strncpy(char *, char *, int);
char *strtok(char *, char *);
int parseIni(char *fname) {
  char buffer[132];
  char key[132];
  char value[132];
  char section[132];
  char *tmp;
  int fd;
  int rc = 0;
  bool runFlag = true;
  int len = 0;
  fd = open(fname, O_RDONLY);
  if (!fd) {
    perror("./gauge.ini");
    exit(1);
  }
  while (runFlag) {
    rc = readLine(fd, buffer, 132);
    if (rc == 0) {
      runFlag = false;
    }
    if (rc > 0) {
      len = strlen(buffer);
      len--;
      buffer[len] = '\0';
      len--;
      if (len > 0) {
        if ((buffer[0] == '[') && (buffer[len]) == ']') {
          memset(section, 0, 132);
          printf("Section\n");
          strncpy(section, &buffer[1], --len);
        } else {
          tmp = strtok(buffer, "=");
          strcpy(key, section);
          strcat(key, ".");
          strcat(key, tmp);
          tmp = strtok(NULL, "\n");
          strcpy(value, tmp);
          printf("Key   : >%s<\n", key);
          printf("Value : >%s<\n", value);
        }
      }
    }
  }
}


x86 assembly (clang, -O0):
<parseIni>:
push   %rbp
mov    %rsp,%rbp
sub    $0x270,%rsp
mov    %rdi,-0x10(%rbp)
movl   $0x0,-0x260(%rbp)
movl   $0x1,-0x264(%rbp)
movl   $0x0,-0x268(%rbp)
mov    -0x10(%rbp),%rdi
mov    0x2e00(%rip),%rax
mov    (%rax),%esi
call   1090 <open@plt>
mov    %eax,-0x25c(%rbp)
cmpl   $0x0,-0x25c(%rbp)
jne    1218 <parseIni+0x68>
lea    0xdf7(%rip),%rdi
call   10a0 <perror@plt>
mov    $0x1,%edi
call   10d0 <exit@plt>
jmp    121d <parseIni+0x6d>
cmpl   $0x0,-0x264(%rbp)
je     13e1 <parseIni+0x231>
mov    -0x25c(%rbp),%edi
lea    -0xa0(%rbp),%rsi
mov    $0x84,%edx
call   1080 <readLine@plt>
mov    %eax,-0x260(%rbp)
cmpl   $0x0,-0x260(%rbp)
jne    125e <parseIni+0xae>
movl   $0x0,-0x264(%rbp)
cmpl   $0x0,-0x260(%rbp)
jle    13dc <parseIni+0x22c>
lea    -0xa0(%rbp),%rdi
call   1050 <strlen@plt>
mov    %eax,-0x268(%rbp)
mov    -0x268(%rbp),%eax
add    $0xffffffff,%eax
mov    %eax,-0x268(%rbp)
movslq -0x268(%rbp),%rax
movb   $0x0,-0xa0(%rbp,%rax,1)
mov    -0x268(%rbp),%eax
add    $0xffffffff,%eax
mov    %eax,-0x268(%rbp)
cmpl   $0x0,-0x268(%rbp)
jle    13d7 <parseIni+0x227>
movsbl -0xa0(%rbp),%eax
cmp    $0x5b,%eax
jne    132b <parseIni+0x17b>
movslq -0x268(%rbp),%rax
movsbl -0xa0(%rbp,%rax,1),%eax
ff
cmp    $0x5d,%eax
jne    132b <parseIni+0x17b>
lea    -0x250(%rbp),%rdi
xor    %esi,%esi
mov    $0x84,%edx
call   1070 <memset@plt>
lea    0xd13(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
lea    -0x250(%rbp),%rdi
lea    -0xa0(%rbp),%rsi
add    $0x1,%rsi
mov    -0x268(%rbp),%edx
add    $0xffffffff,%edx
mov    %edx,-0x268(%rbp)
call   1030 <strncpy@plt>
jmp    13d2 <parseIni+0x222>
lea    -0xa0(%rbp),%rdi
lea    0xcdc(%rip),%rsi
call   10b0 <strtok@plt>
mov    %rax,-0x258(%rbp)
lea    -0x130(%rbp),%rdi
lea    -0x250(%rbp),%rsi
call   1040 <strcpy@plt>
lea    -0x130(%rbp),%rdi
lea    0xcb1(%rip),%rsi
call   10c0 <strcat@plt>
lea    -0x130(%rbp),%rdi
mov    -0x258(%rbp),%rsi
call   10c0 <strcat@plt>
xor    %eax,%eax
mov    %eax,%edi
lea    0xc9c(%rip),%rsi
call   10b0 <strtok@plt>
mov    %rax,-0x258(%rbp)
lea    -0x1c0(%rbp),%rdi
mov    -0x258(%rbp),%rsi
call   1040 <strcpy@plt>
lea    -0x130(%rbp),%rsi
lea    0xc63(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
lea    -0x1c0(%rbp),%rsi
lea    0xc5c(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
jmp    13d7 <parseIni+0x227>
jmp    13dc <parseIni+0x22c>
jmp    121d <parseIni+0x6d>
mov    -0x4(%rbp),%eax
add    $0x270,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<parseIni>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x238,%rsp
mov    0x2e10(%rip),%rax
mov    (%rax),%esi
call   10a0 <open@plt>
test   %eax,%eax
je     131f <parseIni+0x15f>
mov    %eax,%r12d
mov    %rsp,%rbx
lea    0x1b0(%rsp),%r14
jmp    1288 <parseIni+0xc8>
nopw   0x0(%rax,%rax,1)
mov    %rbx,%rdi
lea    0xe02(%rip),%rsi
call   10c0 <strtok@plt>
mov    %rax,%rbp
mov    %r14,%rdi
lea    0x90(%rsp),%rsi
call   1040 <strcpy@plt>
mov    %r14,%rdi
lea    0xde2(%rip),%rsi
call   10d0 <strcat@plt>
mov    %r14,%rdi
mov    %rbp,%rsi
call   10d0 <strcat@plt>
xor    %edi,%edi
lea    0xdd7(%rip),%rsi
call   10c0 <strtok@plt>
lea    0x120(%rsp),%rbp
mov    %rbp,%rdi
mov    %rax,%rsi
call   1040 <strcpy@plt>
lea    0xdac(%rip),%rdi
mov    %r14,%rsi
xor    %eax,%eax
call   1070 <printf@plt>
lea    0xda9(%rip),%rdi
mov    %rbp,%rsi
xor    %eax,%eax
call   1070 <printf@plt>
test   %r13d,%r13d
je     130d <parseIni+0x14d>
mov    %r12d,%edi
mov    %rbx,%rsi
mov    $0x84,%edx
call   1090 <readLine@plt>
mov    %eax,%r13d
test   %eax,%eax
jle    127f <parseIni+0xbf>
mov    %rbx,%rdi
call   1060 <strlen@plt>
mov    %eax,%r15d
cltq
movb   $0x0,-0x1(%rax,%rbx,1)
cmp    $0x3,%r15d
jl     127f <parseIni+0xbf>
cmpb   $0x5b,(%rsp)
jne    1200 <parseIni+0x40>
lea    -0x2(%r15),%eax
mov    %eax,%eax
cmpb   $0x5d,(%rsp,%rax,1)
jne    1200 <parseIni+0x40>
lea    0x90(%rsp),%rbp
mov    %rbp,%rdi
xor    %esi,%esi
mov    $0x84,%edx
call   1080 <memset@plt>
lea    0xd3d(%rip),%rdi
call   1050 <puts@plt>
add    $0xfffffffd,%r15d
mov    %rbp,%rdi
lea    0x1(%rsp),%rsi
mov    %r15d,%edx
call   1030 <strncpy@plt>
jmp    127f <parseIni+0xbf>
add    $0x238,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret
lea    0xcda(%rip),%rdi
call   10b0 <perror@plt>
mov    $0x1,%edi
call   10e0 <exit@plt>

LLVM IR (-O0):
@O_RDONLY = global i32 0
@.str = [12 x i8] c"./gauge.ini\00"
@.str.1 = [9 x i8] c"Section\0A\00"
@.str.2 = [2 x i8] c"=\00"
@.str.3 = [2 x i8] c".\00"
@.str.4 = [2 x i8] c"\0A\00"
@.str.5 = [14 x i8] c"Key : >%s<\0A\00"
@.str.6 = [14 x i8] c"Value : >%s<\0A\00"
define i32 @parseIni(i8* %0) {
%2 = alloca i32
%3 = alloca i8*
%4 = alloca [132 x i8]
%5 = alloca [132 x i8]
%6 = alloca [132 x i8]
%7 = alloca [132 x i8]
%8 = alloca i8*
%9 = alloca i32
%10 = alloca i32
%11 = alloca i32
%12 = alloca i32
store i8* %0, i8** %3
store i32 0, i32* %10
store i32 1, i32* %11
store i32 0, i32* %12
%13 = load i8*, i8** %3
%14 = load i32, i32* @O_RDONLY
%15 = call i32 @open(i8* %13, i32 %14)
store i32 %15, i32* %9
%16 = load i32, i32* %9
%17 = icmp ne i32 %16, 0
br i1 %17, label %21, label %18
18: ; preds = %1
%19 = call i32 @perror(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str, i64 0, i64 0))
%20 = call i32 @exit(i32 1)
unreachable
21: ; preds = %1
br label %22
22: ; preds = %89, %21
%23 = load i32, i32* %11
%24 = icmp ne i32 %23, 0
br i1 %24, label %25, label %90
25: ; preds = %22
%26 = load i32, i32* %9
%27 = getelementptr inbounds [132 x i8], [132 x i8]* %4, i64 0, i64 0
%28 = call i32 @readLine(i32 %26, i8* %27, i32 132)
store i32 %28, i32* %10
%29 = load i32, i32* %10
%30 = icmp eq i32 %29, 0
br i1 %30, label %31, label %32
31: ; preds = %25
store i32 0, i32* %11
br label %32
32: ; preds = %31, %25
%33 = load i32, i32* %10
%34 = icmp sgt i32 %33, 0
br i1 %34, label %35, label %89
35: ; preds = %32
%36 = getelementptr inbounds [132 x i8], [132 x i8]* %4, i64 0, i64 0
%37 = call i32 @strlen(i8* %36)
store i32 %37, i32* %12
%38 = load i32, i32* %12
%39 = add nsw i32 %38, -1
store i32 %39, i32* %12
%40 = load i32, i32* %12
%41 = sext i32 %40 to i64
%42 = getelementptr inbounds [132 x i8], [132 x i8]* %4, i64 0, i64 %41
store i8 0, i8* %42
%43 = load i32, i32* %12
%44 = add nsw i32 %43, -1
store i32 %44, i32* %12
%45 = load i32, i32* %12
%46 = icmp sgt i32 %45, 0
br i1 %46, label %47, label %88
47: ; preds = %35
%48 = getelementptr inbounds [132 x i8], [132 x i8]* %4, i64 0, i64 0
%49 = load i8, i8* %48
%50 = sext i8 %49 to i32
%51 = icmp eq i32 %50, 91
br i1 %51, label %52, label %68
52: ; preds = %47
%53 = load i32, i32* %12
%54 = sext i32 %53 to i64
%55 = getelementptr inbounds [132 x i8], [132 x i8]* %4, i64 0, i64 %54
%56 = load i8, i8* %55
%57 = sext i8 %56 to i32
%58 = icmp eq i32 %57, 93
br i1 %58, label %59, label %68
59: ; preds = %52
%60 = getelementptr inbounds [132 x i8], [132 x i8]* %7, i64 0, i64 0
%61 = call i32 @memset(i8* %60, i32 0, i32 132)
%62 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.1, i64 0, i64 0))
%63 = getelementptr inbounds [132 x i8], [132 x i8]* %7, i64 0, i64 0
%64 = getelementptr inbounds [132 x i8], [132 x i8]* %4, i64 0, i64 1
%65 = load i32, i32* %12
%66 = add nsw i32 %65, -1
store i32 %66, i32* %12
%67 = call i32 @strncpy(i8* %63, i8* %64, i32 %66)
br label %87
68: ; preds = %52, %47
%69 = getelementptr inbounds [132 x i8], [132 x i8]* %4, i64 0, i64 0
%70 = call i8* @strtok(i8* %69, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.2, i64 0, i64 0))
store i8* %70, i8** %8
%71 = getelementptr inbounds [132 x i8], [132 x i8]* %5, i64 0, i64 0
%72 = getelementptr inbounds [132 x i8], [132 x i8]* %7, i64 0, i64 0
%73 = call i32 @strcpy(i8* %71, i8* %72)
%74 = getelementptr inbounds [132 x i8], [132 x i8]* %5, i64 0, i64 0
%75 = call i32 @strcat(i8* %74, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.3, i64 0, i64 0))
%76 = getelementptr inbounds [132 x i8], [132 x i8]* %5, i64 0, i64 0
%77 = load i8*, i8** %8
%78 = call i32 @strcat(i8* %76, i8* %77)
%79 = call i8* @strtok(i8* null, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.4, i64 0, i64 0))
store i8* %79, i8** %8
%80 = getelementptr inbounds [132 x i8], [132 x i8]* %6, i64 0, i64 0
%81 = load i8*, i8** %8
%82 = call i32 @strcpy(i8* %80, i8* %81)
%83 = getelementptr inbounds [132 x i8], [132 x i8]* %5, i64 0, i64 0
%84 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.5, i64 0, i64 0), i8* %83)
%85 = getelementptr inbounds [132 x i8], [132 x i8]* %6, i64 0, i64 0
%86 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.6, i64 0, i64 0), i8* %85)
br label %87
87: ; preds = %68, %59
br label %88
88: ; preds = %87, %35
br label %89
89: ; preds = %88, %32
br label %22
90: ; preds = %22
%91 = load i32, i32* %2
ret i32 %91
}

LLVM IR (-O2):
@O_RDONLY = global i32 0
@.str = [12 x i8] c"./gauge.ini\00"
@.str.2 = [2 x i8] c"=\00"
@.str.3 = [2 x i8] c".\00"
@.str.4 = [2 x i8] c"\0A\00"
@.str.5 = [14 x i8] c"Key : >%s<\0A\00"
@.str.6 = [14 x i8] c"Value : >%s<\0A\00"
@str = [8 x i8] c"Section\00"
define i32 @parseIni(i8* nocapture %0) {
%2 = alloca [132 x i8]
%3 = alloca [132 x i8]
%4 = alloca [132 x i8]
%5 = alloca [132 x i8]
%6 = getelementptr inbounds [132 x i8], [132 x i8]* %2, i64 0, i64 0
%7 = getelementptr inbounds [132 x i8], [132 x i8]* %3, i64 0, i64 0
%8 = getelementptr inbounds [132 x i8], [132 x i8]* %4, i64 0, i64 0
%9 = getelementptr inbounds [132 x i8], [132 x i8]* %5, i64 0, i64 0
%10 = load i32, i32* @O_RDONLY
%11 = tail call i32 @open(i8* %0, i32 %10)
%12 = icmp eq i32 %11, 0
br i1 %12, label %15, label %13
13: ; preds = %1
%14 = getelementptr inbounds [132 x i8], [132 x i8]* %2, i64 0, i64 1
br label %18
15: ; preds = %1
%16 = tail call i32 @perror(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str, i64 0, i64 0))
%17 = tail call i32 @exit(i32 1)
unreachable
18: ; preds = %13, %51
%19 = call i32 @readLine(i32 %11, i8* %6, i32 132)
%20 = icmp eq i32 %19, 0
%21 = icmp sgt i32 %19, 0
br i1 %21, label %22, label %51
22: ; preds = %18
%23 = call i32 @strlen(i8* %6)
%24 = add nsw i32 %23, -1
%25 = sext i32 %24 to i64
%26 = getelementptr inbounds [132 x i8], [132 x i8]* %2, i64 0, i64 %25
store i8 0, i8* %26
%27 = add nsw i32 %23, -2
%28 = icmp sgt i32 %23, 2
br i1 %28, label %29, label %51
29: ; preds = %22
%30 = load i8, i8* %6
%31 = icmp eq i8 %30, 91
br i1 %31, label %32, label %42
32: ; preds = %29
%33 = zext i32 %27 to i64
%34 = getelementptr inbounds [132 x i8], [132 x i8]* %2, i64 0, i64 %33
%35 = load i8, i8* %34
%36 = icmp eq i8 %35, 93
br i1 %36, label %37, label %42
37: ; preds = %32
%38 = call i32 @memset(i8* %9, i32 0, i32 132)
%39 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([8 x i8], [8 x i8]* @str, i64 0, i64 0))
%40 = add nsw i32 %23, -3
%41 = call i32 @strncpy(i8* %9, i8* %14, i32 %40)
br label %51
42: ; preds = %32, %29
%43 = call i8* @strtok(i8* %6, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.2, i64 0, i64 0))
%44 = call i32 @strcpy(i8* %7, i8* %9)
%45 = call i32 @strcat(i8* %7, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.3, i64 0, i64 0))
%46 = call i32 @strcat(i8* %7, i8* %43)
%47 = call i8* @strtok(i8* null, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.4, i64 0, i64 0))
%48 = call i32 @strcpy(i8* %8, i8* %47)
%49 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([14 x i8], [14 x i8]* @.str.5, i64 0, i64 0), i8* %7)
%50 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([14 x i8], [14 x i8]* @.str.6, i64 0, i64 0), i8* %8)
br label %51
51: ; preds = %22, %42, %37, %18
br i1 %20, label %52, label %18
52: ; preds = %51
ret i32 undef
}