// File: /workspace/github_c_makefile_star2_O2/smilingthax[P]libfontembed/test_analyze.c
// Function: show_cmap
void show_cmap(OTF_FILE *otf,int full) // {{{
{
  assert(otf);
  int iA,len=0;

  char *cmap=otf_get_table(otf,OTF_TAG('c','m','a','p'),&len);
  if (!cmap) {
    assert(len==-1);
    printf("No cmap table\n");
    return;
  }
  printf("cmap:\n");
  assert(get_USHORT(cmap)==0x0000); // version
  const int numTables=get_USHORT(cmap+2);
  printf("  numTables: %d\n",numTables);
  for (iA=0;iA<numTables;iA++) {
    const char *nrec=cmap+4+8*iA;
    const char *ndata=cmap+get_ULONG(nrec+4);
    assert(ndata>=cmap+4+8*numTables);
    printf("  platformID/encodingID: %d/%d\n"
           "  offset: %d  data (format: %d, length: %d, language: %d);\n",
           get_USHORT(nrec),get_USHORT(nrec+2),
           get_ULONG(nrec+4),
           get_USHORT(ndata),get_USHORT(ndata+2),get_USHORT(ndata+4));

    if (full) {
      int iB;
      const int format=get_USHORT(ndata);
      if (format==4) {
        const int segCountX2=get_USHORT(ndata+6);
        for (iB=0;iB<segCountX2;iB+=2) {
          const int start=get_USHORT(ndata+16+segCountX2+iB);
          const int delta=get_USHORT(ndata+16+2*segCountX2+iB);
          const int offset=get_USHORT(ndata+16+3*segCountX2+iB);
          printf("    [%x, %x]: delta: %d, offset: %d  ",
                 start,
                 get_USHORT(ndata+14+iB), // end
                 delta,offset);
          if (offset) {
            printf("(glyphIndex offset: ndata + %d + 2*(c - start))",
                   16+3*segCountX2+iB+offset);
          } else {
            printf("(gid of start: %d)",
                   (start+delta)%65536);
          }
          putchar('\n');
          // either  offset!=0: *( ndata+16+3*segCountX2+iB + offset + 2*(X-start) )
          // or: just add delta to X (mod 65536)
        }
        // ... glyphIndexArray from  ndata+16+4*segCountX2  up to  get_USHORT(ndata+2))
      } else if (format==6) {
        const int len=get_USHORT(ndata+8);
        printf("    subrange start char: %x, length: %d, glyph indices:\n",
               get_USHORT(ndata+6),len);
        for (iB=0;iB<len;iB++) {
          printf("%d ",get_USHORT(ndata+10+2*iB));
        }
        putchar('\n');
      }
    }
  }
  free(cmap);
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x68, %rsp
movl %esi, 0x8(%rsp)
testq %rdi, %rdi
je 0x29cc
leaq 0xc(%rsp), %rdx
andl $0x0, (%rdx)
movl $0x636d6170, %esi       # imm = 0x636D6170
callq 0x39d0
testq %rax, %rax
je 0x298d
movq %rax, %rbx
leaq 0x6d9c(%rip), %rdi      # 0x94aa
callq 0x2200
movb 0x1(%rbx), %al
orb (%rbx), %al
jne 0x29e5
movzwl 0x2(%rbx), %eax
rolw $0x8, %ax
movzwl %ax, %r14d
leaq 0x6a75(%rip), %rdi      # 0x91a6
movl %r14d, %esi
xorl %eax, %eax
callq 0x2040
leaq 0x4(%rbx), %r15
movq %r14, 0x38(%rsp)
leaq (%rbx,%r14,8), %rax
addq $0x4, %rax
movq %rax, 0x30(%rsp)
leaq 0xb(%rbx), %rax
movq %rax, 0x18(%rsp)
leaq 0x11(%rbx), %rax
movq %rax, 0x10(%rsp)
xorl %r13d, %r13d
movq %rbx, 0x28(%rsp)
movq %r15, 0x20(%rsp)
cmpq 0x38(%rsp), %r13
je 0x2983
leaq (%r15,%r13,8), %rdi
addq $0x4, %rdi
callq 0x24e9
movl %eax, %r14d
leaq (%rbx,%r14), %r12
cmpq 0x30(%rsp), %r12
jb 0x29af
movq %r13, 0x40(%rsp)
leaq (%r15,%r13,8), %rax
movzwl (%rax), %ecx
movzwl 0x2(%rax), %eax
rolw $0x8, %cx
movzwl %cx, %esi
rolw $0x8, %ax
movzwl %ax, %edx
movzwl (%r12), %eax
movzwl 0x2(%r12), %ecx
rolw $0x8, %ax
movzwl %ax, %r8d
rolw $0x8, %cx
movzwl %cx, %r9d
movzwl 0x4(%r12), %eax
rolw $0x8, %ax
movzwl %ax, %eax
movl %eax, (%rsp)
leaq 0x69e7(%rip), %rdi      # 0x91d1
movl %r14d, %ecx
xorl %eax, %eax
callq 0x2040
cmpl $0x0, 0x8(%rsp)
je 0x296c
movzwl (%r12), %eax
rolw $0x8, %ax
cmpw $0x6, %ax
je 0x290a
movzwl %ax, %eax
cmpl $0x4, %eax
jne 0x296c
movzwl 0x6(%r12), %eax
rolw $0x8, %ax
movzwl %ax, %ecx
leal (%rcx,%rcx,2), %edx
movq 0x10(%rsp), %rax
leaq (%rax,%r14), %rsi
leaq (%rsi,%rdx), %rdi
movq %rdi, 0x58(%rsp)
addq $0x10, %rdx
movq %rdx, 0x48(%rsp)
leaq (%r14,%rcx,2), %rdx
addq %rax, %rdx
movq %rdx, 0x50(%rsp)
movq %rcx, %rbp
addq %rcx, %rsi
movq %rsi, 0x60(%rsp)
xorl %r13d, %r13d
cmpq %rbp, %r13
jae 0x296c
movq 0x60(%rsp), %rax
movzwl -0x1(%rax,%r13), %eax
rolw $0x8, %ax
movzwl %ax, %ebx
movq 0x50(%rsp), %rax
movzwl -0x1(%rax,%r13), %eax
rolw $0x8, %ax
movzwl %ax, %r15d
movq 0x58(%rsp), %rax
movzwl -0x1(%rax,%r13), %eax
rolw $0x8, %ax
movzwl %ax, %r14d
movzwl 0xe(%r12,%r13), %eax
rolw $0x8, %ax
movzwl %ax, %edx
leaq 0x6974(%rip), %rdi      # 0x922c
movl %ebx, %esi
movl %r15d, %ecx
movl %r14d, %r8d
xorl %eax, %eax
callq 0x2040
testw %r14w, %r14w
je 0x28e4
movq 0x48(%rsp), %rax
addl %r13d, %eax
addl %eax, %r14d
leaq 0x6973(%rip), %rdi      # 0x9252
movl %r14d, %esi
jmp 0x28f2
addl %ebx, %r15d
movzwl %r15w, %esi
leaq 0x6990(%rip), %rdi      # 0x9282
xorl %eax, %eax
callq 0x2040
pushq $0xa
popq %rdi
callq 0x21d0
addq $0x2, %r13
jmp 0x2863
movzwl 0x6(%r12), %eax
movzwl 0x8(%r12), %ecx
rolw $0x8, %cx
movzwl %cx, %ebx
rolw $0x8, %ax
movzwl %ax, %esi
leaq 0x696a(%rip), %rdi      # 0x9295
movl %ebx, %edx
xorl %eax, %eax
callq 0x2040
addq 0x18(%rsp), %r14
xorl %r15d, %r15d
leaq 0x698b(%rip), %r12      # 0x92ce
cmpq %r15, %rbx
je 0x2964
movzwl -0x1(%r14,%r15,2), %eax
rolw $0x8, %ax
movzwl %ax, %esi
movq %r12, %rdi
xorl %eax, %eax
callq 0x2040
incq %r15
jmp 0x2943
pushq $0xa
popq %rdi
callq 0x21d0
movq 0x40(%rsp), %r13
incq %r13
movq 0x28(%rsp), %rbx
movq 0x20(%rsp), %r15
jmp 0x2770
movq %rbx, %rdi
callq 0x21a0
jmp 0x29a0
cmpl $-0x1, 0xc(%rsp)
jne 0x29fe
leaq 0x6b01(%rip), %rdi      # 0x949c
callq 0x2200
addq $0x68, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
leaq 0x6801(%rip), %rdi      # 0x91b7
leaq 0x664b(%rip), %rsi      # 0x9008
leaq 0x67a9(%rip), %rcx      # 0x916d
pushq $0x77
popq %rdx
callq 0x20f0
leaq 0x6631(%rip), %rdi      # 0x9004
leaq 0x662e(%rip), %rsi      # 0x9008
leaq 0x678c(%rip), %rcx      # 0x916d
pushq $0x67
jmp 0x29c6
leaq 0x67a1(%rip), %rdi      # 0x918d
leaq 0x6615(%rip), %rsi      # 0x9008
leaq 0x6773(%rip), %rcx      # 0x916d
pushq $0x71
jmp 0x29c6
leaq 0x662d(%rip), %rdi      # 0x9032
leaq 0x65fc(%rip), %rsi      # 0x9008
leaq 0x675a(%rip), %rcx      # 0x916d
pushq $0x6c
jmp 0x29c6