#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*/ fprintf(int /*<<< orphan*/ *, char *, char const, char const,
                           char const, char const);
int /*<<< orphan*/ putc(unsigned int, int /*<<< orphan*/ *);
int strlen(char const *);
int /*<<< orphan*/ u8_mbtouc(unsigned int *, unsigned char const *, int);
void write_escaped_string(FILE *fp, const char *str, bool in_key) {
  static const char hexdigit[] = "0123456789abcdef";
  const char *str_limit = str + strlen(str);
  bool first = true;
  while (str < str_limit) {
    unsigned int uc;
    str += u8_mbtouc(&uc, (const unsigned char *)str, str_limit - str);
    if (uc == 0x0020 && (first || in_key)) {
      putc('\\', fp);
      putc(' ', fp);
    } else if (uc == 0x0009) {
      putc('\\', fp);
      putc('t', fp);
    } else if (uc == 0x000a) {
      putc('\\', fp);
      putc('n', fp);
    } else if (uc == 0x000d) {
      putc('\\', fp);
      putc('r', fp);
    } else if (uc == 0x000c) {
      putc('\\', fp);
      putc('f', fp);
    } else if (uc == '\\' || uc == '#' || uc == '!' || uc == '=' || uc == ':') {
      putc('\\', fp);
      putc(uc, fp);
    } else if (uc >= 0x0020 && uc <= 0x007e) {
      putc(uc, fp);
    } else if (uc < 0x10000) {
      fprintf(fp, "\\u%c%c%c%c", hexdigit[(uc >> 12) & 0x0f],
              hexdigit[(uc >> 8) & 0x0f], hexdigit[(uc >> 4) & 0x0f],
              hexdigit[uc & 0x0f]);
    } else {
      unsigned int uc1 = 0xd800 + ((uc - 0x10000) >> 10);
      unsigned int uc2 = 0xdc00 + ((uc - 0x10000) & 0x3ff);
      fprintf(fp, "\\u%c%c%c%c", hexdigit[(uc1 >> 12) & 0x0f],
              hexdigit[(uc1 >> 8) & 0x0f], hexdigit[(uc1 >> 4) & 0x0f],
              hexdigit[uc1 & 0x0f]);
      fprintf(fp, "\\u%c%c%c%c", hexdigit[(uc2 >> 12) & 0x0f],
              hexdigit[(uc2 >> 8) & 0x0f], hexdigit[(uc2 >> 4) & 0x0f],
              hexdigit[uc2 & 0x0f]);
    }
    first = false;
  }
}


x86 assembly (clang, -O0):
<write_escaped_string>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %edx,-0x14(%rbp)
mov    -0x10(%rbp),%rax
mov    %rax,-0x38(%rbp)
mov    -0x10(%rbp),%rdi
call   1030 <strlen@plt>
mov    %eax,%ecx
mov    -0x38(%rbp),%rax
movslq %ecx,%rcx
add    %rcx,%rax
mov    %rax,-0x20(%rbp)
movl   $0x1,-0x24(%rbp)
mov    -0x10(%rbp),%rax
cmp    -0x20(%rbp),%rax
jae    14e2 <write_escaped_string+0x3a2>
mov    -0x10(%rbp),%rsi
mov    -0x20(%rbp),%rax
mov    -0x10(%rbp),%rcx
sub    %rcx,%rax
mov    %eax,%edx
lea    -0x28(%rbp),%rdi
call   1060 <u8_mbtouc@plt>
mov    %eax,%ecx
mov    -0x10(%rbp),%rax
movslq %ecx,%rcx
add    %rcx,%rax
mov    %rax,-0x10(%rbp)
cmpl   $0x20,-0x28(%rbp)
jne    11f2 <write_escaped_string+0xb2>
cmpl   $0x0,-0x24(%rbp)
jne    11d1 <write_escaped_string+0x91>
cmpl   $0x0,-0x14(%rbp)
je     11f2 <write_escaped_string+0xb2>
mov    -0x8(%rbp),%rsi
mov    $0x5c,%edi
call   1040 <putc@plt>
mov    -0x8(%rbp),%rsi
mov    $0x20,%edi
call   1040 <putc@plt>
jmp    14d6 <write_escaped_string+0x396>
cmpl   $0x9,-0x28(%rbp)
jne    121d <write_escaped_string+0xdd>
mov    -0x8(%rbp),%rsi
mov    $0x5c,%edi
call   1040 <putc@plt>
mov    -0x8(%rbp),%rsi
mov    $0x74,%edi
call   1040 <putc@plt>
jmp    14d1 <write_escaped_string+0x391>
cmpl   $0xa,-0x28(%rbp)
jne    1248 <write_escaped_string+0x108>
mov    -0x8(%rbp),%rsi
mov    $0x5c,%edi
call   1040 <putc@plt>
mov    -0x8(%rbp),%rsi
mov    $0x6e,%edi
call   1040 <putc@plt>
jmp    14cc <write_escaped_string+0x38c>
cmpl   $0xd,-0x28(%rbp)
jne    1273 <write_escaped_string+0x133>
mov    -0x8(%rbp),%rsi
mov    $0x5c,%edi
call   1040 <putc@plt>
mov    -0x8(%rbp),%rsi
mov    $0x72,%edi
call   1040 <putc@plt>
jmp    14c7 <write_escaped_string+0x387>
cmpl   $0xc,-0x28(%rbp)
jne    129e <write_escaped_string+0x15e>
mov    -0x8(%rbp),%rsi
mov    $0x5c,%edi
call   1040 <putc@plt>
mov    -0x8(%rbp),%rsi
mov    $0x66,%edi
call   1040 <putc@plt>
jmp    14c2 <write_escaped_string+0x382>
cmpl   $0x5c,-0x28(%rbp)
je     12d0 <write_escaped_string+0x190>
cmpl   $0x23,-0x28(%rbp)
je     12d0 <write_escaped_string+0x190>
cmpl   $0x21,-0x28(%rbp)
je     12d0 <write_escaped_string+0x190>
cmpl   $0x3d,-0x28(%rbp)
je     12d0 <write_escaped_string+0x190>
cmpl   $0x3a,-0x28(%rbp)
jne    12ef <write_escaped_string+0x1af>
mov    -0x8(%rbp),%rsi
mov    $0x5c,%edi
call   1040 <putc@plt>
mov    -0x28(%rbp),%edi
mov    -0x8(%rbp),%rsi
call   1040 <putc@plt>
jmp    14bd <write_escaped_string+0x37d>
cmpl   $0x20,-0x28(%rbp)
jb     1314 <write_escaped_string+0x1d4>
cmpl   $0x7e,-0x28(%rbp)
ja     1314 <write_escaped_string+0x1d4>
mov    -0x28(%rbp),%edi
mov    -0x8(%rbp),%rsi
call   1040 <putc@plt>
jmp    14b8 <write_escaped_string+0x378>
cmpl   $0x10000,-0x28(%rbp)
jae    139d <write_escaped_string+0x25d>
mov    -0x8(%rbp),%rdi
mov    -0x28(%rbp),%eax
shr    $0xc,%eax
and    $0xf,%eax
mov    %eax,%eax
mov    %eax,%ecx
lea    0xcc7(%rip),%rax
mov    (%rax,%rcx,1),%dl
mov    -0x28(%rbp),%eax
shr    $0x8,%eax
and    $0xf,%eax
mov    %eax,%eax
mov    %eax,%ecx
lea    0xcb0(%rip),%rax
mov    (%rax,%rcx,1),%cl
mov    -0x28(%rbp),%eax
shr    $0x4,%eax
and    $0xf,%eax
mov    %eax,%eax
mov    %eax,%esi
lea    0xc99(%rip),%rax
mov    (%rax,%rsi,1),%r8b
mov    -0x28(%rbp),%eax
and    $0xf,%eax
mov    %eax,%eax
mov    %eax,%r9d
lea    0xc94(%rip),%rsi
lea    0xc7c(%rip),%rax
movsbl %dl,%edx
movsbl %cl,%ecx
movsbl %r8b,%r8d
movsbl (%rax,%r9,1),%r9d
call   1050 <fprintf@plt>
jmp    14b3 <write_escaped_string+0x373>
mov    -0x28(%rbp),%eax
sub    $0x10000,%eax
shr    $0xa,%eax
add    $0xd800,%eax
mov    %eax,-0x2c(%rbp)
mov    -0x28(%rbp),%eax
sub    $0x10000,%eax
and    $0x3ff,%eax
add    $0xdc00,%eax
mov    %eax,-0x30(%rbp)
mov    -0x8(%rbp),%rdi
mov    -0x2c(%rbp),%eax
shr    $0xc,%eax
and    $0xf,%eax
mov    %eax,%eax
mov    %eax,%ecx
lea    0xc23(%rip),%rax
mov    (%rax,%rcx,1),%dl
mov    -0x2c(%rbp),%eax
shr    $0x8,%eax
and    $0xf,%eax
mov    %eax,%eax
mov    %eax,%ecx
lea    0xc0c(%rip),%rax
mov    (%rax,%rcx,1),%cl
mov    -0x2c(%rbp),%eax
shr    $0x4,%eax
and    $0xf,%eax
mov    %eax,%eax
mov    %eax,%esi
lea    0xbf5(%rip),%rax
mov    (%rax,%rsi,1),%r8b
mov    -0x2c(%rbp),%eax
and    $0xf,%eax
mov    %eax,%eax
mov    %eax,%r9d
lea    0xbf0(%rip),%rsi
lea    0xbd8(%rip),%rax
movsbl %dl,%edx
movsbl %cl,%ecx
movsbl %r8b,%r8d
movsbl (%rax,%r9,1),%r9d
call   1050 <fprintf@plt>
mov    -0x8(%rbp),%rdi
mov    -0x30(%rbp),%eax
shr    $0xc,%eax
and    $0xf,%eax
mov    %eax,%eax
mov    %eax,%ecx
lea    0xbac(%rip),%rax
mov    (%rax,%rcx,1),%dl
mov    -0x30(%rbp),%eax
shr    $0x8,%eax
and    $0xf,%eax
mov    %eax,%eax
mov    %eax,%ecx
lea    0xb95(%rip),%rax
mov    (%rax,%rcx,1),%cl
mov    -0x30(%rbp),%eax
shr    $0x4,%eax
and    $0xf,%eax
mov    %eax,%eax
mov    %eax,%esi
lea    0xb7e(%rip),%rax
mov    (%rax,%rsi,1),%r8b
mov    -0x30(%rbp),%eax
and    $0xf,%eax
mov    %eax,%eax
mov    %eax,%r9d
lea    0xb79(%rip),%rsi
lea    0xb61(%rip),%rax
movsbl %dl,%edx
movsbl %cl,%ecx
movsbl %r8b,%r8d
movsbl (%rax,%r9,1),%r9d
call   1050 <fprintf@plt>
jmp    14b8 <write_escaped_string+0x378>
jmp    14bd <write_escaped_string+0x37d>
jmp    14c2 <write_escaped_string+0x382>
jmp    14c7 <write_escaped_string+0x387>
jmp    14cc <write_escaped_string+0x38c>
jmp    14d1 <write_escaped_string+0x391>
jmp    14d6 <write_escaped_string+0x396>
movl   $0x0,-0x24(%rbp)
jmp    117b <write_escaped_string+0x3b>
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<write_escaped_string>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
mov    %edx,0x4(%rsp)
mov    %rsi,%rbp
mov    %rdi,%r13
mov    %rsi,%rdi
call   1030 <strlen@plt>
test   %eax,%eax
jle    1338 <write_escaped_string+0x1f8>
movslq %eax,%r12
add    %rbp,%r12
mov    $0x1,%r15b
xchg   %ax,%ax
mov    %rbp,%rbx
cmpl   $0x0,0x4(%rsp)
sete   %r14b
mov    %r12d,%edx
sub    %ebx,%edx
mov    %rsp,%rdi
mov    %rbp,%rsi
call   1060 <u8_mbtouc@plt>
movslq %eax,%rbp
add    %rbx,%rbp
mov    (%rsp),%ebx
xor    $0x1,%r15b
test   %r15b,%r14b
jne    11c0 <write_escaped_string+0x80>
cmp    $0x20,%ebx
jne    11c0 <write_escaped_string+0x80>
mov    $0x5c,%edi
mov    %r13,%rsi
call   1040 <putc@plt>
mov    $0x20,%edi
jmp    11ec <write_escaped_string+0xac>
nopw   0x0(%rax,%rax,1)
lea    -0x9(%rbx),%eax
cmp    $0x53,%eax
ja     1255 <write_escaped_string+0x115>
lea    0xe2d(%rip),%rcx
movslq (%rcx,%rax,4),%rax
add    %rcx,%rax
jmp    *%rax
mov    $0x5c,%edi
mov    %r13,%rsi
call   1040 <putc@plt>
mov    (%rsp),%edi
mov    %r13,%rsi
call   1040 <putc@plt>
xor    %r15d,%r15d
cmp    %r12,%rbp
jb     1170 <write_escaped_string+0x30>
jmp    1338 <write_escaped_string+0x1f8>
mov    $0x5c,%edi
mov    %r13,%rsi
call   1040 <putc@plt>
mov    $0x74,%edi
jmp    11ec <write_escaped_string+0xac>
mov    $0x5c,%edi
mov    %r13,%rsi
call   1040 <putc@plt>
mov    $0x6e,%edi
jmp    11ec <write_escaped_string+0xac>
mov    $0x5c,%edi
mov    %r13,%rsi
call   1040 <putc@plt>
mov    $0x66,%edi
jmp    11ec <write_escaped_string+0xac>
mov    $0x5c,%edi
mov    %r13,%rsi
call   1040 <putc@plt>
mov    $0x72,%edi
jmp    11ec <write_escaped_string+0xac>
lea    -0x20(%rbx),%eax
cmp    $0x5e,%eax
ja     1261 <write_escaped_string+0x121>
mov    %ebx,%edi
jmp    11ec <write_escaped_string+0xac>
cmp    $0xffff,%ebx
ja     12ab <write_escaped_string+0x16b>
mov    %rbx,%rax
shr    $0xc,%rax
lea    0xed9(%rip),%rsi
movsbl (%rax,%rsi,1),%edx
mov    %ebx,%eax
shr    $0x8,%eax
and    $0xf,%eax
movsbl (%rax,%rsi,1),%ecx
mov    %ebx,%eax
shr    $0x4,%eax
and    $0xf,%eax
movsbl (%rax,%rsi,1),%r8d
and    $0xf,%ebx
movsbl (%rbx,%rsi,1),%r9d
mov    %r13,%rdi
lea    0xebb(%rip),%rsi
jmp    132e <write_escaped_string+0x1ee>
lea    -0x10000(%rbx),%eax
shr    $0xa,%eax
lea    0xd800(%rax),%esi
mov    %esi,%ecx
shr    $0xc,%ecx
and    $0xf,%ecx
lea    0xe87(%rip),%r14
movsbl (%rcx,%r14,1),%edx
mov    %esi,%ecx
shr    $0x8,%ecx
and    $0xf,%ecx
movsbl (%rcx,%r14,1),%ecx
shr    $0x4,%esi
and    $0xf,%esi
movsbl (%rsi,%r14,1),%r8d
and    $0xf,%eax
movsbl (%rax,%r14,1),%r9d
mov    %r13,%rdi
lea    0xe69(%rip),%r15
mov    %r15,%rsi
call   1050 <fprintf@plt>
mov    %ebx,%eax
shr    $0x8,%eax
and    $0x3,%eax
movsbl 0xc(%rax,%r14,1),%ecx
mov    %ebx,%eax
shr    $0x4,%eax
and    $0xf,%eax
movsbl (%rax,%r14,1),%r8d
and    $0xf,%ebx
movsbl (%rbx,%r14,1),%r9d
mov    %r13,%rdi
mov    %r15,%rsi
mov    $0x64,%edx
call   1050 <fprintf@plt>
jmp    11f4 <write_escaped_string+0xb4>
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@write_escaped_string.hexdigit = internal constant [17 x i8] c"0123456789abcdef\00"
@.str = [11 x i8] c"\\u%c%c%c%c\00"
define void @write_escaped_string(i32* %0, i8* %1, i32 %2) {
%4 = alloca i32*
%5 = alloca i8*
%6 = alloca i32
%7 = alloca i8*
%8 = alloca i32
%9 = alloca i32
%10 = alloca i32
%11 = alloca i32
store i32* %0, i32** %4
store i8* %1, i8** %5
store i32 %2, i32* %6
%12 = load i8*, i8** %5
%13 = load i8*, i8** %5
%14 = call i32 @strlen(i8* %13)
%15 = sext i32 %14 to i64
%16 = getelementptr inbounds i8, i8* %12, i64 %15
store i8* %16, i8** %7
store i32 1, i32* %8
br label %17
17: ; preds = %204, %3
%18 = load i8*, i8** %5
%19 = load i8*, i8** %7
%20 = icmp ult i8* %18, %19
br i1 %20, label %21, label %205
21: ; preds = %17
%22 = load i8*, i8** %5
%23 = load i8*, i8** %7
%24 = load i8*, i8** %5
%25 = ptrtoint i8* %23 to i64
%26 = ptrtoint i8* %24 to i64
%27 = sub i64 %25, %26
%28 = trunc i64 %27 to i32
%29 = call i32 @u8_mbtouc(i32* %9, i8* %22, i32 %28)
%30 = load i8*, i8** %5
%31 = sext i32 %29 to i64
%32 = getelementptr inbounds i8, i8* %30, i64 %31
store i8* %32, i8** %5
%33 = load i32, i32* %9
%34 = icmp eq i32 %33, 32
br i1 %34, label %35, label %46
35: ; preds = %21
%36 = load i32, i32* %8
%37 = icmp ne i32 %36, 0
br i1 %37, label %41, label %38
38: ; preds = %35
%39 = load i32, i32* %6
%40 = icmp ne i32 %39, 0
br i1 %40, label %41, label %46
41: ; preds = %38, %35
%42 = load i32*, i32** %4
%43 = call i32 @putc(i32 92, i32* %42)
%44 = load i32*, i32** %4
%45 = call i32 @putc(i32 32, i32* %44)
br label %204
46: ; preds = %38, %21
%47 = load i32, i32* %9
%48 = icmp eq i32 %47, 9
br i1 %48, label %49, label %54
49: ; preds = %46
%50 = load i32*, i32** %4
%51 = call i32 @putc(i32 92, i32* %50)
%52 = load i32*, i32** %4
%53 = call i32 @putc(i32 116, i32* %52)
br label %203
54: ; preds = %46
%55 = load i32, i32* %9
%56 = icmp eq i32 %55, 10
br i1 %56, label %57, label %62
57: ; preds = %54
%58 = load i32*, i32** %4
%59 = call i32 @putc(i32 92, i32* %58)
%60 = load i32*, i32** %4
%61 = call i32 @putc(i32 110, i32* %60)
br label %202
62: ; preds = %54
%63 = load i32, i32* %9
%64 = icmp eq i32 %63, 13
br i1 %64, label %65, label %70
65: ; preds = %62
%66 = load i32*, i32** %4
%67 = call i32 @putc(i32 92, i32* %66)
%68 = load i32*, i32** %4
%69 = call i32 @putc(i32 114, i32* %68)
br label %201
70: ; preds = %62
%71 = load i32, i32* %9
%72 = icmp eq i32 %71, 12
br i1 %72, label %73, label %78
73: ; preds = %70
%74 = load i32*, i32** %4
%75 = call i32 @putc(i32 92, i32* %74)
%76 = load i32*, i32** %4
%77 = call i32 @putc(i32 102, i32* %76)
br label %200
78: ; preds = %70
%79 = load i32, i32* %9
%80 = icmp eq i32 %79, 92
br i1 %80, label %93, label %81
81: ; preds = %78
%82 = load i32, i32* %9
%83 = icmp eq i32 %82, 35
br i1 %83, label %93, label %84
84: ; preds = %81
%85 = load i32, i32* %9
%86 = icmp eq i32 %85, 33
br i1 %86, label %93, label %87
87: ; preds = %84
%88 = load i32, i32* %9
%89 = icmp eq i32 %88, 61
br i1 %89, label %93, label %90
90: ; preds = %87
%91 = load i32, i32* %9
%92 = icmp eq i32 %91, 58
br i1 %92, label %93, label %99
93: ; preds = %90, %87, %84, %81, %78
%94 = load i32*, i32** %4
%95 = call i32 @putc(i32 92, i32* %94)
%96 = load i32, i32* %9
%97 = load i32*, i32** %4
%98 = call i32 @putc(i32 %96, i32* %97)
br label %199
99: ; preds = %90
%100 = load i32, i32* %9
%101 = icmp uge i32 %100, 32
br i1 %101, label %102, label %109
102: ; preds = %99
%103 = load i32, i32* %9
%104 = icmp ule i32 %103, 126
br i1 %104, label %105, label %109
105: ; preds = %102
%106 = load i32, i32* %9
%107 = load i32*, i32** %4
%108 = call i32 @putc(i32 %106, i32* %107)
br label %198
109: ; preds = %102, %99
%110 = load i32, i32* %9
%111 = icmp ult i32 %110, 65536
br i1 %111, label %112, label %138
112: ; preds = %109
%113 = load i32*, i32** %4
%114 = load i32, i32* %9
%115 = lshr i32 %114, 12
%116 = and i32 %115, 15
%117 = zext i32 %116 to i64
%118 = getelementptr inbounds [17 x i8], [17 x i8]* @write_escaped_string.hexdigit, i64 0, i64 %117
%119 = load i8, i8* %118
%120 = load i32, i32* %9
%121 = lshr i32 %120, 8
%122 = and i32 %121, 15
%123 = zext i32 %122 to i64
%124 = getelementptr inbounds [17 x i8], [17 x i8]* @write_escaped_string.hexdigit, i64 0, i64 %123
%125 = load i8, i8* %124
%126 = load i32, i32* %9
%127 = lshr i32 %126, 4
%128 = and i32 %127, 15
%129 = zext i32 %128 to i64
%130 = getelementptr inbounds [17 x i8], [17 x i8]* @write_escaped_string.hexdigit, i64 0, i64 %129
%131 = load i8, i8* %130
%132 = load i32, i32* %9
%133 = and i32 %132, 15
%134 = zext i32 %133 to i64
%135 = getelementptr inbounds [17 x i8], [17 x i8]* @write_escaped_string.hexdigit, i64 0, i64 %134
%136 = load i8, i8* %135
%137 = call i32 @fprintf(i32* %113, i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str, i64 0, i64 0), i8 signext %119, i8 signext %125, i8 signext %131, i8 signext %136)
br label %197
138: ; preds = %109
%139 = load i32, i32* %9
%140 = sub i32 %139, 65536
%141 = lshr i32 %140, 10
%142 = add i32 55296, %141
store i32 %142, i32* %10
%143 = load i32, i32* %9
%144 = sub i32 %143, 65536
%145 = and i32 %144, 1023
%146 = add i32 56320, %145
store i32 %146, i32* %11
%147 = load i32*, i32** %4
%148 = load i32, i32* %10
%149 = lshr i32 %148, 12
%150 = and i32 %149, 15
%151 = zext i32 %150 to i64
%152 = getelementptr inbounds [17 x i8], [17 x i8]* @write_escaped_string.hexdigit, i64 0, i64 %151
%153 = load i8, i8* %152
%154 = load i32, i32* %10
%155 = lshr i32 %154, 8
%156 = and i32 %155, 15
%157 = zext i32 %156 to i64
%158 = getelementptr inbounds [17 x i8], [17 x i8]* @write_escaped_string.hexdigit, i64 0, i64 %157
%159 = load i8, i8* %158
%160 = load i32, i32* %10
%161 = lshr i32 %160, 4
%162 = and i32 %161, 15
%163 = zext i32 %162 to i64
%164 = getelementptr inbounds [17 x i8], [17 x i8]* @write_escaped_string.hexdigit, i64 0, i64 %163
%165 = load i8, i8* %164
%166 = load i32, i32* %10
%167 = and i32 %166, 15
%168 = zext i32 %167 to i64
%169 = getelementptr inbounds [17 x i8], [17 x i8]* @write_escaped_string.hexdigit, i64 0, i64 %168
%170 = load i8, i8* %169
%171 = call i32 @fprintf(i32* %147, i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str, i64 0, i64 0), i8 signext %153, i8 signext %159, i8 signext %165, i8 signext %170)
%172 = load i32*, i32** %4
%173 = load i32, i32* %11
%174 = lshr i32 %173, 12
%175 = and i32 %174, 15
%176 = zext i32 %175 to i64
%177 = getelementptr inbounds [17 x i8], [17 x i8]* @write_escaped_string.hexdigit, i64 0, i64 %176
%178 = load i8, i8* %177
%179 = load i32, i32* %11
%180 = lshr i32 %179, 8
%181 = and i32 %180, 15
%182 = zext i32 %181 to i64
%183 = getelementptr inbounds [17 x i8], [17 x i8]* @write_escaped_string.hexdigit, i64 0, i64 %182
%184 = load i8, i8* %183
%185 = load i32, i32* %11
%186 = lshr i32 %185, 4
%187 = and i32 %186, 15
%188 = zext i32 %187 to i64
%189 = getelementptr inbounds [17 x i8], [17 x i8]* @write_escaped_string.hexdigit, i64 0, i64 %188
%190 = load i8, i8* %189
%191 = load i32, i32* %11
%192 = and i32 %191, 15
%193 = zext i32 %192 to i64
%194 = getelementptr inbounds [17 x i8], [17 x i8]* @write_escaped_string.hexdigit, i64 0, i64 %193
%195 = load i8, i8* %194
%196 = call i32 @fprintf(i32* %172, i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str, i64 0, i64 0), i8 signext %178, i8 signext %184, i8 signext %190, i8 signext %195)
br label %197
197: ; preds = %138, %112
br label %198
198: ; preds = %197, %105
br label %199
199: ; preds = %198, %93
br label %200
200: ; preds = %199, %73
br label %201
201: ; preds = %200, %65
br label %202
202: ; preds = %201, %57
br label %203
203: ; preds = %202, %49
br label %204
204: ; preds = %203, %41
store i32 0, i32* %8
br label %17
205: ; preds = %17
ret void
}

LLVM IR (-O2):
@write_escaped_string.hexdigit = internal unnamed_addr constant [17 x i8] c"0123456789abcdef\00"
@.str = [11 x i8] c"\\u%c%c%c%c\00"
define void @write_escaped_string(i32* nocapture %0, i8* %1, i32 %2) {
%4 = alloca i32
%5 = tail call i32 @strlen(i8* %1)
%6 = sext i32 %5 to i64
%7 = getelementptr inbounds i8, i8* %1, i64 %6
%8 = icmp sgt i32 %5, 0
br i1 %8, label %9, label %115
9: ; preds = %3
%10 = bitcast i32* %4 to i8*
%11 = ptrtoint i8* %7 to i64
%12 = icmp ne i32 %2, 0
br label %13
13: ; preds = %9, %113
%14 = phi i8* [ %1, %9 ], [ %21, %113 ]
%15 = phi i1 [ true, %9 ], [ false, %113 ]
%16 = ptrtoint i8* %14 to i64
%17 = sub i64 %11, %16
%18 = trunc i64 %17 to i32
%19 = call i32 @u8_mbtouc(i32* %4, i8* %14, i32 %18)
%20 = sext i32 %19 to i64
%21 = getelementptr inbounds i8, i8* %14, i64 %20
%22 = load i32, i32* %4
%23 = icmp eq i32 %22, 32
%24 = or i1 %12, %15
%25 = and i1 %24, %23
br i1 %25, label %26, label %29
26: ; preds = %13
%27 = call i32 @putc(i32 92, i32* %0)
%28 = call i32 @putc(i32 32, i32* %0)
br label %113
29: ; preds = %13
switch i32 %22, label %46 [
i32 9, label %30
i32 10, label %33
i32 13, label %36
i32 12, label %39
i32 92, label %42
i32 61, label %42
i32 58, label %42
i32 35, label %42
i32 33, label %42
]
30: ; preds = %29
%31 = call i32 @putc(i32 92, i32* %0)
%32 = call i32 @putc(i32 116, i32* %0)
br label %113
33: ; preds = %29
%34 = call i32 @putc(i32 92, i32* %0)
%35 = call i32 @putc(i32 110, i32* %0)
br label %113
36: ; preds = %29
%37 = call i32 @putc(i32 92, i32* %0)
%38 = call i32 @putc(i32 114, i32* %0)
br label %113
39: ; preds = %29
%40 = call i32 @putc(i32 92, i32* %0)
%41 = call i32 @putc(i32 102, i32* %0)
br label %113
42: ; preds = %29, %29, %29, %29, %29
%43 = call i32 @putc(i32 92, i32* %0)
%44 = load i32, i32* %4
%45 = call i32 @putc(i32 %44, i32* %0)
br label %113
46: ; preds = %29
%47 = add i32 %22, -32
%48 = icmp ult i32 %47, 95
br i1 %48, label %49, label %51
49: ; preds = %46
%50 = call i32 @putc(i32 %22, i32* %0)
br label %113
51: ; preds = %46
%52 = icmp ult i32 %22, 65536
br i1 %52, label %53, label %73
53: ; preds = %51
%54 = lshr i32 %22, 12
%55 = zext i32 %54 to i64
%56 = getelementptr inbounds [17 x i8], [17 x i8]* @write_escaped_string.hexdigit, i64 0, i64 %55
%57 = load i8, i8* %56
%58 = lshr i32 %22, 8
%59 = and i32 %58, 15
%60 = zext i32 %59 to i64
%61 = getelementptr inbounds [17 x i8], [17 x i8]* @write_escaped_string.hexdigit, i64 0, i64 %60
%62 = load i8, i8* %61
%63 = lshr i32 %22, 4
%64 = and i32 %63, 15
%65 = zext i32 %64 to i64
%66 = getelementptr inbounds [17 x i8], [17 x i8]* @write_escaped_string.hexdigit, i64 0, i64 %65
%67 = load i8, i8* %66
%68 = and i32 %22, 15
%69 = zext i32 %68 to i64
%70 = getelementptr inbounds [17 x i8], [17 x i8]* @write_escaped_string.hexdigit, i64 0, i64 %69
%71 = load i8, i8* %70
%72 = call i32 @fprintf(i32* %0, i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str, i64 0, i64 0), i8 signext %57, i8 signext %62, i8 signext %67, i8 signext %71)
br label %113
73: ; preds = %51
%74 = add i32 %22, -65536
%75 = lshr i32 %74, 10
%76 = add nuw nsw i32 %75, 55296
%77 = lshr i32 %76, 12
%78 = and i32 %77, 15
%79 = zext i32 %78 to i64
%80 = getelementptr inbounds [17 x i8], [17 x i8]* @write_escaped_string.hexdigit, i64 0, i64 %79
%81 = load i8, i8* %80
%82 = lshr i32 %76, 8
%83 = and i32 %82, 15
%84 = zext i32 %83 to i64
%85 = getelementptr inbounds [17 x i8], [17 x i8]* @write_escaped_string.hexdigit, i64 0, i64 %84
%86 = load i8, i8* %85
%87 = lshr i32 %76, 4
%88 = and i32 %87, 15
%89 = zext i32 %88 to i64
%90 = getelementptr inbounds [17 x i8], [17 x i8]* @write_escaped_string.hexdigit, i64 0, i64 %89
%91 = load i8, i8* %90
%92 = and i32 %75, 15
%93 = zext i32 %92 to i64
%94 = getelementptr inbounds [17 x i8], [17 x i8]* @write_escaped_string.hexdigit, i64 0, i64 %93
%95 = load i8, i8* %94
%96 = call i32 @fprintf(i32* %0, i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str, i64 0, i64 0), i8 signext %81, i8 signext %86, i8 signext %91, i8 signext %95)
%97 = lshr i32 %22, 8
%98 = and i32 %97, 3
%99 = or i32 %98, 12
%100 = zext i32 %99 to i64
%101 = getelementptr inbounds [17 x i8], [17 x i8]* @write_escaped_string.hexdigit, i64 0, i64 %100
%102 = load i8, i8* %101
%103 = lshr i32 %22, 4
%104 = and i32 %103, 15
%105 = zext i32 %104 to i64
%106 = getelementptr inbounds [17 x i8], [17 x i8]* @write_escaped_string.hexdigit, i64 0, i64 %105
%107 = load i8, i8* %106
%108 = and i32 %22, 15
%109 = zext i32 %108 to i64
%110 = getelementptr inbounds [17 x i8], [17 x i8]* @write_escaped_string.hexdigit, i64 0, i64 %109
%111 = load i8, i8* %110
%112 = call i32 @fprintf(i32* %0, i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str, i64 0, i64 0), i8 signext 100, i8 signext %102, i8 signext %107, i8 signext %111)
br label %113
113: ; preds = %30, %36, %42, %53, %73, %49, %39, %33, %26
%114 = icmp ult i8* %21, %7
br i1 %114, label %13, label %115
115: ; preds = %113, %3
ret void
}