// File: attractivechaos[P]udb2/stb/./stb.h
// Function: stb_to_utf8
char * stb_to_utf8(char *buffer, stb__wchar *str, int n)
{
   int i=0;
   --n;
   while (*str) {
      if (*str < 0x80) {
         if (i+1 > n) return NULL;
         buffer[i++] = (char) *str++;
      } else if (*str < 0x800) {
         if (i+2 > n) return NULL;
         buffer[i++] = 0xc0 + (*str >> 6);
         buffer[i++] = 0x80 + (*str & 0x3f);
         str += 1;
      } else if (*str >= 0xd800 && *str < 0xdc00) {
         stb_uint32 c;
         if (i+4 > n) return NULL;
         c = ((str[0] - 0xd800) << 10) + ((str[1]) - 0xdc00) + 0x10000;
         buffer[i++] = 0xf0 + (c >> 18);
         buffer[i++] = 0x80 + ((c >> 12) & 0x3f);
         buffer[i++] = 0x80 + ((c >>  6) & 0x3f);
         buffer[i++] = 0x80 + ((c      ) & 0x3f);
         str += 2;
      } else if (*str >= 0xdc00 && *str < 0xe000) {
         return NULL;
      } else {
         if (i+3 > n) return NULL;
         buffer[i++] = 0xe0 + (*str >> 12);
         buffer[i++] = 0x80 + ((*str >> 6) & 0x3f);
         buffer[i++] = 0x80 + ((*str     ) & 0x3f);
         str += 1;
      }
   }
   buffer[i] = 0;
   return buffer;
}

// Assembly:
movq %rdi, -0x10(%rsp)
movq %rsi, -0x18(%rsp)
movl %edx, -0x1c(%rsp)
movl $0x0, -0x20(%rsp)
movl -0x1c(%rsp), %eax
addl $-0x1, %eax
movl %eax, -0x1c(%rsp)
movq -0x18(%rsp), %rax
cmpw $0x0, (%rax)
je 0x355f
movq -0x18(%rsp), %rax
movzwl (%rax), %eax
cmpl $0x80, %eax
jge 0x32cd
movl -0x20(%rsp), %eax
addl $0x1, %eax
cmpl -0x1c(%rsp), %eax
jle 0x329a
movq $0x0, -0x8(%rsp)
jmp 0x3577
movq -0x18(%rsp), %rax
movq %rax, %rcx
addq $0x2, %rcx
movq %rcx, -0x18(%rsp)
movw (%rax), %ax
movb %al, %dl
movq -0x10(%rsp), %rax
movl -0x20(%rsp), %ecx
movl %ecx, %esi
addl $0x1, %esi
movl %esi, -0x20(%rsp)
movslq %ecx, %rcx
movb %dl, (%rax,%rcx)
jmp 0x355a
movq -0x18(%rsp), %rax
movzwl (%rax), %eax
cmpl $0x800, %eax            # imm = 0x800
jge 0x3362
movl -0x20(%rsp), %eax
addl $0x2, %eax
cmpl -0x1c(%rsp), %eax
jle 0x32fb
movq $0x0, -0x8(%rsp)
jmp 0x3577
movq -0x18(%rsp), %rax
movzwl (%rax), %eax
sarl $0x6, %eax
addl $0xc0, %eax
movb %al, %dl
movq -0x10(%rsp), %rax
movl -0x20(%rsp), %ecx
movl %ecx, %esi
addl $0x1, %esi
movl %esi, -0x20(%rsp)
movslq %ecx, %rcx
movb %dl, (%rax,%rcx)
movq -0x18(%rsp), %rax
movzwl (%rax), %eax
andl $0x3f, %eax
addl $0x80, %eax
movb %al, %dl
movq -0x10(%rsp), %rax
movl -0x20(%rsp), %ecx
movl %ecx, %esi
addl $0x1, %esi
movl %esi, -0x20(%rsp)
movslq %ecx, %rcx
movb %dl, (%rax,%rcx)
movq -0x18(%rsp), %rax
addq $0x2, %rax
movq %rax, -0x18(%rsp)
jmp 0x3558
movq -0x18(%rsp), %rax
movzwl (%rax), %eax
cmpl $0xd800, %eax           # imm = 0xD800
jl 0x347e
movq -0x18(%rsp), %rax
movzwl (%rax), %eax
cmpl $0xdc00, %eax           # imm = 0xDC00
jge 0x347e
movl -0x20(%rsp), %eax
addl $0x4, %eax
cmpl -0x1c(%rsp), %eax
jle 0x33a3
movq $0x0, -0x8(%rsp)
jmp 0x3577
movq -0x18(%rsp), %rax
movzwl (%rax), %eax
subl $0xd800, %eax           # imm = 0xD800
shll $0xa, %eax
movq -0x18(%rsp), %rcx
movzwl 0x2(%rcx), %ecx
subl $0xdc00, %ecx           # imm = 0xDC00
addl %ecx, %eax
addl $0x10000, %eax          # imm = 0x10000
movl %eax, -0x24(%rsp)
movl -0x24(%rsp), %eax
shrl $0x12, %eax
addl $0xf0, %eax
movb %al, %dl
movq -0x10(%rsp), %rax
movl -0x20(%rsp), %ecx
movl %ecx, %esi
addl $0x1, %esi
movl %esi, -0x20(%rsp)
movslq %ecx, %rcx
movb %dl, (%rax,%rcx)
movl -0x24(%rsp), %eax
shrl $0xc, %eax
andl $0x3f, %eax
addl $0x80, %eax
movb %al, %dl
movq -0x10(%rsp), %rax
movl -0x20(%rsp), %ecx
movl %ecx, %esi
addl $0x1, %esi
movl %esi, -0x20(%rsp)
movslq %ecx, %rcx
movb %dl, (%rax,%rcx)
movl -0x24(%rsp), %eax
shrl $0x6, %eax
andl $0x3f, %eax
addl $0x80, %eax
movb %al, %dl
movq -0x10(%rsp), %rax
movl -0x20(%rsp), %ecx
movl %ecx, %esi
addl $0x1, %esi
movl %esi, -0x20(%rsp)
movslq %ecx, %rcx
movb %dl, (%rax,%rcx)
movl -0x24(%rsp), %eax
andl $0x3f, %eax
addl $0x80, %eax
movb %al, %dl
movq -0x10(%rsp), %rax
movl -0x20(%rsp), %ecx
movl %ecx, %esi
addl $0x1, %esi
movl %esi, -0x20(%rsp)
movslq %ecx, %rcx
movb %dl, (%rax,%rcx)
movq -0x18(%rsp), %rax
addq $0x4, %rax
movq %rax, -0x18(%rsp)
jmp 0x3556
movq -0x18(%rsp), %rax
movzwl (%rax), %eax
cmpl $0xdc00, %eax           # imm = 0xDC00
jl 0x34aa
movq -0x18(%rsp), %rax
movzwl (%rax), %eax
cmpl $0xe000, %eax           # imm = 0xE000
jge 0x34aa
movq $0x0, -0x8(%rsp)
jmp 0x3577
movl -0x20(%rsp), %eax
addl $0x3, %eax
cmpl -0x1c(%rsp), %eax
jle 0x34c5
movq $0x0, -0x8(%rsp)
jmp 0x3577
movq -0x18(%rsp), %rax
movzwl (%rax), %eax
sarl $0xc, %eax
addl $0xe0, %eax
movb %al, %dl
movq -0x10(%rsp), %rax
movl -0x20(%rsp), %ecx
movl %ecx, %esi
addl $0x1, %esi
movl %esi, -0x20(%rsp)
movslq %ecx, %rcx
movb %dl, (%rax,%rcx)
movq -0x18(%rsp), %rax
movzwl (%rax), %eax
sarl $0x6, %eax
andl $0x3f, %eax
addl $0x80, %eax
movb %al, %dl
movq -0x10(%rsp), %rax
movl -0x20(%rsp), %ecx
movl %ecx, %esi
addl $0x1, %esi
movl %esi, -0x20(%rsp)
movslq %ecx, %rcx
movb %dl, (%rax,%rcx)
movq -0x18(%rsp), %rax
movzwl (%rax), %eax
andl $0x3f, %eax
addl $0x80, %eax
movb %al, %dl
movq -0x10(%rsp), %rax
movl -0x20(%rsp), %ecx
movl %ecx, %esi
addl $0x1, %esi
movl %esi, -0x20(%rsp)
movslq %ecx, %rcx
movb %dl, (%rax,%rcx)
movq -0x18(%rsp), %rax
addq $0x2, %rax
movq %rax, -0x18(%rsp)
jmp 0x3556
jmp 0x3558
jmp 0x355a
jmp 0x3261
movq -0x10(%rsp), %rax
movslq -0x20(%rsp), %rcx
movb $0x0, (%rax,%rcx)
movq -0x10(%rsp), %rax
movq %rax, -0x8(%rsp)
movq -0x8(%rsp), %rax
retq
nopl (%rax)