// File: /workspace/github_c_makefile_star2_O1/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 0x7323
movq %rsi, %r12
testq %rsi, %rsi
je 0x7342
movl %edx, %ebx
movq %rdi, %r14
movl $0x12c, %edi            # imm = 0x12C
callq 0x21c0
testq %rax, %rax
je 0x7319
movq %rax, %rbp
movq %r14, 0x20(%rsp)
movl %ebx, 0x14(%rsp)
movq (%r12), %rdi
callq 0x7459
movl 0x8(%r12), %r8d
movl 0x1c(%r12), %r9d
leaq 0x4131(%rip), %rdx      # 0xb240
leaq 0x829a(%rip), %rcx      # 0xf3b0
movl $0x12c, %esi            # imm = 0x12C
movq %rbp, %rdi
xorl %eax, %eax
callq 0x2210
cmpl $0x12c, %eax            # imm = 0x12C
jae 0x7361
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 0x4111(%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 0x7380
movl %eax, %eax
addq %rax, %rbp
movl 0x30(%r12), %ecx
testl %ecx, %ecx
movq %rbp, %r13
je 0x71db
movslq %r15d, %rsi
leaq 0x4125(%rip), %rdx      # 0xb2d9
movq %r13, %rdi
xorl %eax, %eax
callq 0x2210
testl %eax, %eax
movq 0x8(%rsp), %r14
js 0x73be
subl %eax, %r15d
jle 0x73be
movl %eax, %eax
addq %rax, %r13
jmp 0x71e0
movq 0x8(%rsp), %r14
movl 0x34(%r12), %ecx
testl %ecx, %ecx
je 0x7213
movslq %r15d, %rsi
leaq 0x40f5(%rip), %rdx      # 0xb2e8
movq %r13, %rdi
xorl %eax, %eax
callq 0x2210
testl %eax, %eax
js 0x73dd
subl %eax, %r15d
jle 0x73dd
movl %eax, %eax
addq %rax, %r13
cmpq $0x0, 0x38(%r12)
je 0x72ca
movslq %r15d, %rsi
leaq 0x40cf(%rip), %rdx      # 0xb2f8
movq %r13, %rdi
xorl %eax, %eax
callq 0x2210
testl %eax, %eax
js 0x73fc
subl %eax, %r15d
jle 0x73fc
cmpl $0x1e, %r15d
jl 0x741b
movl %eax, %eax
addq %rax, %r13
leaq 0x40b4(%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 0x7264
addl $-0x18, %r15d
movq 0x18(%rsp), %r13
addq $0x18, %r13
leaq 0x4071(%rip), %rdx      # 0xb313
movq %r13, %rdi
movq %r15, %rsi
xorl %eax, %eax
callq 0x2210
testl %eax, %eax
js 0x743a
subl %eax, %r15d
jle 0x743a
movl %eax, %eax
addq %rax, %r13
movq 0x8(%rsp), %r14
movslq %r15d, %rsi
movq 0x20(%rsp), %rax
movl 0x4(%rax), %eax
leaq 0x7a54(%rip), %rcx      # 0xed30
movq (%rcx,%rax,8), %rcx
leaq 0x4032(%rip), %rdx      # 0xb319
movq %r13, %rdi
movl 0x14(%rsp), %r8d
xorl %eax, %eax
callq 0x2210
testl %eax, %eax
js 0x739f
cmpl %r15d, %eax
jge 0x739f
movq %r14, %rax
addq $0x28, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
callq 0x2ccf
xorl %r14d, %r14d
jmp 0x7307
leaq 0x2faa(%rip), %rdi      # 0xa2d4
leaq 0x3cf7(%rip), %rsi      # 0xb028
leaq 0x3ec1(%rip), %rcx      # 0xb1f9
movl $0x171, %edx            # imm = 0x171
callq 0x20e0
leaq 0x2d92(%rip), %rdi      # 0xa0db
leaq 0x3cd8(%rip), %rsi      # 0xb028
leaq 0x3ea2(%rip), %rcx      # 0xb1f9
movl $0x172, %edx            # imm = 0x172
callq 0x20e0
leaq 0x3958(%rip), %rdi      # 0xacc0
leaq 0x3cb9(%rip), %rsi      # 0xb028
leaq 0x3e83(%rip), %rcx      # 0xb1f9
movl $0x186, %edx            # imm = 0x186
callq 0x20e0
leaq 0x3939(%rip), %rdi      # 0xacc0
leaq 0x3c9a(%rip), %rsi      # 0xb028
leaq 0x3e64(%rip), %rcx      # 0xb1f9
movl $0x194, %edx            # imm = 0x194
callq 0x20e0
leaq 0x391a(%rip), %rdi      # 0xacc0
leaq 0x3c7b(%rip), %rsi      # 0xb028
leaq 0x3e45(%rip), %rcx      # 0xb1f9
movl $0x1b5, %edx            # imm = 0x1B5
callq 0x20e0
leaq 0x38fb(%rip), %rdi      # 0xacc0
leaq 0x3c5c(%rip), %rsi      # 0xb028
leaq 0x3e26(%rip), %rcx      # 0xb1f9
movl $0x198, %edx            # imm = 0x198
callq 0x20e0
leaq 0x38dc(%rip), %rdi      # 0xacc0
leaq 0x3c3d(%rip), %rsi      # 0xb028
leaq 0x3e07(%rip), %rcx      # 0xb1f9
movl $0x19c, %edx            # imm = 0x19C
callq 0x20e0
leaq 0x38bd(%rip), %rdi      # 0xacc0
leaq 0x3c1e(%rip), %rsi      # 0xb028
leaq 0x3de8(%rip), %rcx      # 0xb1f9
movl $0x1a1, %edx            # imm = 0x1A1
callq 0x20e0
leaq 0x389e(%rip), %rdi      # 0xacc0
leaq 0x3bff(%rip), %rsi      # 0xb028
leaq 0x3dc9(%rip), %rcx      # 0xb1f9
movl $0x1a3, %edx            # imm = 0x1A3
callq 0x20e0
leaq 0x387f(%rip), %rdi      # 0xacc0
leaq 0x3be0(%rip), %rsi      # 0xb028
leaq 0x3daa(%rip), %rcx      # 0xb1f9
movl $0x1ad, %edx            # imm = 0x1AD
callq 0x20e0