// File: /workspace/github_c_makefile_star2_O2/smilingthax[P]libfontembed/sfnt.c
// Function: otf_load_cmap
int otf_load_cmap(OTF_FILE *otf) // {{{  - 0 on success
{
  int iA;
  int len;

  char *cmap=otf_get_table(otf,OTF_TAG('c','m','a','p'),&len);
  if ( (!cmap)||
       (get_USHORT(cmap)!=0x0000)|| // version
       (len<get_USHORT(cmap+2)*8+4) ) {
    fprintf(stderr,"Unsupported OTF font / cmap table \n");
    free(cmap);
    assert(0);
    return -1;
  }
  // check bounds, find (3,0) or (3,1) [TODO?]
  const int numTables=get_USHORT(cmap+2);
  for (iA=0;iA<numTables;iA++) {
    const char *nrec=cmap+4+8*iA;
    const unsigned int offset=get_ULONG(nrec+4);
    const char *ndata=cmap+offset;
    if ( (ndata<cmap+4+8*numTables)||
         (offset>=len)||
         (offset+get_USHORT(ndata+2)>len) ) {
      fprintf(stderr,"Bad cmap table\n");
      free(cmap);
      assert(0);
      return -1;
    }
    if ( (get_USHORT(nrec)==3)&&
         (get_USHORT(nrec+2)<=1)&&
         (get_USHORT(ndata)==4)&&
         (get_USHORT(ndata+4)==0) ) {
      otf->unimap=ndata;
    }
  }
  if (otf->cmap) {
    free(otf->cmap);
    assert(0);
  }
  otf->cmap=cmap;

  return 0;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
pushq %rax
movq %rdi, %r14
leaq 0x4(%rsp), %rdx
movl $0x636d6170, %esi       # imm = 0x636D6170
callq 0x371c
movq %rax, %rbx
testq %rax, %rax
je 0x3ee6
movb 0x1(%rbx), %al
orb (%rbx), %al
jne 0x3ee6
movzwl 0x2(%rbx), %eax
rolw $0x8, %ax
movl 0x4(%rsp), %ebp
movzwl %ax, %eax
leal 0x4(,%rax,8), %ecx
cmpl %ecx, %ebp
jl 0x3ee6
leal (,%rax,8), %ecx
movl %ecx, %ecx
leaq (%rbx,%rcx), %r12
addq $0x4, %r12
movl %eax, %r13d
leaq 0x8(%rbx), %r15
subq $0x1, %r13
jb 0x3e81
movq %r15, %rdi
callq 0x353a
cmpl %ebp, %eax
jae 0x3ea3
movl %eax, %ecx
addq %rbx, %rcx
cmpq %r12, %rcx
jb 0x3ea3
movzwl 0x2(%rcx), %edx
rolw $0x8, %dx
movzwl %dx, %edx
addl %eax, %edx
cmpl %ebp, %edx
ja 0x3ea3
movzwl -0x4(%r15), %eax
rolw $0x8, %ax
cmpw $0x3, %ax
jne 0x3e7b
movzwl -0x2(%r15), %eax
rolw $0x8, %ax
cmpw $0x1, %ax
ja 0x3e7b
movzwl (%rcx), %eax
rolw $0x8, %ax
cmpw $0x4, %ax
jne 0x3e7b
movb 0x5(%rcx), %al
orb 0x4(%rcx), %al
jne 0x3e7b
movq %rcx, 0x78(%r14)
addq $0x8, %r15
jmp 0x3e17
movq 0x70(%r14), %rdi
testq %rdi, %rdi
jne 0x3f29
movq %rbx, 0x70(%r14)
xorl %eax, %eax
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq 0xb136(%rip), %rax      # 0xefe0
movq (%rax), %rcx
leaq 0x66e7(%rip), %rdi      # 0xa59b
pushq $0xf
popq %rsi
pushq $0x1
popq %rdx
callq 0x2280
movq %rbx, %rdi
callq 0x21b0
leaq 0x6df2(%rip), %rdi      # 0xacc0
leaq 0x6b7a(%rip), %rsi      # 0xaa4f
leaq 0x66a1(%rip), %rcx      # 0xa57d
movl $0x301, %edx            # imm = 0x301
callq 0x20f0
movq 0xb0f3(%rip), %rax      # 0xefe0
movq (%rax), %rcx
leaq 0x6662(%rip), %rdi      # 0xa559
pushq $0x23
popq %rsi
pushq $0x1
popq %rdx
callq 0x2280
movq %rbx, %rdi
callq 0x21b0
leaq 0x6daf(%rip), %rdi      # 0xacc0
leaq 0x6b37(%rip), %rsi      # 0xaa4f
leaq 0x665e(%rip), %rcx      # 0xa57d
movl $0x2f3, %edx            # imm = 0x2F3
callq 0x20f0
callq 0x21b0
leaq 0x6d8b(%rip), %rdi      # 0xacc0
leaq 0x6b13(%rip), %rsi      # 0xaa4f
leaq 0x663a(%rip), %rcx      # 0xa57d
movl $0x30d, %edx            # imm = 0x30D
callq 0x20f0