// File: /workspace/github_c_makefile_star2_O0/smilingthax[P]libfontembed/embed_sfnt.c
// Function: emb_otf_get_post_name
static const char *emb_otf_get_post_name(const char *post,unsigned short gid) // {{{
{
  if (!post) {
    return NULL;
  }
  const unsigned int post_version=get_ULONG(post);
  if (post_version==0x00010000) { // font has only 258 chars... font cannot be used on windows
    if (gid<sizeof(macRoman)/sizeof(macRoman[0])) {
      return macRoman[gid];
    }
  } else if (post_version==0x00020000) {
    const unsigned short num_glyphs=get_USHORT(post+32);
    // assert(num_glyphs==otf->numGlyphs);
    if (gid<num_glyphs) {
      unsigned short idx=get_USHORT(post+34+2*gid);
      if (idx<258) {
        if (idx<sizeof(macRoman)/sizeof(macRoman[0])) {
          return macRoman[idx];
        }
      } else if (idx<32768) {
        const unsigned char *pos=(unsigned char *)post+34+2*num_glyphs;
        for (idx-=258;idx>0;idx--) { // this sucks...
          pos+=*pos+1; // skip this string
        }
        // convert pascal string to asciiz
        static char ret[256];
        const unsigned char len=*pos;
        memcpy(ret,(const char *)pos+1,len);
        ret[len]=0;
        return ret;
      }
    }
  } else if (post_version==0x00025000) { // similiar to 0x00010000, deprecated
    const unsigned short num_glyphs=get_USHORT(post+32);
    if (gid<num_glyphs) {
      const unsigned short idx=post[34+gid]+gid; // post is signed char *
      if (idx<sizeof(macRoman)/sizeof(macRoman[0])) {
        return macRoman[idx];
      }
    }
  } else if (post_version==0x00030000) {
    // no glyph names, sorry
//  } else if (post_version==0x00040000) { // apple AAT ?!
  }
  return NULL;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x30, %rsp
movw %si, %ax
movq %rdi, -0x10(%rbp)
movw %ax, -0x12(%rbp)
cmpq $0x0, -0x10(%rbp)
jne 0x8047
movq $0x0, -0x8(%rbp)
jmp 0x8230
movq -0x10(%rbp), %rdi
callq 0x6e80
movl %eax, -0x18(%rbp)
cmpl $0x10000, -0x18(%rbp)   # imm = 0x10000
jne 0x8085
movzwl -0x12(%rbp), %eax
cmpq $0x1, %rax
jae 0x8080
movzwl -0x12(%rbp), %eax
movl %eax, %ecx
leaq 0xb2fd(%rip), %rax      # 0x13370
movq (%rax,%rcx,8), %rax
movq %rax, -0x8(%rbp)
jmp 0x8230
jmp 0x8228
cmpl $0x20000, -0x18(%rbp)   # imm = 0x20000
jne 0x81b0
movq -0x10(%rbp), %rdi
addq $0x20, %rdi
callq 0x6450
movw %ax, -0x1a(%rbp)
movzwl -0x12(%rbp), %eax
movzwl -0x1a(%rbp), %ecx
cmpl %ecx, %eax
jge 0x81ae
movq -0x10(%rbp), %rdi
addq $0x22, %rdi
movzwl -0x12(%rbp), %eax
shll %eax
cltq
addq %rax, %rdi
callq 0x6450
movw %ax, -0x1c(%rbp)
movzwl -0x1c(%rbp), %eax
cmpl $0x102, %eax            # imm = 0x102
jge 0x8103
movzwl -0x1c(%rbp), %eax
cmpq $0x1, %rax
jae 0x80fe
movzwl -0x1c(%rbp), %eax
movl %eax, %ecx
leaq 0xb27f(%rip), %rax      # 0x13370
movq (%rax,%rcx,8), %rax
movq %rax, -0x8(%rbp)
jmp 0x8230
jmp 0x81ac
movzwl -0x1c(%rbp), %eax
cmpl $0x8000, %eax           # imm = 0x8000
jge 0x81aa
movq -0x10(%rbp), %rax
addq $0x22, %rax
movzwl -0x1a(%rbp), %ecx
shll %ecx
movslq %ecx, %rcx
addq %rcx, %rax
movq %rax, -0x28(%rbp)
movzwl -0x1c(%rbp), %eax
subl $0x102, %eax            # imm = 0x102
movw %ax, -0x1c(%rbp)
movzwl -0x1c(%rbp), %eax
cmpl $0x0, %eax
jle 0x8166
movq -0x28(%rbp), %rax
movzbl (%rax), %ecx
addl $0x1, %ecx
movq -0x28(%rbp), %rax
movslq %ecx, %rcx
addq %rcx, %rax
movq %rax, -0x28(%rbp)
movw -0x1c(%rbp), %ax
addw $-0x1, %ax
movw %ax, -0x1c(%rbp)
jmp 0x8137
movq -0x28(%rbp), %rax
movb (%rax), %al
movb %al, -0x29(%rbp)
movq -0x28(%rbp), %rsi
addq $0x1, %rsi
movzbl -0x29(%rbp), %eax
movl %eax, %edx
leaq 0xb1fc(%rip), %rdi      # 0x13380
callq 0x2120
movzbl -0x29(%rbp), %eax
movl %eax, %ecx
leaq 0xb1ea(%rip), %rax      # 0x13380
movb $0x0, (%rax,%rcx)
leaq 0xb1df(%rip), %rax      # 0x13380
movq %rax, -0x8(%rbp)
jmp 0x8230
jmp 0x81ac
jmp 0x81ae
jmp 0x8226
cmpl $0x25000, -0x18(%rbp)   # imm = 0x25000
jne 0x8217
movq -0x10(%rbp), %rdi
addq $0x20, %rdi
callq 0x6450
movw %ax, -0x2c(%rbp)
movzwl -0x12(%rbp), %eax
movzwl -0x2c(%rbp), %ecx
cmpl %ecx, %eax
jge 0x8215
movq -0x10(%rbp), %rax
movzwl -0x12(%rbp), %ecx
addl $0x22, %ecx
movslq %ecx, %rcx
movsbl (%rax,%rcx), %eax
movzwl -0x12(%rbp), %ecx
addl %ecx, %eax
movw %ax, -0x2e(%rbp)
movzwl -0x2e(%rbp), %eax
cmpq $0x1, %rax
jae 0x8213
movzwl -0x2e(%rbp), %eax
movl %eax, %ecx
leaq 0xb167(%rip), %rax      # 0x13370
movq (%rax,%rcx,8), %rax
movq %rax, -0x8(%rbp)
jmp 0x8230
jmp 0x8215
jmp 0x8224
cmpl $0x30000, -0x18(%rbp)   # imm = 0x30000
jne 0x8222
jmp 0x8222
jmp 0x8224
jmp 0x8226
jmp 0x8228
movq $0x0, -0x8(%rbp)
movq -0x8(%rbp), %rax
addq $0x30, %rsp
popq %rbp
retq
nopw (%rax,%rax)