// File: /workspace/github_c_makefile_star2_O0/smilingthax[P]libfontembed/sfnt.c
// Function: otf_load_glyf
int otf_load_glyf(OTF_FILE *otf) // {{{  - 0 on success
{
  assert(!is_CFF(otf)); // not for CFF
  int iA,len;
  // {{{ find glyf table
  iA=otf_find_table(otf,OTF_TAG('g','l','y','f'));
  if (iA==-1) {
    fprintf(stderr,"Unsupported OTF font / glyf table\n");
    return -1;
  }
  otf->glyfTable=otf->tables+iA;
  // }}}

  // {{{ read loca table
  char *loca=otf_get_table(otf,OTF_TAG('l','o','c','a'),&len);
  if ( (!loca)||
       (otf->indexToLocFormat>=2)||
       (otf_padded(len)!=otf_padded((otf->numGlyphs+1)*(otf->indexToLocFormat+1)*2)) ) {
    fprintf(stderr,"Unsupported OTF font / loca table\n");
    free(loca);
    return -1;
  }
  if (otf->glyphOffsets) {
    free(otf->glyphOffsets);
    assert(0);
  }
  otf->glyphOffsets=malloc((otf->numGlyphs+1)*sizeof(unsigned int));
  if (!otf->glyphOffsets) {
    fprintf(stderr,"Bad alloc: %s\n", strerror(errno));
    return -1;
  }
  if (otf->indexToLocFormat==0) {
    for (iA=0;iA<=otf->numGlyphs;iA++) {
      otf->glyphOffsets[iA]=get_USHORT(loca+iA*2)*2;
    }
  } else { // indexToLocFormat==1
    for (iA=0;iA<=otf->numGlyphs;iA++) {
      otf->glyphOffsets[iA]=get_ULONG(loca+iA*4);
    }
  }
  free(loca);
  if (otf->glyphOffsets[otf->numGlyphs]>otf->glyfTable->length) {
    fprintf(stderr,"Bad loca table\n");
    return -1;
  }
  // }}}

  if (otf->glyf) {
    free(otf->glyf);
    assert(0);
    otf->glyf=NULL;
  }
  if (otf->flags&OTF_F_CACHE_GLYF) {
    otf->glyf=otf_get_table(otf,OTF_TAG('g','l','y','f'),&len);
    if (!otf->glyf) {
      return -1;
    }

    if (otf->gly) {
      free(otf->gly);
      assert(0);
      otf->gly=NULL;
    }
    return 0;
  }

  // {{{ allocate otf->gly slot
  int maxGlyfLen=0;  // no single glyf takes more space
  for (iA=1;iA<=otf->numGlyphs;iA++) {
    const int glyfLen=otf->glyphOffsets[iA]-otf->glyphOffsets[iA-1];
    if (glyfLen<0) {
      fprintf(stderr,"Bad loca table: glyph len %d\n",glyfLen);
      return -1;
    }
    if (maxGlyfLen<glyfLen) {
      maxGlyfLen=glyfLen;
    }
  }
  if (otf->gly) {
    free(otf->gly);
    assert(0);
  }
  otf->gly=malloc(maxGlyfLen*sizeof(char));
  if (!otf->gly) {
    fprintf(stderr,"Bad alloc: %s\n", strerror(errno));
    return -1;
  }
  // }}}

  return 0;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x40, %rsp
movq %rdi, -0x10(%rbp)
movq -0x10(%rbp), %rdi
callq 0x46c0
cmpl $0x0, %eax
jne 0x421c
jmp 0x423b
leaq 0xa201(%rip), %rdi      # 0xe424
leaq 0xa865(%rip), %rsi      # 0xea8f
movl $0x245, %edx            # imm = 0x245
leaq 0xa1fb(%rip), %rcx      # 0xe431
callq 0x2100
movq -0x10(%rbp), %rdi
movl $0x676c7966, %esi       # imm = 0x676C7966
callq 0x3f20
movl %eax, -0x14(%rbp)
cmpl $-0x1, -0x14(%rbp)
jne 0x4276
movq 0xed87(%rip), %rax      # 0x12fe0
movq (%rax), %rdi
leaq 0xa1ec(%rip), %rsi      # 0xe44f
movb $0x0, %al
callq 0x21e0
movl $0xffffffff, -0x4(%rbp) # imm = 0xFFFFFFFF
jmp 0x46b0
movq -0x10(%rbp), %rax
movq 0x40(%rax), %rcx
movslq -0x14(%rbp), %rax
imulq $0x14, %rax, %rax
addq %rax, %rcx
movq -0x10(%rbp), %rax
movq %rcx, 0x88(%rax)
movq -0x10(%rbp), %rdi
movl $0x6c6f6361, %esi       # imm = 0x6C6F6361
leaq -0x18(%rbp), %rdx
callq 0x4000
movq %rax, -0x20(%rbp)
cmpq $0x0, -0x20(%rbp)
je 0x42f2
movq -0x10(%rbp), %rax
movzwl 0x4a(%rax), %eax
cmpl $0x2, %eax
jge 0x42f2
movl -0x18(%rbp), %edi
callq 0x3050
movl %eax, -0x2c(%rbp)
movq -0x10(%rbp), %rax
movzwl 0x4c(%rax), %edi
addl $0x1, %edi
movq -0x10(%rbp), %rax
movzwl 0x4a(%rax), %eax
addl $0x1, %eax
imull %eax, %edi
shll %edi
callq 0x3050
movl %eax, %ecx
movl -0x2c(%rbp), %eax
cmpl %ecx, %eax
je 0x431f
movq 0xece7(%rip), %rax      # 0x12fe0
movq (%rax), %rdi
leaq 0xa16f(%rip), %rsi      # 0xe472
movb $0x0, %al
callq 0x21e0
movq -0x20(%rbp), %rdi
callq 0x21b0
movl $0xffffffff, -0x4(%rbp) # imm = 0xFFFFFFFF
jmp 0x46b0
movq -0x10(%rbp), %rax
cmpq $0x0, 0x50(%rax)
je 0x4356
movq -0x10(%rbp), %rax
movq 0x50(%rax), %rdi
callq 0x21b0
leaq 0xa9c2(%rip), %rdi      # 0xed00
leaq 0xa74a(%rip), %rsi      # 0xea8f
movl $0x25b, %edx            # imm = 0x25B
leaq 0xa0e0(%rip), %rcx      # 0xe431
callq 0x2100
movq -0x10(%rbp), %rax
movzwl 0x4c(%rax), %eax
addl $0x1, %eax
movslq %eax, %rdi
shlq $0x2, %rdi
callq 0x21d0
movq %rax, %rcx
movq -0x10(%rbp), %rax
movq %rcx, 0x50(%rax)
movq -0x10(%rbp), %rax
cmpq $0x0, 0x50(%rax)
jne 0x43be
movq 0xec56(%rip), %rax      # 0x12fe0
movq (%rax), %rax
movq %rax, -0x38(%rbp)
callq 0x2040
movl (%rax), %edi
callq 0x2070
movq -0x38(%rbp), %rdi
movq %rax, %rdx
leaq 0x9fb1(%rip), %rsi      # 0xe35c
movb $0x0, %al
callq 0x21e0
movl $0xffffffff, -0x4(%rbp) # imm = 0xFFFFFFFF
jmp 0x46b0
movq -0x10(%rbp), %rax
movzwl 0x4a(%rax), %eax
cmpl $0x0, %eax
jne 0x4415
movl $0x0, -0x14(%rbp)
movl -0x14(%rbp), %eax
movq -0x10(%rbp), %rcx
movzwl 0x4c(%rcx), %ecx
cmpl %ecx, %eax
jg 0x4413
movq -0x20(%rbp), %rdi
movl -0x14(%rbp), %eax
shll %eax
cltq
addq %rax, %rdi
callq 0x46f0
movzwl %ax, %edx
shll %edx
movq -0x10(%rbp), %rax
movq 0x50(%rax), %rax
movslq -0x14(%rbp), %rcx
movl %edx, (%rax,%rcx,4)
movl -0x14(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x14(%rbp)
jmp 0x43d2
jmp 0x445d
movl $0x0, -0x14(%rbp)
movl -0x14(%rbp), %eax
movq -0x10(%rbp), %rcx
movzwl 0x4c(%rcx), %ecx
cmpl %ecx, %eax
jg 0x445b
movq -0x20(%rbp), %rdi
movl -0x14(%rbp), %eax
shll $0x2, %eax
cltq
addq %rax, %rdi
callq 0x3540
movl %eax, %edx
movq -0x10(%rbp), %rax
movq 0x50(%rax), %rax
movslq -0x14(%rbp), %rcx
movl %edx, (%rax,%rcx,4)
movl -0x14(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x14(%rbp)
jmp 0x441c
jmp 0x445d
movq -0x20(%rbp), %rdi
callq 0x21b0
movq -0x10(%rbp), %rax
movq 0x50(%rax), %rax
movq -0x10(%rbp), %rcx
movzwl 0x4c(%rcx), %ecx
movl (%rax,%rcx,4), %eax
movq -0x10(%rbp), %rcx
movq 0x88(%rcx), %rcx
cmpl 0xc(%rcx), %eax
jbe 0x44ad
movq 0xeb50(%rip), %rax      # 0x12fe0
movq (%rax), %rdi
leaq 0x9ffb(%rip), %rsi      # 0xe495
movb $0x0, %al
callq 0x21e0
movl $0xffffffff, -0x4(%rbp) # imm = 0xFFFFFFFF
jmp 0x46b0
movq -0x10(%rbp), %rax
cmpq $0x0, 0x90(%rax)
je 0x44ea
movq -0x10(%rbp), %rax
movq 0x90(%rax), %rdi
callq 0x21b0
leaq 0xa82e(%rip), %rdi      # 0xed00
leaq 0xa5b6(%rip), %rsi      # 0xea8f
movl $0x274, %edx            # imm = 0x274
leaq 0x9f4c(%rip), %rcx      # 0xe431
callq 0x2100
movq -0x10(%rbp), %rax
movl 0x8(%rax), %eax
andl $0x1, %eax
cmpl $0x0, %eax
je 0x4580
movq -0x10(%rbp), %rdi
movl $0x676c7966, %esi       # imm = 0x676C7966
leaq -0x18(%rbp), %rdx
callq 0x4000
movq %rax, %rcx
movq -0x10(%rbp), %rax
movq %rcx, 0x90(%rax)
movq -0x10(%rbp), %rax
cmpq $0x0, 0x90(%rax)
jne 0x4537
movl $0xffffffff, -0x4(%rbp) # imm = 0xFFFFFFFF
jmp 0x46b0
movq -0x10(%rbp), %rax
cmpq $0x0, 0x80(%rax)
je 0x4574
movq -0x10(%rbp), %rax
movq 0x80(%rax), %rdi
callq 0x21b0
leaq 0xa7a4(%rip), %rdi      # 0xed00
leaq 0xa52c(%rip), %rsi      # 0xea8f
movl $0x27f, %edx            # imm = 0x27F
leaq 0x9ec2(%rip), %rcx      # 0xe431
callq 0x2100
movl $0x0, -0x4(%rbp)
jmp 0x46b0
movl $0x0, -0x24(%rbp)
movl $0x1, -0x14(%rbp)
movl -0x14(%rbp), %eax
movq -0x10(%rbp), %rcx
movzwl 0x4c(%rcx), %ecx
cmpl %ecx, %eax
jg 0x460b
movq -0x10(%rbp), %rax
movq 0x50(%rax), %rax
movslq -0x14(%rbp), %rcx
movl (%rax,%rcx,4), %eax
movq -0x10(%rbp), %rcx
movq 0x50(%rcx), %rcx
movl -0x14(%rbp), %edx
subl $0x1, %edx
movslq %edx, %rdx
subl (%rcx,%rdx,4), %eax
movl %eax, -0x28(%rbp)
cmpl $0x0, -0x28(%rbp)
jge 0x45f0
movq 0xea10(%rip), %rax      # 0x12fe0
movq (%rax), %rdi
movl -0x28(%rbp), %edx
leaq 0x9ec8(%rip), %rsi      # 0xe4a5
movb $0x0, %al
callq 0x21e0
movl $0xffffffff, -0x4(%rbp) # imm = 0xFFFFFFFF
jmp 0x46b0
movl -0x24(%rbp), %eax
cmpl -0x28(%rbp), %eax
jge 0x45fe
movl -0x28(%rbp), %eax
movl %eax, -0x24(%rbp)
jmp 0x4600
movl -0x14(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x14(%rbp)
jmp 0x458e
movq -0x10(%rbp), %rax
cmpq $0x0, 0x80(%rax)
je 0x4648
movq -0x10(%rbp), %rax
movq 0x80(%rax), %rdi
callq 0x21b0
leaq 0xa6d0(%rip), %rdi      # 0xed00
leaq 0xa458(%rip), %rsi      # 0xea8f
movl $0x293, %edx            # imm = 0x293
leaq 0x9dee(%rip), %rcx      # 0xe431
callq 0x2100
movslq -0x24(%rbp), %rdi
shlq $0x0, %rdi
callq 0x21d0
movq %rax, %rcx
movq -0x10(%rbp), %rax
movq %rcx, 0x80(%rax)
movq -0x10(%rbp), %rax
cmpq $0x0, 0x80(%rax)
jne 0x46a9
movq 0xe968(%rip), %rax      # 0x12fe0
movq (%rax), %rax
movq %rax, -0x40(%rbp)
callq 0x2040
movl (%rax), %edi
callq 0x2070
movq -0x40(%rbp), %rdi
movq %rax, %rdx
leaq 0x9cc3(%rip), %rsi      # 0xe35c
movb $0x0, %al
callq 0x21e0
movl $0xffffffff, -0x4(%rbp) # imm = 0xFFFFFFFF
jmp 0x46b0
movl $0x0, -0x4(%rbp)
movl -0x4(%rbp), %eax
addq $0x40, %rsp
popq %rbp
retq
nopl (%rax)