// File: /workspace/github_c_makefile_star2_O0/smilingthax[P]libfontembed/sfnt.c
// Function: otf_get_glyph
int otf_get_glyph(OTF_FILE *otf,unsigned short gid) // {{{ result in >otf->gly, returns length, -1 on error
{
  assert(otf);
  assert(!is_CFF(otf)); // not for CFF

  if (gid>=otf->numGlyphs) {
    return -1;
  }

  // ensure >glyphOffsets is there
  if (!otf->glyphOffsets) {
    if (otf_load_more(otf)!=0) {
      assert(0);
      return -1;
    }
  }

  const int len=otf->glyphOffsets[gid+1]-otf->glyphOffsets[gid];
  if (len==0) {
    return 0;
  }

  assert(otf->glyfTable->length>=otf->glyphOffsets[gid+1]);
  if (otf->glyf) { // i.e. OTF_F_CACHE_GLYF
    otf->gly=otf->glyf+otf->glyphOffsets[gid];
  } else if (otf->gly) {
    if (otf->flags&OTF_F_WOFF) {
      fprintf(stderr,"OTF_F_CACHE_GLYF is needed to read glyphs from wOFF files\n");
      return -1;
    }
    if (!otf_read_raw(otf->f,otf->gly,
                  otf->glyfTable->offset+otf->glyphOffsets[gid],len)) {
      return -1;
    }
  } else {
    assert(0);
    return -1;
  }

  return len;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x20, %rsp
movw %si, %ax
movq %rdi, -0x10(%rbp)
movw %ax, -0x12(%rbp)
cmpq $0x0, -0x10(%rbp)
je 0x505c
jmp 0x507b
leaq 0x8fd5(%rip), %rdi      # 0xe038
leaq 0x9a25(%rip), %rsi      # 0xea8f
movl $0x359, %edx            # imm = 0x359
leaq 0x95a6(%rip), %rcx      # 0xe61c
callq 0x2100
movq -0x10(%rbp), %rdi
callq 0x46c0
cmpl $0x0, %eax
jne 0x508b
jmp 0x50aa
leaq 0x9392(%rip), %rdi      # 0xe424
leaq 0x99f6(%rip), %rsi      # 0xea8f
movl $0x35a, %edx            # imm = 0x35A
leaq 0x9577(%rip), %rcx      # 0xe61c
callq 0x2100
movzwl -0x12(%rbp), %eax
movq -0x10(%rbp), %rcx
movzwl 0x4c(%rcx), %ecx
cmpl %ecx, %eax
jl 0x50c6
movl $0xffffffff, -0x4(%rbp) # imm = 0xFFFFFFFF
jmp 0x526c
movq -0x10(%rbp), %rax
cmpq $0x0, 0x50(%rax)
jne 0x5100
movq -0x10(%rbp), %rdi
callq 0x4710
cmpl $0x0, %eax
je 0x50fe
leaq 0x9c1a(%rip), %rdi      # 0xed00
leaq 0x99a2(%rip), %rsi      # 0xea8f
movl $0x363, %edx            # imm = 0x363
leaq 0x9523(%rip), %rcx      # 0xe61c
callq 0x2100
jmp 0x5100
movq -0x10(%rbp), %rax
movq 0x50(%rax), %rax
movzwl -0x12(%rbp), %ecx
addl $0x1, %ecx
movslq %ecx, %rcx
movl (%rax,%rcx,4), %eax
movq -0x10(%rbp), %rcx
movq 0x50(%rcx), %rcx
movzwl -0x12(%rbp), %edx
subl (%rcx,%rdx,4), %eax
movl %eax, -0x18(%rbp)
cmpl $0x0, -0x18(%rbp)
jne 0x5139
movl $0x0, -0x4(%rbp)
jmp 0x526c
movq -0x10(%rbp), %rax
movq 0x88(%rax), %rax
movl 0xc(%rax), %eax
movq -0x10(%rbp), %rcx
movq 0x50(%rcx), %rcx
movzwl -0x12(%rbp), %edx
addl $0x1, %edx
movslq %edx, %rdx
cmpl (%rcx,%rdx,4), %eax
jb 0x5160
jmp 0x517f
leaq 0x94e3(%rip), %rdi      # 0xe64a
leaq 0x9921(%rip), %rsi      # 0xea8f
movl $0x36d, %edx            # imm = 0x36D
leaq 0x94a2(%rip), %rcx      # 0xe61c
callq 0x2100
movq -0x10(%rbp), %rax
cmpq $0x0, 0x90(%rax)
je 0x51ba
movq -0x10(%rbp), %rax
movq 0x90(%rax), %rcx
movq -0x10(%rbp), %rax
movq 0x50(%rax), %rax
movzwl -0x12(%rbp), %edx
movl (%rax,%rdx,4), %eax
addq %rax, %rcx
movq -0x10(%rbp), %rax
movq %rcx, 0x80(%rax)
jmp 0x5266
movq -0x10(%rbp), %rax
cmpq $0x0, 0x80(%rax)
je 0x5245
movq -0x10(%rbp), %rax
movl 0x8(%rax), %eax
andl $0x8000, %eax           # imm = 0x8000
cmpl $0x0, %eax
je 0x51fa
movq 0xde00(%rip), %rax      # 0x12fe0
movq (%rax), %rdi
leaq 0x9491(%rip), %rsi      # 0xe67b
movb $0x0, %al
callq 0x21e0
movl $0xffffffff, -0x4(%rbp) # imm = 0xFFFFFFFF
jmp 0x526c
movq -0x10(%rbp), %rax
movq (%rax), %rdi
movq -0x10(%rbp), %rax
movq 0x80(%rax), %rsi
movq -0x10(%rbp), %rax
movq 0x88(%rax), %rax
movl 0x8(%rax), %eax
movq -0x10(%rbp), %rcx
movq 0x50(%rcx), %rcx
movzwl -0x12(%rbp), %edx
addl (%rcx,%rdx,4), %eax
movl %eax, %eax
movl %eax, %edx
movl -0x18(%rbp), %ecx
callq 0x3190
cmpl $0x0, %eax
jne 0x5243
movl $0xffffffff, -0x4(%rbp) # imm = 0xFFFFFFFF
jmp 0x526c
jmp 0x5264
leaq 0x9ab4(%rip), %rdi      # 0xed00
leaq 0x983c(%rip), %rsi      # 0xea8f
movl $0x37a, %edx            # imm = 0x37A
leaq 0x93bd(%rip), %rcx      # 0xe61c
callq 0x2100
jmp 0x5266
movl -0x18(%rbp), %eax
movl %eax, -0x4(%rbp)
movl -0x4(%rbp), %eax
addq $0x20, %rsp
popq %rbp
retq
nopw %cs:(%rax,%rax)