// File: attractivechaos[P]udb2/stb/./stb.h
// Function: stb_from_utf8
stb__wchar * stb_from_utf8(stb__wchar *buffer, char *ostr, int n)
{
   unsigned char *str = (unsigned char *) ostr;
   stb_uint32 c;
   int i=0;
   --n;
   while (*str) {
      if (i >= n)
         return NULL;
      if (!(*str & 0x80))
         buffer[i++] = *str++;
      else if ((*str & 0xe0) == 0xc0) {
         if (*str < 0xc2) return NULL;
         c = (*str++ & 0x1f) << 6;
         if ((*str & 0xc0) != 0x80) return NULL;
         buffer[i++] = c + (*str++ & 0x3f);
      } else if ((*str & 0xf0) == 0xe0) {
         if (*str == 0xe0 && (str[1] < 0xa0 || str[1] > 0xbf)) return NULL;
         if (*str == 0xed && str[1] > 0x9f) return NULL; // str[1] < 0x80 is checked below
         c = (*str++ & 0x0f) << 12;
         if ((*str & 0xc0) != 0x80) return NULL;
         c += (*str++ & 0x3f) << 6;
         if ((*str & 0xc0) != 0x80) return NULL;
         buffer[i++] = c + (*str++ & 0x3f);
      } else if ((*str & 0xf8) == 0xf0) {
         if (*str > 0xf4) return NULL;
         if (*str == 0xf0 && (str[1] < 0x90 || str[1] > 0xbf)) return NULL;
         if (*str == 0xf4 && str[1] > 0x8f) return NULL; // str[1] < 0x80 is checked below
         c = (*str++ & 0x07) << 18;
         if ((*str & 0xc0) != 0x80) return NULL;
         c += (*str++ & 0x3f) << 12;
         if ((*str & 0xc0) != 0x80) return NULL;
         c += (*str++ & 0x3f) << 6;
         if ((*str & 0xc0) != 0x80) return NULL;
         c += (*str++ & 0x3f);
         // utf-8 encodings of values used in surrogate pairs are invalid
         if ((c & 0xFFFFF800) == 0xD800) return NULL;
         if (c >= 0x10000) {
            c -= 0x10000;
            if (i + 2 > n) return NULL;
            buffer[i++] = 0xD800 | (0x3ff & (c >> 10));
            buffer[i++] = 0xDC00 | (0x3ff & (c      ));
         }
      } else
         return NULL;
   }
   buffer[i] = 0;
   return buffer;
}

// Assembly:
movq %rdi, -0x10(%rsp)
movq %rsi, -0x18(%rsp)
movl %edx, -0x1c(%rsp)
movq -0x18(%rsp), %rax
movq %rax, -0x28(%rsp)
movl $0x0, -0x30(%rsp)
movl -0x1c(%rsp), %eax
addl $-0x1, %eax
movl %eax, -0x1c(%rsp)
movq -0x28(%rsp), %rax
cmpb $0x0, (%rax)
je 0x3214
movl -0x30(%rsp), %eax
cmpl -0x1c(%rsp), %eax
jl 0x2d91
movq $0x0, -0x8(%rsp)
jmp 0x322e
movq -0x28(%rsp), %rax
movzbl (%rax), %eax
andl $0x80, %eax
cmpl $0x0, %eax
jne 0x2dd8
movq -0x28(%rsp), %rax
movq %rax, %rcx
addq $0x1, %rcx
movq %rcx, -0x28(%rsp)
movzbl (%rax), %eax
movw %ax, %dx
movq -0x10(%rsp), %rax
movl -0x30(%rsp), %ecx
movl %ecx, %esi
addl $0x1, %esi
movl %esi, -0x30(%rsp)
movslq %ecx, %rcx
movw %dx, (%rax,%rcx,2)
jmp 0x320f
movq -0x28(%rsp), %rax
movzbl (%rax), %eax
andl $0xe0, %eax
cmpl $0xc0, %eax
jne 0x2e8b
movq -0x28(%rsp), %rax
movzbl (%rax), %eax
cmpl $0xc2, %eax
jge 0x2e0d
movq $0x0, -0x8(%rsp)
jmp 0x322e
movq -0x28(%rsp), %rax
movq %rax, %rcx
addq $0x1, %rcx
movq %rcx, -0x28(%rsp)
movzbl (%rax), %eax
andl $0x1f, %eax
shll $0x6, %eax
movl %eax, -0x2c(%rsp)
movq -0x28(%rsp), %rax
movzbl (%rax), %eax
andl $0xc0, %eax
cmpl $0x80, %eax
je 0x2e4d
movq $0x0, -0x8(%rsp)
jmp 0x322e
movl -0x2c(%rsp), %eax
movq -0x28(%rsp), %rcx
movq %rcx, %rdx
addq $0x1, %rdx
movq %rdx, -0x28(%rsp)
movzbl (%rcx), %ecx
andl $0x3f, %ecx
addl %ecx, %eax
movw %ax, %dx
movq -0x10(%rsp), %rax
movl -0x30(%rsp), %ecx
movl %ecx, %esi
addl $0x1, %esi
movl %esi, -0x30(%rsp)
movslq %ecx, %rcx
movw %dx, (%rax,%rcx,2)
jmp 0x320d
movq -0x28(%rsp), %rax
movzbl (%rax), %eax
andl $0xf0, %eax
cmpl $0xe0, %eax
jne 0x2fcf
movq -0x28(%rsp), %rax
movzbl (%rax), %eax
cmpl $0xe0, %eax
jne 0x2ee0
movq -0x28(%rsp), %rax
movzbl 0x1(%rax), %eax
cmpl $0xa0, %eax
jl 0x2ed2
movq -0x28(%rsp), %rax
movzbl 0x1(%rax), %eax
cmpl $0xbf, %eax
jle 0x2ee0
movq $0x0, -0x8(%rsp)
jmp 0x322e
movq -0x28(%rsp), %rax
movzbl (%rax), %eax
cmpl $0xed, %eax
jne 0x2f0d
movq -0x28(%rsp), %rax
movzbl 0x1(%rax), %eax
cmpl $0x9f, %eax
jle 0x2f0d
movq $0x0, -0x8(%rsp)
jmp 0x322e
movq -0x28(%rsp), %rax
movq %rax, %rcx
addq $0x1, %rcx
movq %rcx, -0x28(%rsp)
movzbl (%rax), %eax
andl $0xf, %eax
shll $0xc, %eax
movl %eax, -0x2c(%rsp)
movq -0x28(%rsp), %rax
movzbl (%rax), %eax
andl $0xc0, %eax
cmpl $0x80, %eax
je 0x2f4d
movq $0x0, -0x8(%rsp)
jmp 0x322e
movq -0x28(%rsp), %rax
movq %rax, %rcx
addq $0x1, %rcx
movq %rcx, -0x28(%rsp)
movzbl (%rax), %eax
andl $0x3f, %eax
shll $0x6, %eax
addl -0x2c(%rsp), %eax
movl %eax, -0x2c(%rsp)
movq -0x28(%rsp), %rax
movzbl (%rax), %eax
andl $0xc0, %eax
cmpl $0x80, %eax
je 0x2f91
movq $0x0, -0x8(%rsp)
jmp 0x322e
movl -0x2c(%rsp), %eax
movq -0x28(%rsp), %rcx
movq %rcx, %rdx
addq $0x1, %rdx
movq %rdx, -0x28(%rsp)
movzbl (%rcx), %ecx
andl $0x3f, %ecx
addl %ecx, %eax
movw %ax, %dx
movq -0x10(%rsp), %rax
movl -0x30(%rsp), %ecx
movl %ecx, %esi
addl $0x1, %esi
movl %esi, -0x30(%rsp)
movslq %ecx, %rcx
movw %dx, (%rax,%rcx,2)
jmp 0x320b
movq -0x28(%rsp), %rax
movzbl (%rax), %eax
andl $0xf8, %eax
cmpl $0xf0, %eax
jne 0x31fe
movq -0x28(%rsp), %rax
movzbl (%rax), %eax
cmpl $0xf4, %eax
jle 0x3004
movq $0x0, -0x8(%rsp)
jmp 0x322e
movq -0x28(%rsp), %rax
movzbl (%rax), %eax
cmpl $0xf0, %eax
jne 0x3041
movq -0x28(%rsp), %rax
movzbl 0x1(%rax), %eax
cmpl $0x90, %eax
jl 0x3033
movq -0x28(%rsp), %rax
movzbl 0x1(%rax), %eax
cmpl $0xbf, %eax
jle 0x3041
movq $0x0, -0x8(%rsp)
jmp 0x322e
movq -0x28(%rsp), %rax
movzbl (%rax), %eax
cmpl $0xf4, %eax
jne 0x306e
movq -0x28(%rsp), %rax
movzbl 0x1(%rax), %eax
cmpl $0x8f, %eax
jle 0x306e
movq $0x0, -0x8(%rsp)
jmp 0x322e
movq -0x28(%rsp), %rax
movq %rax, %rcx
addq $0x1, %rcx
movq %rcx, -0x28(%rsp)
movzbl (%rax), %eax
andl $0x7, %eax
shll $0x12, %eax
movl %eax, -0x2c(%rsp)
movq -0x28(%rsp), %rax
movzbl (%rax), %eax
andl $0xc0, %eax
cmpl $0x80, %eax
je 0x30ae
movq $0x0, -0x8(%rsp)
jmp 0x322e
movq -0x28(%rsp), %rax
movq %rax, %rcx
addq $0x1, %rcx
movq %rcx, -0x28(%rsp)
movzbl (%rax), %eax
andl $0x3f, %eax
shll $0xc, %eax
addl -0x2c(%rsp), %eax
movl %eax, -0x2c(%rsp)
movq -0x28(%rsp), %rax
movzbl (%rax), %eax
andl $0xc0, %eax
cmpl $0x80, %eax
je 0x30f2
movq $0x0, -0x8(%rsp)
jmp 0x322e
movq -0x28(%rsp), %rax
movq %rax, %rcx
addq $0x1, %rcx
movq %rcx, -0x28(%rsp)
movzbl (%rax), %eax
andl $0x3f, %eax
shll $0x6, %eax
addl -0x2c(%rsp), %eax
movl %eax, -0x2c(%rsp)
movq -0x28(%rsp), %rax
movzbl (%rax), %eax
andl $0xc0, %eax
cmpl $0x80, %eax
je 0x3136
movq $0x0, -0x8(%rsp)
jmp 0x322e
movq -0x28(%rsp), %rax
movq %rax, %rcx
addq $0x1, %rcx
movq %rcx, -0x28(%rsp)
movzbl (%rax), %eax
andl $0x3f, %eax
addl -0x2c(%rsp), %eax
movl %eax, -0x2c(%rsp)
movl -0x2c(%rsp), %eax
andl $0xfffff800, %eax       # imm = 0xFFFFF800
cmpl $0xd800, %eax           # imm = 0xD800
jne 0x3173
movq $0x0, -0x8(%rsp)
jmp 0x322e
cmpl $0x10000, -0x2c(%rsp)   # imm = 0x10000
jb 0x31fc
movl -0x2c(%rsp), %eax
subl $0x10000, %eax          # imm = 0x10000
movl %eax, -0x2c(%rsp)
movl -0x30(%rsp), %eax
addl $0x2, %eax
cmpl -0x1c(%rsp), %eax
jle 0x31a5
movq $0x0, -0x8(%rsp)
jmp 0x322e
movl -0x2c(%rsp), %eax
shrl $0xa, %eax
andl $0x3ff, %eax            # imm = 0x3FF
orl $0xd800, %eax           # imm = 0xD800
movw %ax, %dx
movq -0x10(%rsp), %rax
movl -0x30(%rsp), %ecx
movl %ecx, %esi
addl $0x1, %esi
movl %esi, -0x30(%rsp)
movslq %ecx, %rcx
movw %dx, (%rax,%rcx,2)
movl -0x2c(%rsp), %eax
andl $0x3ff, %eax            # imm = 0x3FF
orl $0xdc00, %eax           # imm = 0xDC00
movw %ax, %dx
movq -0x10(%rsp), %rax
movl -0x30(%rsp), %ecx
movl %ecx, %esi
addl $0x1, %esi
movl %esi, -0x30(%rsp)
movslq %ecx, %rcx
movw %dx, (%rax,%rcx,2)
jmp 0x3209
movq $0x0, -0x8(%rsp)
jmp 0x322e
jmp 0x320b
jmp 0x320d
jmp 0x320f
jmp 0x2d6b
movq -0x10(%rsp), %rax
movslq -0x30(%rsp), %rcx
movw $0x0, (%rax,%rcx,2)
movq -0x10(%rsp), %rax
movq %rax, -0x8(%rsp)
movq -0x8(%rsp), %rax
retq
nopw %cs:(%rax,%rax)