// File: /workspace/github_c_makefile_star2_O2/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 %r15
pushq %r14
pushq %rbx
subq $0x10, %rsp
movq %rdi, %r14
testb $0x1, 0xa(%rdi)
pushq $-0x1
popq %rbx
jne 0x3ba5
movq %r14, %rdi
callq 0x386e
cmpl $-0x1, %eax
je 0x3d59
leaq 0xc(%rsp), %rdx
movq %r14, %rdi
movl $0x68686561, %esi       # imm = 0x68686561
callq 0x371c
movq %rax, %r15
testq %rax, %rax
je 0x3d0d
movq %r15, %rdi
callq 0x353a
cmpl $0x10000, %eax          # imm = 0x10000
jne 0x3d0d
cmpl $0x24, 0xc(%rsp)
jne 0x3d0d
movb 0x21(%r15), %al
orb 0x20(%r15), %al
jne 0x3d0d
movzwl 0x22(%r15), %eax
rolw $0x8, %ax
movw %ax, 0x58(%r14)
movq %r15, %rdi
callq 0x21b0
leaq 0xc(%rsp), %rdx
movq %r14, %rdi
movl $0x686d7478, %esi       # imm = 0x686D7478
callq 0x371c
movq %rax, %r15
testq %rax, %rax
je 0x3d35
movzwl 0x58(%r14), %eax
movzwl 0x4c(%r14), %ecx
addl %eax, %ecx
addl %ecx, %ecx
cmpl %ecx, 0xc(%rsp)
jne 0x3d35
movq 0x60(%r14), %rdi
testq %rdi, %rdi
jne 0x3d65
movq %r15, 0x60(%r14)
leaq 0xc(%rsp), %rdx
movq %r14, %rdi
movl $0x6e616d65, %esi       # imm = 0x6E616D65
callq 0x371c
movq %rax, %r15
testq %rax, %rax
je 0x3d20
movb 0x1(%r15), %al
orb (%r15), %al
jne 0x3d20
movl 0xc(%rsp), %eax
movzwl 0x2(%r15), %ecx
rolw $0x8, %cx
movzwl %cx, %edx
imull $0xc, %edx, %ecx
addl $0x6, %ecx
cmpl %ecx, %eax
jl 0x3d20
movzwl 0x4(%r15), %ecx
rolw $0x8, %cx
movzwl %cx, %ecx
cmpl %ecx, %eax
jbe 0x3d20
movl %edx, %edx
imulq $0xc, %rdx, %rdx
addq $0xc, %rdx
xorl %edi, %edi
leaq 0xc(%rdi), %rsi
cmpq %rsi, %rdx
je 0x3cf8
movzwl 0xe(%r15,%rdi), %r8d
movzwl 0x10(%r15,%rdi), %edi
rolw $0x8, %di
movzwl %di, %edi
addl %ecx, %edi
rolw $0x8, %r8w
movzwl %r8w, %r8d
addl %edi, %r8d
movq %rsi, %rdi
cmpl %eax, %r8d
jbe 0x3cb1
movq 0xb2f6(%rip), %rax      # 0xefe0
movq (%rax), %rcx
leaq 0x6854(%rip), %rdi      # 0xa548
pushq $0x10
jmp 0x3d48
movq 0x68(%r14), %rdi
testq %rdi, %rdi
jne 0x3d89
movq %r15, 0x68(%r14)
xorl %ebx, %ebx
jmp 0x3d59
movq 0xb2cc(%rip), %rax      # 0xefe0
movq (%rax), %rcx
leaq 0x67a2(%rip), %rdi      # 0xa4c0
jmp 0x3d46
movq 0xb2b9(%rip), %rax      # 0xefe0
movq (%rax), %rcx
leaq 0x67f3(%rip), %rdi      # 0xa524
pushq $0x23
jmp 0x3d48
movq 0xb2a4(%rip), %rax      # 0xefe0
movq (%rax), %rcx
leaq 0x679d(%rip), %rdi      # 0xa4e3
pushq $0x22
popq %rsi
pushq $0x1
popq %rdx
callq 0x2280
movq %r15, %rdi
callq 0x21b0
movl %ebx, %eax
addq $0x10, %rsp
popq %rbx
popq %r14
popq %r15
retq
callq 0x21b0
leaq 0x6f4f(%rip), %rdi      # 0xacc0
leaq 0x6cd7(%rip), %rsi      # 0xaa4f
leaq 0x6787(%rip), %rcx      # 0xa506
movl $0x2c3, %edx            # imm = 0x2C3
callq 0x20f0
callq 0x21b0
leaq 0x6f2b(%rip), %rdi      # 0xacc0
leaq 0x6cb3(%rip), %rsi      # 0xaa4f
leaq 0x6763(%rip), %rcx      # 0xa506
movl $0x2df, %edx            # imm = 0x2DF
callq 0x20f0