// File: /workspace/github_c_makefile_star2_O0/smilingthax[P]libfontembed/sfnt_subset.c
// Function: otf_subset_glyf
static int otf_subset_glyf(OTF_FILE *otf,int curgid,int donegid,BITSET glyphs) // {{{
{
  int ret=0;
  if (get_SHORT(otf->gly)>=0) { // not composite
    return ret; // done
  }

  char *cur=otf->gly+10;

  unsigned short flags;
  do {
    flags=get_USHORT(cur);
    const unsigned short sub_gid=get_USHORT(cur+2);
    assert(sub_gid<otf->numGlyphs);
    if (!bit_check(glyphs,sub_gid)) {
      // bad: temporarily load sub glyph
      const int len=otf_get_glyph(otf,sub_gid);
      assert(len>0);
      bit_set(glyphs,sub_gid);
      if (sub_gid<donegid) {
        ret+=len;
        ret+=otf_subset_glyf(otf,sub_gid,donegid,glyphs); // composite of composites?, e.g. in DejaVu
      }
      const int res=otf_get_glyph(otf,curgid); // reload current glyph
      assert(res);
    }

    // skip parameters
    cur+=6;
    if (flags&0x01) {
      cur+=2;
    }
    if (flags&0x08) {
      cur+=2;
    } else if (flags&0x40) {
      cur+=4;
    } else if (flags&0x80) {
      cur+=8;
    }
  } while (flags&0x20); // more components

  return ret;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x40, %rsp
movq %rdi, -0x10(%rbp)
movl %esi, -0x14(%rbp)
movl %edx, -0x18(%rbp)
movq %rcx, -0x20(%rbp)
movl $0x0, -0x24(%rbp)
movq -0x10(%rbp), %rax
movq 0x80(%rax), %rdi
callq 0xbbe0
cwtl
cmpl $0x0, %eax
jl 0xb34e
movl -0x24(%rbp), %eax
movl %eax, -0x4(%rbp)
jmp 0xb4ff
movq -0x10(%rbp), %rax
movq 0x80(%rax), %rax
addq $0xa, %rax
movq %rax, -0x30(%rbp)
movq -0x30(%rbp), %rdi
callq 0xbc00
movw %ax, -0x32(%rbp)
movq -0x30(%rbp), %rdi
addq $0x2, %rdi
callq 0xbc00
movw %ax, -0x34(%rbp)
movzwl -0x34(%rbp), %eax
movq -0x10(%rbp), %rcx
movzwl 0x4c(%rcx), %ecx
cmpl %ecx, %eax
jge 0xb391
jmp 0xb3b0
leaq 0x4731(%rip), %rdi      # 0xfac9
leaq 0x4566(%rip), %rsi      # 0xf905
movl $0x65, %edx
leaq 0x4735(%rip), %rcx      # 0xfae0
callq 0x2100
movq -0x20(%rbp), %rdi
movzwl -0x34(%rbp), %esi
callq 0xbc20
cmpl $0x0, %eax
jne 0xb471
movq -0x10(%rbp), %rdi
movzwl -0x34(%rbp), %esi
callq 0x5040
movl %eax, -0x38(%rbp)
cmpl $0x0, -0x38(%rbp)
jle 0xb3de
jmp 0xb3fd
leaq 0x472d(%rip), %rdi      # 0xfb12
leaq 0x4519(%rip), %rsi      # 0xf905
movl $0x69, %edx
leaq 0x46e8(%rip), %rcx      # 0xfae0
callq 0x2100
movq -0x20(%rbp), %rdi
movzwl -0x34(%rbp), %esi
callq 0xb2e0
movzwl -0x34(%rbp), %eax
cmpl -0x18(%rbp), %eax
jge 0xb436
movl -0x38(%rbp), %eax
addl -0x24(%rbp), %eax
movl %eax, -0x24(%rbp)
movq -0x10(%rbp), %rdi
movzwl -0x34(%rbp), %esi
movl -0x18(%rbp), %edx
movq -0x20(%rbp), %rcx
callq 0xb310
addl -0x24(%rbp), %eax
movl %eax, -0x24(%rbp)
movq -0x10(%rbp), %rdi
movl -0x14(%rbp), %eax
movzwl %ax, %esi
callq 0x5040
movl %eax, -0x3c(%rbp)
cmpl $0x0, -0x3c(%rbp)
je 0xb450
jmp 0xb46f
leaq 0x2cd9(%rip), %rdi      # 0xe130
leaq 0x44a7(%rip), %rsi      # 0xf905
movl $0x70, %edx
leaq 0x4676(%rip), %rcx      # 0xfae0
callq 0x2100
jmp 0xb471
movq -0x30(%rbp), %rax
addq $0x6, %rax
movq %rax, -0x30(%rbp)
movzwl -0x32(%rbp), %eax
andl $0x1, %eax
cmpl $0x0, %eax
je 0xb495
movq -0x30(%rbp), %rax
addq $0x2, %rax
movq %rax, -0x30(%rbp)
movzwl -0x32(%rbp), %eax
andl $0x8, %eax
cmpl $0x0, %eax
je 0xb4af
movq -0x30(%rbp), %rax
addq $0x2, %rax
movq %rax, -0x30(%rbp)
jmp 0xb4e7
movzwl -0x32(%rbp), %eax
andl $0x40, %eax
cmpl $0x0, %eax
je 0xb4c9
movq -0x30(%rbp), %rax
addq $0x4, %rax
movq %rax, -0x30(%rbp)
jmp 0xb4e5
movzwl -0x32(%rbp), %eax
andl $0x80, %eax
cmpl $0x0, %eax
je 0xb4e3
movq -0x30(%rbp), %rax
addq $0x8, %rax
movq %rax, -0x30(%rbp)
jmp 0xb4e5
jmp 0xb4e7
jmp 0xb4e9
movzwl -0x32(%rbp), %eax
andl $0x20, %eax
cmpl $0x0, %eax
jne 0xb361
movl -0x24(%rbp), %eax
movl %eax, -0x4(%rbp)
movl -0x4(%rbp), %eax
addq $0x40, %rsp
popq %rbp
retq
nopl (%rax,%rax)