// File: /workspace/github_c_makefile_star2_O3/smilingthax[P]libfontembed/sfnt.c
// Function: otf_load_more
int otf_load_more(OTF_FILE *otf) // {{{  - 0 on success   => hhea,hmtx,name,[glyf]
{
  int iA;

  int len;
  if (!is_CFF(otf)) { // not for CFF
    if (otf_load_glyf(otf)==-1) {
      return -1;
    }
  }

  // {{{ read hhea table
  char *hhea=otf_get_table(otf,OTF_TAG('h','h','e','a'),&len);
  if ( (!hhea)||
       (get_ULONG(hhea)!=0x00010000)|| // version
       (len!=36)||
       (get_SHORT(hhea+32)!=0) ) { // metric format
    fprintf(stderr,"Unsupported OTF font / hhea table\n");
    free(hhea);
    return -1;
  }
  otf->numberOfHMetrics=get_USHORT(hhea+34);
  free(hhea);
  // }}}

  // {{{ read hmtx table
  char *hmtx=otf_get_table(otf,OTF_TAG('h','m','t','x'),&len);
  if ( (!hmtx)||
       (len!=otf->numberOfHMetrics*2+otf->numGlyphs*2) ) {
    fprintf(stderr,"Unsupported OTF font / hmtx table\n");
    free(hmtx);
    return -1;
  }
  if (otf->hmtx) {
    free(otf->hmtx);
    assert(0);
  }
  otf->hmtx=hmtx;
  // }}}

  // {{{ read name table
  char *name=otf_get_table(otf,OTF_TAG('n','a','m','e'),&len);
  if ( (!name)||
       (get_USHORT(name)!=0x0000)|| // version
       (len<get_USHORT(name+2)*12+6)||
       (len<=get_USHORT(name+4)) ) {
    fprintf(stderr,"Unsupported OTF font / name table \n");
    free(name);
    return -1;
  }
  // check bounds
  int name_count=get_USHORT(name+2);
  const char *nstore=name+get_USHORT(name+4);
  for (iA=0;iA<name_count;iA++) {
    const char *nrec=name+6+12*iA;
    if (nstore-name+get_USHORT(nrec+10)+get_USHORT(nrec+8)>len) {
      fprintf(stderr,"Bad name table \n");
      free(name);
      return -1;
    }
  }
  if (otf->name) {
    free(otf->name);
    assert(0);
  }
  otf->name=name;
  // }}}

  return 0;
}

// Assembly:
pushq %rbx
subq $0x10, %rsp
movq %rdi, %rbx
testb $0x1, 0xa(%rdi)
jne 0x45f7
movq %rbx, %rdi
callq 0x4330
cmpl $-0x1, %eax
je 0x474d
leaq 0xc(%rsp), %rdx
movq %rbx, %rdi
movl $0x68686561, %esi       # imm = 0x68686561
callq 0x423c
testq %rax, %rax
je 0x4731
movl (%rax), %ecx
bswapl %ecx
cmpl $0x10000, %ecx          # imm = 0x10000
jne 0x4731
cmpl $0x24, 0xc(%rsp)
jne 0x4731
movb 0x21(%rax), %cl
orb 0x20(%rax), %cl
jne 0x4731
movzwl 0x22(%rax), %ecx
rolw $0x8, %cx
movw %cx, 0x58(%rbx)
movq %rax, %rdi
callq 0x21a0
leaq 0xc(%rsp), %rdx
movq %rbx, %rdi
movl $0x686d7478, %esi       # imm = 0x686D7478
callq 0x423c
testq %rax, %rax
je 0x4745
movzwl 0x58(%rbx), %ecx
movzwl 0x4c(%rbx), %edx
addl %ecx, %edx
addl %edx, %edx
cmpl %edx, 0xc(%rsp)
jne 0x4745
movq 0x60(%rbx), %rdi
testq %rdi, %rdi
jne 0x4762
movq %rax, 0x60(%rbx)
leaq 0xc(%rsp), %rdx
movq %rbx, %rdi
movl $0x6e616d65, %esi       # imm = 0x6E616D65
callq 0x423c
testq %rax, %rax
je 0x473b
movb 0x1(%rax), %cl
orb (%rax), %cl
jne 0x473b
movl 0xc(%rsp), %ecx
movzwl 0x2(%rax), %edx
rolw $0x8, %dx
movzwl %dx, %esi
leal (%rsi,%rsi,2), %edx
leal 0x6(,%rdx,4), %edx
cmpl %edx, %ecx
jl 0x473b
movzwl 0x4(%rax), %edx
rolw $0x8, %dx
movzwl %dx, %edx
cmpl %edx, %ecx
jbe 0x473b
testl %esi, %esi
je 0x4720
shll $0x2, %esi
leaq (%rsi,%rsi,2), %rsi
xorl %edi, %edi
movzwl 0x10(%rax,%rdi), %r8d
rolw $0x8, %r8w
movzwl 0xe(%rax,%rdi), %r9d
movzwl %r8w, %r8d
rolw $0x8, %r9w
addl %edx, %r8d
movzwl %r9w, %r9d
addl %r8d, %r9d
cmpl %ecx, %r9d
ja 0x4758
addq $0xc, %rdi
cmpq %rdi, %rsi
jne 0x46ee
movq 0x68(%rbx), %rdi
testq %rdi, %rdi
jne 0x4786
movq %rax, 0x68(%rbx)
xorl %eax, %eax
jmp 0x4752
movq %rax, %rdi
callq 0x2833
jmp 0x474d
movq %rax, %rdi
callq 0x27df
jmp 0x474d
movq %rax, %rdi
callq 0x2809
movl $0xffffffff, %eax       # imm = 0xFFFFFFFF
addq $0x10, %rsp
popq %rbx
retq
movq %rax, %rdi
callq 0x27b5
jmp 0x474d
callq 0x21a0
leaq 0x6552(%rip), %rdi      # 0xacc0
leaq 0x62da(%rip), %rsi      # 0xaa4f
leaq 0x5d8a(%rip), %rcx      # 0xa506
movl $0x2c3, %edx            # imm = 0x2C3
callq 0x20e0
callq 0x21a0
leaq 0x652e(%rip), %rdi      # 0xacc0
leaq 0x62b6(%rip), %rsi      # 0xaa4f
leaq 0x5d66(%rip), %rcx      # 0xa506
movl $0x2df, %edx            # imm = 0x2DF
callq 0x20e0