// File: /workspace/github_c_makefile_star2_O3/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 0x7290
movq %rsi, %r12
testq %rsi, %rsi
je 0x72af
movl %edx, %ebx
movq %rdi, %r14
movl $0x12c, %edi            # imm = 0x12C
callq 0x21c0
movq %rax, %rbp
testq %rax, %rax
je 0x7289
movq %r14, 0x20(%rsp)
movl %ebx, 0x14(%rsp)
movq (%r12), %rdi
callq 0x73c6
movl 0x8(%r12), %r8d
movl 0x1c(%r12), %r9d
leaq 0x41c1(%rip), %rdx      # 0xb240
leaq 0x832a(%rip), %rcx      # 0xf3b0
movl $0x12c, %esi            # imm = 0x12C
movq %rbp, %rdi
xorl %eax, %eax
callq 0x2210
cmpl $0x12c, %eax            # imm = 0x12C
jae 0x72ce
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 0x41a1(%rip), %rdx      # 0xb287
movq %rbp, %rdi
movq %r15, %rsi
xorl %eax, %eax
pushq %r13
pushq %r14
pushq %rbx
pushq %r11
pushq %r10
callq 0x2210
addq $0x30, %rsp
subl %eax, %r15d
jbe 0x72ed
movl %eax, %eax
addq %rax, %rbp
movl 0x30(%r12), %ecx
testl %ecx, %ecx
movq %rbp, %r13
je 0x714b
movslq %r15d, %rsi
leaq 0x41b5(%rip), %rdx      # 0xb2d9
movq %r13, %rdi
xorl %eax, %eax
callq 0x2210
testl %eax, %eax
movq 0x8(%rsp), %rbp
js 0x732b
subl %eax, %r15d
jle 0x732b
movl %eax, %eax
addq %rax, %r13
jmp 0x7150
movq 0x8(%rsp), %rbp
movl 0x34(%r12), %ecx
testl %ecx, %ecx
je 0x7183
movslq %r15d, %rsi
leaq 0x4185(%rip), %rdx      # 0xb2e8
movq %r13, %rdi
xorl %eax, %eax
callq 0x2210
testl %eax, %eax
js 0x734a
subl %eax, %r15d
jle 0x734a
movl %eax, %eax
addq %rax, %r13
cmpq $0x0, 0x38(%r12)
je 0x723a
movslq %r15d, %rsi
leaq 0x415f(%rip), %rdx      # 0xb2f8
movq %r13, %rdi
xorl %eax, %eax
callq 0x2210
testl %eax, %eax
js 0x7369
subl %eax, %r15d
jle 0x7369
cmpl $0x1e, %r15d
jl 0x7388
movl %eax, %eax
addq %rax, %r13
leaq 0x4144(%rip), %rbp      # 0xb30e
movl %r15d, %r14d
movq %r13, 0x18(%rsp)
xorl %ebx, %ebx
movl %r14d, %esi
movq 0x38(%r12), %rax
movsbl (%rax,%rbx), %ecx
movq %r13, %rdi
movq %rbp, %rdx
xorl %eax, %eax
callq 0x2210
incq %rbx
addq $0x2, %r13
addl $-0x2, %r14d
cmpq $0xc, %rbx
jne 0x71d4
addl $-0x18, %r15d
movq 0x18(%rsp), %r13
addq $0x18, %r13
leaq 0x4101(%rip), %rdx      # 0xb313
movq %r13, %rdi
movq %r15, %rsi
xorl %eax, %eax
callq 0x2210
testl %eax, %eax
js 0x73a7
subl %eax, %r15d
jle 0x73a7
movl %eax, %eax
addq %rax, %r13
movq 0x8(%rsp), %rbp
movslq %r15d, %rsi
movq 0x20(%rsp), %rax
movl 0x4(%rax), %eax
leaq 0x7ae4(%rip), %rcx      # 0xed30
movq (%rcx,%rax,8), %rcx
leaq 0x40c2(%rip), %rdx      # 0xb319
movq %r13, %rdi
movl 0x14(%rsp), %r8d
xorl %eax, %eax
callq 0x2210
testl %eax, %eax
js 0x730c
cmpl %r15d, %eax
jge 0x730c
movq %rbp, %rax
addq $0x28, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
callq 0x2cd7
jmp 0x7277
leaq 0x303d(%rip), %rdi      # 0xa2d4
leaq 0x3d8a(%rip), %rsi      # 0xb028
leaq 0x3f54(%rip), %rcx      # 0xb1f9
movl $0x171, %edx            # imm = 0x171
callq 0x20e0
leaq 0x2e25(%rip), %rdi      # 0xa0db
leaq 0x3d6b(%rip), %rsi      # 0xb028
leaq 0x3f35(%rip), %rcx      # 0xb1f9
movl $0x172, %edx            # imm = 0x172
callq 0x20e0
leaq 0x39eb(%rip), %rdi      # 0xacc0
leaq 0x3d4c(%rip), %rsi      # 0xb028
leaq 0x3f16(%rip), %rcx      # 0xb1f9
movl $0x186, %edx            # imm = 0x186
callq 0x20e0
leaq 0x39cc(%rip), %rdi      # 0xacc0
leaq 0x3d2d(%rip), %rsi      # 0xb028
leaq 0x3ef7(%rip), %rcx      # 0xb1f9
movl $0x194, %edx            # imm = 0x194
callq 0x20e0
leaq 0x39ad(%rip), %rdi      # 0xacc0
leaq 0x3d0e(%rip), %rsi      # 0xb028
leaq 0x3ed8(%rip), %rcx      # 0xb1f9
movl $0x1b5, %edx            # imm = 0x1B5
callq 0x20e0
leaq 0x398e(%rip), %rdi      # 0xacc0
leaq 0x3cef(%rip), %rsi      # 0xb028
leaq 0x3eb9(%rip), %rcx      # 0xb1f9
movl $0x198, %edx            # imm = 0x198
callq 0x20e0
leaq 0x396f(%rip), %rdi      # 0xacc0
leaq 0x3cd0(%rip), %rsi      # 0xb028
leaq 0x3e9a(%rip), %rcx      # 0xb1f9
movl $0x19c, %edx            # imm = 0x19C
callq 0x20e0
leaq 0x3950(%rip), %rdi      # 0xacc0
leaq 0x3cb1(%rip), %rsi      # 0xb028
leaq 0x3e7b(%rip), %rcx      # 0xb1f9
movl $0x1a1, %edx            # imm = 0x1A1
callq 0x20e0
leaq 0x3931(%rip), %rdi      # 0xacc0
leaq 0x3c92(%rip), %rsi      # 0xb028
leaq 0x3e5c(%rip), %rcx      # 0xb1f9
movl $0x1a3, %edx            # imm = 0x1A3
callq 0x20e0
leaq 0x3912(%rip), %rdi      # 0xacc0
leaq 0x3c73(%rip), %rsi      # 0xb028
leaq 0x3e3d(%rip), %rcx      # 0xb1f9
movl $0x1ad, %edx            # imm = 0x1AD
callq 0x20e0