// File: /workspace/github_c_makefile_star2_O1/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 0x4624
movq %rbx, %rdi
callq 0x4339
cmpl $-0x1, %eax
je 0x477b
leaq 0xc(%rsp), %rdx
movq %rbx, %rdi
movl $0x68686561, %esi       # imm = 0x68686561
callq 0x4249
testq %rax, %rax
je 0x475f
movl (%rax), %ecx
bswapl %ecx
cmpl $0x10000, %ecx          # imm = 0x10000
jne 0x475f
cmpl $0x24, 0xc(%rsp)
jne 0x475f
movb 0x21(%rax), %cl
orb 0x20(%rax), %cl
jne 0x475f
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 0x4249
testq %rax, %rax
je 0x4773
movzwl 0x58(%rbx), %ecx
movzwl 0x4c(%rbx), %edx
addl %ecx, %edx
addl %edx, %edx
cmpl %edx, 0xc(%rsp)
jne 0x4773
movq 0x60(%rbx), %rdi
testq %rdi, %rdi
jne 0x4790
movq %rax, 0x60(%rbx)
leaq 0xc(%rsp), %rdx
movq %rbx, %rdi
movl $0x6e616d65, %esi       # imm = 0x6E616D65
callq 0x4249
testq %rax, %rax
je 0x4769
movb 0x1(%rax), %cl
orb (%rax), %cl
jne 0x4769
movslq 0xc(%rsp), %rcx
movzwl 0x2(%rax), %edx
rolw $0x8, %dx
movzwl %dx, %esi
leal (%rsi,%rsi,2), %edx
leal 0x6(,%rdx,4), %edx
cmpl %edx, %ecx
jl 0x4769
movzwl 0x4(%rax), %edx
rolw $0x8, %dx
movzwl %dx, %edx
cmpl %edx, %ecx
jle 0x4769
testl %esi, %esi
je 0x474e
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
addq %rdx, %r8
movzwl %r9w, %r9d
addq %r8, %r9
cmpq %rcx, %r9
jg 0x4786
addq $0xc, %rdi
cmpq %rdi, %rsi
jne 0x471c
movq 0x68(%rbx), %rdi
testq %rdi, %rdi
jne 0x47b4
movq %rax, 0x68(%rbx)
xorl %eax, %eax
jmp 0x4780
movq %rax, %rdi
callq 0x282b
jmp 0x477b
movq %rax, %rdi
callq 0x27d7
jmp 0x477b
movq %rax, %rdi
callq 0x2801
movl $0xffffffff, %eax       # imm = 0xFFFFFFFF
addq $0x10, %rsp
popq %rbx
retq
movq %rax, %rdi
callq 0x27ad
jmp 0x477b
callq 0x21a0
leaq 0x6524(%rip), %rdi      # 0xacc0
leaq 0x62ac(%rip), %rsi      # 0xaa4f
leaq 0x5d5c(%rip), %rcx      # 0xa506
movl $0x2c3, %edx            # imm = 0x2C3
callq 0x20e0
callq 0x21a0
leaq 0x6500(%rip), %rdi      # 0xacc0
leaq 0x6288(%rip), %rsi      # 0xaa4f
leaq 0x5d38(%rip), %rcx      # 0xa506
movl $0x2df, %edx            # imm = 0x2DF
callq 0x20e0