#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 */
struct htrace_log {
  int dummy;
};

/* Variables and functions */
int /*<<< orphan*/ append_char(char **, int *, char);
int /*<<< orphan*/ free(char *);
int /*<<< orphan*/ handle_process_subst_var(struct htrace_log *, char **,
                                            char *, char const *);
int /*<<< orphan*/ htrace_log(struct htrace_log *, char *, char const *);
char *strdup(char *);
int strlen(char *);
char *calculate_tracer_id(struct htrace_log *lg, const char *fmt,
                          const char *tname) {
  int i = 0, j = 0, escaping = 0, v = 0;
  char *out = NULL, *var = NULL;
  out = strdup("");
  if (!out) {
    goto oom;
  }
  while (1) {
    char c = fmt[i++];
    if (c == '\0') {
      break;
    } else if (c == '\\') {
      if (!escaping) {
        escaping = 1;
        continue;
      }
    }
    switch (v) {
    case 0:
      if (c == '%') {
        if (!escaping) {
          if (!append_char(&var, &v, '%')) {
            goto oom;
          }
          continue;
        }
      }
      break;
    case 1:
      if (c == '{') {
        if (!escaping) {
          if (!append_char(&var, &v, '{')) {
            goto oom;
          }
          continue;
        }
      }
      if (!append_char(&out, &j, '%')) {
        goto oom;
      }
      break;
    default:
      if (c == '}') {
        if (!escaping) {
          if (!append_char(&var, &v, '}')) {
            goto oom;
          }
          var[v++] = '\0';
          if (!handle_process_subst_var(lg, &out, var, tname)) {
            goto oom;
          }
          free(var);
          var = NULL;
          j = strlen(out);
          v = 0;
          continue;
        }
      }
      escaping = 0;
      if (!append_char(&var, &v, c)) {
        goto oom;
      }
      continue;
    }
    escaping = 0;
    v = 0;
    if (!append_char(&out, &j, c)) {
      goto oom;
    }
  }
  out[j] = '\0';
  if (v > 0) {
    htrace_log(lg,
               "calculate_tracer_id(%s): unterminated process ID "
               "substitution variable at the end of the format string.",
               fmt);
  }
  free(var);
  return out;
oom:
  htrace_log(lg, "calculate_tracer_id(tname=%s): OOM\n", tname);
  free(out);
  free(var);
  return NULL;
}


x86 assembly (clang, -O0):
<calculate_tracer_id>:
push   %rbp
mov    %rsp,%rbp
sub    $0x50,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
mov    %rdx,-0x20(%rbp)
movl   $0x0,-0x24(%rbp)
movl   $0x0,-0x28(%rbp)
movl   $0x0,-0x2c(%rbp)
movl   $0x0,-0x30(%rbp)
movq   $0x0,-0x38(%rbp)
movq   $0x0,-0x40(%rbp)
lea    0xee4(%rip),%rdi
call   1070 <strdup@plt>
mov    %rax,-0x38(%rbp)
cmpq   $0x0,-0x38(%rbp)
jne    11c0 <calculate_tracer_id+0x60>
jmp    1427 <calculate_tracer_id+0x2c7>
jmp    11c5 <calculate_tracer_id+0x65>
mov    -0x18(%rbp),%rax
mov    -0x24(%rbp),%ecx
mov    %ecx,%edx
add    $0x1,%edx
mov    %edx,-0x24(%rbp)
movslq %ecx,%rcx
mov    (%rax,%rcx,1),%al
mov    %al,-0x41(%rbp)
movsbl -0x41(%rbp),%eax
cmp    $0x0,%eax
jne    11ef <calculate_tracer_id+0x8f>
jmp    13e7 <calculate_tracer_id+0x287>
movsbl -0x41(%rbp),%eax
cmp    $0x5c,%eax
jne    1217 <calculate_tracer_id+0xb7>
cmpl   $0x0,-0x2c(%rbp)
jne    1212 <calculate_tracer_id+0xb2>
movl   $0x1,-0x2c(%rbp)
jmp    11c5 <calculate_tracer_id+0x65>
jmp    1217 <calculate_tracer_id+0xb7>
jmp    121c <calculate_tracer_id+0xbc>
mov    -0x30(%rbp),%eax
mov    %eax,-0x48(%rbp)
test   %eax,%eax
je     1240 <calculate_tracer_id+0xe0>
jmp    122f <calculate_tracer_id+0xcf>
mov    -0x48(%rbp),%eax
sub    $0x1,%eax
je     1286 <calculate_tracer_id+0x126>
jmp    12ec <calculate_tracer_id+0x18c>
movsbl -0x41(%rbp),%eax
cmp    $0x25,%eax
jne    1281 <calculate_tracer_id+0x121>
cmpl   $0x0,-0x2c(%rbp)
jne    127c <calculate_tracer_id+0x11c>
lea    -0x40(%rbp),%rdi
lea    -0x30(%rbp),%rsi
mov    $0x25,%edx
call   1050 <append_char@plt>
cmp    $0x0,%eax
jne    1277 <calculate_tracer_id+0x117>
jmp    1427 <calculate_tracer_id+0x2c7>
jmp    11c5 <calculate_tracer_id+0x65>
jmp    1281 <calculate_tracer_id+0x121>
jmp    13b5 <calculate_tracer_id+0x255>
movsbl -0x41(%rbp),%eax
cmp    $0x7b,%eax
jne    12c7 <calculate_tracer_id+0x167>
cmpl   $0x0,-0x2c(%rbp)
jne    12c2 <calculate_tracer_id+0x162>
lea    -0x40(%rbp),%rdi
lea    -0x30(%rbp),%rsi
mov    $0x7b,%edx
call   1050 <append_char@plt>
cmp    $0x0,%eax
jne    12bd <calculate_tracer_id+0x15d>
jmp    1427 <calculate_tracer_id+0x2c7>
jmp    11c5 <calculate_tracer_id+0x65>
jmp    12c7 <calculate_tracer_id+0x167>
lea    -0x38(%rbp),%rdi
lea    -0x28(%rbp),%rsi
mov    $0x25,%edx
call   1050 <append_char@plt>
cmp    $0x0,%eax
jne    12e7 <calculate_tracer_id+0x187>
jmp    1427 <calculate_tracer_id+0x2c7>
jmp    13b5 <calculate_tracer_id+0x255>
movsbl -0x41(%rbp),%eax
cmp    $0x7d,%eax
jne    138a <calculate_tracer_id+0x22a>
cmpl   $0x0,-0x2c(%rbp)
jne    1385 <calculate_tracer_id+0x225>
lea    -0x40(%rbp),%rdi
lea    -0x30(%rbp),%rsi
mov    $0x7d,%edx
call   1050 <append_char@plt>
cmp    $0x0,%eax
jne    1323 <calculate_tracer_id+0x1c3>
jmp    1427 <calculate_tracer_id+0x2c7>
mov    -0x40(%rbp),%rax
mov    -0x30(%rbp),%ecx
mov    %ecx,%edx
add    $0x1,%edx
mov    %edx,-0x30(%rbp)
movslq %ecx,%rcx
movb   $0x0,(%rax,%rcx,1)
mov    -0x10(%rbp),%rdi
mov    -0x40(%rbp),%rdx
mov    -0x20(%rbp),%rcx
lea    -0x38(%rbp),%rsi
call   1060 <handle_process_subst_var@plt>
cmp    $0x0,%eax
jne    135c <calculate_tracer_id+0x1fc>
jmp    1427 <calculate_tracer_id+0x2c7>
mov    -0x40(%rbp),%rdi
call   1030 <free@plt>
movq   $0x0,-0x40(%rbp)
mov    -0x38(%rbp),%rdi
call   1040 <strlen@plt>
mov    %eax,-0x28(%rbp)
movl   $0x0,-0x30(%rbp)
jmp    11c5 <calculate_tracer_id+0x65>
jmp    138a <calculate_tracer_id+0x22a>
movl   $0x0,-0x2c(%rbp)
lea    -0x40(%rbp),%rdi
lea    -0x30(%rbp),%rsi
movsbl -0x41(%rbp),%edx
call   1050 <append_char@plt>
cmp    $0x0,%eax
jne    13b0 <calculate_tracer_id+0x250>
jmp    1427 <calculate_tracer_id+0x2c7>
jmp    11c5 <calculate_tracer_id+0x65>
movl   $0x0,-0x2c(%rbp)
movl   $0x0,-0x30(%rbp)
lea    -0x38(%rbp),%rdi
lea    -0x28(%rbp),%rsi
movsbl -0x41(%rbp),%edx
call   1050 <append_char@plt>
cmp    $0x0,%eax
jne    13e2 <calculate_tracer_id+0x282>
jmp    1427 <calculate_tracer_id+0x2c7>
jmp    11c5 <calculate_tracer_id+0x65>
mov    -0x38(%rbp),%rax
movslq -0x28(%rbp),%rcx
movb   $0x0,(%rax,%rcx,1)
cmpl   $0x0,-0x30(%rbp)
jle    1411 <calculate_tracer_id+0x2b1>
mov    -0x10(%rbp),%rdi
mov    -0x18(%rbp),%rdx
lea    0xbf4(%rip),%rsi
call   1080 <htrace_log@plt>
mov    -0x40(%rbp),%rdi
call   1030 <free@plt>
mov    -0x38(%rbp),%rax
mov    %rax,-0x8(%rbp)
jmp    1455 <calculate_tracer_id+0x2f5>
mov    -0x10(%rbp),%rdi
mov    -0x20(%rbp),%rdx
lea    0xc32(%rip),%rsi
call   1080 <htrace_log@plt>
mov    -0x38(%rbp),%rdi
call   1030 <free@plt>
mov    -0x40(%rbp),%rdi
call   1030 <free@plt>
movq   $0x0,-0x8(%rbp)
mov    -0x8(%rbp),%rax
add    $0x50,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<calculate_tracer_id>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x28,%rsp
mov    %rdx,%r15
mov    %rsi,%r14
mov    %rdi,%rbx
movl   $0x0,0x1c(%rsp)
movl   $0x0,0xc(%rsp)
movq   $0x0,0x10(%rsp)
lea    0xef4(%rip),%rdi
call   1070 <strdup@plt>
mov    %rax,0x20(%rsp)
test   %rax,%rax
je     12fd <calculate_tracer_id+0x19d>
mov    (%r14),%bpl
xor    %ecx,%ecx
test   %bpl,%bpl
je     1331 <calculate_tracer_id+0x1d1>
lea    0x1(%r14),%r12
lea    0xc(%rsp),%r13
jmp    1218 <calculate_tracer_id+0xb8>
lea    0x20(%rsp),%rdi
lea    0x1c(%rsp),%rsi
mov    $0x25,%edx
call   1050 <append_char@plt>
test   %eax,%eax
je     12fd <calculate_tracer_id+0x19d>
movl   $0x0,0xc(%rsp)
movsbl %bpl,%edx
lea    0x20(%rsp),%rdi
lea    0x1c(%rsp),%rsi
call   1050 <append_char@plt>
xor    %edx,%edx
test   %eax,%eax
je     12fd <calculate_tracer_id+0x19d>
movzbl (%r12),%ebp
add    $0x1,%r12
mov    %edx,%ecx
test   %bpl,%bpl
je     1327 <calculate_tracer_id+0x1c7>
test   %ecx,%ecx
jne    1227 <calculate_tracer_id+0xc7>
mov    $0x1,%edx
cmp    $0x5c,%bpl
je     1204 <calculate_tracer_id+0xa4>
mov    0xc(%rsp),%eax
cmp    $0x1,%eax
je     124d <calculate_tracer_id+0xed>
test   %eax,%eax
jne    126e <calculate_tracer_id+0x10e>
test   %ecx,%ecx
jne    11df <calculate_tracer_id+0x7f>
cmp    $0x25,%bpl
jne    11df <calculate_tracer_id+0x7f>
lea    0x10(%rsp),%rdi
mov    %r13,%rsi
mov    $0x25,%edx
jmp    11f5 <calculate_tracer_id+0x95>
test   %ecx,%ecx
jne    11c3 <calculate_tracer_id+0x63>
cmp    $0x7b,%bpl
jne    11c3 <calculate_tracer_id+0x63>
lea    0x10(%rsp),%rdi
mov    %r13,%rsi
mov    $0x7b,%edx
jmp    11f5 <calculate_tracer_id+0x95>
test   %ecx,%ecx
jne    12ec <calculate_tracer_id+0x18c>
cmp    $0x7d,%bpl
jne    12ec <calculate_tracer_id+0x18c>
lea    0x10(%rsp),%rdi
mov    %r13,%rsi
mov    $0x7d,%edx
call   1050 <append_char@plt>
test   %eax,%eax
je     12fd <calculate_tracer_id+0x19d>
mov    0x10(%rsp),%rax
movslq 0xc(%rsp),%rcx
lea    0x1(%rcx),%edx
mov    %edx,0xc(%rsp)
movb   $0x0,(%rax,%rcx,1)
mov    0x10(%rsp),%rdx
mov    %rbx,%rdi
lea    0x20(%rsp),%rsi
mov    %r15,%rcx
call   1060 <handle_process_subst_var@plt>
test   %eax,%eax
je     12fd <calculate_tracer_id+0x19d>
mov    0x10(%rsp),%rdi
call   1030 <free@plt>
movq   $0x0,0x10(%rsp)
mov    0x20(%rsp),%rdi
call   1040 <strlen@plt>
mov    %eax,0x1c(%rsp)
movl   $0x0,0xc(%rsp)
xor    %edx,%edx
jmp    1204 <calculate_tracer_id+0xa4>
movsbl %bpl,%edx
lea    0x10(%rsp),%rdi
mov    %r13,%rsi
jmp    11f5 <calculate_tracer_id+0x95>
lea    0xd64(%rip),%rsi
mov    %rbx,%rdi
mov    %r15,%rdx
call   1080 <htrace_log@plt>
mov    0x20(%rsp),%rdi
call   1030 <free@plt>
mov    0x10(%rsp),%rdi
call   1030 <free@plt>
xor    %eax,%eax
jmp    135d <calculate_tracer_id+0x1fd>
mov    0x20(%rsp),%rax
movslq 0x1c(%rsp),%rcx
movb   $0x0,(%rax,%rcx,1)
cmpl   $0x0,0xc(%rsp)
jle    134e <calculate_tracer_id+0x1ee>
lea    0xcbd(%rip),%rsi
mov    %rbx,%rdi
mov    %r14,%rdx
call   1080 <htrace_log@plt>
mov    0x10(%rsp),%rdi
call   1030 <free@plt>
mov    0x20(%rsp),%rax
add    $0x28,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
%struct.htrace_log = type { i32 }
@.str = [1 x i8] zeroinitializer
@.str.1 = [104 x i8] c"calculate_tracer_id(%s): unterminated process ID substitution variable at the end of the format string.\00"
@.str.2 = [36 x i8] c"calculate_tracer_id(tname=%s): OOM\0A\00"
define i8* @calculate_tracer_id(%struct.htrace_log* %0, i8* %1, i8* %2) {
%4 = alloca i8*
%5 = alloca %struct.htrace_log*
%6 = alloca i8*
%7 = alloca i8*
%8 = alloca i32
%9 = alloca i32
%10 = alloca i32
%11 = alloca i32
%12 = alloca i8*
%13 = alloca i8*
%14 = alloca i8
store %struct.htrace_log* %0, %struct.htrace_log** %5
store i8* %1, i8** %6
store i8* %2, i8** %7
store i32 0, i32* %8
store i32 0, i32* %9
store i32 0, i32* %10
store i32 0, i32* %11
store i8* null, i8** %12
store i8* null, i8** %13
%15 = call i8* @strdup(i8* getelementptr inbounds ([1 x i8], [1 x i8]* @.str, i64 0, i64 0))
store i8* %15, i8** %12
%16 = load i8*, i8** %12
%17 = icmp ne i8* %16, null
br i1 %17, label %19, label %18
18: ; preds = %3
br label %131
19: ; preds = %3
br label %20
20: ; preds = %19, %38, %54, %68, %98, %109, %115
%21 = load i8*, i8** %6
%22 = load i32, i32* %8
%23 = add nsw i32 %22, 1
store i32 %23, i32* %8
%24 = sext i32 %22 to i64
%25 = getelementptr inbounds i8, i8* %21, i64 %24
%26 = load i8, i8* %25
store i8 %26, i8* %14
%27 = load i8, i8* %14
%28 = sext i8 %27 to i32
%29 = icmp eq i32 %28, 0
br i1 %29, label %30, label %31
30: ; preds = %20
br label %116
31: ; preds = %20
%32 = load i8, i8* %14
%33 = sext i8 %32 to i32
%34 = icmp eq i32 %33, 92
br i1 %34, label %35, label %40
35: ; preds = %31
%36 = load i32, i32* %10
%37 = icmp ne i32 %36, 0
br i1 %37, label %39, label %38
38: ; preds = %35
store i32 1, i32* %10
br label %20
39: ; preds = %35
br label %40
40: ; preds = %39, %31
br label %41
41: ; preds = %40
%42 = load i32, i32* %11
switch i32 %42, label %75 [
i32 0, label %43
i32 1, label %57
]
43: ; preds = %41
%44 = load i8, i8* %14
%45 = sext i8 %44 to i32
%46 = icmp eq i32 %45, 37
br i1 %46, label %47, label %56
47: ; preds = %43
%48 = load i32, i32* %10
%49 = icmp ne i32 %48, 0
br i1 %49, label %55, label %50
50: ; preds = %47
%51 = call i32 @append_char(i8** %13, i32* %11, i8 signext 37)
%52 = icmp ne i32 %51, 0
br i1 %52, label %54, label %53
53: ; preds = %50
br label %131
54: ; preds = %50
br label %20
55: ; preds = %47
br label %56
56: ; preds = %55, %43
br label %110
57: ; preds = %41
%58 = load i8, i8* %14
%59 = sext i8 %58 to i32
%60 = icmp eq i32 %59, 123
br i1 %60, label %61, label %70
61: ; preds = %57
%62 = load i32, i32* %10
%63 = icmp ne i32 %62, 0
br i1 %63, label %69, label %64
64: ; preds = %61
%65 = call i32 @append_char(i8** %13, i32* %11, i8 signext 123)
%66 = icmp ne i32 %65, 0
br i1 %66, label %68, label %67
67: ; preds = %64
br label %131
68: ; preds = %64
br label %20
69: ; preds = %61
br label %70
70: ; preds = %69, %57
%71 = call i32 @append_char(i8** %12, i32* %9, i8 signext 37)
%72 = icmp ne i32 %71, 0
br i1 %72, label %74, label %73
73: ; preds = %70
br label %131
74: ; preds = %70
br label %110
75: ; preds = %41
%76 = load i8, i8* %14
%77 = sext i8 %76 to i32
%78 = icmp eq i32 %77, 125
br i1 %78, label %79, label %104
79: ; preds = %75
%80 = load i32, i32* %10
%81 = icmp ne i32 %80, 0
br i1 %81, label %103, label %82
82: ; preds = %79
%83 = call i32 @append_char(i8** %13, i32* %11, i8 signext 125)
%84 = icmp ne i32 %83, 0
br i1 %84, label %86, label %85
85: ; preds = %82
br label %131
86: ; preds = %82
%87 = load i8*, i8** %13
%88 = load i32, i32* %11
%89 = add nsw i32 %88, 1
store i32 %89, i32* %11
%90 = sext i32 %88 to i64
%91 = getelementptr inbounds i8, i8* %87, i64 %90
store i8 0, i8* %91
%92 = load %struct.htrace_log*, %struct.htrace_log** %5
%93 = load i8*, i8** %13
%94 = load i8*, i8** %7
%95 = call i32 @handle_process_subst_var(%struct.htrace_log* %92, i8** %12, i8* %93, i8* %94)
%96 = icmp ne i32 %95, 0
br i1 %96, label %98, label %97
97: ; preds = %86
br label %131
98: ; preds = %86
%99 = load i8*, i8** %13
%100 = call i32 @free(i8* %99)
store i8* null, i8** %13
%101 = load i8*, i8** %12
%102 = call i32 @strlen(i8* %101)
store i32 %102, i32* %9
store i32 0, i32* %11
br label %20
103: ; preds = %79
br label %104
104: ; preds = %103, %75
store i32 0, i32* %10
%105 = load i8, i8* %14
%106 = call i32 @append_char(i8** %13, i32* %11, i8 signext %105)
%107 = icmp ne i32 %106, 0
br i1 %107, label %109, label %108
108: ; preds = %104
br label %131
109: ; preds = %104
br label %20
110: ; preds = %74, %56
store i32 0, i32* %10
store i32 0, i32* %11
%111 = load i8, i8* %14
%112 = call i32 @append_char(i8** %12, i32* %9, i8 signext %111)
%113 = icmp ne i32 %112, 0
br i1 %113, label %115, label %114
114: ; preds = %110
br label %131
115: ; preds = %110
br label %20
116: ; preds = %30
%117 = load i8*, i8** %12
%118 = load i32, i32* %9
%119 = sext i32 %118 to i64
%120 = getelementptr inbounds i8, i8* %117, i64 %119
store i8 0, i8* %120
%121 = load i32, i32* %11
%122 = icmp sgt i32 %121, 0
br i1 %122, label %123, label %127
123: ; preds = %116
%124 = load %struct.htrace_log*, %struct.htrace_log** %5
%125 = load i8*, i8** %6
%126 = call i32 @htrace_log(%struct.htrace_log* %124, i8* getelementptr inbounds ([104 x i8], [104 x i8]* @.str.1, i64 0, i64 0), i8* %125)
br label %127
127: ; preds = %123, %116
%128 = load i8*, i8** %13
%129 = call i32 @free(i8* %128)
%130 = load i8*, i8** %12
store i8* %130, i8** %4
br label %139
131: ; preds = %114, %108, %97, %85, %73, %67, %53, %18
%132 = load %struct.htrace_log*, %struct.htrace_log** %5
%133 = load i8*, i8** %7
%134 = call i32 @htrace_log(%struct.htrace_log* %132, i8* getelementptr inbounds ([36 x i8], [36 x i8]* @.str.2, i64 0, i64 0), i8* %133)
%135 = load i8*, i8** %12
%136 = call i32 @free(i8* %135)
%137 = load i8*, i8** %13
%138 = call i32 @free(i8* %137)
store i8* null, i8** %4
br label %139
139: ; preds = %131, %127
%140 = load i8*, i8** %4
ret i8* %140
}

LLVM IR (-O2):
%struct.htrace_log = type { i32 }
@.str = [1 x i8] zeroinitializer
@.str.1 = [104 x i8] c"calculate_tracer_id(%s): unterminated process ID substitution variable at the end of the format string.\00"
@.str.2 = [36 x i8] c"calculate_tracer_id(tname=%s): OOM\0A\00"
define i8* @calculate_tracer_id(%struct.htrace_log* %0, i8* %1, i8* %2) {
%4 = alloca i32
%5 = alloca i32
%6 = alloca i8*
%7 = alloca i8*
%8 = bitcast i32* %4 to i8*
store i32 0, i32* %4
%9 = bitcast i32* %5 to i8*
store i32 0, i32* %5
%10 = bitcast i8** %6 to i8*
%11 = bitcast i8** %7 to i8*
store i8* null, i8** %7
%12 = tail call dereferenceable_or_null(1) i8* @strdup(i8* getelementptr inbounds ([1 x i8], [1 x i8]* @.str, i64 0, i64 0))
store i8* %12, i8** %6
%13 = icmp eq i8* %12, null
br i1 %13, label %89, label %14
14: ; preds = %3
%15 = load i8, i8* %1
%16 = icmp eq i8 %15, 0
br i1 %16, label %77, label %17
17: ; preds = %14, %67
%18 = phi i64 [ %69, %67 ], [ 1, %14 ]
%19 = phi i8 [ %71, %67 ], [ %15, %14 ]
%20 = phi i32 [ %68, %67 ], [ 0, %14 ]
%21 = icmp ne i8 %19, 92
%22 = icmp ne i32 %20, 0
%23 = or i1 %22, %21
br i1 %23, label %24, label %67
24: ; preds = %17
%25 = load i32, i32* %5
switch i32 %25, label %41 [
i32 0, label %26
i32 1, label %32
]
26: ; preds = %24
%27 = icmp ne i8 %19, 37
%28 = or i1 %22, %27
br i1 %28, label %64, label %29
29: ; preds = %26
%30 = call i32 @append_char(i8** %7, i32* %5, i8 signext 37)
%31 = icmp eq i32 %30, 0
br i1 %31, label %89, label %67
32: ; preds = %24
%33 = icmp ne i8 %19, 123
%34 = or i1 %22, %33
br i1 %34, label %38, label %35
35: ; preds = %32
%36 = call i32 @append_char(i8** %7, i32* %5, i8 signext 123)
%37 = icmp eq i32 %36, 0
br i1 %37, label %89, label %67
38: ; preds = %32
%39 = call i32 @append_char(i8** %6, i32* %4, i8 signext 37)
%40 = icmp eq i32 %39, 0
br i1 %40, label %89, label %64
41: ; preds = %24
%42 = icmp ne i8 %19, 125
%43 = or i1 %22, %42
br i1 %43, label %61, label %44
44: ; preds = %41
%45 = call i32 @append_char(i8** %7, i32* %5, i8 signext 125)
%46 = icmp eq i32 %45, 0
br i1 %46, label %89, label %47
47: ; preds = %44
%48 = load i8*, i8** %7
%49 = load i32, i32* %5
%50 = add nsw i32 %49, 1
store i32 %50, i32* %5
%51 = sext i32 %49 to i64
%52 = getelementptr inbounds i8, i8* %48, i64 %51
store i8 0, i8* %52
%53 = load i8*, i8** %7
%54 = call i32 @handle_process_subst_var(%struct.htrace_log* %0, i8** %6, i8* %53, i8* %2)
%55 = icmp eq i32 %54, 0
br i1 %55, label %89, label %56
56: ; preds = %47
%57 = load i8*, i8** %7
%58 = call i32 @free(i8* %57)
store i8* null, i8** %7
%59 = load i8*, i8** %6
%60 = call i32 @strlen(i8* %59)
store i32 %60, i32* %4
store i32 0, i32* %5
br label %67
61: ; preds = %41
%62 = call i32 @append_char(i8** %7, i32* %5, i8 signext %19)
%63 = icmp eq i32 %62, 0
br i1 %63, label %89, label %67
64: ; preds = %38, %26
store i32 0, i32* %5
%65 = call i32 @append_char(i8** %6, i32* %4, i8 signext %19)
%66 = icmp eq i32 %65, 0
br i1 %66, label %89, label %67
67: ; preds = %64, %61, %35, %29, %17, %56
%68 = phi i32 [ 0, %56 ], [ 1, %17 ], [ 0, %29 ], [ 0, %35 ], [ 0, %61 ], [ 0, %64 ]
%69 = add nuw i64 %18, 1
%70 = getelementptr inbounds i8, i8* %1, i64 %18
%71 = load i8, i8* %70
%72 = icmp eq i8 %71, 0
br i1 %72, label %73, label %17
73: ; preds = %67
%74 = load i8*, i8** %6
%75 = load i32, i32* %4
%76 = sext i32 %75 to i64
br label %77
77: ; preds = %73, %14
%78 = phi i64 [ %76, %73 ], [ 0, %14 ]
%79 = phi i8* [ %74, %73 ], [ %12, %14 ]
%80 = getelementptr inbounds i8, i8* %79, i64 %78
store i8 0, i8* %80
%81 = load i32, i32* %5
%82 = icmp sgt i32 %81, 0
br i1 %82, label %83, label %85
83: ; preds = %77
%84 = call i32 @htrace_log(%struct.htrace_log* %0, i8* getelementptr inbounds ([104 x i8], [104 x i8]* @.str.1, i64 0, i64 0), i8* %1)
br label %85
85: ; preds = %83, %77
%86 = load i8*, i8** %7
%87 = call i32 @free(i8* %86)
%88 = load i8*, i8** %6
br label %95
89: ; preds = %64, %61, %35, %29, %47, %44, %38, %3
%90 = call i32 @htrace_log(%struct.htrace_log* %0, i8* getelementptr inbounds ([36 x i8], [36 x i8]* @.str.2, i64 0, i64 0), i8* %2)
%91 = load i8*, i8** %6
%92 = call i32 @free(i8* %91)
%93 = load i8*, i8** %7
%94 = call i32 @free(i8* %93)
br label %95
95: ; preds = %89, %85
%96 = phi i8* [ null, %89 ], [ %88, %85 ]
ret i8* %96
}