// File: /workspace/github_c_makefile_star2_O1/smilingthax[P]libfontembed/sfnt.c
// Function: otf_load_glyf
int otf_load_glyf(OTF_FILE *otf) // {{{  - 0 on success
{
  assert(!is_CFF(otf)); // not for CFF
  int iA,len;
  // {{{ find glyf table
  iA=otf_find_table(otf,OTF_TAG('g','l','y','f'));
  if (iA==-1) {
    fprintf(stderr,"Unsupported OTF font / glyf table\n");
    return -1;
  }
  otf->glyfTable=otf->tables+iA;
  // }}}

  // {{{ read loca table
  char *loca=otf_get_table(otf,OTF_TAG('l','o','c','a'),&len);
  if ( (!loca)||
       (otf->indexToLocFormat>=2)||
       (otf_padded(len)!=otf_padded((otf->numGlyphs+1)*(otf->indexToLocFormat+1)*2)) ) {
    fprintf(stderr,"Unsupported OTF font / loca table\n");
    free(loca);
    return -1;
  }
  if (otf->glyphOffsets) {
    free(otf->glyphOffsets);
    assert(0);
  }
  otf->glyphOffsets=malloc((otf->numGlyphs+1)*sizeof(unsigned int));
  if (!otf->glyphOffsets) {
    fprintf(stderr,"Bad alloc: %s\n", strerror(errno));
    return -1;
  }
  if (otf->indexToLocFormat==0) {
    for (iA=0;iA<=otf->numGlyphs;iA++) {
      otf->glyphOffsets[iA]=get_USHORT(loca+iA*2)*2;
    }
  } else { // indexToLocFormat==1
    for (iA=0;iA<=otf->numGlyphs;iA++) {
      otf->glyphOffsets[iA]=get_ULONG(loca+iA*4);
    }
  }
  free(loca);
  if (otf->glyphOffsets[otf->numGlyphs]>otf->glyfTable->length) {
    fprintf(stderr,"Bad loca table\n");
    return -1;
  }
  // }}}

  if (otf->glyf) {
    free(otf->glyf);
    assert(0);
    otf->glyf=NULL;
  }
  if (otf->flags&OTF_F_CACHE_GLYF) {
    otf->glyf=otf_get_table(otf,OTF_TAG('g','l','y','f'),&len);
    if (!otf->glyf) {
      return -1;
    }

    if (otf->gly) {
      free(otf->gly);
      assert(0);
      otf->gly=NULL;
    }
    return 0;
  }

  // {{{ allocate otf->gly slot
  int maxGlyfLen=0;  // no single glyf takes more space
  for (iA=1;iA<=otf->numGlyphs;iA++) {
    const int glyfLen=otf->glyphOffsets[iA]-otf->glyphOffsets[iA-1];
    if (glyfLen<0) {
      fprintf(stderr,"Bad loca table: glyph len %d\n",glyfLen);
      return -1;
    }
    if (maxGlyfLen<glyfLen) {
      maxGlyfLen=glyfLen;
    }
  }
  if (otf->gly) {
    free(otf->gly);
    assert(0);
  }
  otf->gly=malloc(maxGlyfLen*sizeof(char));
  if (!otf->gly) {
    fprintf(stderr,"Bad alloc: %s\n", strerror(errno));
    return -1;
  }
  // }}}

  return 0;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
pushq %rax
testb $0x1, 0xa(%rdi)
jne 0x4577
movq %rdi, %rbx
movl $0x676c7966, %esi       # imm = 0x676C7966
callq 0x41e4
cmpl $-0x1, %eax
je 0x4549
cltq
leaq (%rax,%rax,4), %rax
shlq $0x2, %rax
addq 0x40(%rbx), %rax
movq %rax, 0x88(%rbx)
leaq 0x4(%rsp), %rdx
movq %rbx, %rdi
movl $0x6c6f6361, %esi       # imm = 0x6C6F6361
callq 0x4249
movq %rax, %r14
testq %rax, %rax
je 0x4517
movzwl 0x4a(%rbx), %r12d
cmpl $0x1, %r12d
ja 0x4517
movl 0x4(%rsp), %ecx
addl $0x3, %ecx
andl $-0x4, %ecx
movzwl 0x4c(%rbx), %eax
leaq 0x1(%rax), %r15
leal 0x2(,%r12,2), %edx
imull %r15d, %edx
addl $0x3, %edx
andl $0x7ffffffc, %edx       # imm = 0x7FFFFFFC
cmpl %edx, %ecx
jne 0x4517
movq 0x50(%rbx), %rdi
testq %rdi, %rdi
jne 0x4596
leaq 0x4(,%rax,4), %rdi
callq 0x21c0
movq %rax, 0x50(%rbx)
testq %rax, %rax
je 0x4550
xorl %ecx, %ecx
testl %r12d, %r12d
je 0x4416
movl (%r14,%rcx,4), %edx
bswapl %edx
movl %edx, (%rax,%rcx,4)
incq %rcx
cmpq %rcx, %r15
jne 0x4403
jmp 0x4432
movzbl (%r14,%rcx,2), %edx
movzbl 0x1(%r14,%rcx,2), %esi
shll $0x9, %edx
leal (%rdx,%rsi,2), %edx
movl %edx, (%rax,%rcx,4)
incq %rcx
cmpq %rcx, %r15
jne 0x4416
movq %r14, %rdi
callq 0x21a0
movzwl 0x4c(%rbx), %eax
movq 0x50(%rbx), %rcx
movq 0x88(%rbx), %rdx
movl (%rcx,%rax,4), %eax
cmpl 0xc(%rdx), %eax
ja 0x4557
movq 0x90(%rbx), %rdi
testq %rdi, %rdi
jne 0x45ba
testb $0x1, 0x8(%rbx)
jne 0x44c9
xorl %edi, %edi
cmpw $0x0, 0x4c(%rbx)
je 0x4524
movq 0xab61(%rip), %r15      # 0xefe0
leaq 0x601c(%rip), %r14      # 0xa4a2
xorl %r13d, %r13d
xorl %r12d, %r12d
movq 0x50(%rbx), %rax
movl 0x4(%rax,%r13,4), %ebp
subl (%rax,%r13,4), %ebp
js 0x44b8
cmpl %ebp, %r12d
cmovlel %ebp, %r12d
testl %ebp, %ebp
js 0x4563
movzwl 0x4c(%rbx), %eax
incq %r13
cmpq %rax, %r13
jb 0x448c
jmp 0x4521
movq (%r15), %rdi
movq %r14, %rsi
movl %ebp, %edx
xorl %eax, %eax
callq 0x21d0
jmp 0x44a2
leaq 0x4(%rsp), %rdx
movq %rbx, %rdi
movl $0x676c7966, %esi       # imm = 0x676C7966
callq 0x4249
movq %rax, 0x90(%rbx)
testq %rax, %rax
je 0x4563
movq 0x80(%rbx), %rdi
testq %rdi, %rdi
je 0x4545
callq 0x21a0
leaq 0x67c1(%rip), %rdi      # 0xacc0
leaq 0x6549(%rip), %rsi      # 0xaa4f
leaq 0x5f21(%rip), %rcx      # 0xa42e
movl $0x27f, %edx            # imm = 0x27F
callq 0x20e0
movq %r14, %rdi
callq 0x2767
jmp 0x4563
movl %r12d, %edi
movq 0x80(%rbx), %rax
testq %rax, %rax
jne 0x45de
callq 0x21c0
movq %rax, 0x80(%rbx)
testq %rax, %rax
je 0x455e
xorl %eax, %eax
jmp 0x4568
callq 0x2791
jmp 0x4563
callq 0x273a
jmp 0x4563
callq 0x2718
jmp 0x4563
callq 0x26eb
movl $0xffffffff, %eax       # imm = 0xFFFFFFFF
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
leaq 0x5ea3(%rip), %rdi      # 0xa421
leaq 0x64ca(%rip), %rsi      # 0xaa4f
leaq 0x5ea2(%rip), %rcx      # 0xa42e
movl $0x245, %edx            # imm = 0x245
callq 0x20e0
callq 0x21a0
leaq 0x671e(%rip), %rdi      # 0xacc0
leaq 0x64a6(%rip), %rsi      # 0xaa4f
leaq 0x5e7e(%rip), %rcx      # 0xa42e
movl $0x25b, %edx            # imm = 0x25B
callq 0x20e0
callq 0x21a0
leaq 0x66fa(%rip), %rdi      # 0xacc0
leaq 0x6482(%rip), %rsi      # 0xaa4f
leaq 0x5e5a(%rip), %rcx      # 0xa42e
movl $0x274, %edx            # imm = 0x274
callq 0x20e0
movq %rax, %rdi
callq 0x21a0
leaq 0x66d3(%rip), %rdi      # 0xacc0
leaq 0x645b(%rip), %rsi      # 0xaa4f
leaq 0x5e33(%rip), %rcx      # 0xa42e
movl $0x293, %edx            # imm = 0x293
callq 0x20e0