// File: /workspace/github_c_makefile_star2_O0/smilingthax[P]libfontembed/embed_sfnt.c
// Function: emb_otf_get_pdf_widths
EMB_PDF_FONTWIDTHS *emb_otf_get_pdf_widths(OTF_FILE *otf,const unsigned short *encoding,int len,const BITSET glyphs) // {{{ glyphs==NULL -> all from 0 to len
{
  assert(otf);

  int first=len,last=0;
  int iA;

  if (glyphs) {
    for (iA=0;iA<len;iA++) { // iA is a "gid" when in multi_byte mode...
      const int gid=(encoding)?encoding[iA]:otf_from_unicode(otf,iA); // TODO
      if (bit_check(glyphs,gid)) {
        if (first>iA) { // first is a character index
          first=iA;
        }
        if (last<iA) {
          last=iA;
        }
      }
    }
  } else {
    first=0;
    last=len;
  }
  if (last<first) {
    // empty
    fprintf(stderr,"WARNING: empty embedding range\n");
    return NULL;
  }

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

  // now create the array
  EMB_PDF_FONTWIDTHS *ret=emb_pdf_fw_new(last-first+1);
  if (!ret) {
    return NULL;
  }
  ret->first=first;
  ret->last=last;
  ret->widths=ret->data;
  for (iA=0;first<=last;iA++,first++) {
    const int gid=(encoding)?encoding[first]:otf_from_unicode(otf,first); // TODO
    if (gid>=otf->numGlyphs) {
      fprintf(stderr,"Bad glyphid\n");
      assert(0);
      free(ret);
      return NULL;
    }
    if ( (!glyphs)||(bit_check(glyphs,gid)) ) {
      ret->widths[iA]=get_width_fast(otf,gid)*1000/otf->unitsPerEm;
    } // else 0 from calloc
  }

  return ret;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x50, %rsp
movq %rdi, -0x10(%rbp)
movq %rsi, -0x18(%rbp)
movl %edx, -0x1c(%rbp)
movq %rcx, -0x28(%rbp)
cmpq $0x0, -0x10(%rbp)
je 0x6f20
jmp 0x6f3f
leaq 0x7111(%rip), %rdi      # 0xe038
leaq 0x7b5b(%rip), %rsi      # 0xea89
movl $0xe3, %edx
leaq 0x7dc8(%rip), %rcx      # 0xed02
callq 0x2100
movl -0x1c(%rbp), %eax
movl %eax, -0x2c(%rbp)
movl $0x0, -0x30(%rbp)
cmpq $0x0, -0x28(%rbp)
je 0x6fd0
movl $0x0, -0x34(%rbp)
movl -0x34(%rbp), %eax
cmpl -0x1c(%rbp), %eax
jge 0x6fce
cmpq $0x0, -0x18(%rbp)
je 0x6f7a
movq -0x18(%rbp), %rax
movslq -0x34(%rbp), %rcx
movzwl (%rax,%rcx,2), %eax
movl %eax, -0x48(%rbp)
jmp 0x6f8c
movq -0x10(%rbp), %rdi
movl -0x34(%rbp), %esi
callq 0x5280
movzwl %ax, %eax
movl %eax, -0x48(%rbp)
movl -0x48(%rbp), %eax
movl %eax, -0x38(%rbp)
movq -0x28(%rbp), %rdi
movl -0x38(%rbp), %esi
callq 0x7190
cmpl $0x0, %eax
je 0x6fc1
movl -0x2c(%rbp), %eax
cmpl -0x34(%rbp), %eax
jle 0x6fb1
movl -0x34(%rbp), %eax
movl %eax, -0x2c(%rbp)
movl -0x30(%rbp), %eax
cmpl -0x34(%rbp), %eax
jge 0x6fbf
movl -0x34(%rbp), %eax
movl %eax, -0x30(%rbp)
jmp 0x6fc1
jmp 0x6fc3
movl -0x34(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x34(%rbp)
jmp 0x6f5a
jmp 0x6fdd
movl $0x0, -0x2c(%rbp)
movl -0x1c(%rbp), %eax
movl %eax, -0x30(%rbp)
movl -0x30(%rbp), %eax
cmpl -0x2c(%rbp), %eax
jge 0x700a
movq 0xbff4(%rip), %rax      # 0x12fe0
movq (%rax), %rdi
leaq 0x7d6e(%rip), %rsi      # 0xed64
movb $0x0, %al
callq 0x21e0
movq $0x0, -0x8(%rbp)
jmp 0x717d
movq -0x10(%rbp), %rax
cmpq $0x0, 0x60(%rax)
jne 0x7044
movq -0x10(%rbp), %rdi
callq 0x4710
cmpl $0x0, %eax
je 0x7042
leaq 0x7cd6(%rip), %rdi      # 0xed00
leaq 0x7a58(%rip), %rsi      # 0xea89
movl $0x101, %edx            # imm = 0x101
leaq 0x7cc5(%rip), %rcx      # 0xed02
callq 0x2100
jmp 0x7044
movl -0x30(%rbp), %edi
subl -0x2c(%rbp), %edi
addl $0x1, %edi
callq 0x88c0
movq %rax, -0x40(%rbp)
cmpq $0x0, -0x40(%rbp)
jne 0x706a
movq $0x0, -0x8(%rbp)
jmp 0x717d
movl -0x2c(%rbp), %ecx
movq -0x40(%rbp), %rax
movl %ecx, (%rax)
movl -0x30(%rbp), %ecx
movq -0x40(%rbp), %rax
movl %ecx, 0x4(%rax)
movq -0x40(%rbp), %rcx
addq $0x20, %rcx
movq -0x40(%rbp), %rax
movq %rcx, 0x8(%rax)
movl $0x0, -0x34(%rbp)
movl -0x2c(%rbp), %eax
cmpl -0x30(%rbp), %eax
jg 0x7175
cmpq $0x0, -0x18(%rbp)
je 0x70b8
movq -0x18(%rbp), %rax
movslq -0x2c(%rbp), %rcx
movzwl (%rax,%rcx,2), %eax
movl %eax, -0x4c(%rbp)
jmp 0x70ca
movq -0x10(%rbp), %rdi
movl -0x2c(%rbp), %esi
callq 0x5280
movzwl %ax, %eax
movl %eax, -0x4c(%rbp)
movl -0x4c(%rbp), %eax
movl %eax, -0x44(%rbp)
movl -0x44(%rbp), %eax
movq -0x10(%rbp), %rcx
movzwl 0x4c(%rcx), %ecx
cmpl %ecx, %eax
jl 0x7116
movq 0xbefa(%rip), %rax      # 0x12fe0
movq (%rax), %rdi
leaq 0x7c94(%rip), %rsi      # 0xed84
movb $0x0, %al
callq 0x21e0
leaq 0x7c02(%rip), %rdi      # 0xed00
leaq 0x7984(%rip), %rsi      # 0xea89
movl $0x112, %edx            # imm = 0x112
leaq 0x7bf1(%rip), %rcx      # 0xed02
callq 0x2100
cmpq $0x0, -0x28(%rbp)
je 0x712e
movq -0x28(%rbp), %rdi
movl -0x44(%rbp), %esi
callq 0x7190
cmpl $0x0, %eax
je 0x715c
movq -0x10(%rbp), %rdi
movl -0x44(%rbp), %esi
callq 0x71c0
imull $0x3e8, %eax, %eax      # imm = 0x3E8
movq -0x10(%rbp), %rcx
movzwl 0x48(%rcx), %ecx
cltd
idivl %ecx
movl %eax, %edx
movq -0x40(%rbp), %rax
movq 0x8(%rax), %rax
movslq -0x34(%rbp), %rcx
movl %edx, (%rax,%rcx,4)
jmp 0x715e
movl -0x34(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x34(%rbp)
movl -0x2c(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x2c(%rbp)
jmp 0x7094
movq -0x40(%rbp), %rax
movq %rax, -0x8(%rbp)
movq -0x8(%rbp), %rax
addq $0x50, %rsp
popq %rbp
retq
nopw (%rax,%rax)