// File: /workspace/github_c_makefile_star2_O2/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 0x3af4
movq %rdi, %rbx
movl $0x676c7966, %esi       # imm = 0x676C7966
callq 0x36be
cmpl $-0x1, %eax
je 0x3a97
cltq
imulq $0x14, %rax, %rax
addq 0x40(%rbx), %rax
movq %rax, 0x88(%rbx)
leaq 0x4(%rsp), %rdx
movq %rbx, %rdi
movl $0x6c6f6361, %esi       # imm = 0x6C6F6361
callq 0x371c
movq %rax, %r14
testq %rax, %rax
je 0x3a45
movzwl 0x4a(%rbx), %ebp
cmpl $0x1, %ebp
ja 0x3a45
movl 0x4(%rsp), %ecx
addl $0x3, %ecx
andl $-0x4, %ecx
movzwl 0x4c(%rbx), %eax
leaq 0x1(%rax), %r13
leal 0x2(,%rbp,2), %edx
imull %r13d, %edx
addl $0x3, %edx
andl $0x7ffffffc, %edx       # imm = 0x7FFFFFFC
cmpl %edx, %ecx
jne 0x3a45
movq 0x50(%rbx), %rdi
testq %rdi, %rdi
jne 0x3b13
leaq 0x4(,%rax,4), %r12
movq %r12, %rdi
callq 0x21d0
movq %rax, 0x50(%rbx)
testq %rax, %rax
je 0x3a6b
movq %rax, %r15
testl %ebp, %ebp
je 0x394f
xorl %r13d, %r13d
cmpq %r13, %r12
je 0x3970
leaq (%r14,%r13), %rdi
callq 0x353a
movl %eax, (%r15,%r13)
addq $0x4, %r13
jmp 0x3937
xorl %eax, %eax
cmpq %rax, %r13
je 0x3970
movzbl (%r14,%rax,2), %ecx
movzbl 0x1(%r14,%rax,2), %edx
shll $0x9, %ecx
leal (%rcx,%rdx,2), %ecx
movl %ecx, (%r15,%rax,4)
incq %rax
jmp 0x3951
movq %r14, %rdi
callq 0x21b0
movq 0x50(%rbx), %rax
movq 0x88(%rbx), %rdx
movzwl 0x4c(%rbx), %ecx
movl (%rax,%rcx,4), %esi
cmpl 0xc(%rdx), %esi
ja 0x3aac
movq 0x90(%rbx), %rdi
testq %rdi, %rdi
jne 0x3b37
testb $0x1, 0x8(%rbx)
jne 0x39c9
xorl %edi, %edi
xorl %esi, %esi
cmpq %rdi, %rcx
je 0x3a1b
movl 0x4(%rax,%rdi,4), %edx
subl (%rax,%rdi,4), %edx
js 0x3ada
cmpl %edx, %esi
cmovlel %edx, %esi
incq %rdi
jmp 0x39ad
leaq 0x4(%rsp), %rdx
movq %rbx, %rdi
movl $0x676c7966, %esi       # imm = 0x676C7966
callq 0x371c
movq %rax, 0x90(%rbx)
testq %rax, %rax
je 0x3ac8
movq 0x80(%rbx), %rdi
testq %rdi, %rdi
je 0x3a3e
callq 0x21b0
leaq 0x72bd(%rip), %rdi      # 0xacc0
leaq 0x7045(%rip), %rsi      # 0xaa4f
leaq 0x6a1d(%rip), %rcx      # 0xa42e
movl $0x27f, %edx            # imm = 0x27F
callq 0x20f0
movq 0x80(%rbx), %rdi
testq %rdi, %rdi
jne 0x3b5b
movl %esi, %edi
callq 0x21d0
movq %rax, 0x80(%rbx)
testq %rax, %rax
je 0x3a6b
xorl %eax, %eax
jmp 0x3acb
movq 0xb594(%rip), %rax      # 0xefe0
movq (%rax), %rcx
leaq 0x6a19(%rip), %rdi      # 0xa46f
pushq $0x22
popq %rsi
pushq $0x1
popq %rdx
callq 0x2280
movq %r14, %rdi
callq 0x21b0
jmp 0x3ac8
movq 0xb56e(%rip), %rax      # 0xefe0
movq (%rax), %rbx
callq 0x2040
movl (%rax), %edi
callq 0x2070
leaq 0x68d1(%rip), %rsi      # 0xa359
movq %rbx, %rdi
movq %rax, %rdx
xorl %eax, %eax
callq 0x21e0
jmp 0x3ac8
movq 0xb542(%rip), %rax      # 0xefe0
movq (%rax), %rcx
leaq 0x69a4(%rip), %rdi      # 0xa44c
pushq $0x22
jmp 0x3abf
movq 0xb52d(%rip), %rax      # 0xefe0
movq (%rax), %rcx
leaq 0x69d5(%rip), %rdi      # 0xa492
pushq $0xf
popq %rsi
pushq $0x1
popq %rdx
callq 0x2280
pushq $-0x1
popq %rax
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq 0xb4ff(%rip), %rax      # 0xefe0
movq (%rax), %rdi
leaq 0x69b7(%rip), %rsi      # 0xa4a2
xorl %eax, %eax
callq 0x21e0
jmp 0x3ac8
leaq 0x6926(%rip), %rdi      # 0xa421
leaq 0x6f4d(%rip), %rsi      # 0xaa4f
leaq 0x6925(%rip), %rcx      # 0xa42e
movl $0x245, %edx            # imm = 0x245
callq 0x20f0
callq 0x21b0
leaq 0x71a1(%rip), %rdi      # 0xacc0
leaq 0x6f29(%rip), %rsi      # 0xaa4f
leaq 0x6901(%rip), %rcx      # 0xa42e
movl $0x25b, %edx            # imm = 0x25B
callq 0x20f0
callq 0x21b0
leaq 0x717d(%rip), %rdi      # 0xacc0
leaq 0x6f05(%rip), %rsi      # 0xaa4f
leaq 0x68dd(%rip), %rcx      # 0xa42e
movl $0x274, %edx            # imm = 0x274
callq 0x20f0
callq 0x21b0
leaq 0x7159(%rip), %rdi      # 0xacc0
leaq 0x6ee1(%rip), %rsi      # 0xaa4f
leaq 0x68b9(%rip), %rcx      # 0xa42e
movl $0x293, %edx            # imm = 0x293
callq 0x20f0