#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*/ fclose(int /*<<< orphan*/ *);
int /*<<< orphan*/ feof(int /*<<< orphan*/ *);
int /*<<< orphan*/ ferror(int /*<<< orphan*/ *);
int /*<<< orphan*/ fgets(char *, int, int /*<<< orphan*/ *);
int /*<<< orphan*/ *fopen(char *, char *);
int /*<<< orphan*/ sgets(char *, char *);
scalar_t__ strcasecmp(char *, char *);
int /*<<< orphan*/ strcat(char *, char *);
int /*<<< orphan*/ strcpy(char *, char *);
int strlen(char *);
scalar_t__ strncasecmp(char *, char *, int);
void GetINIString(char *section, char *key, char *def, char *dest, int destsize,
                  char *filename) {
  FILE *fp;
  char s1[80], s2[80], s3[80];
  if (dest != def)
    strcpy(dest, def);
  fp = fopen(filename, "rb");
  if (fp == NULL)
    return;
  strcpy(s2, "[");
  strcat(s2, section);
  strcat(s2, "]");
  strcpy(s3, key);
  strcat(s3, "=");
  do {
    fgets(s1, 80, fp);
    sgets(s1, s1);
    if (strcasecmp(s1, s2) == 0) {
      do {
        fgets(s1, 80, fp);
        sgets(s1, s1);
        if (strncasecmp(s1, s3, strlen(s3)) == 0) {
          strcpy(dest, s1 + strlen(s3));
          fclose(fp);
          return;
        }
      } while (s1[0] != 0 && !feof(fp) && !ferror(fp));
    }
  } while (!feof(fp) && !ferror(fp));
  fclose(fp);
}


x86 assembly (clang, -O0):
<GetINIString>:
push   %rbp
mov    %rsp,%rbp
sub    $0x160,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
mov    %rcx,-0x20(%rbp)
mov    %r8d,-0x24(%rbp)
mov    %r9,-0x30(%rbp)
mov    -0x20(%rbp),%rax
cmp    -0x18(%rbp),%rax
je     11ee <GetINIString+0x3e>
mov    -0x20(%rbp),%rdi
mov    -0x18(%rbp),%rsi
call   1040 <strcpy@plt>
mov    -0x30(%rbp),%rdi
lea    0xe07(%rip),%rsi
call   10c0 <fopen@plt>
mov    %rax,-0x38(%rbp)
cmpq   $0x0,-0x38(%rbp)
jne    1212 <GetINIString+0x62>
jmp    1421 <GetINIString+0x271>
lea    -0xe0(%rbp),%rdi
lea    0xde3(%rip),%rsi
call   1040 <strcpy@plt>
lea    -0xe0(%rbp),%rdi
mov    -0x8(%rbp),%rsi
call   10d0 <strcat@plt>
lea    -0xe0(%rbp),%rdi
lea    0xdc2(%rip),%rsi
call   10d0 <strcat@plt>
lea    -0x130(%rbp),%rdi
mov    -0x10(%rbp),%rsi
call   1040 <strcpy@plt>
lea    -0x130(%rbp),%rdi
lea    0xda1(%rip),%rsi
call   10d0 <strcat@plt>
lea    -0x90(%rbp),%rdi
mov    -0x38(%rbp),%rdx
mov    $0x50,%esi
call   1080 <fgets@plt>
lea    -0x90(%rbp),%rdi
lea    -0x90(%rbp),%rsi
call   10b0 <sgets@plt>
lea    -0x90(%rbp),%rdi
lea    -0xe0(%rbp),%rsi
call   1030 <strcasecmp@plt>
cmp    $0x0,%rax
jne    13d2 <GetINIString+0x222>
jmp    12b5 <GetINIString+0x105>
lea    -0x90(%rbp),%rdi
mov    -0x38(%rbp),%rdx
mov    $0x50,%esi
call   1080 <fgets@plt>
lea    -0x90(%rbp),%rdi
lea    -0x90(%rbp),%rsi
call   10b0 <sgets@plt>
lea    -0x90(%rbp),%rax
mov    %rax,-0x140(%rbp)
lea    -0x130(%rbp),%rax
mov    %rax,-0x138(%rbp)
lea    -0x130(%rbp),%rdi
call   1070 <strlen@plt>
mov    -0x140(%rbp),%rdi
mov    -0x138(%rbp),%rsi
mov    %eax,%edx
call   10a0 <strncasecmp@plt>
cmp    $0x0,%rax
jne    136f <GetINIString+0x1bf>
mov    -0x20(%rbp),%rax
mov    %rax,-0x148(%rbp)
lea    -0x90(%rbp),%rax
mov    %rax,-0x150(%rbp)
lea    -0x130(%rbp),%rdi
call   1070 <strlen@plt>
mov    -0x150(%rbp),%rsi
mov    -0x148(%rbp),%rdi
cltq
add    %rax,%rsi
call   1040 <strcpy@plt>
mov    -0x38(%rbp),%rdi
call   1060 <fclose@plt>
jmp    1421 <GetINIString+0x271>
jmp    1374 <GetINIString+0x1c4>
movsbl -0x90(%rbp),%ecx
xor    %eax,%eax
cmp    $0x0,%ecx
mov    %al,-0x151(%rbp)
je     13bf <GetINIString+0x20f>
mov    -0x38(%rbp),%rdi
call   1090 <feof@plt>
mov    %eax,%ecx
xor    %eax,%eax
cmp    $0x0,%ecx
mov    %al,-0x151(%rbp)
jne    13bf <GetINIString+0x20f>
mov    -0x38(%rbp),%rdi
call   1050 <ferror@plt>
cmp    $0x0,%eax
setne  %al
xor    $0xff,%al
mov    %al,-0x151(%rbp)
mov    -0x151(%rbp),%al
test   $0x1,%al
jne    12b5 <GetINIString+0x105>
jmp    13d2 <GetINIString+0x222>
jmp    13d7 <GetINIString+0x227>
mov    -0x38(%rbp),%rdi
call   1090 <feof@plt>
mov    %eax,%ecx
xor    %eax,%eax
cmp    $0x0,%ecx
mov    %al,-0x152(%rbp)
jne    140a <GetINIString+0x25a>
mov    -0x38(%rbp),%rdi
call   1050 <ferror@plt>
cmp    $0x0,%eax
setne  %al
xor    $0xff,%al
mov    %al,-0x152(%rbp)
mov    -0x152(%rbp),%al
test   $0x1,%al
jne    126b <GetINIString+0xbb>
mov    -0x38(%rbp),%rdi
call   1060 <fclose@plt>
add    $0x160,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<GetINIString>:
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0xf0,%rsp
mov    %r9,%rbx
mov    %rcx,%r14
mov    %rsi,%r13
mov    %rdi,%r12
cmp    %rdx,%rcx
je     11dc <GetINIString+0x2c>
mov    %r14,%rdi
mov    %rdx,%rsi
call   1040 <strcpy@plt>
lea    0xe1d(%rip),%rsi
mov    %rbx,%rdi
call   10c0 <fopen@plt>
test   %rax,%rax
je     1315 <GetINIString+0x165>
mov    %rax,%rbx
lea    0xe05(%rip),%rsi
lea    0xa0(%rsp),%r15
mov    %r15,%rdi
call   1040 <strcpy@plt>
mov    %r15,%rdi
mov    %r12,%rsi
call   10d0 <strcat@plt>
lea    0xde5(%rip),%rsi
mov    %r15,%rdi
call   10d0 <strcat@plt>
lea    0x50(%rsp),%r12
mov    %r12,%rdi
mov    %r13,%rsi
call   1040 <strcpy@plt>
lea    0xdc8(%rip),%rsi
mov    %r12,%rdi
call   10d0 <strcat@plt>
mov    %rsp,%r13
nopw   0x0(%rax,%rax,1)
mov    %r13,%rdi
mov    $0x50,%esi
mov    %rbx,%rdx
call   1080 <fgets@plt>
mov    %r13,%rdi
mov    %r13,%rsi
call   10b0 <sgets@plt>
mov    %r13,%rdi
mov    %r15,%rsi
call   1030 <strcasecmp@plt>
test   %rax,%rax
je     12a0 <GetINIString+0xf0>
mov    %rbx,%rdi
call   1090 <feof@plt>
test   %eax,%eax
jne    130d <GetINIString+0x15d>
mov    %rbx,%rdi
call   1050 <ferror@plt>
test   %eax,%eax
je     1250 <GetINIString+0xa0>
jmp    130d <GetINIString+0x15d>
nopl   0x0(%rax)
mov    %r13,%rdi
mov    $0x50,%esi
mov    %rbx,%rdx
call   1080 <fgets@plt>
mov    %r13,%rdi
mov    %r13,%rsi
call   10b0 <sgets@plt>
mov    %r12,%rdi
call   1070 <strlen@plt>
mov    %r13,%rdi
mov    %r12,%rsi
mov    %eax,%edx
call   10a0 <strncasecmp@plt>
test   %rax,%rax
je     12f5 <GetINIString+0x145>
cmpb   $0x0,(%rsp)
je     127b <GetINIString+0xcb>
mov    %rbx,%rdi
call   1090 <feof@plt>
test   %eax,%eax
jne    127b <GetINIString+0xcb>
mov    %rbx,%rdi
call   1050 <ferror@plt>
test   %eax,%eax
je     12a0 <GetINIString+0xf0>
jmp    127b <GetINIString+0xcb>
lea    0x50(%rsp),%rdi
call   1070 <strlen@plt>
cltq
lea    (%rsp,%rax,1),%rsi
mov    %r14,%rdi
call   1040 <strcpy@plt>
mov    %rbx,%rdi
call   1060 <fclose@plt>
add    $0xf0,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@.str = [3 x i8] c"rb\00"
@.str.1 = [2 x i8] c"[\00"
@.str.2 = [2 x i8] c"]\00"
@.str.3 = [2 x i8] c"=\00"
define void @GetINIString(i8* %0, i8* %1, i8* %2, i8* %3, i32 %4, i8* %5) {
%7 = alloca i8*
%8 = alloca i8*
%9 = alloca i8*
%10 = alloca i8*
%11 = alloca i32
%12 = alloca i8*
%13 = alloca i32*
%14 = alloca [80 x i8]
%15 = alloca [80 x i8]
%16 = alloca [80 x i8]
store i8* %0, i8** %7
store i8* %1, i8** %8
store i8* %2, i8** %9
store i8* %3, i8** %10
store i32 %4, i32* %11
store i8* %5, i8** %12
%17 = load i8*, i8** %10
%18 = load i8*, i8** %9
%19 = icmp ne i8* %17, %18
br i1 %19, label %20, label %24
20: ; preds = %6
%21 = load i8*, i8** %10
%22 = load i8*, i8** %9
%23 = call i32 @strcpy(i8* %21, i8* %22)
br label %24
24: ; preds = %20, %6
%25 = load i8*, i8** %12
%26 = call i32* @fopen(i8* %25, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0))
store i32* %26, i32** %13
%27 = load i32*, i32** %13
%28 = icmp eq i32* %27, null
br i1 %28, label %29, label %30
29: ; preds = %24
br label %111
30: ; preds = %24
%31 = getelementptr inbounds [80 x i8], [80 x i8]* %15, i64 0, i64 0
%32 = call i32 @strcpy(i8* %31, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
%33 = getelementptr inbounds [80 x i8], [80 x i8]* %15, i64 0, i64 0
%34 = load i8*, i8** %7
%35 = call i32 @strcat(i8* %33, i8* %34)
%36 = getelementptr inbounds [80 x i8], [80 x i8]* %15, i64 0, i64 0
%37 = call i32 @strcat(i8* %36, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.2, i64 0, i64 0))
%38 = getelementptr inbounds [80 x i8], [80 x i8]* %16, i64 0, i64 0
%39 = load i8*, i8** %8
%40 = call i32 @strcpy(i8* %38, i8* %39)
%41 = getelementptr inbounds [80 x i8], [80 x i8]* %16, i64 0, i64 0
%42 = call i32 @strcat(i8* %41, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.3, i64 0, i64 0))
br label %43
43: ; preds = %106, %30
%44 = getelementptr inbounds [80 x i8], [80 x i8]* %14, i64 0, i64 0
%45 = load i32*, i32** %13
%46 = call i32 @fgets(i8* %44, i32 80, i32* %45)
%47 = getelementptr inbounds [80 x i8], [80 x i8]* %14, i64 0, i64 0
%48 = getelementptr inbounds [80 x i8], [80 x i8]* %14, i64 0, i64 0
%49 = call i32 @sgets(i8* %47, i8* %48)
%50 = getelementptr inbounds [80 x i8], [80 x i8]* %14, i64 0, i64 0
%51 = getelementptr inbounds [80 x i8], [80 x i8]* %15, i64 0, i64 0
%52 = call i64 @strcasecmp(i8* %50, i8* %51)
%53 = icmp eq i64 %52, 0
br i1 %53, label %54, label %96
54: ; preds = %43
br label %55
55: ; preds = %93, %54
%56 = getelementptr inbounds [80 x i8], [80 x i8]* %14, i64 0, i64 0
%57 = load i32*, i32** %13
%58 = call i32 @fgets(i8* %56, i32 80, i32* %57)
%59 = getelementptr inbounds [80 x i8], [80 x i8]* %14, i64 0, i64 0
%60 = getelementptr inbounds [80 x i8], [80 x i8]* %14, i64 0, i64 0
%61 = call i32 @sgets(i8* %59, i8* %60)
%62 = getelementptr inbounds [80 x i8], [80 x i8]* %14, i64 0, i64 0
%63 = getelementptr inbounds [80 x i8], [80 x i8]* %16, i64 0, i64 0
%64 = getelementptr inbounds [80 x i8], [80 x i8]* %16, i64 0, i64 0
%65 = call i32 @strlen(i8* %64)
%66 = call i64 @strncasecmp(i8* %62, i8* %63, i32 %65)
%67 = icmp eq i64 %66, 0
br i1 %67, label %68, label %78
68: ; preds = %55
%69 = load i8*, i8** %10
%70 = getelementptr inbounds [80 x i8], [80 x i8]* %14, i64 0, i64 0
%71 = getelementptr inbounds [80 x i8], [80 x i8]* %16, i64 0, i64 0
%72 = call i32 @strlen(i8* %71)
%73 = sext i32 %72 to i64
%74 = getelementptr inbounds i8, i8* %70, i64 %73
%75 = call i32 @strcpy(i8* %69, i8* %74)
%76 = load i32*, i32** %13
%77 = call i32 @fclose(i32* %76)
br label %111
78: ; preds = %55
br label %79
79: ; preds = %78
%80 = getelementptr inbounds [80 x i8], [80 x i8]* %14, i64 0, i64 0
%81 = load i8, i8* %80
%82 = sext i8 %81 to i32
%83 = icmp ne i32 %82, 0
br i1 %83, label %84, label %93
84: ; preds = %79
%85 = load i32*, i32** %13
%86 = call i32 @feof(i32* %85)
%87 = icmp ne i32 %86, 0
br i1 %87, label %93, label %88
88: ; preds = %84
%89 = load i32*, i32** %13
%90 = call i32 @ferror(i32* %89)
%91 = icmp ne i32 %90, 0
%92 = xor i1 %91, true
br label %93
93: ; preds = %88, %84, %79
%94 = phi i1 [ false, %84 ], [ false, %79 ], [ %92, %88 ]
br i1 %94, label %55, label %95
95: ; preds = %93
br label %96
96: ; preds = %95, %43
br label %97
97: ; preds = %96
%98 = load i32*, i32** %13
%99 = call i32 @feof(i32* %98)
%100 = icmp ne i32 %99, 0
br i1 %100, label %106, label %101
101: ; preds = %97
%102 = load i32*, i32** %13
%103 = call i32 @ferror(i32* %102)
%104 = icmp ne i32 %103, 0
%105 = xor i1 %104, true
br label %106
106: ; preds = %101, %97
%107 = phi i1 [ false, %97 ], [ %105, %101 ]
br i1 %107, label %43, label %108
108: ; preds = %106
%109 = load i32*, i32** %13
%110 = call i32 @fclose(i32* %109)
br label %111
111: ; preds = %108, %68, %29
ret void
}

LLVM IR (-O2):
@.str = [3 x i8] c"rb\00"
@.str.1 = [2 x i8] c"[\00"
@.str.2 = [2 x i8] c"]\00"
@.str.3 = [2 x i8] c"=\00"
define void @GetINIString(i8* %0, i8* %1, i8* %2, i8* %3, i32 %4, i8* nocapture %5) {
%7 = alloca [80 x i8]
%8 = alloca [80 x i8]
%9 = alloca [80 x i8]
%10 = getelementptr inbounds [80 x i8], [80 x i8]* %7, i64 0, i64 0
%11 = getelementptr inbounds [80 x i8], [80 x i8]* %8, i64 0, i64 0
%12 = getelementptr inbounds [80 x i8], [80 x i8]* %9, i64 0, i64 0
%13 = icmp eq i8* %3, %2
br i1 %13, label %16, label %14
14: ; preds = %6
%15 = tail call i32 @strcpy(i8* %3, i8* %2)
br label %16
16: ; preds = %14, %6
%17 = tail call i32* @fopen(i8* %5, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0))
%18 = icmp eq i32* %17, null
br i1 %18, label %58, label %19
19: ; preds = %16
%20 = call i32 @strcpy(i8* %11, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
%21 = call i32 @strcat(i8* %11, i8* %0)
%22 = call i32 @strcat(i8* %11, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.2, i64 0, i64 0))
%23 = call i32 @strcpy(i8* %12, i8* %1)
%24 = call i32 @strcat(i8* %12, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.3, i64 0, i64 0))
br label %25
25: ; preds = %53, %19
%26 = call i32 @fgets(i8* %10, i32 80, i32* %17)
%27 = call i32 @sgets(i8* %10, i8* %10)
%28 = call i64 @strcasecmp(i8* %10, i8* %11)
%29 = icmp eq i64 %28, 0
br i1 %29, label %30, label %50
30: ; preds = %25, %47
%31 = call i32 @fgets(i8* %10, i32 80, i32* %17)
%32 = call i32 @sgets(i8* %10, i8* %10)
%33 = call i32 @strlen(i8* %12)
%34 = call i64 @strncasecmp(i8* %10, i8* %12, i32 %33)
%35 = icmp eq i64 %34, 0
br i1 %35, label %36, label %41
36: ; preds = %30
%37 = call i32 @strlen(i8* %12)
%38 = sext i32 %37 to i64
%39 = getelementptr inbounds [80 x i8], [80 x i8]* %7, i64 0, i64 %38
%40 = call i32 @strcpy(i8* %3, i8* %39)
br label %56
41: ; preds = %30
%42 = load i8, i8* %10
%43 = icmp eq i8 %42, 0
br i1 %43, label %50, label %44
44: ; preds = %41
%45 = call i32 @feof(i32* %17)
%46 = icmp eq i32 %45, 0
br i1 %46, label %47, label %50
47: ; preds = %44
%48 = call i32 @ferror(i32* %17)
%49 = icmp eq i32 %48, 0
br i1 %49, label %30, label %50
50: ; preds = %41, %44, %47, %25
%51 = call i32 @feof(i32* %17)
%52 = icmp eq i32 %51, 0
br i1 %52, label %53, label %56
53: ; preds = %50
%54 = call i32 @ferror(i32* %17)
%55 = icmp eq i32 %54, 0
br i1 %55, label %25, label %56
56: ; preds = %53, %50, %36
%57 = call i32 @fclose(i32* %17)
br label %58
58: ; preds = %56, %16
ret void
}