#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 */

/* Variables and functions */
scalar_t__ is_ascii_string(char const *);
int /*<<< orphan*/ sprintf(char *, char *, char const, char const, char const,
                           char const);
int strlen(char const *);
int /*<<< orphan*/ u8_mbtouc(unsigned int *, unsigned char const *, int);
scalar_t__ xmalloc(size_t);
const char *conv_to_java(const char *string) {
  static const char hexdigit[] = "0123456789abcdef";
  size_t length;
  char *result;
  if (is_ascii_string(string))
    return string;
  length = 0;
  {
    const char *str = string;
    const char *str_limit = str + strlen(str);
    while (str < str_limit) {
      unsigned int uc;
      str += u8_mbtouc(&uc, (const unsigned char *)str, str_limit - str);
      length += (uc <= 0x007f ? 1 : uc < 0x10000 ? 6 : 12);
    }
  }
  result = (char *)xmalloc(length + 1);
  {
    char *newstr = result;
    const char *str = string;
    const char *str_limit = str + strlen(str);
    while (str < str_limit) {
      unsigned int uc;
      str += u8_mbtouc(&uc, (const unsigned char *)str, str_limit - str);
      if (uc <= 0x007f)
        *newstr++ = uc;
      else if (uc < 0x10000) {
        sprintf(newstr, "\\u%c%c%c%c", hexdigit[(uc >> 12) & 0x0f],
                hexdigit[(uc >> 8) & 0x0f], hexdigit[(uc >> 4) & 0x0f],
                hexdigit[uc & 0x0f]);
        newstr += 6;
      } else {
        unsigned int uc1 = 0xd800 + ((uc - 0x10000) >> 10);
        unsigned int uc2 = 0xdc00 + ((uc - 0x10000) & 0x3ff);
        sprintf(newstr, "\\u%c%c%c%c", hexdigit[(uc1 >> 12) & 0x0f],
                hexdigit[(uc1 >> 8) & 0x0f], hexdigit[(uc1 >> 4) & 0x0f],
                hexdigit[uc1 & 0x0f]);
        newstr += 6;
        sprintf(newstr, "\\u%c%c%c%c", hexdigit[(uc2 >> 12) & 0x0f],
                hexdigit[(uc2 >> 8) & 0x0f], hexdigit[(uc2 >> 4) & 0x0f],
                hexdigit[uc2 & 0x0f]);
        newstr += 6;
      }
    }
    *newstr = '\0';
  }
  return result;
}


x86 assembly (clang, -O0):
<conv_to_java>:
push   %rbp
mov    %rsp,%rbp
sub    $0x80,%rsp
mov    %rdi,-0x10(%rbp)
mov    -0x10(%rbp),%rdi
call   1050 <is_ascii_string@plt>
cmp    $0x0,%rax
je     117f <conv_to_java+0x2f>
mov    -0x10(%rbp),%rax
mov    %rax,-0x8(%rbp)
jmp    14a5 <conv_to_java+0x355>
movq   $0x0,-0x18(%rbp)
mov    -0x10(%rbp),%rax
mov    %rax,-0x28(%rbp)
mov    -0x28(%rbp),%rax
mov    %rax,-0x68(%rbp)
mov    -0x28(%rbp),%rdi
call   1030 <strlen@plt>
mov    %eax,%ecx
mov    -0x68(%rbp),%rax
movslq %ecx,%rcx
add    %rcx,%rax
mov    %rax,-0x30(%rbp)
mov    -0x28(%rbp),%rax
cmp    -0x30(%rbp),%rax
jae    122a <conv_to_java+0xda>
mov    -0x28(%rbp),%rsi
mov    -0x30(%rbp),%rax
mov    -0x28(%rbp),%rcx
sub    %rcx,%rax
mov    %eax,%edx
lea    -0x34(%rbp),%rdi
call   1060 <u8_mbtouc@plt>
mov    %eax,%ecx
mov    -0x28(%rbp),%rax
movslq %ecx,%rcx
add    %rcx,%rax
mov    %rax,-0x28(%rbp)
cmpl   $0x7f,-0x34(%rbp)
ja     11ff <conv_to_java+0xaf>
mov    $0x1,%eax
mov    %eax,-0x6c(%rbp)
jmp    1218 <conv_to_java+0xc8>
mov    -0x34(%rbp),%edx
mov    $0xc,%eax
mov    $0x6,%ecx
cmp    $0x10000,%edx
cmovb  %ecx,%eax
mov    %eax,-0x6c(%rbp)
mov    -0x6c(%rbp),%eax
cltq
add    -0x18(%rbp),%rax
mov    %rax,-0x18(%rbp)
jmp    11b0 <conv_to_java+0x60>
mov    -0x18(%rbp),%rdi
add    $0x1,%rdi
call   1040 <xmalloc@plt>
mov    %rax,-0x20(%rbp)
mov    -0x20(%rbp),%rax
mov    %rax,-0x40(%rbp)
mov    -0x10(%rbp),%rax
mov    %rax,-0x48(%rbp)
mov    -0x48(%rbp),%rax
mov    %rax,-0x78(%rbp)
mov    -0x48(%rbp),%rdi
call   1030 <strlen@plt>
mov    %eax,%ecx
mov    -0x78(%rbp),%rax
movslq %ecx,%rcx
add    %rcx,%rax
mov    %rax,-0x50(%rbp)
mov    -0x48(%rbp),%rax
cmp    -0x50(%rbp),%rax
jae    1496 <conv_to_java+0x346>
mov    -0x48(%rbp),%rsi
mov    -0x50(%rbp),%rax
mov    -0x48(%rbp),%rcx
sub    %rcx,%rax
mov    %eax,%edx
lea    -0x54(%rbp),%rdi
call   1060 <u8_mbtouc@plt>
mov    %eax,%ecx
mov    -0x48(%rbp),%rax
movslq %ecx,%rcx
add    %rcx,%rax
mov    %rax,-0x48(%rbp)
cmpl   $0x7f,-0x54(%rbp)
ja     12c9 <conv_to_java+0x179>
mov    -0x54(%rbp),%eax
mov    %al,%cl
mov    -0x40(%rbp),%rax
mov    %rax,%rdx
add    $0x1,%rdx
mov    %rdx,-0x40(%rbp)
mov    %cl,(%rax)
jmp    1491 <conv_to_java+0x341>
cmpl   $0x10000,-0x54(%rbp)
jae    135e <conv_to_java+0x20e>
mov    -0x40(%rbp),%rdi
mov    -0x54(%rbp),%eax
shr    $0xc,%eax
and    $0xf,%eax
mov    %eax,%eax
mov    %eax,%ecx
lea    0xd12(%rip),%rax
mov    (%rax,%rcx,1),%dl
mov    -0x54(%rbp),%eax
shr    $0x8,%eax
and    $0xf,%eax
mov    %eax,%eax
mov    %eax,%ecx
lea    0xcfb(%rip),%rax
mov    (%rax,%rcx,1),%cl
mov    -0x54(%rbp),%eax
shr    $0x4,%eax
and    $0xf,%eax
mov    %eax,%eax
mov    %eax,%esi
lea    0xce4(%rip),%rax
mov    (%rax,%rsi,1),%r8b
mov    -0x54(%rbp),%eax
and    $0xf,%eax
mov    %eax,%eax
mov    %eax,%r9d
lea    0xcdf(%rip),%rsi
lea    0xcc7(%rip),%rax
movsbl %dl,%edx
movsbl %cl,%ecx
movsbl %r8b,%r8d
movsbl (%rax,%r9,1),%r9d
call   1070 <sprintf@plt>
mov    -0x40(%rbp),%rax
add    $0x6,%rax
mov    %rax,-0x40(%rbp)
jmp    148c <conv_to_java+0x33c>
mov    -0x54(%rbp),%eax
sub    $0x10000,%eax
shr    $0xa,%eax
add    $0xd800,%eax
mov    %eax,-0x58(%rbp)
mov    -0x54(%rbp),%eax
sub    $0x10000,%eax
and    $0x3ff,%eax
add    $0xdc00,%eax
mov    %eax,-0x5c(%rbp)
mov    -0x40(%rbp),%rdi
mov    -0x58(%rbp),%eax
shr    $0xc,%eax
and    $0xf,%eax
mov    %eax,%eax
mov    %eax,%ecx
lea    0xc62(%rip),%rax
mov    (%rax,%rcx,1),%dl
mov    -0x58(%rbp),%eax
shr    $0x8,%eax
and    $0xf,%eax
mov    %eax,%eax
mov    %eax,%ecx
lea    0xc4b(%rip),%rax
mov    (%rax,%rcx,1),%cl
mov    -0x58(%rbp),%eax
shr    $0x4,%eax
and    $0xf,%eax
mov    %eax,%eax
mov    %eax,%esi
lea    0xc34(%rip),%rax
mov    (%rax,%rsi,1),%r8b
mov    -0x58(%rbp),%eax
and    $0xf,%eax
mov    %eax,%eax
mov    %eax,%r9d
lea    0xc2f(%rip),%rsi
lea    0xc17(%rip),%rax
movsbl %dl,%edx
movsbl %cl,%ecx
movsbl %r8b,%r8d
movsbl (%rax,%r9,1),%r9d
call   1070 <sprintf@plt>
mov    -0x40(%rbp),%rax
add    $0x6,%rax
mov    %rax,-0x40(%rbp)
mov    -0x40(%rbp),%rdi
mov    -0x5c(%rbp),%eax
shr    $0xc,%eax
and    $0xf,%eax
mov    %eax,%eax
mov    %eax,%ecx
lea    0xbdf(%rip),%rax
mov    (%rax,%rcx,1),%dl
mov    -0x5c(%rbp),%eax
shr    $0x8,%eax
and    $0xf,%eax
mov    %eax,%eax
mov    %eax,%ecx
lea    0xbc8(%rip),%rax
mov    (%rax,%rcx,1),%cl
mov    -0x5c(%rbp),%eax
shr    $0x4,%eax
and    $0xf,%eax
mov    %eax,%eax
mov    %eax,%esi
lea    0xbb1(%rip),%rax
mov    (%rax,%rsi,1),%r8b
mov    -0x5c(%rbp),%eax
and    $0xf,%eax
mov    %eax,%eax
mov    %eax,%r9d
lea    0xbac(%rip),%rsi
lea    0xb94(%rip),%rax
movsbl %dl,%edx
movsbl %cl,%ecx
movsbl %r8b,%r8d
movsbl (%rax,%r9,1),%r9d
call   1070 <sprintf@plt>
mov    -0x40(%rbp),%rax
add    $0x6,%rax
mov    %rax,-0x40(%rbp)
jmp    1491 <conv_to_java+0x341>
jmp    126c <conv_to_java+0x11c>
mov    -0x40(%rbp),%rax
movb   $0x0,(%rax)
mov    -0x20(%rbp),%rax
mov    %rax,-0x8(%rbp)
mov    -0x8(%rbp),%rax
add    $0x80,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<conv_to_java>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x18,%rsp
mov    %rdi,%r14
call   1050 <is_ascii_string@plt>
test   %rax,%rax
jne    1351 <conv_to_java+0x201>
mov    %r14,%rdi
call   1030 <strlen@plt>
test   %eax,%eax
jle    11e0 <conv_to_java+0x90>
movslq %eax,%r12
add    %r14,%r12
xor    %ebx,%ebx
mov    $0x6,%r13d
mov    $0x1,%r15d
mov    %r14,%rbp
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax)
mov    %r12d,%edx
sub    %ebp,%edx
lea    0xc(%rsp),%rdi
mov    %rbp,%rsi
call   1060 <u8_mbtouc@plt>
cltq
add    %rax,%rbp
mov    0xc(%rsp),%eax
cmp    $0x10000,%eax
mov    $0xc,%ecx
cmovb  %r13,%rcx
cmp    $0x80,%eax
cmovb  %r15,%rcx
add    %rcx,%rbx
cmp    %r12,%rbp
jb     11a0 <conv_to_java+0x50>
add    $0x1,%rbx
jmp    11e5 <conv_to_java+0x95>
mov    $0x1,%ebx
mov    %rbx,%rdi
call   1040 <xmalloc@plt>
mov    %rax,%r15
mov    %r14,%rdi
call   1030 <strlen@plt>
test   %eax,%eax
mov    %r15,0x10(%rsp)
jle    1348 <conv_to_java+0x1f8>
movslq %eax,%rbx
add    %r14,%rbx
lea    0x8(%rsp),%r12
jmp    1230 <conv_to_java+0xe0>
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax)
mov    %bpl,(%r15)
add    $0x1,%r15
cmp    %rbx,%r14
jae    1348 <conv_to_java+0x1f8>
mov    %r14,%rbp
mov    %ebx,%edx
sub    %ebp,%edx
mov    %r12,%rdi
mov    %r14,%rsi
call   1060 <u8_mbtouc@plt>
movslq %eax,%r14
add    %rbp,%r14
mov    0x8(%rsp),%ebp
cmp    $0x7f,%rbp
jbe    1220 <conv_to_java+0xd0>
cmp    $0xffff,%ebp
ja     12b0 <conv_to_java+0x160>
mov    %rbp,%rax
shr    $0xc,%rax
lea    0xd98(%rip),%rsi
movsbl (%rax,%rsi,1),%edx
mov    %ebp,%eax
shr    $0x8,%eax
and    $0xf,%eax
movsbl (%rax,%rsi,1),%ecx
mov    %ebp,%eax
shr    $0x4,%eax
and    $0xf,%eax
movsbl (%rax,%rsi,1),%r8d
and    $0xf,%ebp
movsbl 0x0(%rbp,%rsi,1),%r9d
mov    %r15,%rdi
lea    0xd79(%rip),%rsi
call   1070 <sprintf@plt>
add    $0x6,%r15
jmp    1227 <conv_to_java+0xd7>
cs nopw 0x0(%rax,%rax,1)
nopl   (%rax)
lea    -0x10000(%rbp),%eax
shr    $0xa,%eax
lea    0xd800(%rax),%esi
mov    %esi,%ecx
shr    $0xc,%ecx
and    $0xf,%ecx
lea    0xd32(%rip),%r13
movsbl (%rcx,%r13,1),%edx
mov    %esi,%ecx
shr    $0x8,%ecx
and    $0xf,%ecx
movsbl (%rcx,%r13,1),%ecx
shr    $0x4,%esi
and    $0xf,%esi
movsbl (%rsi,%r13,1),%r8d
and    $0xf,%eax
movsbl (%rax,%r13,1),%r9d
mov    %r15,%rdi
lea    0xd14(%rip),%r12
mov    %r12,%rsi
call   1070 <sprintf@plt>
lea    0x6(%r15),%rdi
mov    %ebp,%eax
shr    $0x8,%eax
and    $0x3,%eax
movsbl 0xc(%rax,%r13,1),%ecx
mov    %ebp,%eax
shr    $0x4,%eax
and    $0xf,%eax
movsbl (%rax,%r13,1),%r8d
and    $0xf,%ebp
movsbl 0x0(%rbp,%r13,1),%r9d
mov    %r12,%rsi
lea    0x8(%rsp),%r12
mov    $0x64,%edx
call   1070 <sprintf@plt>
add    $0xc,%r15
jmp    1227 <conv_to_java+0xd7>
movb   $0x0,(%r15)
mov    0x10(%rsp),%r14
mov    %r14,%rax
add    $0x18,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

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

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