// File: /workspace/github_c_makefile_star2_O0/ggerganov[P]font-rasterizer/./stb_truetype.h
// Function: stbtt_InitFont_internal
static int stbtt_InitFont_internal(stbtt_fontinfo *info, unsigned char *data, int fontstart)
{
   stbtt_uint32 cmap, t;
   stbtt_int32 i,numTables;

   info->data = data;
   info->fontstart = fontstart;
   info->cff = stbtt__new_buf(NULL, 0);

   cmap = stbtt__find_table(data, fontstart, "cmap");       // required
   info->loca = stbtt__find_table(data, fontstart, "loca"); // required
   info->head = stbtt__find_table(data, fontstart, "head"); // required
   info->glyf = stbtt__find_table(data, fontstart, "glyf"); // required
   info->hhea = stbtt__find_table(data, fontstart, "hhea"); // required
   info->hmtx = stbtt__find_table(data, fontstart, "hmtx"); // required
   info->kern = stbtt__find_table(data, fontstart, "kern"); // not required
   info->gpos = stbtt__find_table(data, fontstart, "GPOS"); // not required

   if (!cmap || !info->head || !info->hhea || !info->hmtx)
      return 0;
   if (info->glyf) {
      // required for truetype
      if (!info->loca) return 0;
   } else {
      // initialization for CFF / Type2 fonts (OTF)
      stbtt__buf b, topdict, topdictidx;
      stbtt_uint32 cstype = 2, charstrings = 0, fdarrayoff = 0, fdselectoff = 0;
      stbtt_uint32 cff;

      cff = stbtt__find_table(data, fontstart, "CFF ");
      if (!cff) return 0;

      info->fontdicts = stbtt__new_buf(NULL, 0);
      info->fdselect = stbtt__new_buf(NULL, 0);

      // @TODO this should use size from table (not 512MB)
      info->cff = stbtt__new_buf(data+cff, 512*1024*1024);
      b = info->cff;

      // read the header
      stbtt__buf_skip(&b, 2);
      stbtt__buf_seek(&b, stbtt__buf_get8(&b)); // hdrsize

      // @TODO the name INDEX could list multiple fonts,
      // but we just use the first one.
      stbtt__cff_get_index(&b);  // name INDEX
      topdictidx = stbtt__cff_get_index(&b);
      topdict = stbtt__cff_index_get(topdictidx, 0);
      stbtt__cff_get_index(&b);  // string INDEX
      info->gsubrs = stbtt__cff_get_index(&b);

      stbtt__dict_get_ints(&topdict, 17, 1, &charstrings);
      stbtt__dict_get_ints(&topdict, 0x100 | 6, 1, &cstype);
      stbtt__dict_get_ints(&topdict, 0x100 | 36, 1, &fdarrayoff);
      stbtt__dict_get_ints(&topdict, 0x100 | 37, 1, &fdselectoff);
      info->subrs = stbtt__get_subrs(b, topdict);

      // we only support Type 2 charstrings
      if (cstype != 2) return 0;
      if (charstrings == 0) return 0;

      if (fdarrayoff) {
         // looks like a CID font
         if (!fdselectoff) return 0;
         stbtt__buf_seek(&b, fdarrayoff);
         info->fontdicts = stbtt__cff_get_index(&b);
         info->fdselect = stbtt__buf_range(&b, fdselectoff, b.size-fdselectoff);
      }

      stbtt__buf_seek(&b, charstrings);
      info->charstrings = stbtt__cff_get_index(&b);
   }

   t = stbtt__find_table(data, fontstart, "maxp");
   if (t)
      info->numGlyphs = ttUSHORT(data+t+4);
   else
      info->numGlyphs = 0xffff;

   // find a cmap encoding table we understand *now* to avoid searching
   // later. (todo: could make this installable)
   // the same regardless of glyph.
   numTables = ttUSHORT(data + cmap + 2);
   info->index_map = 0;
   for (i=0; i < numTables; ++i) {
      stbtt_uint32 encoding_record = cmap + 4 + 8 * i;
      // find an encoding we understand:
      switch(ttUSHORT(data+encoding_record)) {
         case STBTT_PLATFORM_ID_MICROSOFT:
            switch (ttUSHORT(data+encoding_record+2)) {
               case STBTT_MS_EID_UNICODE_BMP:
               case STBTT_MS_EID_UNICODE_FULL:
                  // MS/Unicode
                  info->index_map = cmap + ttULONG(data+encoding_record+4);
                  break;
            }
            break;
        case STBTT_PLATFORM_ID_UNICODE:
            // Mac/iOS has these
            // all the encodingIDs are unicode, so we don't bother to check it
            info->index_map = cmap + ttULONG(data+encoding_record+4);
            break;
      }
   }
   if (info->index_map == 0)
      return 0;

   info->indexToLocFormat = ttUSHORT(data+info->head + 50);
   return 1;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x1b0, %rsp            # imm = 0x1B0
movq %rdi, -0x10(%rbp)
movq %rsi, -0x18(%rbp)
movl %edx, -0x1c(%rbp)
movq -0x18(%rbp), %rcx
movq -0x10(%rbp), %rax
movq %rcx, 0x8(%rax)
movl -0x1c(%rbp), %ecx
movq -0x10(%rbp), %rax
movl %ecx, 0x10(%rax)
movq -0x10(%rbp), %rax
movq %rax, -0x158(%rbp)
xorl %eax, %eax
movl %eax, %esi
movq %rsi, %rdi
callq 0x10710
movq %rax, %rcx
movq -0x158(%rbp), %rax
movq %rcx, -0x40(%rbp)
movq %rdx, -0x38(%rbp)
movq -0x40(%rbp), %rcx
movq %rcx, 0x40(%rax)
movq -0x38(%rbp), %rcx
movq %rcx, 0x48(%rax)
movq -0x18(%rbp), %rdi
movl -0x1c(%rbp), %esi
leaq 0xadd4(%rip), %rdx      # 0x17457
callq 0x6a90
movl %eax, -0x20(%rbp)
movq -0x18(%rbp), %rdi
movl -0x1c(%rbp), %esi
leaq 0xadc3(%rip), %rdx      # 0x1745c
callq 0x6a90
movl %eax, %ecx
movq -0x10(%rbp), %rax
movl %ecx, 0x18(%rax)
movq -0x18(%rbp), %rdi
movl -0x1c(%rbp), %esi
leaq 0xadac(%rip), %rdx      # 0x17461
callq 0x6a90
movl %eax, %ecx
movq -0x10(%rbp), %rax
movl %ecx, 0x1c(%rax)
movq -0x18(%rbp), %rdi
movl -0x1c(%rbp), %esi
leaq 0xad95(%rip), %rdx      # 0x17466
callq 0x6a90
movl %eax, %ecx
movq -0x10(%rbp), %rax
movl %ecx, 0x20(%rax)
movq -0x18(%rbp), %rdi
movl -0x1c(%rbp), %esi
leaq 0xad7e(%rip), %rdx      # 0x1746b
callq 0x6a90
movl %eax, %ecx
movq -0x10(%rbp), %rax
movl %ecx, 0x24(%rax)
movq -0x18(%rbp), %rdi
movl -0x1c(%rbp), %esi
leaq 0xad67(%rip), %rdx      # 0x17470
callq 0x6a90
movl %eax, %ecx
movq -0x10(%rbp), %rax
movl %ecx, 0x28(%rax)
movq -0x18(%rbp), %rdi
movl -0x1c(%rbp), %esi
leaq 0xad50(%rip), %rdx      # 0x17475
callq 0x6a90
movl %eax, %ecx
movq -0x10(%rbp), %rax
movl %ecx, 0x2c(%rax)
movq -0x18(%rbp), %rdi
movl -0x1c(%rbp), %esi
leaq 0xad39(%rip), %rdx      # 0x1747a
callq 0x6a90
movl %eax, %ecx
movq -0x10(%rbp), %rax
movl %ecx, 0x30(%rax)
cmpl $0x0, -0x20(%rbp)
je 0xc773
movq -0x10(%rbp), %rax
cmpl $0x0, 0x1c(%rax)
je 0xc773
movq -0x10(%rbp), %rax
cmpl $0x0, 0x24(%rax)
je 0xc773
movq -0x10(%rbp), %rax
cmpl $0x0, 0x28(%rax)
jne 0xc77f
movl $0x0, -0x4(%rbp)
jmp 0xcd58
movq -0x10(%rbp), %rax
cmpl $0x0, 0x20(%rax)
je 0xc7a4
movq -0x10(%rbp), %rax
cmpl $0x0, 0x18(%rax)
jne 0xc79f
movl $0x0, -0x4(%rbp)
jmp 0xcd58
jmp 0xcbb8
movl $0x2, -0x74(%rbp)
movl $0x0, -0x78(%rbp)
movl $0x0, -0x7c(%rbp)
movl $0x0, -0x80(%rbp)
movq -0x18(%rbp), %rdi
movl -0x1c(%rbp), %esi
leaq 0xacb1(%rip), %rdx      # 0x1747f
callq 0x6a90
movl %eax, -0x84(%rbp)
cmpl $0x0, -0x84(%rbp)
jne 0xc7ee
movl $0x0, -0x4(%rbp)
jmp 0xcd58
movq -0x10(%rbp), %rax
movq %rax, -0x180(%rbp)
xorl %eax, %eax
movl %eax, %esi
movq %rsi, %rdi
callq 0x10710
movq %rax, %rcx
movq -0x180(%rbp), %rax
movq %rcx, -0x98(%rbp)
movq %rdx, -0x90(%rbp)
movq -0x98(%rbp), %rcx
movq %rcx, 0x80(%rax)
movq -0x90(%rbp), %rcx
movq %rcx, 0x88(%rax)
movq -0x10(%rbp), %rax
movq %rax, -0x178(%rbp)
xorl %eax, %eax
movl %eax, %esi
movq %rsi, %rdi
callq 0x10710
movq %rax, %rcx
movq -0x178(%rbp), %rax
movq %rcx, -0xa8(%rbp)
movq %rdx, -0xa0(%rbp)
movq -0xa8(%rbp), %rcx
movq %rcx, 0x90(%rax)
movq -0xa0(%rbp), %rcx
movq %rcx, 0x98(%rax)
movq -0x10(%rbp), %rax
movq %rax, -0x170(%rbp)
movq -0x18(%rbp), %rdi
movl -0x84(%rbp), %eax
addq %rax, %rdi
movl $0x20000000, %esi       # imm = 0x20000000
callq 0x10710
movq %rax, %rcx
movq -0x170(%rbp), %rax
movq %rcx, -0xb8(%rbp)
movq %rdx, -0xb0(%rbp)
movq -0xb8(%rbp), %rcx
movq %rcx, 0x40(%rax)
movq -0xb0(%rbp), %rcx
movq %rcx, 0x48(%rax)
movq -0x10(%rbp), %rax
movq 0x40(%rax), %rcx
movq %rcx, -0x50(%rbp)
movq 0x48(%rax), %rax
movq %rax, -0x48(%rbp)
leaq -0x50(%rbp), %rdi
movl $0x2, %esi
callq 0xffa0
leaq -0x50(%rbp), %rdi
callq 0xff50
movzbl %al, %esi
leaq -0x50(%rbp), %rdi
callq 0x10610
leaq -0x50(%rbp), %rdi
callq 0x10ad0
movq %rax, -0xc8(%rbp)
movq %rdx, -0xc0(%rbp)
leaq -0x50(%rbp), %rdi
callq 0x10ad0
movq %rax, -0xd8(%rbp)
movq %rdx, -0xd0(%rbp)
movq -0xd8(%rbp), %rax
movq %rax, -0x70(%rbp)
movq -0xd0(%rbp), %rax
movq %rax, -0x68(%rbp)
movq -0x70(%rbp), %rdi
movq -0x68(%rbp), %rsi
xorl %edx, %edx
callq 0xfe40
movq %rax, -0xe8(%rbp)
movq %rdx, -0xe0(%rbp)
movq -0xe8(%rbp), %rax
movq %rax, -0x60(%rbp)
movq -0xe0(%rbp), %rax
movq %rax, -0x58(%rbp)
leaq -0x50(%rbp), %rdi
callq 0x10ad0
movq %rax, -0xf8(%rbp)
movq %rdx, -0xf0(%rbp)
movq -0x10(%rbp), %rax
movq %rax, -0x168(%rbp)
leaq -0x50(%rbp), %rdi
callq 0x10ad0
movq %rax, %rcx
movq -0x168(%rbp), %rax
movq %rcx, -0x108(%rbp)
movq %rdx, -0x100(%rbp)
movq -0x108(%rbp), %rcx
movq %rcx, 0x60(%rax)
movq -0x100(%rbp), %rcx
movq %rcx, 0x68(%rax)
leaq -0x60(%rbp), %rdi
movl $0x11, %esi
movl $0x1, %edx
leaq -0x78(%rbp), %rcx
callq 0x10a50
leaq -0x60(%rbp), %rdi
movl $0x106, %esi            # imm = 0x106
movl $0x1, %edx
leaq -0x74(%rbp), %rcx
callq 0x10a50
leaq -0x60(%rbp), %rdi
movl $0x124, %esi            # imm = 0x124
movl $0x1, %edx
leaq -0x7c(%rbp), %rcx
callq 0x10a50
leaq -0x60(%rbp), %rdi
movl $0x125, %esi            # imm = 0x125
movl $0x1, %edx
leaq -0x80(%rbp), %rcx
callq 0x10a50
movq -0x10(%rbp), %rax
movq %rax, -0x160(%rbp)
movq -0x50(%rbp), %rdi
movq -0x48(%rbp), %rsi
movq -0x60(%rbp), %rdx
movq -0x58(%rbp), %rcx
callq 0x10960
movq %rax, %rcx
movq -0x160(%rbp), %rax
movq %rcx, -0x118(%rbp)
movq %rdx, -0x110(%rbp)
movq -0x118(%rbp), %rcx
movq %rcx, 0x70(%rax)
movq -0x110(%rbp), %rcx
movq %rcx, 0x78(%rax)
cmpl $0x2, -0x74(%rbp)
je 0xca97
movl $0x0, -0x4(%rbp)
jmp 0xcd58
cmpl $0x0, -0x78(%rbp)
jne 0xcaa9
movl $0x0, -0x4(%rbp)
jmp 0xcd58
cmpl $0x0, -0x7c(%rbp)
je 0xcb6a
cmpl $0x0, -0x80(%rbp)
jne 0xcac5
movl $0x0, -0x4(%rbp)
jmp 0xcd58
movl -0x7c(%rbp), %esi
leaq -0x50(%rbp), %rdi
callq 0x10610
movq -0x10(%rbp), %rax
movq %rax, -0x190(%rbp)
leaq -0x50(%rbp), %rdi
callq 0x10ad0
movq %rax, %rcx
movq -0x190(%rbp), %rax
movq %rcx, -0x128(%rbp)
movq %rdx, -0x120(%rbp)
movq -0x128(%rbp), %rcx
movq %rcx, 0x80(%rax)
movq -0x120(%rbp), %rcx
movq %rcx, 0x88(%rax)
movq -0x10(%rbp), %rax
movq %rax, -0x188(%rbp)
movl -0x80(%rbp), %esi
movl -0x44(%rbp), %edx
subl -0x80(%rbp), %edx
leaq -0x50(%rbp), %rdi
callq 0x10690
movq %rax, %rcx
movq -0x188(%rbp), %rax
movq %rcx, -0x138(%rbp)
movq %rdx, -0x130(%rbp)
movq -0x138(%rbp), %rcx
movq %rcx, 0x90(%rax)
movq -0x130(%rbp), %rcx
movq %rcx, 0x98(%rax)
movl -0x78(%rbp), %esi
leaq -0x50(%rbp), %rdi
callq 0x10610
movq -0x10(%rbp), %rax
movq %rax, -0x198(%rbp)
leaq -0x50(%rbp), %rdi
callq 0x10ad0
movq %rax, %rcx
movq -0x198(%rbp), %rax
movq %rcx, -0x148(%rbp)
movq %rdx, -0x140(%rbp)
movq -0x148(%rbp), %rcx
movq %rcx, 0x50(%rax)
movq -0x140(%rbp), %rcx
movq %rcx, 0x58(%rax)
movq -0x18(%rbp), %rdi
movl -0x1c(%rbp), %esi
leaq 0xa8be(%rip), %rdx      # 0x17484
callq 0x6a90
movl %eax, -0x24(%rbp)
cmpl $0x0, -0x24(%rbp)
je 0xcbf3
movq -0x18(%rbp), %rdi
movl -0x24(%rbp), %eax
addq %rax, %rdi
addq $0x4, %rdi
callq 0x4990
movzwl %ax, %ecx
movq -0x10(%rbp), %rax
movl %ecx, 0x14(%rax)
jmp 0xcbfe
movq -0x10(%rbp), %rax
movl $0xffff, 0x14(%rax)     # imm = 0xFFFF
movq -0x18(%rbp), %rdi
movl -0x20(%rbp), %eax
addq %rax, %rdi
addq $0x2, %rdi
callq 0x4990
movzwl %ax, %eax
movl %eax, -0x2c(%rbp)
movq -0x10(%rbp), %rax
movl $0x0, 0x34(%rax)
movl $0x0, -0x28(%rbp)
movl -0x28(%rbp), %eax
cmpl -0x2c(%rbp), %eax
jge 0xcd1c
movl -0x20(%rbp), %edx
movl -0x28(%rbp), %eax
movl %eax, %ecx
movl %edx, %eax
leal 0x4(%rax,%rcx,8), %eax
movl %eax, -0x14c(%rbp)
movq -0x18(%rbp), %rdi
movl -0x14c(%rbp), %eax
addq %rax, %rdi
callq 0x4990
movzwl %ax, %ecx
movl %ecx, -0x19c(%rbp)
testw %ax, %ax
je 0xccde
jmp 0xcc6b
movl -0x19c(%rbp), %eax
subl $0x3, %eax
jne 0xcd0c
jmp 0xcc7c
movq -0x18(%rbp), %rax
movl -0x14c(%rbp), %ecx
leaq 0x2(%rax,%rcx), %rdi
callq 0x4990
movzwl %ax, %ecx
movl %ecx, -0x1a0(%rbp)
subw $0x1, %ax
je 0xccae
jmp 0xcca1
movl -0x1a0(%rbp), %eax
subl $0xa, %eax
jne 0xccdc
jmp 0xccae
movl -0x20(%rbp), %eax
movl %eax, -0x1a4(%rbp)
movq -0x18(%rbp), %rdi
movl -0x14c(%rbp), %eax
addq %rax, %rdi
addq $0x4, %rdi
callq 0x49d0
movl -0x1a4(%rbp), %ecx
addl %eax, %ecx
movq -0x10(%rbp), %rax
movl %ecx, 0x34(%rax)
jmp 0xcd0c
movl -0x20(%rbp), %eax
movl %eax, -0x1a8(%rbp)
movq -0x18(%rbp), %rdi
movl -0x14c(%rbp), %eax
addq %rax, %rdi
addq $0x4, %rdi
callq 0x49d0
movl -0x1a8(%rbp), %ecx
addl %eax, %ecx
movq -0x10(%rbp), %rax
movl %ecx, 0x34(%rax)
jmp 0xcd0e
movl -0x28(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x28(%rbp)
jmp 0xcc29
movq -0x10(%rbp), %rax
cmpl $0x0, 0x34(%rax)
jne 0xcd2f
movl $0x0, -0x4(%rbp)
jmp 0xcd58
movq -0x18(%rbp), %rdi
movq -0x10(%rbp), %rax
movslq 0x1c(%rax), %rax
addq %rax, %rdi
addq $0x32, %rdi
callq 0x4990
movzwl %ax, %ecx
movq -0x10(%rbp), %rax
movl %ecx, 0x38(%rax)
movl $0x1, -0x4(%rbp)
movl -0x4(%rbp), %eax
addq $0x1b0, %rsp            # imm = 0x1B0
popq %rbp
retq
nopw %cs:(%rax,%rax)