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

/* Variables and functions */
int /*<<< orphan*/ SEEK_SET;
int /*<<< orphan*/ a_trim(char *, char *);
int /*<<< orphan*/ errno;
int /*<<< orphan*/ fclose(int /*<<< orphan*/ *);
int /*<<< orphan*/ feof(int /*<<< orphan*/ *);
int /*<<< orphan*/ *fgets(char *, int, int /*<<< orphan*/ *);
int /*<<< orphan*/ *fopen(char *, char *);
int /*<<< orphan*/ free(char *);
int /*<<< orphan*/ fseek(int /*<<< orphan*/ *, int /*<<< orphan*/,
                         int /*<<< orphan*/);
int /*<<< orphan*/ l_trim(char *, char *);
scalar_t__ malloc(scalar_t__);
int /*<<< orphan*/ memset(char *, int /*<<< orphan*/, int);
int /*<<< orphan*/ printf(char *, char *, char *);
int /*<<< orphan*/ sprintf(char *, char *, char *);
int /*<<< orphan*/ sscanf(char *, char *, char *);
scalar_t__ strchr(char *, char);
scalar_t__ strcmp(char *, char *);
int /*<<< orphan*/ strcpy(char *, char *);
char *strerror(int /*<<< orphan*/);
scalar_t__ strlen(char *);
scalar_t__ strncmp(char *, char *, scalar_t__);
int GetProfileString(char *profile, char *AppName, char *KeyName,
                     char *KeyVal) {
  char appname[32], keyname[32];
  char *buf, *c;
  char buf_i[100], buf_o[100];
  FILE *fp;
  int found = 0;
  if ((fp = fopen(profile, "r")) == NULL) {
    printf("openfile [%s] error [%s]\n", profile, strerror(errno));
    return (-1);
  }
  fseek(fp, 0, SEEK_SET);
  memset(appname, 0, sizeof(appname));
  sprintf(appname, "[%s]", AppName);
  while (!feof(fp) && fgets(buf_i, 100, fp) != NULL) {
    l_trim(buf_o, buf_i);
    if (strlen(buf_o) <= 0)
      continue;
    buf = NULL;
    buf = buf_o;
    if (found == 0) {
      if (buf[0] != '[') {
        continue;
      } else if (strncmp(buf, appname, strlen(appname)) == 0) {
        found = 1;
        continue;
      }
    } else if (found == 1) {
      if (buf[0] == '#') {
        continue;
      } else if (buf[0] == '[') {
        break;
      } else {
        if ((c = (char *)strchr(buf, '=')) == NULL)
          continue;
        memset(keyname, 0, sizeof(keyname));
        sscanf(buf, "%[^=|^ |^\t]", keyname);
        if (strcmp(keyname, KeyName) == 0) {
          sscanf(++c, "%[^\n]", KeyVal);
          char *KeyVal_o = (char *)malloc(strlen(KeyVal) + 1);
          if (KeyVal_o != NULL) {
            memset(KeyVal_o, 0, sizeof(KeyVal_o));
            a_trim(KeyVal_o, KeyVal);
            if (KeyVal_o && strlen(KeyVal_o) > 0)
              strcpy(KeyVal, KeyVal_o);
            free(KeyVal_o);
            KeyVal_o = NULL;
          }
          found = 2;
          break;
        } else {
          continue;
        }
      }
    }
  }
  fclose(fp);
  if (found == 2)
    return (0);
  else
    return (-1);
}


x86 assembly (clang, -O0):
<GetProfileString>:
push   %rbp
mov    %rsp,%rbp
sub    $0x1a0,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
mov    %rdx,-0x20(%rbp)
mov    %rcx,-0x28(%rbp)
movl   $0x0,-0x16c(%rbp)
mov    -0x10(%rbp),%rdi
lea    0xda0(%rip),%rsi
call   1120 <fopen@plt>
mov    %rax,-0x168(%rbp)
cmp    $0x0,%rax
jne    12b1 <GetProfileString+0x81>
mov    -0x10(%rbp),%rax
mov    %rax,-0x180(%rbp)
mov    0x2d58(%rip),%rax
mov    (%rax),%edi
call   1150 <strerror@plt>
mov    -0x180(%rbp),%rsi
mov    %rax,%rdx
lea    0xd62(%rip),%rdi
call   10a0 <printf@plt>
movl   $0xffffffff,-0x4(%rbp)
jmp    158f <GetProfileString+0x35f>
mov    -0x168(%rbp),%rdi
mov    0x2d19(%rip),%rax
mov    (%rax),%edx
xor    %esi,%esi
call   1110 <fseek@plt>
lea    -0x50(%rbp),%rdi
xor    %esi,%esi
mov    $0x20,%edx
call   10b0 <memset@plt>
lea    -0x50(%rbp),%rdi
mov    -0x18(%rbp),%rdx
lea    0xd35(%rip),%rsi
call   1130 <sprintf@plt>
mov    -0x168(%rbp),%rdi
call   10e0 <feof@plt>
mov    %eax,%ecx
xor    %eax,%eax
cmp    $0x0,%ecx
mov    %al,-0x181(%rbp)
jne    1330 <GetProfileString+0x100>
lea    -0xf0(%rbp),%rdi
mov    -0x168(%rbp),%rdx
mov    $0x64,%esi
call   10c0 <fgets@plt>
cmp    $0x0,%rax
setne  %al
mov    %al,-0x181(%rbp)
mov    -0x181(%rbp),%al
test   $0x1,%al
jne    1343 <GetProfileString+0x113>
jmp    1563 <GetProfileString+0x333>
lea    -0x160(%rbp),%rdi
lea    -0xf0(%rbp),%rsi
call   1060 <l_trim@plt>
lea    -0x160(%rbp),%rdi
call   1080 <strlen@plt>
cmp    $0x0,%rax
jg     1371 <GetProfileString+0x141>
jmp    12ec <GetProfileString+0xbc>
movq   $0x0,-0x78(%rbp)
lea    -0x160(%rbp),%rax
mov    %rax,-0x78(%rbp)
cmpl   $0x0,-0x16c(%rbp)
jne    13fe <GetProfileString+0x1ce>
mov    -0x78(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x5b,%eax
je     13a6 <GetProfileString+0x176>
jmp    12ec <GetProfileString+0xbc>
mov    -0x78(%rbp),%rax
mov    %rax,-0x198(%rbp)
lea    -0x50(%rbp),%rax
mov    %rax,-0x190(%rbp)
lea    -0x50(%rbp),%rdi
call   1080 <strlen@plt>
mov    -0x198(%rbp),%rdi
mov    -0x190(%rbp),%rsi
mov    %rax,%rdx
call   1040 <strncmp@plt>
cmp    $0x0,%rax
jne    13f4 <GetProfileString+0x1c4>
movl   $0x1,-0x16c(%rbp)
jmp    12ec <GetProfileString+0xbc>
jmp    13f9 <GetProfileString+0x1c9>
jmp    155e <GetProfileString+0x32e>
cmpl   $0x1,-0x16c(%rbp)
jne    1559 <GetProfileString+0x329>
mov    -0x78(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x23,%eax
jne    1420 <GetProfileString+0x1f0>
jmp    12ec <GetProfileString+0xbc>
mov    -0x78(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x5b,%eax
jne    1435 <GetProfileString+0x205>
jmp    1563 <GetProfileString+0x333>
mov    -0x78(%rbp),%rdi
mov    $0x3d,%esi
call   1090 <strchr@plt>
mov    %rax,-0x80(%rbp)
cmp    $0x0,%rax
jne    1456 <GetProfileString+0x226>
jmp    12ec <GetProfileString+0xbc>
lea    -0x70(%rbp),%rdi
xor    %esi,%esi
mov    $0x20,%edx
call   10b0 <memset@plt>
mov    -0x78(%rbp),%rdi
lea    -0x70(%rbp),%rdx
lea    0xbac(%rip),%rsi
call   1100 <sscanf@plt>
lea    -0x70(%rbp),%rdi
mov    -0x20(%rbp),%rsi
call   10d0 <strcmp@plt>
cmp    $0x0,%rax
jne    1554 <GetProfileString+0x324>
mov    -0x80(%rbp),%rdi
add    $0x1,%rdi
mov    %rdi,-0x80(%rbp)
mov    -0x28(%rbp),%rdx
lea    0xb85(%rip),%rsi
call   1100 <sscanf@plt>
mov    -0x28(%rbp),%rdi
call   1080 <strlen@plt>
mov    %rax,%rdi
add    $0x1,%rdi
call   10f0 <malloc@plt>
mov    %rax,-0x178(%rbp)
cmpq   $0x0,-0x178(%rbp)
je     1545 <GetProfileString+0x315>
mov    -0x178(%rbp),%rdi
xor    %esi,%esi
mov    $0x8,%edx
call   10b0 <memset@plt>
mov    -0x178(%rbp),%rdi
mov    -0x28(%rbp),%rsi
call   1140 <a_trim@plt>
cmpq   $0x0,-0x178(%rbp)
je     152e <GetProfileString+0x2fe>
mov    -0x178(%rbp),%rdi
call   1080 <strlen@plt>
cmp    $0x0,%rax
jle    152e <GetProfileString+0x2fe>
mov    -0x28(%rbp),%rdi
mov    -0x178(%rbp),%rsi
call   1050 <strcpy@plt>
mov    -0x178(%rbp),%rdi
call   1030 <free@plt>
movq   $0x0,-0x178(%rbp)
movl   $0x2,-0x16c(%rbp)
jmp    1563 <GetProfileString+0x333>
jmp    12ec <GetProfileString+0xbc>
jmp    155e <GetProfileString+0x32e>
jmp    12ec <GetProfileString+0xbc>
mov    -0x168(%rbp),%rdi
call   1070 <fclose@plt>
cmpl   $0x2,-0x16c(%rbp)
jne    1588 <GetProfileString+0x358>
movl   $0x0,-0x4(%rbp)
jmp    158f <GetProfileString+0x35f>
movl   $0xffffffff,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x1a0,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<GetProfileString>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x128,%rsp
mov    %rcx,%r14
mov    %rdx,%r15
mov    %rsi,%r13
mov    %rdi,%rbp
lea    0xdac(%rip),%rsi
call   1120 <fopen@plt>
test   %rax,%rax
je     13ad <GetProfileString+0x17d>
mov    %rax,%rbx
mov    %r14,0x8(%rsp)
mov    0x2d67(%rip),%rax
mov    (%rax),%edx
xor    %r14d,%r14d
mov    %rbx,%rdi
xor    %esi,%esi
call   1110 <fseek@plt>
lea    0x30(%rsp),%r12
mov    %r12,%rdi
xor    %esi,%esi
mov    $0x20,%edx
call   10b0 <memset@plt>
lea    0xd81(%rip),%rsi
mov    %r12,%rdi
mov    %r13,%rdx
call   1130 <sprintf@plt>
lea    0xc0(%rsp),%r13
lea    0x50(%rsp),%rbp
cs nopw 0x0(%rax,%rax,1)
nopl   (%rax)
mov    %rbx,%rdi
call   10e0 <feof@plt>
test   %eax,%eax
jne    13a3 <GetProfileString+0x173>
mov    %r13,%rdi
mov    $0x64,%esi
mov    %rbx,%rdx
call   10c0 <fgets@plt>
test   %rax,%rax
je     13a3 <GetProfileString+0x173>
mov    %rbp,%rdi
mov    %r13,%rsi
call   1060 <l_trim@plt>
mov    %rbp,%rdi
call   1080 <strlen@plt>
test   %rax,%rax
jle    12c0 <GetProfileString+0x90>
movzbl 0x50(%rsp),%eax
test   %r14d,%r14d
je     1370 <GetProfileString+0x140>
mov    $0x1,%r14d
cmp    $0x23,%al
je     12c0 <GetProfileString+0x90>
cmp    $0x5b,%al
je     13a3 <GetProfileString+0x173>
mov    %rbp,%rdi
mov    $0x3d,%esi
call   1090 <strchr@plt>
mov    %rax,(%rsp)
test   %rax,%rax
je     12c0 <GetProfileString+0x90>
lea    0x10(%rsp),%rdi
xor    %esi,%esi
mov    $0x20,%edx
call   10b0 <memset@plt>
mov    %rbp,%rdi
lea    0xcd3(%rip),%rsi
lea    0x10(%rsp),%rdx
call   1100 <sscanf@plt>
lea    0x10(%rsp),%rdi
mov    %r15,%rsi
call   10d0 <strcmp@plt>
test   %rax,%rax
jne    12c0 <GetProfileString+0x90>
jmp    13e4 <GetProfileString+0x1b4>
mov    $0x0,%r14d
cmp    $0x5b,%al
jne    12c0 <GetProfileString+0x90>
mov    %r12,%rdi
call   1080 <strlen@plt>
mov    %rbp,%rdi
mov    %r12,%rsi
mov    %rax,%rdx
call   1040 <strncmp@plt>
xor    %r14d,%r14d
test   %rax,%rax
sete   %r14b
jmp    12c0 <GetProfileString+0x90>
mov    %rbx,%rdi
call   1070 <fclose@plt>
jmp    13cd <GetProfileString+0x19d>
mov    0x2c2c(%rip),%rax
mov    (%rax),%edi
call   1150 <strerror@plt>
lea    0xc40(%rip),%rdi
mov    %rbp,%rsi
mov    %rax,%rdx
call   10a0 <printf@plt>
mov    $0xffffffff,%eax
add    $0x128,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret
mov    (%rsp),%rdi
add    $0x1,%rdi
lea    0xc3a(%rip),%rsi
mov    0x8(%rsp),%r14
mov    %r14,%rdx
call   1100 <sscanf@plt>
mov    %r14,%rdi
call   1080 <strlen@plt>
lea    0x1(%rax),%rdi
call   10f0 <malloc@plt>
test   %rax,%rax
je     1453 <GetProfileString+0x223>
mov    %rax,%rbp
mov    %rax,%rdi
xor    %esi,%esi
mov    $0x8,%edx
call   10b0 <memset@plt>
mov    %rbp,%rdi
mov    %r14,%rsi
call   1140 <a_trim@plt>
mov    %rbp,%rdi
call   1080 <strlen@plt>
test   %rax,%rax
jle    144b <GetProfileString+0x21b>
mov    %r14,%rdi
mov    %rbp,%rsi
call   1050 <strcpy@plt>
mov    %rbp,%rdi
call   1030 <free@plt>
mov    %rbx,%rdi
call   1070 <fclose@plt>
xor    %eax,%eax
jmp    13d2 <GetProfileString+0x1a2>

LLVM IR (-O0):
@.str = [2 x i8] c"r\00"
@.str.1 = [26 x i8] c"openfile [%s] error [%s]\0A\00"
@errno = global i32 0
@SEEK_SET = global i32 0
@.str.2 = [5 x i8] c"[%s]\00"
@.str.3 = [12 x i8] c"%[^=|^ |^\09]\00"
@.str.4 = [6 x i8] c"%[^\0A]\00"
define i32 @GetProfileString(i8* %0, i8* %1, i8* %2, i8* %3) {
%5 = alloca i32
%6 = alloca i8*
%7 = alloca i8*
%8 = alloca i8*
%9 = alloca i8*
%10 = alloca [32 x i8]
%11 = alloca [32 x i8]
%12 = alloca i8*
%13 = alloca i8*
%14 = alloca [100 x i8]
%15 = alloca [100 x i8]
%16 = alloca i32*
%17 = alloca i32
%18 = alloca i8*
store i8* %0, i8** %6
store i8* %1, i8** %7
store i8* %2, i8** %8
store i8* %3, i8** %9
store i32 0, i32* %17
%19 = load i8*, i8** %6
%20 = call i32* @fopen(i8* %19, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
store i32* %20, i32** %16
%21 = icmp eq i32* %20, null
br i1 %21, label %22, label %27
22: ; preds = %4
%23 = load i8*, i8** %6
%24 = load i32, i32* @errno
%25 = call i8* @strerror(i32 %24)
%26 = call i32 @printf(i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str.1, i64 0, i64 0), i8* %23, i8* %25)
store i32 -1, i32* %5
br label %151
27: ; preds = %4
%28 = load i32*, i32** %16
%29 = load i32, i32* @SEEK_SET
%30 = call i32 @fseek(i32* %28, i32 0, i32 %29)
%31 = getelementptr inbounds [32 x i8], [32 x i8]* %10, i64 0, i64 0
%32 = call i32 @memset(i8* %31, i32 0, i32 32)
%33 = getelementptr inbounds [32 x i8], [32 x i8]* %10, i64 0, i64 0
%34 = load i8*, i8** %7
%35 = call i32 @sprintf(i8* %33, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.2, i64 0, i64 0), i8* %34)
br label %36
36: ; preds = %143, %141, %98, %85, %73, %65, %54, %27
%37 = load i32*, i32** %16
%38 = call i32 @feof(i32* %37)
%39 = icmp ne i32 %38, 0
br i1 %39, label %45, label %40
40: ; preds = %36
%41 = getelementptr inbounds [100 x i8], [100 x i8]* %14, i64 0, i64 0
%42 = load i32*, i32** %16
%43 = call i32* @fgets(i8* %41, i32 100, i32* %42)
%44 = icmp ne i32* %43, null
br label %45
45: ; preds = %40, %36
%46 = phi i1 [ false, %36 ], [ %44, %40 ]
br i1 %46, label %47, label %144
47: ; preds = %45
%48 = getelementptr inbounds [100 x i8], [100 x i8]* %15, i64 0, i64 0
%49 = getelementptr inbounds [100 x i8], [100 x i8]* %14, i64 0, i64 0
%50 = call i32 @l_trim(i8* %48, i8* %49)
%51 = getelementptr inbounds [100 x i8], [100 x i8]* %15, i64 0, i64 0
%52 = call i64 @strlen(i8* %51)
%53 = icmp sle i64 %52, 0
br i1 %53, label %54, label %55
54: ; preds = %47
br label %36
55: ; preds = %47
store i8* null, i8** %12
%56 = getelementptr inbounds [100 x i8], [100 x i8]* %15, i64 0, i64 0
store i8* %56, i8** %12
%57 = load i32, i32* %17
%58 = icmp eq i32 %57, 0
br i1 %58, label %59, label %76
59: ; preds = %55
%60 = load i8*, i8** %12
%61 = getelementptr inbounds i8, i8* %60, i64 0
%62 = load i8, i8* %61
%63 = sext i8 %62 to i32
%64 = icmp ne i32 %63, 91
br i1 %64, label %65, label %66
65: ; preds = %59
br label %36
66: ; preds = %59
%67 = load i8*, i8** %12
%68 = getelementptr inbounds [32 x i8], [32 x i8]* %10, i64 0, i64 0
%69 = getelementptr inbounds [32 x i8], [32 x i8]* %10, i64 0, i64 0
%70 = call i64 @strlen(i8* %69)
%71 = call i64 @strncmp(i8* %67, i8* %68, i64 %70)
%72 = icmp eq i64 %71, 0
br i1 %72, label %73, label %74
73: ; preds = %66
store i32 1, i32* %17
br label %36
74: ; preds = %66
br label %75
75: ; preds = %74
br label %143
76: ; preds = %55
%77 = load i32, i32* %17
%78 = icmp eq i32 %77, 1
br i1 %78, label %79, label %142
79: ; preds = %76
%80 = load i8*, i8** %12
%81 = getelementptr inbounds i8, i8* %80, i64 0
%82 = load i8, i8* %81
%83 = sext i8 %82 to i32
%84 = icmp eq i32 %83, 35
br i1 %84, label %85, label %86
85: ; preds = %79
br label %36
86: ; preds = %79
%87 = load i8*, i8** %12
%88 = getelementptr inbounds i8, i8* %87, i64 0
%89 = load i8, i8* %88
%90 = sext i8 %89 to i32
%91 = icmp eq i32 %90, 91
br i1 %91, label %92, label %93
92: ; preds = %86
br label %144
93: ; preds = %86
%94 = load i8*, i8** %12
%95 = call i64 @strchr(i8* %94, i8 signext 61)
%96 = inttoptr i64 %95 to i8*
store i8* %96, i8** %13
%97 = icmp eq i8* %96, null
br i1 %97, label %98, label %99
98: ; preds = %93
br label %36
99: ; preds = %93
%100 = getelementptr inbounds [32 x i8], [32 x i8]* %11, i64 0, i64 0
%101 = call i32 @memset(i8* %100, i32 0, i32 32)
%102 = load i8*, i8** %12
%103 = getelementptr inbounds [32 x i8], [32 x i8]* %11, i64 0, i64 0
%104 = call i32 @sscanf(i8* %102, i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.3, i64 0, i64 0), i8* %103)
%105 = getelementptr inbounds [32 x i8], [32 x i8]* %11, i64 0, i64 0
%106 = load i8*, i8** %8
%107 = call i64 @strcmp(i8* %105, i8* %106)
%108 = icmp eq i64 %107, 0
br i1 %108, label %109, label %141
109: ; preds = %99
%110 = load i8*, i8** %13
%111 = getelementptr inbounds i8, i8* %110, i32 1
store i8* %111, i8** %13
%112 = load i8*, i8** %9
%113 = call i32 @sscanf(i8* %111, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.4, i64 0, i64 0), i8* %112)
%114 = load i8*, i8** %9
%115 = call i64 @strlen(i8* %114)
%116 = add nsw i64 %115, 1
%117 = call i64 @malloc(i64 %116)
%118 = inttoptr i64 %117 to i8*
store i8* %118, i8** %18
%119 = load i8*, i8** %18
%120 = icmp ne i8* %119, null
br i1 %120, label %121, label %140
121: ; preds = %109
%122 = load i8*, i8** %18
%123 = call i32 @memset(i8* %122, i32 0, i32 8)
%124 = load i8*, i8** %18
%125 = load i8*, i8** %9
%126 = call i32 @a_trim(i8* %124, i8* %125)
%127 = load i8*, i8** %18
%128 = icmp ne i8* %127, null
br i1 %128, label %129, label %137
129: ; preds = %121
%130 = load i8*, i8** %18
%131 = call i64 @strlen(i8* %130)
%132 = icmp sgt i64 %131, 0
br i1 %132, label %133, label %137
133: ; preds = %129
%134 = load i8*, i8** %9
%135 = load i8*, i8** %18
%136 = call i32 @strcpy(i8* %134, i8* %135)
br label %137
137: ; preds = %133, %129, %121
%138 = load i8*, i8** %18
%139 = call i32 @free(i8* %138)
store i8* null, i8** %18
br label %140
140: ; preds = %137, %109
store i32 2, i32* %17
br label %144
141: ; preds = %99
br label %36
142: ; preds = %76
br label %143
143: ; preds = %142, %75
br label %36
144: ; preds = %140, %92, %45
%145 = load i32*, i32** %16
%146 = call i32 @fclose(i32* %145)
%147 = load i32, i32* %17
%148 = icmp eq i32 %147, 2
br i1 %148, label %149, label %150
149: ; preds = %144
store i32 0, i32* %5
br label %151
150: ; preds = %144
store i32 -1, i32* %5
br label %151
151: ; preds = %150, %149, %22
%152 = load i32, i32* %5
ret i32 %152
}

LLVM IR (-O2):
@.str = [2 x i8] c"r\00"
@.str.1 = [26 x i8] c"openfile [%s] error [%s]\0A\00"
@errno = global i32 0
@SEEK_SET = global i32 0
@.str.2 = [5 x i8] c"[%s]\00"
@.str.3 = [12 x i8] c"%[^=|^ |^\09]\00"
@.str.4 = [6 x i8] c"%[^\0A]\00"
define i32 @GetProfileString(i8* %0, i8* %1, i8* %2, i8* %3) {
%5 = alloca [32 x i8]
%6 = alloca [32 x i8]
%7 = alloca [100 x i8]
%8 = alloca [100 x i8]
%9 = getelementptr inbounds [32 x i8], [32 x i8]* %5, i64 0, i64 0
%10 = getelementptr inbounds [32 x i8], [32 x i8]* %6, i64 0, i64 0
%11 = getelementptr inbounds [100 x i8], [100 x i8]* %7, i64 0, i64 0
%12 = getelementptr inbounds [100 x i8], [100 x i8]* %8, i64 0, i64 0
%13 = tail call i32* @fopen(i8* %0, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
%14 = icmp eq i32* %13, null
br i1 %14, label %15, label %19
15: ; preds = %4
%16 = load i32, i32* @errno
%17 = tail call i8* @strerror(i32 %16)
%18 = tail call i32 @printf(i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str.1, i64 0, i64 0), i8* %0, i8* %17)
br label %81
19: ; preds = %4
%20 = load i32, i32* @SEEK_SET
%21 = tail call i32 @fseek(i32* %13, i32 0, i32 %20)
%22 = call i32 @memset(i8* %9, i32 0, i32 32)
%23 = call i32 @sprintf(i8* %9, i8* dereferenceable(1) getelementptr inbounds ([5 x i8], [5 x i8]* @.str.2, i64 0, i64 0), i8* %1)
br label %24
24: ; preds = %41, %19
%25 = phi i32 [ 0, %19 ], [ %42, %41 ]
br label %26
26: ; preds = %24, %32
%27 = call i32 @feof(i32* %13)
%28 = icmp eq i32 %27, 0
br i1 %28, label %29, label %77
29: ; preds = %26
%30 = call i32* @fgets(i8* %11, i32 100, i32* %13)
%31 = icmp eq i32* %30, null
br i1 %31, label %77, label %32
32: ; preds = %29
%33 = call i32 @l_trim(i8* %12, i8* %11)
%34 = call i64 @strlen(i8* %12)
%35 = icmp slt i64 %34, 1
br i1 %35, label %26, label %36
36: ; preds = %32
%37 = icmp eq i32 %25, 0
%38 = load i8, i8* %12
br i1 %37, label %39, label %48
39: ; preds = %36
%40 = icmp eq i8 %38, 91
br i1 %40, label %43, label %41
41: ; preds = %39, %48, %51, %54, %43
%42 = phi i32 [ %47, %43 ], [ 1, %54 ], [ 1, %51 ], [ 1, %48 ], [ 0, %39 ]
br label %24
43: ; preds = %39
%44 = call i64 @strlen(i8* %9)
%45 = call i64 @strncmp(i8* %12, i8* %9, i64 %44)
%46 = icmp eq i64 %45, 0
%47 = zext i1 %46 to i32
br label %41
48: ; preds = %36
switch i8 %38, label %51 [
i8 35, label %41
i8 91, label %49
]
49: ; preds = %48
%50 = call i32 @fclose(i32* %13)
br label %81
51: ; preds = %48
%52 = call i64 @strchr(i8* %12, i8 signext 61)
%53 = icmp eq i64 %52, 0
br i1 %53, label %41, label %54
54: ; preds = %51
%55 = call i32 @memset(i8* %10, i32 0, i32 32)
%56 = call i32 @sscanf(i8* %12, i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.3, i64 0, i64 0), i8* %10)
%57 = call i64 @strcmp(i8* %10, i8* %2)
%58 = icmp eq i64 %57, 0
br i1 %58, label %59, label %41
59: ; preds = %54
%60 = inttoptr i64 %52 to i8*
%61 = getelementptr inbounds i8, i8* %60, i64 1
%62 = call i32 @sscanf(i8* %61, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.4, i64 0, i64 0), i8* %3)
%63 = call i64 @strlen(i8* dereferenceable(1) %3)
%64 = add nsw i64 %63, 1
%65 = call i64 @malloc(i64 %64)
%66 = inttoptr i64 %65 to i8*
%67 = icmp eq i64 %65, 0
br i1 %67, label %79, label %68
68: ; preds = %59
%69 = call i32 @memset(i8* %66, i32 0, i32 8)
%70 = call i32 @a_trim(i8* %66, i8* %3)
%71 = call i64 @strlen(i8* %66)
%72 = icmp sgt i64 %71, 0
br i1 %72, label %73, label %75
73: ; preds = %68
%74 = call i32 @strcpy(i8* %3, i8* %66)
br label %75
75: ; preds = %73, %68
%76 = call i32 @free(i8* %66)
br label %79
77: ; preds = %26, %29
%78 = call i32 @fclose(i32* %13)
br label %81
79: ; preds = %59, %75
%80 = call i32 @fclose(i32* %13)
br label %81
81: ; preds = %77, %79, %49, %15
%82 = phi i32 [ -1, %15 ], [ 0, %79 ], [ -1, %77 ], [ -1, %49 ]
ret i32 %82
}