// File: /workspace/github_c_makefile_star2_O2/smilingthax[P]libfontembed/embed_pdf.c
// Function: emb_pdf_simple_fontdescr
char *emb_pdf_simple_fontdescr(EMB_PARAMS *emb,EMB_PDF_FONTDESCR *fdes,int fontfile_obj_ref) // {{{ - to be freed by user
{
  assert(emb);
  assert(fdes);

  char *ret=NULL,*pos;
  int len,size;

  size=300;
  pos=ret=malloc(size);
  if (!ret) {
    fprintf(stderr,"Bad alloc: %s\n", strerror(errno));
    return NULL;
  }

  len=snprintf(pos,size,
               "<</Type /FontDescriptor\n"
               "  /FontName /%s\n" // TODO? handle quoting in struct?
               "  /Flags %d\n"
               "  /ItalicAngle %d\n",
               emb_pdf_escape_name(fdes->fontname,-1),
               fdes->flags,
               fdes->italicAngle);
  NEXT;

  if (1) { // TODO type!=EMB_PDF_TYPE3
    len=snprintf(pos,size,
                 "  /FontBBox [%d %d %d %d]\n"
                 "  /Ascent %d\n"
                 "  /Descent %d\n"
                 "  /CapHeight %d\n" // if font has Latin chars
                 "  /StemV %d\n",
                 fdes->bbxmin,fdes->bbymin,fdes->bbxmax,fdes->bbymax,
                 fdes->ascent,
                 fdes->descent,
                 fdes->capHeight,
                 fdes->stemV);
    NEXT;
  }
  if (fdes->xHeight) {
    len=snprintf(pos,size,"  /XHeight %d\n",fdes->xHeight);
    NEXT;
  }
  if (fdes->avgWidth) {
    len=snprintf(pos,size,"  /AvgWidth %d\n",fdes->avgWidth);
    NEXT;
  }
  if (fdes->panose) {
    int iA;
    len=snprintf(pos,size,"  /Style << /Panose <");
    NEXT;
    if (size<30) {
      assert(0);
      free(ret);
      return NULL;
    }
    for (iA=0;iA<12;iA++) {
      snprintf(pos+iA*2,size-iA*2,"%02x",fdes->panose[iA]);
    }
    size-=24;
    pos+=24;
    len=snprintf(pos,size,"> >>\n");
    NEXT;
  }
  // TODO (for Type0)? CIDSet  -> simply our glyphs BITSET  (ok. endianess?)
  len=snprintf(pos,size,
               "  /%s %d 0 R\n"
               ">>\n",
               emb_pdf_get_fontfile_key(emb),
               fontfile_obj_ref);
  NEXT;

  return ret;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x28, %rsp
testq %rdi, %rdi
je 0x6a65
movq %rsi, %r12
testq %rsi, %rsi
je 0x6a84
movl %edx, %ebx
movq %rdi, %r14
movl $0x12c, %edi            # imm = 0x12C
callq 0x21d0
movq %rax, %rbp
testq %rax, %rax
je 0x6a39
movq %r14, 0x20(%rsp)
movl %ebx, 0x14(%rsp)
movq (%r12), %rdi
callq 0x6b9b
movl 0x8(%r12), %r8d
movl 0x1c(%r12), %r9d
leaq 0x4a13(%rip), %rdx      # 0xb240
leaq 0x8b8c(%rip), %rcx      # 0xf3c0
movl $0x12c, %esi            # imm = 0x12C
movq %rbp, %rdi
xorl %eax, %eax
callq 0x2220
cmpl $0x12c, %eax            # imm = 0x12C
jae 0x6aa3
movl %eax, %ecx
movq %rbp, 0x8(%rsp)
addq %rcx, %rbp
movl $0x12c, %r15d           # imm = 0x12C
subl %eax, %r15d
movl 0xc(%r12), %ecx
movl 0x10(%r12), %r8d
movl 0x14(%r12), %r9d
movl 0x18(%r12), %r10d
movl 0x20(%r12), %r11d
movl 0x24(%r12), %ebx
movl 0x28(%r12), %r14d
movl 0x2c(%r12), %r13d
subq $0x8, %rsp
leaq 0x49f3(%rip), %rdx      # 0xb287
movq %rbp, %rdi
movq %r15, %rsi
xorl %eax, %eax
pushq %r13
pushq %r14
pushq %rbx
pushq %r11
pushq %r10
callq 0x2220
addq $0x30, %rsp
subl %eax, %r15d
jbe 0x6ac2
movl %eax, %eax
addq %rax, %rbp
movl 0x30(%r12), %ecx
testl %ecx, %ecx
movq %rbp, %r13
je 0x68f9
movslq %r15d, %rsi
leaq 0x4a07(%rip), %rdx      # 0xb2d9
movq %r13, %rdi
xorl %eax, %eax
callq 0x2220
testl %eax, %eax
movq 0x8(%rsp), %rbp
js 0x6b00
subl %eax, %r15d
jle 0x6b00
movl %eax, %eax
addq %rax, %r13
jmp 0x68fe
movq 0x8(%rsp), %rbp
movl 0x34(%r12), %ecx
testl %ecx, %ecx
je 0x6931
movslq %r15d, %rsi
leaq 0x49d7(%rip), %rdx      # 0xb2e8
movq %r13, %rdi
xorl %eax, %eax
callq 0x2220
testl %eax, %eax
js 0x6b1f
subl %eax, %r15d
jle 0x6b1f
movl %eax, %eax
addq %rax, %r13
cmpq $0x0, 0x38(%r12)
je 0x69ea
movslq %r15d, %rsi
leaq 0x49b1(%rip), %rdx      # 0xb2f8
movq %r13, %rdi
xorl %eax, %eax
callq 0x2220
testl %eax, %eax
js 0x6b3e
subl %eax, %r15d
jle 0x6b3e
cmpl $0x1e, %r15d
jl 0x6b5d
movl %eax, %eax
addq %rax, %r13
leaq 0x4996(%rip), %rbp      # 0xb30e
movl %r15d, %r14d
movq %r13, 0x18(%rsp)
xorl %ebx, %ebx
cmpq $0xc, %rbx
je 0x69ae
movl %r14d, %esi
movq 0x38(%r12), %rax
movsbl (%rax,%rbx), %ecx
movq %r13, %rdi
movq %rbp, %rdx
xorl %eax, %eax
callq 0x2220
incq %rbx
addq $0x2, %r13
addl $-0x2, %r14d
jmp 0x6982
addl $-0x18, %r15d
movq 0x18(%rsp), %r13
addq $0x18, %r13
leaq 0x4951(%rip), %rdx      # 0xb313
movq %r13, %rdi
movq %r15, %rsi
xorl %eax, %eax
callq 0x2220
testl %eax, %eax
js 0x6b7c
subl %eax, %r15d
jle 0x6b7c
movl %eax, %eax
addq %rax, %r13
movq 0x8(%rsp), %rbp
movslq %r15d, %rsi
movq 0x20(%rsp), %rax
movl 0x4(%rax), %eax
leaq 0x8334(%rip), %rcx      # 0xed30
movq (%rcx,%rax,8), %rcx
leaq 0x4912(%rip), %rdx      # 0xb319
movq %r13, %rdi
movl 0x14(%rsp), %r8d
xorl %eax, %eax
callq 0x2220
testl %eax, %eax
js 0x6ae1
cmpl %r15d, %eax
jge 0x6ae1
movq %rbp, %rax
addq $0x28, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq 0x85a0(%rip), %rax      # 0xefe0
movq (%rax), %rbx
callq 0x2040
movl (%rax), %edi
callq 0x2070
leaq 0x3903(%rip), %rsi      # 0xa359
movq %rbx, %rdi
movq %rax, %rdx
xorl %eax, %eax
callq 0x21e0
jmp 0x6a27
leaq 0x3868(%rip), %rdi      # 0xa2d4
leaq 0x45b5(%rip), %rsi      # 0xb028
leaq 0x477f(%rip), %rcx      # 0xb1f9
movl $0x171, %edx            # imm = 0x171
callq 0x20f0
leaq 0x3650(%rip), %rdi      # 0xa0db
leaq 0x4596(%rip), %rsi      # 0xb028
leaq 0x4760(%rip), %rcx      # 0xb1f9
movl $0x172, %edx            # imm = 0x172
callq 0x20f0
leaq 0x4216(%rip), %rdi      # 0xacc0
leaq 0x4577(%rip), %rsi      # 0xb028
leaq 0x4741(%rip), %rcx      # 0xb1f9
movl $0x186, %edx            # imm = 0x186
callq 0x20f0
leaq 0x41f7(%rip), %rdi      # 0xacc0
leaq 0x4558(%rip), %rsi      # 0xb028
leaq 0x4722(%rip), %rcx      # 0xb1f9
movl $0x194, %edx            # imm = 0x194
callq 0x20f0
leaq 0x41d8(%rip), %rdi      # 0xacc0
leaq 0x4539(%rip), %rsi      # 0xb028
leaq 0x4703(%rip), %rcx      # 0xb1f9
movl $0x1b5, %edx            # imm = 0x1B5
callq 0x20f0
leaq 0x41b9(%rip), %rdi      # 0xacc0
leaq 0x451a(%rip), %rsi      # 0xb028
leaq 0x46e4(%rip), %rcx      # 0xb1f9
movl $0x198, %edx            # imm = 0x198
callq 0x20f0
leaq 0x419a(%rip), %rdi      # 0xacc0
leaq 0x44fb(%rip), %rsi      # 0xb028
leaq 0x46c5(%rip), %rcx      # 0xb1f9
movl $0x19c, %edx            # imm = 0x19C
callq 0x20f0
leaq 0x417b(%rip), %rdi      # 0xacc0
leaq 0x44dc(%rip), %rsi      # 0xb028
leaq 0x46a6(%rip), %rcx      # 0xb1f9
movl $0x1a1, %edx            # imm = 0x1A1
callq 0x20f0
leaq 0x415c(%rip), %rdi      # 0xacc0
leaq 0x44bd(%rip), %rsi      # 0xb028
leaq 0x4687(%rip), %rcx      # 0xb1f9
movl $0x1a3, %edx            # imm = 0x1A3
callq 0x20f0
leaq 0x413d(%rip), %rdi      # 0xacc0
leaq 0x449e(%rip), %rsi      # 0xb028
leaq 0x4668(%rip), %rcx      # 0xb1f9
movl $0x1ad, %edx            # imm = 0x1AD
callq 0x20f0