// File: /workspace/github_c_makefile_star2_O0/ggerganov[P]font-rasterizer/./stb_truetype.h
// Function: stbtt_FindGlyphIndex
STBTT_DEF int stbtt_FindGlyphIndex(const stbtt_fontinfo *info, int unicode_codepoint)
{
   stbtt_uint8 *data = info->data;
   stbtt_uint32 index_map = info->index_map;

   stbtt_uint16 format = ttUSHORT(data + index_map + 0);
   if (format == 0) { // apple byte encoding
      stbtt_int32 bytes = ttUSHORT(data + index_map + 2);
      if (unicode_codepoint < bytes-6)
         return ttBYTE(data + index_map + 6 + unicode_codepoint);
      return 0;
   } else if (format == 6) {
      stbtt_uint32 first = ttUSHORT(data + index_map + 6);
      stbtt_uint32 count = ttUSHORT(data + index_map + 8);
      if ((stbtt_uint32) unicode_codepoint >= first && (stbtt_uint32) unicode_codepoint < first+count)
         return ttUSHORT(data + index_map + 10 + (unicode_codepoint - first)*2);
      return 0;
   } else if (format == 2) {
      STBTT_assert(0); // @TODO: high-byte mapping for japanese/chinese/korean
      return 0;
   } else if (format == 4) { // standard mapping for windows fonts: binary search collection of ranges
      stbtt_uint16 segcount = ttUSHORT(data+index_map+6) >> 1;
      stbtt_uint16 searchRange = ttUSHORT(data+index_map+8) >> 1;
      stbtt_uint16 entrySelector = ttUSHORT(data+index_map+10);
      stbtt_uint16 rangeShift = ttUSHORT(data+index_map+12) >> 1;

      // do a binary search of the segments
      stbtt_uint32 endCount = index_map + 14;
      stbtt_uint32 search = endCount;

      if (unicode_codepoint > 0xffff)
         return 0;

      // they lie from endCount .. endCount + segCount
      // but searchRange is the nearest power of two, so...
      if (unicode_codepoint >= ttUSHORT(data + search + rangeShift*2))
         search += rangeShift*2;

      // now decrement to bias correctly to find smallest
      search -= 2;
      while (entrySelector) {
         stbtt_uint16 end;
         searchRange >>= 1;
         end = ttUSHORT(data + search + searchRange*2);
         if (unicode_codepoint > end)
            search += searchRange*2;
         --entrySelector;
      }
      search += 2;

      {
         stbtt_uint16 offset, start;
         stbtt_uint16 item = (stbtt_uint16) ((search - endCount) >> 1);

         STBTT_assert(unicode_codepoint <= ttUSHORT(data + endCount + 2*item));
         start = ttUSHORT(data + index_map + 14 + segcount*2 + 2 + 2*item);
         if (unicode_codepoint < start)
            return 0;

         offset = ttUSHORT(data + index_map + 14 + segcount*6 + 2 + 2*item);
         if (offset == 0)
            return (stbtt_uint16) (unicode_codepoint + ttSHORT(data + index_map + 14 + segcount*4 + 2 + 2*item));

         return ttUSHORT(data + offset + (unicode_codepoint-start)*2 + index_map + 14 + segcount*6 + 2 + 2*item);
      }
   } else if (format == 12 || format == 13) {
      stbtt_uint32 ngroups = ttULONG(data+index_map+12);
      stbtt_int32 low,high;
      low = 0; high = (stbtt_int32)ngroups;
      // Binary search the right group.
      while (low < high) {
         stbtt_int32 mid = low + ((high-low) >> 1); // rounds down, so low <= mid < high
         stbtt_uint32 start_char = ttULONG(data+index_map+16+mid*12);
         stbtt_uint32 end_char = ttULONG(data+index_map+16+mid*12+4);
         if ((stbtt_uint32) unicode_codepoint < start_char)
            high = mid;
         else if ((stbtt_uint32) unicode_codepoint > end_char)
            low = mid+1;
         else {
            stbtt_uint32 start_glyph = ttULONG(data+index_map+16+mid*12+8);
            if (format == 12)
               return start_glyph + unicode_codepoint-start_char;
            else // format == 13
               return start_glyph;
         }
      }
      return 0; // not found
   }
   // @TODO
   STBTT_assert(0);
   return 0;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x80, %rsp
movq %rdi, -0x10(%rbp)
movl %esi, -0x14(%rbp)
movq -0x10(%rbp), %rax
movq 0x8(%rax), %rax
movq %rax, -0x20(%rbp)
movq -0x10(%rbp), %rax
movl 0x34(%rax), %eax
movl %eax, -0x24(%rbp)
movq -0x20(%rbp), %rdi
movl -0x24(%rbp), %eax
addq %rax, %rdi
callq 0x4990
movw %ax, -0x26(%rbp)
movzwl -0x26(%rbp), %eax
cmpl $0x0, %eax
jne 0x44e1
movq -0x20(%rbp), %rdi
movl -0x24(%rbp), %eax
addq %rax, %rdi
addq $0x2, %rdi
callq 0x4990
movzwl %ax, %eax
movl %eax, -0x2c(%rbp)
movl -0x14(%rbp), %eax
movl -0x2c(%rbp), %ecx
subl $0x6, %ecx
cmpl %ecx, %eax
jge 0x44d5
movq -0x20(%rbp), %rax
movl -0x24(%rbp), %ecx
addq %rcx, %rax
movslq -0x14(%rbp), %rcx
movzbl 0x6(%rax,%rcx), %eax
movl %eax, -0x4(%rbp)
jmp 0x4977
movl $0x0, -0x4(%rbp)
jmp 0x4977
movzwl -0x26(%rbp), %eax
cmpl $0x6, %eax
jne 0x4568
movq -0x20(%rbp), %rdi
movl -0x24(%rbp), %eax
addq %rax, %rdi
addq $0x6, %rdi
callq 0x4990
movzwl %ax, %eax
movl %eax, -0x30(%rbp)
movq -0x20(%rbp), %rdi
movl -0x24(%rbp), %eax
addq %rax, %rdi
addq $0x8, %rdi
callq 0x4990
movzwl %ax, %eax
movl %eax, -0x34(%rbp)
movl -0x14(%rbp), %eax
cmpl -0x30(%rbp), %eax
jb 0x455c
movl -0x14(%rbp), %eax
movl -0x30(%rbp), %ecx
addl -0x34(%rbp), %ecx
cmpl %ecx, %eax
jae 0x455c
movq -0x20(%rbp), %rdi
movl -0x24(%rbp), %eax
addq %rax, %rdi
addq $0xa, %rdi
movl -0x14(%rbp), %eax
subl -0x30(%rbp), %eax
shll %eax
movl %eax, %eax
addq %rax, %rdi
callq 0x4990
movzwl %ax, %eax
movl %eax, -0x4(%rbp)
jmp 0x4977
movl $0x0, -0x4(%rbp)
jmp 0x4977
movzwl -0x26(%rbp), %eax
cmpl $0x2, %eax
jne 0x4590
leaq 0x1233d(%rip), %rdi     # 0x168b5
leaq 0x12238(%rip), %rsi     # 0x167b7
movl $0x5b6, %edx            # imm = 0x5B6
leaq 0x1223d(%rip), %rcx     # 0x167c8
callq 0x10a0
movzwl -0x26(%rbp), %eax
cmpl $0x4, %eax
jne 0x4844
movq -0x20(%rbp), %rdi
movl -0x24(%rbp), %eax
addq %rax, %rdi
addq $0x6, %rdi
callq 0x4990
movzwl %ax, %eax
sarl %eax
movw %ax, -0x36(%rbp)
movq -0x20(%rbp), %rdi
movl -0x24(%rbp), %eax
addq %rax, %rdi
addq $0x8, %rdi
callq 0x4990
movzwl %ax, %eax
sarl %eax
movw %ax, -0x38(%rbp)
movq -0x20(%rbp), %rdi
movl -0x24(%rbp), %eax
addq %rax, %rdi
addq $0xa, %rdi
callq 0x4990
movw %ax, -0x3a(%rbp)
movq -0x20(%rbp), %rdi
movl -0x24(%rbp), %eax
addq %rax, %rdi
addq $0xc, %rdi
callq 0x4990
movzwl %ax, %eax
sarl %eax
movw %ax, -0x3c(%rbp)
movl -0x24(%rbp), %eax
addl $0xe, %eax
movl %eax, -0x40(%rbp)
movl -0x40(%rbp), %eax
movl %eax, -0x44(%rbp)
cmpl $0xffff, -0x14(%rbp)    # imm = 0xFFFF
jle 0x462c
movl $0x0, -0x4(%rbp)
jmp 0x4977
movl -0x14(%rbp), %eax
movl %eax, -0x6c(%rbp)
movq -0x20(%rbp), %rdi
movl -0x44(%rbp), %eax
addq %rax, %rdi
movzwl -0x3c(%rbp), %eax
shll %eax
cltq
addq %rax, %rdi
callq 0x4990
movw %ax, %cx
movl -0x6c(%rbp), %eax
movzwl %cx, %ecx
cmpl %ecx, %eax
jl 0x4665
movzwl -0x3c(%rbp), %eax
shll %eax
addl -0x44(%rbp), %eax
movl %eax, -0x44(%rbp)
movl -0x44(%rbp), %eax
subl $0x2, %eax
movl %eax, -0x44(%rbp)
cmpw $0x0, -0x3a(%rbp)
je 0x46c2
movzwl -0x38(%rbp), %eax
sarl %eax
movw %ax, -0x38(%rbp)
movq -0x20(%rbp), %rdi
movl -0x44(%rbp), %eax
addq %rax, %rdi
movzwl -0x38(%rbp), %eax
shll %eax
cltq
addq %rax, %rdi
callq 0x4990
movw %ax, -0x46(%rbp)
movl -0x14(%rbp), %eax
movzwl -0x46(%rbp), %ecx
cmpl %ecx, %eax
jle 0x46b4
movzwl -0x38(%rbp), %eax
shll %eax
addl -0x44(%rbp), %eax
movl %eax, -0x44(%rbp)
movw -0x3a(%rbp), %ax
addw $-0x1, %ax
movw %ax, -0x3a(%rbp)
jmp 0x466e
movl -0x44(%rbp), %eax
addl $0x2, %eax
movl %eax, -0x44(%rbp)
movl -0x44(%rbp), %eax
subl -0x40(%rbp), %eax
shrl %eax
movw %ax, -0x4c(%rbp)
movl -0x14(%rbp), %eax
movl %eax, -0x70(%rbp)
movq -0x20(%rbp), %rdi
movl -0x40(%rbp), %eax
addq %rax, %rdi
movzwl -0x4c(%rbp), %eax
shll %eax
cltq
addq %rax, %rdi
callq 0x4990
movw %ax, %cx
movl -0x70(%rbp), %eax
movzwl %cx, %ecx
cmpl %ecx, %eax
jg 0x4706
jmp 0x4725
leaq 0x120f1(%rip), %rdi     # 0x167fe
leaq 0x120a3(%rip), %rsi     # 0x167b7
movl $0x5da, %edx            # imm = 0x5DA
leaq 0x120a8(%rip), %rcx     # 0x167c8
callq 0x10a0
movq -0x20(%rbp), %rdi
movl -0x24(%rbp), %eax
addq %rax, %rdi
addq $0xe, %rdi
movzwl -0x36(%rbp), %eax
shll %eax
cltq
addq %rax, %rdi
addq $0x2, %rdi
movzwl -0x4c(%rbp), %eax
shll %eax
cltq
addq %rax, %rdi
callq 0x4990
movw %ax, -0x4a(%rbp)
movl -0x14(%rbp), %eax
movzwl -0x4a(%rbp), %ecx
cmpl %ecx, %eax
jge 0x476d
movl $0x0, -0x4(%rbp)
jmp 0x4977
movq -0x20(%rbp), %rdi
movl -0x24(%rbp), %eax
addq %rax, %rdi
addq $0xe, %rdi
movzwl -0x36(%rbp), %eax
imull $0x6, %eax, %eax
cltq
addq %rax, %rdi
addq $0x2, %rdi
movzwl -0x4c(%rbp), %eax
shll %eax
cltq
addq %rax, %rdi
callq 0x4990
movw %ax, -0x48(%rbp)
movzwl -0x48(%rbp), %eax
cmpl $0x0, %eax
jne 0x47f2
movl -0x14(%rbp), %eax
movl %eax, -0x74(%rbp)
movq -0x20(%rbp), %rdi
movl -0x24(%rbp), %eax
addq %rax, %rdi
addq $0xe, %rdi
movzwl -0x36(%rbp), %eax
shll $0x2, %eax
cltq
addq %rax, %rdi
addq $0x2, %rdi
movzwl -0x4c(%rbp), %eax
shll %eax
cltq
addq %rax, %rdi
callq 0x49b0
movw %ax, %cx
movl -0x74(%rbp), %eax
movswl %cx, %ecx
addl %ecx, %eax
movzwl %ax, %eax
movl %eax, -0x4(%rbp)
jmp 0x4977
movq -0x20(%rbp), %rdi
movzwl -0x48(%rbp), %eax
cltq
addq %rax, %rdi
movl -0x14(%rbp), %eax
movzwl -0x4a(%rbp), %ecx
subl %ecx, %eax
shll %eax
cltq
addq %rax, %rdi
movl -0x24(%rbp), %eax
addq %rax, %rdi
addq $0xe, %rdi
movzwl -0x36(%rbp), %eax
imull $0x6, %eax, %eax
cltq
addq %rax, %rdi
addq $0x2, %rdi
movzwl -0x4c(%rbp), %eax
shll %eax
cltq
addq %rax, %rdi
callq 0x4990
movzwl %ax, %eax
movl %eax, -0x4(%rbp)
jmp 0x4977
movzwl -0x26(%rbp), %eax
cmpl $0xc, %eax
je 0x485a
movzwl -0x26(%rbp), %eax
cmpl $0xd, %eax
jne 0x4950
movq -0x20(%rbp), %rdi
movl -0x24(%rbp), %eax
addq %rax, %rdi
addq $0xc, %rdi
callq 0x49d0
movl %eax, -0x50(%rbp)
movl $0x0, -0x54(%rbp)
movl -0x50(%rbp), %eax
movl %eax, -0x58(%rbp)
movl -0x54(%rbp), %eax
cmpl -0x58(%rbp), %eax
jge 0x4947
movl -0x54(%rbp), %eax
movl -0x58(%rbp), %ecx
subl -0x54(%rbp), %ecx
sarl %ecx
addl %ecx, %eax
movl %eax, -0x5c(%rbp)
movq -0x20(%rbp), %rdi
movl -0x24(%rbp), %eax
addq %rax, %rdi
addq $0x10, %rdi
imull $0xc, -0x5c(%rbp), %eax
cltq
addq %rax, %rdi
callq 0x49d0
movl %eax, -0x60(%rbp)
movq -0x20(%rbp), %rdi
movl -0x24(%rbp), %eax
addq %rax, %rdi
addq $0x10, %rdi
imull $0xc, -0x5c(%rbp), %eax
cltq
addq %rax, %rdi
addq $0x4, %rdi
callq 0x49d0
movl %eax, -0x64(%rbp)
movl -0x14(%rbp), %eax
cmpl -0x60(%rbp), %eax
jae 0x48eb
movl -0x5c(%rbp), %eax
movl %eax, -0x58(%rbp)
jmp 0x4942
movl -0x14(%rbp), %eax
cmpl -0x64(%rbp), %eax
jbe 0x48fe
movl -0x5c(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x54(%rbp)
jmp 0x4940
movq -0x20(%rbp), %rdi
movl -0x24(%rbp), %eax
addq %rax, %rdi
addq $0x10, %rdi
imull $0xc, -0x5c(%rbp), %eax
cltq
addq %rax, %rdi
addq $0x8, %rdi
callq 0x49d0
movl %eax, -0x68(%rbp)
movzwl -0x26(%rbp), %eax
cmpl $0xc, %eax
jne 0x4938
movl -0x68(%rbp), %eax
addl -0x14(%rbp), %eax
subl -0x60(%rbp), %eax
movl %eax, -0x4(%rbp)
jmp 0x4977
movl -0x68(%rbp), %eax
movl %eax, -0x4(%rbp)
jmp 0x4977
jmp 0x4942
jmp 0x487d
movl $0x0, -0x4(%rbp)
jmp 0x4977
jmp 0x4952
jmp 0x4954
jmp 0x4956
jmp 0x4958
leaq 0x11f56(%rip), %rdi     # 0x168b5
leaq 0x11e51(%rip), %rsi     # 0x167b7
movl $0x5fd, %edx            # imm = 0x5FD
leaq 0x11e56(%rip), %rcx     # 0x167c8
callq 0x10a0
movl -0x4(%rbp), %eax
addq $0x80, %rsp
popq %rbp
retq
nopw %cs:(%rax,%rax)