// File: /workspace/github_c_makefile_star2_O2/ggerganov[P]font-rasterizer/./stb_truetype.h
// Function: stbtt__CompareUTF8toUTF16_bigendian_prefix
static stbtt_int32 stbtt__CompareUTF8toUTF16_bigendian_prefix(stbtt_uint8 *s1, stbtt_int32 len1, stbtt_uint8 *s2, stbtt_int32 len2) 
{
   stbtt_int32 i=0;

   // convert utf16 to utf8 and compare the results while converting
   while (len2) {
      stbtt_uint16 ch = s2[0]*256 + s2[1];
      if (ch < 0x80) {
         if (i >= len1) return -1;
         if (s1[i++] != ch) return -1;
      } else if (ch < 0x800) {
         if (i+1 >= len1) return -1;
         if (s1[i++] != 0xc0 + (ch >> 6)) return -1;
         if (s1[i++] != 0x80 + (ch & 0x3f)) return -1;
      } else if (ch >= 0xd800 && ch < 0xdc00) {
         stbtt_uint32 c;
         stbtt_uint16 ch2 = s2[2]*256 + s2[3];
         if (i+3 >= len1) return -1;
         c = ((ch - 0xd800) << 10) + (ch2 - 0xdc00) + 0x10000;
         if (s1[i++] != 0xf0 + (c >> 18)) return -1;
         if (s1[i++] != 0x80 + ((c >> 12) & 0x3f)) return -1;
         if (s1[i++] != 0x80 + ((c >>  6) & 0x3f)) return -1;
         if (s1[i++] != 0x80 + ((c      ) & 0x3f)) return -1;
         s2 += 2; // plus another 2 below
         len2 -= 2;
      } else if (ch >= 0xdc00 && ch < 0xe000) {
         return -1;
      } else {
         if (i+2 >= len1) return -1;
         if (s1[i++] != 0xe0 + (ch >> 12)) return -1;
         if (s1[i++] != 0x80 + ((ch >> 6) & 0x3f)) return -1;
         if (s1[i++] != 0x80 + ((ch     ) & 0x3f)) return -1;
      }
      s2 += 2;
      len2 -= 2;
   }
   return i;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %rbx
xorl %eax, %eax
movl $0xffffffff, %r8d       # imm = 0xFFFFFFFF
testl %ecx, %ecx
je 0xbd6d
movzbl (%rdx), %ebx
movl %ebx, %r9d
shll $0x8, %r9d
movzbl 0x1(%rdx), %r11d
orl %r11d, %r9d
movslq %eax, %r10
cmpl $0x7f, %r9d
ja 0xbc0d
cmpl %esi, %eax
jge 0xbd6a
movzbl (%rdi,%r10), %r10d
cmpl %r10d, %r9d
jne 0xbd6a
incl %eax
jmp 0xbd5e
cmpb $0x7, %bl
ja 0xbc58
leaq 0x1(%r10), %rbx
cmpl %esi, %ebx
jge 0xbd6a
movzbl (%rdi,%r10), %r10d
shrl $0x6, %r9d
orl $0xc0, %r9d
cmpl %r10d, %r9d
jne 0xbd6a
movzbl (%rdi,%rbx), %r9d
andl $0x3f, %r11d
orl $0x80, %r11d
cmpl %r9d, %r11d
jne 0xbd6a
addl $0x2, %eax
jmp 0xbd5e
movl %ebx, %r14d
andb $-0x4, %r14b
cmpb $-0x28, %r14b
jne 0xbd0a
leaq 0x3(%r10), %r11
cmpl %esi, %r11d
jge 0xbd6a
movzbl 0x3(%rdx), %ebx
movzbl 0x2(%rdx), %r14d
shll $0x8, %r14d
orl %ebx, %r14d
shll $0xa, %r9d
addl %r14d, %r9d
addl $0xfca02400, %r9d       # imm = 0xFCA02400
movzbl (%rdi,%r10), %r14d
movl %r9d, %r15d
shrl $0x12, %r15d
addl $0xf0, %r15d
cmpl %r14d, %r15d
jne 0xbd6a
movzbl 0x1(%rdi,%r10), %r14d
movl %r9d, %r15d
shrl $0xc, %r15d
andl $0x3f, %r15d
orl $0x80, %r15d
cmpl %r14d, %r15d
jne 0xbd6a
movzbl 0x2(%rdi,%r10), %r10d
shrl $0x6, %r9d
andl $0x3f, %r9d
orl $0x80, %r9d
cmpl %r10d, %r9d
jne 0xbd6a
movzbl (%rdi,%r11), %r9d
andl $0x3f, %ebx
orl $0x80, %ebx
cmpl %r9d, %ebx
jne 0xbd6a
addq $0x2, %rdx
addl $0x4, %eax
addl $-0x2, %ecx
jmp 0xbd5e
cmpb $-0x24, %r14b
je 0xbd6a
leaq 0x2(%r10), %r14
cmpl %esi, %r14d
jge 0xbd6a
movzbl (%rdi,%r10), %r15d
shrl $0x4, %ebx
orl $0xe0, %ebx
cmpl %r15d, %ebx
jne 0xbd6a
movzbl 0x1(%rdi,%r10), %r10d
shrl $0x6, %r9d
andl $0x3f, %r9d
orl $0x80, %r9d
cmpl %r10d, %r9d
jne 0xbd6a
movzbl (%rdi,%r14), %r9d
andl $0x3f, %r11d
orl $0x80, %r11d
cmpl %r9d, %r11d
jne 0xbd6a
addl $0x3, %eax
addq $0x2, %rdx
addl $-0x2, %ecx
jmp 0xbbcd
movl %r8d, %eax
popq %rbx
popq %r14
popq %r15
popq %rbp
retq