#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*/ assert(int);
int /*<<< orphan*/ fclose(int /*<<< orphan*/ *);
int /*<<< orphan*/ *fopen(char const *, char *);
int fputs(char *, int /*<<< orphan*/ *);
int /*<<< orphan*/ load_ini_file(char const *, char *, int *);
int /*<<< orphan*/ memcpy(char *, char const *, int);
int /*<<< orphan*/ parse_file(char const *, char const *, char *, int *, int *,
                              int *, int *, int *, int *);
int /*<<< orphan*/ sprintf(char *, char *, ...);
int strlen(char const *);
int write_profile_string(const char *section, const char *key,
                         const char *value, const char *file) {
  char buf[1024 * 16] = {0};
  char w_buf[1024 * 16] = {0};
  int sec_s, sec_e, key_s, key_e, value_s, value_e;
  int value_len = (int)strlen(value);
  int file_size;
  FILE *out;
  assert(section != NULL && strlen(section));
  assert(key != NULL && strlen(key));
  assert(value != NULL);
  assert(file != NULL && strlen(key));
  if (!load_ini_file(file, buf, &file_size)) {
    sec_s = -1;
  } else {
    parse_file(section, key, buf, &sec_s, &sec_e, &key_s, &key_e, &value_s,
               &value_e);
  }
  if (-1 == sec_s) {
    if (0 == file_size) {
      sprintf(w_buf + file_size, "[%s]\n%s=%s\n", section, key, value);
    } else {
      memcpy(w_buf, buf, file_size);
      sprintf(w_buf + file_size, "\n[%s]\n%s=%s\n", section, key, value);
    }
  } else if (-1 == key_s) {
    memcpy(w_buf, buf, sec_e);
    sprintf(w_buf + sec_e, "%s=%s\n", key, value);
    sprintf(w_buf + sec_e + strlen(key) + strlen(value) + 2, buf + sec_e,
            file_size - sec_e);
  } else {
    memcpy(w_buf, buf, value_s);
    memcpy(w_buf + value_s, value, value_len);
    memcpy(w_buf + value_s + value_len, buf + value_e, file_size - value_e);
  }
  out = fopen(file, "w");
  if (NULL == out) {
    return 0;
  }
  if (-1 == fputs(w_buf, out)) {
    fclose(out);
    return 0;
  }
  fclose(out);
  return 1;
}


x86 assembly (clang, -O0):
<write_profile_string>:
push   %rbp
mov    %rsp,%rbp
sub    $0x8090,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
mov    %rdx,-0x20(%rbp)
mov    %rcx,-0x28(%rbp)
lea    -0x4030(%rbp),%rdi
xor    %esi,%esi
mov    $0x4000,%edx
call   1070 <memset@plt>
lea    -0x8030(%rbp),%rdi
xor    %esi,%esi
mov    $0x4000,%edx
call   1070 <memset@plt>
mov    -0x20(%rbp),%rdi
call   1050 <strlen@plt>
mov    %eax,-0x804c(%rbp)
xor    %eax,%eax
cmpq   $0x0,-0x10(%rbp)
mov    %al,-0x8059(%rbp)
je     1218 <write_profile_string+0x78>
mov    -0x10(%rbp),%rdi
call   1050 <strlen@plt>
cmp    $0x0,%eax
setne  %al
mov    %al,-0x8059(%rbp)
mov    -0x8059(%rbp),%al
and    $0x1,%al
movzbl %al,%edi
call   1080 <assert@plt>
xor    %eax,%eax
cmpq   $0x0,-0x18(%rbp)
mov    %al,-0x805a(%rbp)
je     1250 <write_profile_string+0xb0>
mov    -0x18(%rbp),%rdi
call   1050 <strlen@plt>
cmp    $0x0,%eax
setne  %al
mov    %al,-0x805a(%rbp)
mov    -0x805a(%rbp),%al
and    $0x1,%al
movzbl %al,%edi
call   1080 <assert@plt>
cmpq   $0x0,-0x20(%rbp)
setne  %al
and    $0x1,%al
movzbl %al,%edi
call   1080 <assert@plt>
xor    %eax,%eax
cmpq   $0x0,-0x28(%rbp)
mov    %al,-0x805b(%rbp)
je     129a <write_profile_string+0xfa>
mov    -0x18(%rbp),%rdi
call   1050 <strlen@plt>
cmp    $0x0,%eax
setne  %al
mov    %al,-0x805b(%rbp)
mov    -0x805b(%rbp),%al
and    $0x1,%al
movzbl %al,%edi
call   1080 <assert@plt>
mov    -0x28(%rbp),%rdi
lea    -0x4030(%rbp),%rsi
lea    -0x8050(%rbp),%rdx
call   1030 <load_ini_file@plt>
cmp    $0x0,%eax
jne    12d9 <write_profile_string+0x139>
movl   $0xffffffff,-0x8034(%rbp)
ff ff ff
jmp    1325 <write_profile_string+0x185>
mov    -0x10(%rbp),%rdi
mov    -0x18(%rbp),%rsi
lea    -0x4030(%rbp),%rdx
lea    -0x8034(%rbp),%rcx
lea    -0x8038(%rbp),%r8
lea    -0x803c(%rbp),%r9
lea    -0x8040(%rbp),%r11
lea    -0x8044(%rbp),%r10
lea    -0x8048(%rbp),%rax
mov    %r11,(%rsp)
mov    %r10,0x8(%rsp)
mov    %rax,0x10(%rsp)
call   10b0 <parse_file@plt>
mov    $0xffffffff,%eax
cmp    -0x8034(%rbp),%eax
jne    13bd <write_profile_string+0x21d>
xor    %eax,%eax
cmp    -0x8050(%rbp),%eax
jne    1374 <write_profile_string+0x1d4>
lea    -0x8030(%rbp),%rdi
movslq -0x8050(%rbp),%rax
add    %rax,%rdi
mov    -0x10(%rbp),%rdx
mov    -0x18(%rbp),%rcx
mov    -0x20(%rbp),%r8
lea    0xc99(%rip),%rsi
mov    $0x0,%al
call   10c0 <sprintf@plt>
jmp    13b8 <write_profile_string+0x218>
lea    -0x8030(%rbp),%rdi
lea    -0x4030(%rbp),%rsi
mov    -0x8050(%rbp),%edx
call   1090 <memcpy@plt>
lea    -0x8030(%rbp),%rdi
movslq -0x8050(%rbp),%rax
add    %rax,%rdi
mov    -0x10(%rbp),%rdx
mov    -0x18(%rbp),%rcx
mov    -0x20(%rbp),%r8
lea    0xc4f(%rip),%rsi
mov    $0x0,%al
call   10c0 <sprintf@plt>
jmp    1502 <write_profile_string+0x362>
mov    $0xffffffff,%eax
cmp    -0x803c(%rbp),%eax
jne    1487 <write_profile_string+0x2e7>
lea    -0x8030(%rbp),%rdi
lea    -0x4030(%rbp),%rsi
mov    -0x8038(%rbp),%edx
call   1090 <memcpy@plt>
lea    -0x8030(%rbp),%rdi
movslq -0x8038(%rbp),%rax
add    %rax,%rdi
mov    -0x18(%rbp),%rdx
mov    -0x20(%rbp),%rcx
lea    0xbff(%rip),%rsi
mov    $0x0,%al
call   10c0 <sprintf@plt>
lea    -0x8030(%rbp),%rax
movslq -0x8038(%rbp),%rcx
add    %rcx,%rax
mov    %rax,-0x8070(%rbp)
mov    -0x18(%rbp),%rdi
call   1050 <strlen@plt>
mov    %eax,%ecx
mov    -0x8070(%rbp),%rax
movslq %ecx,%rcx
add    %rcx,%rax
mov    %rax,-0x8068(%rbp)
mov    -0x20(%rbp),%rdi
call   1050 <strlen@plt>
mov    -0x8068(%rbp),%rdi
cltq
add    %rax,%rdi
add    $0x2,%rdi
lea    -0x4030(%rbp),%rsi
movslq -0x8038(%rbp),%rax
add    %rax,%rsi
mov    -0x8050(%rbp),%edx
sub    -0x8038(%rbp),%edx
mov    $0x0,%al
call   10c0 <sprintf@plt>
jmp    14fd <write_profile_string+0x35d>
lea    -0x8030(%rbp),%rdi
lea    -0x4030(%rbp),%rsi
mov    -0x8044(%rbp),%edx
call   1090 <memcpy@plt>
lea    -0x8030(%rbp),%rdi
movslq -0x8044(%rbp),%rax
add    %rax,%rdi
mov    -0x20(%rbp),%rsi
mov    -0x804c(%rbp),%edx
call   1090 <memcpy@plt>
lea    -0x8030(%rbp),%rdi
movslq -0x8044(%rbp),%rax
add    %rax,%rdi
movslq -0x804c(%rbp),%rax
add    %rax,%rdi
lea    -0x4030(%rbp),%rsi
movslq -0x8048(%rbp),%rax
add    %rax,%rsi
mov    -0x8050(%rbp),%edx
sub    -0x8048(%rbp),%edx
call   1090 <memcpy@plt>
jmp    1502 <write_profile_string+0x362>
mov    -0x28(%rbp),%rdi
lea    0xb00(%rip),%rsi
call   10a0 <fopen@plt>
mov    %rax,-0x8058(%rbp)
xor    %eax,%eax
cmp    -0x8058(%rbp),%rax
jne    1534 <write_profile_string+0x394>
movl   $0x0,-0x4(%rbp)
jmp    1581 <write_profile_string+0x3e1>
lea    -0x8030(%rbp),%rdi
mov    -0x8058(%rbp),%rsi
call   1060 <fputs@plt>
mov    %eax,%ecx
mov    $0xffffffff,%eax
cmp    %ecx,%eax
jne    156e <write_profile_string+0x3ce>
mov    -0x8058(%rbp),%rdi
call   1040 <fclose@plt>
movl   $0x0,-0x4(%rbp)
jmp    1581 <write_profile_string+0x3e1>
mov    -0x8058(%rbp),%rdi
call   1040 <fclose@plt>
movl   $0x1,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x8090,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<write_profile_string>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x8028,%rsp
mov    %rcx,%r14
mov    %rdx,%r15
mov    %rsi,%rbx
mov    %rdi,%r12
lea    0x4020(%rsp),%rdi
xor    %ebp,%ebp
mov    $0x4000,%edx
xor    %esi,%esi
call   1070 <memset@plt>
lea    0x20(%rsp),%rdi
mov    $0x4000,%edx
xor    %esi,%esi
call   1070 <memset@plt>
mov    %r15,%rdi
call   1050 <strlen@plt>
mov    %eax,%r13d
mov    $0x0,%edi
test   %r12,%r12
je     1209 <write_profile_string+0x69>
mov    %r12,%rdi
call   1050 <strlen@plt>
xor    %edi,%edi
test   %eax,%eax
setne  %dil
call   1080 <assert@plt>
test   %rbx,%rbx
je     1223 <write_profile_string+0x83>
mov    %rbx,%rdi
call   1050 <strlen@plt>
xor    %ebp,%ebp
test   %eax,%eax
setne  %bpl
mov    %ebp,%edi
call   1080 <assert@plt>
xor    %edi,%edi
test   %r15,%r15
setne  %dil
call   1080 <assert@plt>
test   %r14,%r14
je     124f <write_profile_string+0xaf>
mov    %rbx,%rdi
call   1050 <strlen@plt>
xor    %edi,%edi
test   %eax,%eax
setne  %dil
jmp    1251 <write_profile_string+0xb1>
xor    %edi,%edi
call   1080 <assert@plt>
lea    0x4020(%rsp),%rsi
lea    0x4(%rsp),%rdx
mov    %r14,%rdi
call   1030 <load_ini_file@plt>
test   %eax,%eax
je     1322 <write_profile_string+0x182>
sub    $0x8,%rsp
lea    0x1c(%rsp),%rax
lea    0x14(%rsp),%rbp
lea    0x24(%rsp),%r10
lea    0x4028(%rsp),%rdx
lea    0x18(%rsp),%rcx
lea    0x10(%rsp),%r8
lea    0x20(%rsp),%r9
mov    %r12,%rdi
mov    %rbx,%rsi
push   %rax
push   %rbp
push   %r10
call   10b0 <parse_file@plt>
add    $0x20,%rsp
cmpl   $0xffffffff,0x10(%rsp)
je     132a <write_profile_string+0x18a>
cmpl   $0xffffffff,0x18(%rsp)
je     137b <write_profile_string+0x1db>
mov    0xc(%rsp),%edx
lea    0x20(%rsp),%rdi
lea    0x4020(%rsp),%rsi
call   1090 <memcpy@plt>
movslq 0xc(%rsp),%rax
lea    (%rsp,%rax,1),%rdi
add    $0x20,%rdi
mov    %r15,%rsi
mov    %r13d,%edx
call   1090 <memcpy@plt>
movslq 0xc(%rsp),%rax
add    %rsp,%rax
add    $0x20,%rax
movslq %r13d,%rdi
add    %rax,%rdi
movslq 0x14(%rsp),%rax
lea    (%rsp,%rax,1),%rsi
add    $0x4020,%rsi
mov    0x4(%rsp),%edx
sub    %eax,%edx
call   1090 <memcpy@plt>
jmp    13fc <write_profile_string+0x25c>
movl   $0xffffffff,0x10(%rsp)
ff
mov    0x4(%rsp),%edx
test   %edx,%edx
je     135a <write_profile_string+0x1ba>
lea    0x20(%rsp),%rdi
lea    0x4020(%rsp),%rsi
call   1090 <memcpy@plt>
movslq 0x4(%rsp),%rax
lea    (%rsp,%rax,1),%rdi
add    $0x20,%rdi
lea    0xca8(%rip),%rsi
jmp    1366 <write_profile_string+0x1c6>
lea    0xca0(%rip),%rsi
lea    0x20(%rsp),%rdi
mov    %r12,%rdx
mov    %rbx,%rcx
mov    %r15,%r8
xor    %eax,%eax
call   10c0 <sprintf@plt>
jmp    13fc <write_profile_string+0x25c>
mov    0x8(%rsp),%edx
lea    0x20(%rsp),%rdi
lea    0x4020(%rsp),%rsi
call   1090 <memcpy@plt>
movslq 0x8(%rsp),%rax
lea    (%rsp,%rax,1),%rdi
add    $0x20,%rdi
lea    0xc61(%rip),%rsi
mov    %rbx,%rdx
mov    %r15,%rcx
xor    %eax,%eax
call   10c0 <sprintf@plt>
movslq 0x8(%rsp),%rax
lea    (%rsp,%rax,1),%rbp
add    $0x20,%rbp
mov    %rbx,%rdi
call   1050 <strlen@plt>
movslq %eax,%rbx
add    %rbp,%rbx
mov    %r15,%rdi
call   1050 <strlen@plt>
cltq
lea    (%rax,%rbx,1),%rdi
add    $0x2,%rdi
movslq 0x8(%rsp),%rax
lea    (%rsp,%rax,1),%rsi
add    $0x4020,%rsi
mov    0x4(%rsp),%edx
sub    %eax,%edx
xor    %eax,%eax
call   10c0 <sprintf@plt>
lea    0xc0a(%rip),%rsi
mov    %r14,%rdi
call   10a0 <fopen@plt>
test   %rax,%rax
je     1433 <write_profile_string+0x293>
mov    %rax,%rbx
lea    0x20(%rsp),%rdi
mov    %rax,%rsi
call   1060 <fputs@plt>
xor    %ebp,%ebp
cmp    $0xffffffff,%eax
setne  %bpl
mov    %rbx,%rdi
call   1040 <fclose@plt>
jmp    1435 <write_profile_string+0x295>
xor    %ebp,%ebp
mov    %ebp,%eax
add    $0x8028,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [12 x i8] c"[%s]\0A%s=%s\0A\00"
@.str.1 = [13 x i8] c"\0A[%s]\0A%s=%s\0A\00"
@.str.2 = [7 x i8] c"%s=%s\0A\00"
@.str.3 = [2 x i8] c"w\00"
define i32 @write_profile_string(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 [16384 x i8]
%11 = alloca [16384 x i8]
%12 = alloca i32
%13 = alloca i32
%14 = alloca i32
%15 = alloca i32
%16 = alloca i32
%17 = alloca i32
%18 = alloca i32
%19 = alloca i32
%20 = alloca i32*
store i8* %0, i8** %6
store i8* %1, i8** %7
store i8* %2, i8** %8
store i8* %3, i8** %9
%21 = bitcast [16384 x i8]* %10 to i8*
%22 = bitcast [16384 x i8]* %11 to i8*
%23 = load i8*, i8** %8
%24 = call i32 @strlen(i8* %23)
store i32 %24, i32* %18
%25 = load i8*, i8** %6
%26 = icmp ne i8* %25, null
br i1 %26, label %27, label %31
27: ; preds = %4
%28 = load i8*, i8** %6
%29 = call i32 @strlen(i8* %28)
%30 = icmp ne i32 %29, 0
br label %31
31: ; preds = %27, %4
%32 = phi i1 [ false, %4 ], [ %30, %27 ]
%33 = zext i1 %32 to i32
%34 = call i32 @assert(i32 %33)
%35 = load i8*, i8** %7
%36 = icmp ne i8* %35, null
br i1 %36, label %37, label %41
37: ; preds = %31
%38 = load i8*, i8** %7
%39 = call i32 @strlen(i8* %38)
%40 = icmp ne i32 %39, 0
br label %41
41: ; preds = %37, %31
%42 = phi i1 [ false, %31 ], [ %40, %37 ]
%43 = zext i1 %42 to i32
%44 = call i32 @assert(i32 %43)
%45 = load i8*, i8** %8
%46 = icmp ne i8* %45, null
%47 = zext i1 %46 to i32
%48 = call i32 @assert(i32 %47)
%49 = load i8*, i8** %9
%50 = icmp ne i8* %49, null
br i1 %50, label %51, label %55
51: ; preds = %41
%52 = load i8*, i8** %7
%53 = call i32 @strlen(i8* %52)
%54 = icmp ne i32 %53, 0
br label %55
55: ; preds = %51, %41
%56 = phi i1 [ false, %41 ], [ %54, %51 ]
%57 = zext i1 %56 to i32
%58 = call i32 @assert(i32 %57)
%59 = load i8*, i8** %9
%60 = getelementptr inbounds [16384 x i8], [16384 x i8]* %10, i64 0, i64 0
%61 = call i32 @load_ini_file(i8* %59, i8* %60, i32* %19)
%62 = icmp ne i32 %61, 0
br i1 %62, label %64, label %63
63: ; preds = %55
store i32 -1, i32* %12
br label %69
64: ; preds = %55
%65 = load i8*, i8** %6
%66 = load i8*, i8** %7
%67 = getelementptr inbounds [16384 x i8], [16384 x i8]* %10, i64 0, i64 0
%68 = call i32 @parse_file(i8* %65, i8* %66, i8* %67, i32* %12, i32* %13, i32* %14, i32* %15, i32* %16, i32* %17)
br label %69
69: ; preds = %64, %63
%70 = load i32, i32* %12
%71 = icmp eq i32 -1, %70
br i1 %71, label %72, label %98
72: ; preds = %69
%73 = load i32, i32* %19
%74 = icmp eq i32 0, %73
br i1 %74, label %75, label %84
75: ; preds = %72
%76 = getelementptr inbounds [16384 x i8], [16384 x i8]* %11, i64 0, i64 0
%77 = load i32, i32* %19
%78 = sext i32 %77 to i64
%79 = getelementptr inbounds i8, i8* %76, i64 %78
%80 = load i8*, i8** %6
%81 = load i8*, i8** %7
%82 = load i8*, i8** %8
%83 = call i32 (i8*, i8*, ...) @sprintf(i8* %79, i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str, i64 0, i64 0), i8* %80, i8* %81, i8* %82)
br label %97
84: ; preds = %72
%85 = getelementptr inbounds [16384 x i8], [16384 x i8]* %11, i64 0, i64 0
%86 = getelementptr inbounds [16384 x i8], [16384 x i8]* %10, i64 0, i64 0
%87 = load i32, i32* %19
%88 = call i32 @memcpy(i8* %85, i8* %86, i32 %87)
%89 = getelementptr inbounds [16384 x i8], [16384 x i8]* %11, i64 0, i64 0
%90 = load i32, i32* %19
%91 = sext i32 %90 to i64
%92 = getelementptr inbounds i8, i8* %89, i64 %91
%93 = load i8*, i8** %6
%94 = load i8*, i8** %7
%95 = load i8*, i8** %8
%96 = call i32 (i8*, i8*, ...) @sprintf(i8* %92, i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.1, i64 0, i64 0), i8* %93, i8* %94, i8* %95)
br label %97
97: ; preds = %84, %75
br label %162
98: ; preds = %69
%99 = load i32, i32* %14
%100 = icmp eq i32 -1, %99
br i1 %100, label %101, label %134
101: ; preds = %98
%102 = getelementptr inbounds [16384 x i8], [16384 x i8]* %11, i64 0, i64 0
%103 = getelementptr inbounds [16384 x i8], [16384 x i8]* %10, i64 0, i64 0
%104 = load i32, i32* %13
%105 = call i32 @memcpy(i8* %102, i8* %103, i32 %104)
%106 = getelementptr inbounds [16384 x i8], [16384 x i8]* %11, i64 0, i64 0
%107 = load i32, i32* %13
%108 = sext i32 %107 to i64
%109 = getelementptr inbounds i8, i8* %106, i64 %108
%110 = load i8*, i8** %7
%111 = load i8*, i8** %8
%112 = call i32 (i8*, i8*, ...) @sprintf(i8* %109, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.2, i64 0, i64 0), i8* %110, i8* %111)
%113 = getelementptr inbounds [16384 x i8], [16384 x i8]* %11, i64 0, i64 0
%114 = load i32, i32* %13
%115 = sext i32 %114 to i64
%116 = getelementptr inbounds i8, i8* %113, i64 %115
%117 = load i8*, i8** %7
%118 = call i32 @strlen(i8* %117)
%119 = sext i32 %118 to i64
%120 = getelementptr inbounds i8, i8* %116, i64 %119
%121 = load i8*, i8** %8
%122 = call i32 @strlen(i8* %121)
%123 = sext i32 %122 to i64
%124 = getelementptr inbounds i8, i8* %120, i64 %123
%125 = getelementptr inbounds i8, i8* %124, i64 2
%126 = getelementptr inbounds [16384 x i8], [16384 x i8]* %10, i64 0, i64 0
%127 = load i32, i32* %13
%128 = sext i32 %127 to i64
%129 = getelementptr inbounds i8, i8* %126, i64 %128
%130 = load i32, i32* %19
%131 = load i32, i32* %13
%132 = sub nsw i32 %130, %131
%133 = call i32 (i8*, i8*, ...) @sprintf(i8* %125, i8* %129, i32 %132)
br label %161
134: ; preds = %98
%135 = getelementptr inbounds [16384 x i8], [16384 x i8]* %11, i64 0, i64 0
%136 = getelementptr inbounds [16384 x i8], [16384 x i8]* %10, i64 0, i64 0
%137 = load i32, i32* %16
%138 = call i32 @memcpy(i8* %135, i8* %136, i32 %137)
%139 = getelementptr inbounds [16384 x i8], [16384 x i8]* %11, i64 0, i64 0
%140 = load i32, i32* %16
%141 = sext i32 %140 to i64
%142 = getelementptr inbounds i8, i8* %139, i64 %141
%143 = load i8*, i8** %8
%144 = load i32, i32* %18
%145 = call i32 @memcpy(i8* %142, i8* %143, i32 %144)
%146 = getelementptr inbounds [16384 x i8], [16384 x i8]* %11, i64 0, i64 0
%147 = load i32, i32* %16
%148 = sext i32 %147 to i64
%149 = getelementptr inbounds i8, i8* %146, i64 %148
%150 = load i32, i32* %18
%151 = sext i32 %150 to i64
%152 = getelementptr inbounds i8, i8* %149, i64 %151
%153 = getelementptr inbounds [16384 x i8], [16384 x i8]* %10, i64 0, i64 0
%154 = load i32, i32* %17
%155 = sext i32 %154 to i64
%156 = getelementptr inbounds i8, i8* %153, i64 %155
%157 = load i32, i32* %19
%158 = load i32, i32* %17
%159 = sub nsw i32 %157, %158
%160 = call i32 @memcpy(i8* %152, i8* %156, i32 %159)
br label %161
161: ; preds = %134, %101
br label %162
162: ; preds = %161, %97
%163 = load i8*, i8** %9
%164 = call i32* @fopen(i8* %163, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.3, i64 0, i64 0))
store i32* %164, i32** %20
%165 = load i32*, i32** %20
%166 = icmp eq i32* null, %165
br i1 %166, label %167, label %168
167: ; preds = %162
store i32 0, i32* %5
br label %179
168: ; preds = %162
%169 = getelementptr inbounds [16384 x i8], [16384 x i8]* %11, i64 0, i64 0
%170 = load i32*, i32** %20
%171 = call i32 @fputs(i8* %169, i32* %170)
%172 = icmp eq i32 -1, %171
br i1 %172, label %173, label %176
173: ; preds = %168
%174 = load i32*, i32** %20
%175 = call i32 @fclose(i32* %174)
store i32 0, i32* %5
br label %179
176: ; preds = %168
%177 = load i32*, i32** %20
%178 = call i32 @fclose(i32* %177)
store i32 1, i32* %5
br label %179
179: ; preds = %176, %173, %167
%180 = load i32, i32* %5
ret i32 %180
}

LLVM IR (-O2):
@.str = [12 x i8] c"[%s]\0A%s=%s\0A\00"
@.str.1 = [13 x i8] c"\0A[%s]\0A%s=%s\0A\00"
@.str.2 = [7 x i8] c"%s=%s\0A\00"
@.str.3 = [2 x i8] c"w\00"
define i32 @write_profile_string(i8* %0, i8* %1, i8* %2, i8* %3) {
%5 = alloca [16384 x i8]
%6 = alloca [16384 x i8]
%7 = alloca i32
%8 = alloca i32
%9 = alloca i32
%10 = alloca i32
%11 = alloca i32
%12 = alloca i32
%13 = alloca i32
%14 = getelementptr inbounds [16384 x i8], [16384 x i8]* %5, i64 0, i64 0
%15 = getelementptr inbounds [16384 x i8], [16384 x i8]* %6, i64 0, i64 0
%16 = bitcast i32* %7 to i8*
%17 = bitcast i32* %8 to i8*
%18 = bitcast i32* %9 to i8*
%19 = bitcast i32* %10 to i8*
%20 = bitcast i32* %11 to i8*
%21 = bitcast i32* %12 to i8*
%22 = tail call i32 @strlen(i8* %2)
%23 = bitcast i32* %13 to i8*
%24 = icmp eq i8* %0, null
br i1 %24, label %29, label %25
25: ; preds = %4
%26 = tail call i32 @strlen(i8* %0)
%27 = icmp ne i32 %26, 0
%28 = zext i1 %27 to i32
br label %29
29: ; preds = %25, %4
%30 = phi i32 [ 0, %4 ], [ %28, %25 ]
%31 = tail call i32 @assert(i32 %30)
%32 = icmp eq i8* %1, null
br i1 %32, label %37, label %33
33: ; preds = %29
%34 = tail call i32 @strlen(i8* %1)
%35 = icmp ne i32 %34, 0
%36 = zext i1 %35 to i32
br label %37
37: ; preds = %33, %29
%38 = phi i32 [ 0, %29 ], [ %36, %33 ]
%39 = tail call i32 @assert(i32 %38)
%40 = icmp ne i8* %2, null
%41 = zext i1 %40 to i32
%42 = tail call i32 @assert(i32 %41)
%43 = icmp eq i8* %3, null
br i1 %43, label %48, label %44
44: ; preds = %37
%45 = tail call i32 @strlen(i8* %1)
%46 = icmp ne i32 %45, 0
%47 = zext i1 %46 to i32
br label %48
48: ; preds = %44, %37
%49 = phi i32 [ 0, %37 ], [ %47, %44 ]
%50 = tail call i32 @assert(i32 %49)
%51 = call i32 @load_ini_file(i8* %3, i8* %14, i32* %13)
%52 = icmp eq i32 %51, 0
br i1 %52, label %53, label %54
53: ; preds = %48
store i32 -1, i32* %7
br label %58
54: ; preds = %48
%55 = call i32 @parse_file(i8* %0, i8* %1, i8* %14, i32* %7, i32* %8, i32* %9, i32* %10, i32* %11, i32* %12)
%56 = load i32, i32* %7
%57 = icmp eq i32 %56, -1
br i1 %57, label %58, label %69
58: ; preds = %53, %54
%59 = load i32, i32* %13
%60 = icmp eq i32 %59, 0
br i1 %60, label %61, label %63
61: ; preds = %58
%62 = call i32 (i8*, i8*, ...) @sprintf(i8* %15, i8* dereferenceable(1) getelementptr inbounds ([12 x i8], [12 x i8]* @.str, i64 0, i64 0), i8* %0, i8* %1, i8* %2)
br label %113
63: ; preds = %58
%64 = call i32 @memcpy(i8* %15, i8* %14, i32 %59)
%65 = load i32, i32* %13
%66 = sext i32 %65 to i64
%67 = getelementptr inbounds [16384 x i8], [16384 x i8]* %6, i64 0, i64 %66
%68 = call i32 (i8*, i8*, ...) @sprintf(i8* %67, i8* dereferenceable(1) getelementptr inbounds ([13 x i8], [13 x i8]* @.str.1, i64 0, i64 0), i8* %0, i8* %1, i8* %2)
br label %113
69: ; preds = %54
%70 = load i32, i32* %9
%71 = icmp eq i32 %70, -1
br i1 %71, label %72, label %95
72: ; preds = %69
%73 = load i32, i32* %8
%74 = call i32 @memcpy(i8* %15, i8* %14, i32 %73)
%75 = load i32, i32* %8
%76 = sext i32 %75 to i64
%77 = getelementptr inbounds [16384 x i8], [16384 x i8]* %6, i64 0, i64 %76
%78 = call i32 (i8*, i8*, ...) @sprintf(i8* %77, i8* dereferenceable(1) getelementptr inbounds ([7 x i8], [7 x i8]* @.str.2, i64 0, i64 0), i8* %1, i8* %2)
%79 = load i32, i32* %8
%80 = sext i32 %79 to i64
%81 = getelementptr inbounds [16384 x i8], [16384 x i8]* %6, i64 0, i64 %80
%82 = call i32 @strlen(i8* %1)
%83 = sext i32 %82 to i64
%84 = getelementptr inbounds i8, i8* %81, i64 %83
%85 = call i32 @strlen(i8* %2)
%86 = sext i32 %85 to i64
%87 = getelementptr inbounds i8, i8* %84, i64 %86
%88 = getelementptr inbounds i8, i8* %87, i64 2
%89 = load i32, i32* %8
%90 = sext i32 %89 to i64
%91 = getelementptr inbounds [16384 x i8], [16384 x i8]* %5, i64 0, i64 %90
%92 = load i32, i32* %13
%93 = sub nsw i32 %92, %89
%94 = call i32 (i8*, i8*, ...) @sprintf(i8* %88, i8* %91, i32 %93)
br label %113
95: ; preds = %69
%96 = load i32, i32* %11
%97 = call i32 @memcpy(i8* %15, i8* %14, i32 %96)
%98 = load i32, i32* %11
%99 = sext i32 %98 to i64
%100 = getelementptr inbounds [16384 x i8], [16384 x i8]* %6, i64 0, i64 %99
%101 = call i32 @memcpy(i8* %100, i8* %2, i32 %22)
%102 = load i32, i32* %11
%103 = sext i32 %102 to i64
%104 = getelementptr inbounds [16384 x i8], [16384 x i8]* %6, i64 0, i64 %103
%105 = sext i32 %22 to i64
%106 = getelementptr inbounds i8, i8* %104, i64 %105
%107 = load i32, i32* %12
%108 = sext i32 %107 to i64
%109 = getelementptr inbounds [16384 x i8], [16384 x i8]* %5, i64 0, i64 %108
%110 = load i32, i32* %13
%111 = sub nsw i32 %110, %107
%112 = call i32 @memcpy(i8* %106, i8* %109, i32 %111)
br label %113
113: ; preds = %72, %95, %61, %63
%114 = call i32* @fopen(i8* %3, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.3, i64 0, i64 0))
%115 = icmp eq i32* %114, null
br i1 %115, label %121, label %116
116: ; preds = %113
%117 = call i32 @fputs(i8* %15, i32* %114)
%118 = icmp ne i32 %117, -1
%119 = call i32 @fclose(i32* %114)
%120 = zext i1 %118 to i32
br label %121
121: ; preds = %116, %113
%122 = phi i32 [ 0, %113 ], [ %120, %116 ]
ret i32 %122
}