char *TlsIntToUTF8(char *d, int *s) {
  int *p;
  char *q;
  p = s;
  q = d;
  while (*p) {
    int c;
    c = *p++;
    if ((c > 0x10ffff) || (c < 0)) {
      c = 0xfffd;
    }
    if (c < 0x80) {
      *q++ = c;
    } else {
      int max, shft, frst;
      max = 0x800;
      shft = 6;
      frst = 0xffc0;
      while (c >= max) {
        max = max << 5;
        shft += 6;
        frst = frst >> 1;
      }
      *q++ = (c >> shft) | frst;
      while (shft) {
        shft -= 6;
        *q++ = 0x80 | ((c >> shft) & 0x3f);
      }
    }
  }
  *q++ = 0;
  return q;
}


x86 assembly (clang, -O0):
<TlsIntToUTF8>:
push   %rbp
mov    %rsp,%rbp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    -0x10(%rbp),%rax
mov    %rax,-0x18(%rbp)
mov    -0x8(%rbp),%rax
mov    %rax,-0x20(%rbp)
mov    -0x18(%rbp),%rax
cmpl   $0x0,(%rax)
je     1227 <TlsIntToUTF8+0x127>
mov    -0x18(%rbp),%rax
mov    %rax,%rcx
add    $0x4,%rcx
mov    %rcx,-0x18(%rbp)
mov    (%rax),%eax
mov    %eax,-0x24(%rbp)
cmpl   $0x10ffff,-0x24(%rbp)
jg     1154 <TlsIntToUTF8+0x54>
cmpl   $0x0,-0x24(%rbp)
jge    115b <TlsIntToUTF8+0x5b>
movl   $0xfffd,-0x24(%rbp)
cmpl   $0x80,-0x24(%rbp)
jge    1183 <TlsIntToUTF8+0x83>
mov    -0x24(%rbp),%eax
mov    %al,%cl
mov    -0x20(%rbp),%rax
mov    %rax,%rdx
add    $0x1,%rdx
mov    %rdx,-0x20(%rbp)
mov    %cl,(%rax)
jmp    1222 <TlsIntToUTF8+0x122>
movl   $0x800,-0x28(%rbp)
movl   $0x6,-0x2c(%rbp)
movl   $0xffc0,-0x30(%rbp)
mov    -0x24(%rbp),%eax
cmp    -0x28(%rbp),%eax
jl     11c4 <TlsIntToUTF8+0xc4>
mov    -0x28(%rbp),%eax
shl    $0x5,%eax
mov    %eax,-0x28(%rbp)
mov    -0x2c(%rbp),%eax
add    $0x6,%eax
mov    %eax,-0x2c(%rbp)
mov    -0x30(%rbp),%eax
sar    $0x1,%eax
mov    %eax,-0x30(%rbp)
jmp    1198 <TlsIntToUTF8+0x98>
mov    -0x24(%rbp),%eax
mov    -0x2c(%rbp),%ecx
sar    %cl,%eax
or     -0x30(%rbp),%eax
mov    %al,%cl
mov    -0x20(%rbp),%rax
mov    %rax,%rdx
add    $0x1,%rdx
mov    %rdx,-0x20(%rbp)
mov    %cl,(%rax)
cmpl   $0x0,-0x2c(%rbp)
je     121d <TlsIntToUTF8+0x11d>
mov    -0x2c(%rbp),%eax
sub    $0x6,%eax
mov    %eax,-0x2c(%rbp)
mov    -0x24(%rbp),%eax
mov    -0x2c(%rbp),%ecx
sar    %cl,%eax
and    $0x3f,%eax
or     $0x80,%eax
mov    %al,%cl
mov    -0x20(%rbp),%rax
mov    %rax,%rdx
add    $0x1,%rdx
mov    %rdx,-0x20(%rbp)
mov    %cl,(%rax)
jmp    11e2 <TlsIntToUTF8+0xe2>
jmp    1222 <TlsIntToUTF8+0x122>
jmp    111c <TlsIntToUTF8+0x1c>
mov    -0x20(%rbp),%rax
mov    %rax,%rcx
add    $0x1,%rcx
mov    %rcx,-0x20(%rbp)
movb   $0x0,(%rax)
mov    -0x20(%rbp),%rax
pop    %rbp
ret

x86 assembly (clang, -O2):
<TlsIntToUTF8>:
push   %rbp
push   %r14
push   %rbx
mov    (%rsi),%ebp
test   %ebp,%ebp
je     177b <TlsIntToUTF8+0x67b>
mov    $0xfffd,%r9d
mov    $0xaaaaaaab,%r8d
movdqa 0xf1d(%rip),%xmm12
movaps 0xf25(%rip),%xmm10
movdqa 0xf2c(%rip),%xmm9
movdqa 0xf33(%rip),%xmm14
movdqa 0xf3a(%rip),%xmm15
movdqa 0xf41(%rip),%xmm11
jmp    1177 <TlsIntToUTF8+0x77>
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax,%rax,1)
mov    %bpl,(%rdi)
add    $0x1,%rdi
mov    %rdi,%rax
mov    (%rsi),%ebp
mov    %rax,%rdi
test   %ebp,%ebp
je     177e <TlsIntToUTF8+0x67e>
add    $0x4,%rsi
cmp    $0x110000,%ebp
cmovae %r9d,%ebp
cmp    $0x80,%ebp
jb     1160 <TlsIntToUTF8+0x60>
cmp    $0x800,%ebp
jae    11b0 <TlsIntToUTF8+0xb0>
mov    $0xffc0,%eax
mov    $0x6,%ecx
jmp    11cc <TlsIntToUTF8+0xcc>
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax,%rax,1)
mov    $0x800,%edx
mov    $0x6,%ecx
mov    $0xffc0,%eax
nop
shl    $0x5,%edx
add    $0x6,%ecx
shr    %eax
cmp    %edx,%ebp
jge    11c0 <TlsIntToUTF8+0xc0>
mov    %ebp,%edx
sar    %cl,%edx
or     %eax,%edx
mov    %dl,(%rdi)
lea    0x1(%rdi),%rax
lea    -0x6(%rcx),%r10d
cmp    $0x5a,%r10d
jb     174c <TlsIntToUTF8+0x64c>
imul   %r8,%r10
shr    $0x22,%r10
add    $0x1,%r10d
mov    %r10d,%r11d
and    $0xfffffff0,%r11d
movd   %ecx,%xmm0
pshufd $0x0,%xmm0,%xmm7
movdqa %xmm7,%xmm4
paddd  0xdf2(%rip),%xmm4
movdqa %xmm7,%xmm5
paddd  0xdf6(%rip),%xmm5
movdqa %xmm7,%xmm6
paddd  0xdfa(%rip),%xmm6
paddd  0xe02(%rip),%xmm7
movd   %ebp,%xmm0
pshufd $0x0,%xmm0,%xmm13
lea    -0x10(%r11),%rdx
mov    %rdx,%r14
shr    $0x4,%r14
add    $0x1,%r14
test   %rdx,%rdx
je     176d <TlsIntToUTF8+0x66d>
mov    %r14,%rdx
and    $0xfffffffffffffffe,%rdx
xor    %ebx,%ebx
nopl   0x0(%rax)
movdqa %xmm4,-0x30(%rsp)
movdqa %xmm5,-0x20(%rsp)
movdqa %xmm6,-0x10(%rsp)
movdqa %xmm7,%xmm10
paddd  %xmm12,%xmm10
movdqa %xmm6,%xmm3
paddd  %xmm12,%xmm3
movdqa %xmm5,%xmm0
movdqa %xmm4,%xmm1
paddd  %xmm12,%xmm1
pshuflw $0xfe,%xmm1,%xmm2
movdqa %xmm13,%xmm4
psrad  %xmm2,%xmm4
paddd  %xmm12,%xmm0
pshuflw $0x54,%xmm1,%xmm5
movdqa %xmm13,%xmm2
psrad  %xmm5,%xmm2
pshufd $0xee,%xmm1,%xmm1
pshuflw $0xfe,%xmm1,%xmm5
movdqa %xmm13,%xmm6
psrad  %xmm5,%xmm6
punpcklqdq %xmm4,%xmm2
pshuflw $0x54,%xmm1,%xmm1
movdqa %xmm13,%xmm4
psrad  %xmm1,%xmm4
punpckhqdq %xmm6,%xmm4
pshuflw $0xfe,%xmm0,%xmm1
movdqa %xmm13,%xmm5
psrad  %xmm1,%xmm5
shufps $0xcc,%xmm4,%xmm2
pshuflw $0x54,%xmm0,%xmm4
movdqa %xmm13,%xmm1
psrad  %xmm4,%xmm1
pshufd $0xee,%xmm0,%xmm0
pshuflw $0xfe,%xmm0,%xmm4
movdqa %xmm13,%xmm6
psrad  %xmm4,%xmm6
punpcklqdq %xmm5,%xmm1
pshuflw $0x54,%xmm0,%xmm0
movdqa %xmm13,%xmm4
psrad  %xmm0,%xmm4
punpckhqdq %xmm6,%xmm4
pshuflw $0xfe,%xmm3,%xmm0
movdqa %xmm13,%xmm5
psrad  %xmm0,%xmm5
shufps $0xcc,%xmm4,%xmm1
pshuflw $0x54,%xmm3,%xmm0
movdqa %xmm15,%xmm8
movdqa %xmm14,%xmm15
movdqa %xmm12,%xmm14
movdqa %xmm9,%xmm12
movdqa %xmm13,%xmm9
psrad  %xmm0,%xmm9
pshufd $0xee,%xmm3,%xmm0
pshuflw $0xfe,%xmm0,%xmm3
movdqa %xmm13,%xmm4
psrad  %xmm3,%xmm4
punpcklqdq %xmm5,%xmm9
pshuflw $0x54,%xmm0,%xmm0
movdqa %xmm13,%xmm3
psrad  %xmm0,%xmm3
punpckhqdq %xmm4,%xmm3
pshuflw $0xfe,%xmm10,%xmm0
movdqa %xmm13,%xmm4
psrad  %xmm0,%xmm4
shufps $0xcc,%xmm3,%xmm9
pshuflw $0x54,%xmm10,%xmm3
movdqa %xmm13,%xmm0
psrad  %xmm3,%xmm0
pshufd $0xee,%xmm10,%xmm3
movaps 0xc9b(%rip),%xmm10
pshuflw $0xfe,%xmm3,%xmm5
movdqa %xmm13,%xmm6
psrad  %xmm5,%xmm6
punpcklqdq %xmm4,%xmm0
pshuflw $0x54,%xmm3,%xmm3
movdqa %xmm13,%xmm4
psrad  %xmm3,%xmm4
punpckhqdq %xmm6,%xmm4
shufps $0xcc,%xmm4,%xmm0
andps  %xmm10,%xmm0
andps  %xmm10,%xmm9
packuswb %xmm9,%xmm0
movdqa %xmm12,%xmm9
movdqa %xmm14,%xmm12
movdqa %xmm15,%xmm14
movdqa %xmm8,%xmm15
andps  %xmm10,%xmm1
andps  %xmm10,%xmm2
packuswb %xmm2,%xmm1
packuswb %xmm1,%xmm0
pand   %xmm9,%xmm0
por    %xmm14,%xmm0
movdqu %xmm0,0x1(%rdi,%rbx,1)
movdqa %xmm7,%xmm4
paddd  %xmm8,%xmm4
movdqa -0x10(%rsp),%xmm3
paddd  %xmm8,%xmm3
movdqa -0x20(%rsp),%xmm0
paddd  %xmm8,%xmm0
movdqa -0x30(%rsp),%xmm1
paddd  %xmm8,%xmm1
pshuflw $0xfe,%xmm1,%xmm2
movdqa %xmm13,%xmm5
psrad  %xmm2,%xmm5
pshuflw $0x54,%xmm1,%xmm6
movdqa %xmm13,%xmm2
psrad  %xmm6,%xmm2
punpcklqdq %xmm5,%xmm2
pshufd $0xee,%xmm1,%xmm1
pshuflw $0xfe,%xmm1,%xmm5
movdqa %xmm13,%xmm6
psrad  %xmm5,%xmm6
pshuflw $0x54,%xmm1,%xmm1
movdqa %xmm13,%xmm5
psrad  %xmm1,%xmm5
punpckhqdq %xmm6,%xmm5
shufps $0xcc,%xmm5,%xmm2
pshuflw $0xfe,%xmm0,%xmm1
movdqa %xmm13,%xmm5
psrad  %xmm1,%xmm5
pshuflw $0x54,%xmm0,%xmm6
movdqa %xmm13,%xmm1
psrad  %xmm6,%xmm1
punpcklqdq %xmm5,%xmm1
pshufd $0xee,%xmm0,%xmm0
pshuflw $0xfe,%xmm0,%xmm5
movdqa %xmm13,%xmm6
psrad  %xmm5,%xmm6
pshuflw $0x54,%xmm0,%xmm0
movdqa %xmm13,%xmm5
psrad  %xmm0,%xmm5
punpckhqdq %xmm6,%xmm5
shufps $0xcc,%xmm5,%xmm1
pshuflw $0xfe,%xmm3,%xmm0
movdqa %xmm13,%xmm5
psrad  %xmm0,%xmm5
pshuflw $0x54,%xmm3,%xmm6
movdqa %xmm13,%xmm0
psrad  %xmm6,%xmm0
punpcklqdq %xmm5,%xmm0
pshufd $0xee,%xmm3,%xmm3
pshuflw $0xfe,%xmm3,%xmm5
movdqa %xmm13,%xmm6
psrad  %xmm5,%xmm6
pshuflw $0x54,%xmm3,%xmm3
movdqa %xmm13,%xmm5
psrad  %xmm3,%xmm5
punpckhqdq %xmm6,%xmm5
shufps $0xcc,%xmm5,%xmm0
pshuflw $0xfe,%xmm4,%xmm3
movdqa %xmm13,%xmm5
psrad  %xmm3,%xmm5
pshuflw $0x54,%xmm4,%xmm6
movdqa %xmm13,%xmm3
psrad  %xmm6,%xmm3
punpcklqdq %xmm5,%xmm3
pshufd $0xee,%xmm4,%xmm4
pshuflw $0xfe,%xmm4,%xmm5
movdqa %xmm13,%xmm6
psrad  %xmm5,%xmm6
pshuflw $0x54,%xmm4,%xmm4
movdqa %xmm13,%xmm5
psrad  %xmm4,%xmm5
movdqa -0x30(%rsp),%xmm4
punpckhqdq %xmm6,%xmm5
movdqa -0x10(%rsp),%xmm6
shufps $0xcc,%xmm5,%xmm3
movdqa -0x20(%rsp),%xmm5
andps  %xmm10,%xmm3
andps  %xmm10,%xmm0
packuswb %xmm0,%xmm3
andps  %xmm10,%xmm1
andps  %xmm10,%xmm2
packuswb %xmm2,%xmm1
packuswb %xmm1,%xmm3
pand   %xmm9,%xmm3
por    %xmm14,%xmm3
movdqu %xmm3,0x11(%rdi,%rbx,1)
add    $0x20,%rbx
paddd  %xmm11,%xmm7
paddd  %xmm11,%xmm6
paddd  %xmm11,%xmm5
paddd  %xmm11,%xmm4
add    $0xfffffffffffffffe,%rdx
jne    1260 <TlsIntToUTF8+0x160>
test   $0x1,%r14b
je     1737 <TlsIntToUTF8+0x637>
paddd  %xmm12,%xmm7
paddd  %xmm12,%xmm6
paddd  %xmm12,%xmm4
pshuflw $0xfe,%xmm4,%xmm0
movdqa %xmm13,%xmm1
psrad  %xmm0,%xmm1
paddd  %xmm12,%xmm5
pshuflw $0x54,%xmm4,%xmm0
movdqa %xmm13,%xmm2
psrad  %xmm0,%xmm2
pshufd $0xee,%xmm4,%xmm0
pshuflw $0xfe,%xmm0,%xmm3
movdqa %xmm13,%xmm4
psrad  %xmm3,%xmm4
punpcklqdq %xmm1,%xmm2
pshuflw $0x54,%xmm0,%xmm0
movdqa %xmm13,%xmm1
psrad  %xmm0,%xmm1
punpckhqdq %xmm4,%xmm1
pshuflw $0xfe,%xmm5,%xmm0
movdqa %xmm13,%xmm3
psrad  %xmm0,%xmm3
shufps $0xcc,%xmm1,%xmm2
pshuflw $0x54,%xmm5,%xmm0
movdqa %xmm13,%xmm1
psrad  %xmm0,%xmm1
pshufd $0xee,%xmm5,%xmm0
pshuflw $0xfe,%xmm0,%xmm4
movdqa %xmm13,%xmm5
psrad  %xmm4,%xmm5
punpcklqdq %xmm3,%xmm1
pshuflw $0x54,%xmm0,%xmm0
movdqa %xmm13,%xmm3
psrad  %xmm0,%xmm3
punpckhqdq %xmm5,%xmm3
pshuflw $0xfe,%xmm6,%xmm0
movdqa %xmm13,%xmm4
psrad  %xmm0,%xmm4
shufps $0xcc,%xmm3,%xmm1
pshuflw $0x54,%xmm6,%xmm3
movdqa %xmm13,%xmm0
psrad  %xmm3,%xmm0
pshufd $0xee,%xmm6,%xmm3
pshuflw $0xfe,%xmm3,%xmm5
movdqa %xmm13,%xmm6
psrad  %xmm5,%xmm6
punpcklqdq %xmm4,%xmm0
pshuflw $0x54,%xmm3,%xmm3
movdqa %xmm13,%xmm4
psrad  %xmm3,%xmm4
punpckhqdq %xmm6,%xmm4
pshuflw $0xfe,%xmm7,%xmm3
movdqa %xmm13,%xmm5
psrad  %xmm3,%xmm5
shufps $0xcc,%xmm4,%xmm0
pshuflw $0x54,%xmm7,%xmm4
movdqa %xmm13,%xmm3
psrad  %xmm4,%xmm3
pshufd $0xee,%xmm7,%xmm4
pshuflw $0xfe,%xmm4,%xmm6
movdqa %xmm13,%xmm7
psrad  %xmm6,%xmm7
punpcklqdq %xmm5,%xmm3
pshuflw $0x54,%xmm4,%xmm4
psrad  %xmm4,%xmm13
punpckhqdq %xmm7,%xmm13
shufps $0xcc,%xmm13,%xmm3
andps  %xmm10,%xmm3
andps  %xmm10,%xmm0
packuswb %xmm0,%xmm3
andps  %xmm10,%xmm1
andps  %xmm10,%xmm2
packuswb %xmm2,%xmm1
packuswb %xmm1,%xmm3
pand   %xmm9,%xmm3
por    %xmm14,%xmm3
movdqu %xmm3,(%rax,%rbx,1)
add    %r11,%rax
cmp    %r10,%r11
je     116a <TlsIntToUTF8+0x6a>
add    %r11d,%r11d
lea    (%r11,%r11,2),%edx
sub    %edx,%ecx
add    $0xfffffffa,%ecx
nop
mov    %ebp,%edx
sar    %cl,%edx
and    $0x3f,%dl
or     $0x80,%dl
mov    %dl,(%rax)
add    $0x1,%rax
add    $0xfffffffa,%ecx
cmp    $0xfffffffa,%ecx
jne    1750 <TlsIntToUTF8+0x650>
jmp    116a <TlsIntToUTF8+0x6a>
xor    %ebx,%ebx
test   $0x1,%r14b
jne    15d6 <TlsIntToUTF8+0x4d6>
jmp    1737 <TlsIntToUTF8+0x637>
mov    %rdi,%rax
movb   $0x0,(%rax)
add    $0x1,%rax
pop    %rbx
pop    %r14
pop    %rbp
ret

LLVM IR (-O0):
define i8* @TlsIntToUTF8(i8* %0, i32* %1) {
%3 = alloca i8*
%4 = alloca i32*
%5 = alloca i32*
%6 = alloca i8*
%7 = alloca i32
%8 = alloca i32
%9 = alloca i32
%10 = alloca i32
store i8* %0, i8** %3
store i32* %1, i32** %4
%11 = load i32*, i32** %4
store i32* %11, i32** %5
%12 = load i8*, i8** %3
store i8* %12, i8** %6
br label %13
13: ; preds = %71, %2
%14 = load i32*, i32** %5
%15 = load i32, i32* %14
%16 = icmp ne i32 %15, 0
br i1 %16, label %17, label %72
17: ; preds = %13
%18 = load i32*, i32** %5
%19 = getelementptr inbounds i32, i32* %18, i32 1
store i32* %19, i32** %5
%20 = load i32, i32* %18
store i32 %20, i32* %7
%21 = load i32, i32* %7
%22 = icmp sgt i32 %21, 1114111
br i1 %22, label %26, label %23
23: ; preds = %17
%24 = load i32, i32* %7
%25 = icmp slt i32 %24, 0
br i1 %25, label %26, label %27
26: ; preds = %23, %17
store i32 65533, i32* %7
br label %27
27: ; preds = %26, %23
%28 = load i32, i32* %7
%29 = icmp slt i32 %28, 128
br i1 %29, label %30, label %35
30: ; preds = %27
%31 = load i32, i32* %7
%32 = trunc i32 %31 to i8
%33 = load i8*, i8** %6
%34 = getelementptr inbounds i8, i8* %33, i32 1
store i8* %34, i8** %6
store i8 %32, i8* %33
br label %71
35: ; preds = %27
store i32 2048, i32* %8
store i32 6, i32* %9
store i32 65472, i32* %10
br label %36
36: ; preds = %40, %35
%37 = load i32, i32* %7
%38 = load i32, i32* %8
%39 = icmp sge i32 %37, %38
br i1 %39, label %40, label %47
40: ; preds = %36
%41 = load i32, i32* %8
%42 = shl i32 %41, 5
store i32 %42, i32* %8
%43 = load i32, i32* %9
%44 = add nsw i32 %43, 6
store i32 %44, i32* %9
%45 = load i32, i32* %10
%46 = ashr i32 %45, 1
store i32 %46, i32* %10
br label %36
47: ; preds = %36
%48 = load i32, i32* %7
%49 = load i32, i32* %9
%50 = ashr i32 %48, %49
%51 = load i32, i32* %10
%52 = or i32 %50, %51
%53 = trunc i32 %52 to i8
%54 = load i8*, i8** %6
%55 = getelementptr inbounds i8, i8* %54, i32 1
store i8* %55, i8** %6
store i8 %53, i8* %54
br label %56
56: ; preds = %59, %47
%57 = load i32, i32* %9
%58 = icmp ne i32 %57, 0
br i1 %58, label %59, label %70
59: ; preds = %56
%60 = load i32, i32* %9
%61 = sub nsw i32 %60, 6
store i32 %61, i32* %9
%62 = load i32, i32* %7
%63 = load i32, i32* %9
%64 = ashr i32 %62, %63
%65 = and i32 %64, 63
%66 = or i32 128, %65
%67 = trunc i32 %66 to i8
%68 = load i8*, i8** %6
%69 = getelementptr inbounds i8, i8* %68, i32 1
store i8* %69, i8** %6
store i8 %67, i8* %68
br label %56
70: ; preds = %56
br label %71
71: ; preds = %70, %30
br label %13
72: ; preds = %13
%73 = load i8*, i8** %6
%74 = getelementptr inbounds i8, i8* %73, i32 1
store i8* %74, i8** %6
store i8 0, i8* %73
%75 = load i8*, i8** %6
ret i8* %75
}

LLVM IR (-O2):
define i8* @TlsIntToUTF8(i8* writeonly %0, i32* nocapture %1) {
%3 = load i32, i32* %1
%4 = icmp eq i32 %3, 0
br i1 %4, label %110, label %5
5: ; preds = %2, %106
%6 = phi i32 [ %108, %106 ], [ %3, %2 ]
%7 = phi i8* [ %107, %106 ], [ %0, %2 ]
%8 = phi i32* [ %9, %106 ], [ %1, %2 ]
%9 = getelementptr inbounds i32, i32* %8, i64 1
%10 = icmp ugt i32 %6, 1114111
%11 = select i1 %10, i32 65533, i32 %6
%12 = icmp ult i32 %11, 128
br i1 %12, label %15, label %13
13: ; preds = %5
%14 = icmp ult i32 %11, 2048
br i1 %14, label %26, label %18
15: ; preds = %5
%16 = trunc i32 %11 to i8
%17 = getelementptr inbounds i8, i8* %7, i64 1
store i8 %16, i8* %7
br label %106
18: ; preds = %13, %18
%19 = phi i32 [ %24, %18 ], [ 65472, %13 ]
%20 = phi i32 [ %23, %18 ], [ 6, %13 ]
%21 = phi i32 [ %22, %18 ], [ 2048, %13 ]
%22 = shl i32 %21, 5
%23 = add nuw nsw i32 %20, 6
%24 = lshr i32 %19, 1
%25 = icmp slt i32 %11, %22
br i1 %25, label %26, label %18
26: ; preds = %18, %13
%27 = phi i32 [ 6, %13 ], [ %23, %18 ]
%28 = phi i32 [ 65472, %13 ], [ %24, %18 ]
%29 = ashr i32 %11, %27
%30 = or i32 %29, %28
%31 = trunc i32 %30 to i8
store i8 %31, i8* %7
%32 = getelementptr inbounds i8, i8* %7, i64 1
%33 = add i32 %27, -6
%34 = udiv i32 %33, 6
%35 = add nuw nsw i32 %34, 1
%36 = zext i32 %35 to i64
%37 = icmp ult i32 %33, 90
br i1 %37, label %93, label %38
38: ; preds = %26
%39 = and i64 %36, 2147483632
%40 = getelementptr i8, i8* %32, i64 %39
%41 = trunc i64 %39 to i32
%42 = mul i32 %41, -6
%43 = add i32 %27, %42
%44 = insertelement <16 x i32> poison, i32 %27, i64 0
%45 = shufflevector <16 x i32> %44, <16 x i32> poison, <16 x i32> zeroinitializer
%46 = add <16 x i32> %45, <i32 0, i32 -6, i32 -12, i32 -18, i32 -24, i32 -30, i32 -36, i32 -42, i32 -48, i32 -54, i32 -60, i32 -66, i32 -72, i32 -78, i32 -84, i32 -90>
%47 = insertelement <16 x i32> poison, i32 %11, i64 0
%48 = shufflevector <16 x i32> %47, <16 x i32> poison, <16 x i32> zeroinitializer
%49 = add nsw i64 %39, -16
%50 = lshr exact i64 %49, 4
%51 = add nuw nsw i64 %50, 1
%52 = and i64 %51, 1
%53 = icmp eq i64 %49, 0
br i1 %53, label %79, label %54
54: ; preds = %38
%55 = and i64 %51, 2305843009213693950
br label %56
56: ; preds = %56, %54
%57 = phi i64 [ 0, %54 ], [ %75, %56 ]
%58 = phi <16 x i32> [ %46, %54 ], [ %76, %56 ]
%59 = phi i64 [ 0, %54 ], [ %77, %56 ]
%60 = getelementptr i8, i8* %32, i64 %57
%61 = add nsw <16 x i32> %58, <i32 -6, i32 -6, i32 -6, i32 -6, i32 -6, i32 -6, i32 -6, i32 -6, i32 -6, i32 -6, i32 -6, i32 -6, i32 -6, i32 -6, i32 -6, i32 -6>
%62 = ashr <16 x i32> %48, %61
%63 = trunc <16 x i32> %62 to <16 x i8>
%64 = and <16 x i8> %63, <i8 63, i8 63, i8 63, i8 63, i8 63, i8 63, i8 63, i8 63, i8 63, i8 63, i8 63, i8 63, i8 63, i8 63, i8 63, i8 63>
%65 = or <16 x i8> %64, <i8 -128, i8 -128, i8 -128, i8 -128, i8 -128, i8 -128, i8 -128, i8 -128, i8 -128, i8 -128, i8 -128, i8 -128, i8 -128, i8 -128, i8 -128, i8 -128>
%66 = bitcast i8* %60 to <16 x i8>*
store <16 x i8> %65, <16 x i8>* %66
%67 = or i64 %57, 16
%68 = getelementptr i8, i8* %32, i64 %67
%69 = add <16 x i32> %58, <i32 -102, i32 -102, i32 -102, i32 -102, i32 -102, i32 -102, i32 -102, i32 -102, i32 -102, i32 -102, i32 -102, i32 -102, i32 -102, i32 -102, i32 -102, i32 -102>
%70 = ashr <16 x i32> %48, %69
%71 = trunc <16 x i32> %70 to <16 x i8>
%72 = and <16 x i8> %71, <i8 63, i8 63, i8 63, i8 63, i8 63, i8 63, i8 63, i8 63, i8 63, i8 63, i8 63, i8 63, i8 63, i8 63, i8 63, i8 63>
%73 = or <16 x i8> %72, <i8 -128, i8 -128, i8 -128, i8 -128, i8 -128, i8 -128, i8 -128, i8 -128, i8 -128, i8 -128, i8 -128, i8 -128, i8 -128, i8 -128, i8 -128, i8 -128>
%74 = bitcast i8* %68 to <16 x i8>*
store <16 x i8> %73, <16 x i8>* %74
%75 = add nuw i64 %57, 32
%76 = add <16 x i32> %58, <i32 -192, i32 -192, i32 -192, i32 -192, i32 -192, i32 -192, i32 -192, i32 -192, i32 -192, i32 -192, i32 -192, i32 -192, i32 -192, i32 -192, i32 -192, i32 -192>
%77 = add i64 %59, 2
%78 = icmp eq i64 %77, %55
br i1 %78, label %79, label %56
79: ; preds = %56, %38
%80 = phi i64 [ 0, %38 ], [ %75, %56 ]
%81 = phi <16 x i32> [ %46, %38 ], [ %76, %56 ]
%82 = icmp eq i64 %52, 0
br i1 %82, label %91, label %83
83: ; preds = %79
%84 = getelementptr i8, i8* %32, i64 %80
%85 = add nsw <16 x i32> %81, <i32 -6, i32 -6, i32 -6, i32 -6, i32 -6, i32 -6, i32 -6, i32 -6, i32 -6, i32 -6, i32 -6, i32 -6, i32 -6, i32 -6, i32 -6, i32 -6>
%86 = ashr <16 x i32> %48, %85
%87 = trunc <16 x i32> %86 to <16 x i8>
%88 = and <16 x i8> %87, <i8 63, i8 63, i8 63, i8 63, i8 63, i8 63, i8 63, i8 63, i8 63, i8 63, i8 63, i8 63, i8 63, i8 63, i8 63, i8 63>
%89 = or <16 x i8> %88, <i8 -128, i8 -128, i8 -128, i8 -128, i8 -128, i8 -128, i8 -128, i8 -128, i8 -128, i8 -128, i8 -128, i8 -128, i8 -128, i8 -128, i8 -128, i8 -128>
%90 = bitcast i8* %84 to <16 x i8>*
store <16 x i8> %89, <16 x i8>* %90
br label %91
91: ; preds = %79, %83
%92 = icmp eq i64 %39, %36
br i1 %92, label %106, label %93
93: ; preds = %26, %91
%94 = phi i8* [ %32, %26 ], [ %40, %91 ]
%95 = phi i32 [ %27, %26 ], [ %43, %91 ]
br label %96
96: ; preds = %93, %96
%97 = phi i8* [ %104, %96 ], [ %94, %93 ]
%98 = phi i32 [ %99, %96 ], [ %95, %93 ]
%99 = add nsw i32 %98, -6
%100 = ashr i32 %11, %99
%101 = trunc i32 %100 to i8
%102 = and i8 %101, 63
%103 = or i8 %102, -128
store i8 %103, i8* %97
%104 = getelementptr inbounds i8, i8* %97, i64 1
%105 = icmp eq i32 %99, 0
br i1 %105, label %106, label %96
106: ; preds = %96, %91, %15
%107 = phi i8* [ %17, %15 ], [ %40, %91 ], [ %104, %96 ]
%108 = load i32, i32* %9
%109 = icmp eq i32 %108, 0
br i1 %109, label %110, label %5
110: ; preds = %106, %2
%111 = phi i8* [ %0, %2 ], [ %107, %106 ]
%112 = getelementptr inbounds i8, i8* %111, i64 1
store i8 0, i8* %111
ret i8* %112
}