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

  int iA,iB;
  DYN_STRING ret;

  if (dyn_init(&ret,500)==-1) {
    return NULL;
  }

  dyn_printf(&ret,"<</Type /Font\n"
                  "  /Subtype /%s\n"
                  "  /BaseFont /%s\n"
                  "  /FontDescriptor %d 0 R\n",
                  emb_pdf_get_font_subtype(emb),
                  emb_pdf_escape_name(fdes->fontname,-1),
                  fontdescr_obj_ref);

  if (emb->plan&EMB_A_MULTIBYTE) { // multibyte
    assert(fwid->warray);
    dyn_printf(&ret,"  /CIDSystemInfo <<\n"
                    "    /Registry (%s)\n"
                    "    /Ordering (%s)\n"
                    "    /Supplement %d\n"
                    "  >>\n"
                    "  /DW %d\n",
//                    "  /CIDToGIDMap /Id...\n" // TrueType only, default /Identity  [optional?  which PDF version says what?]
                    fdes->registry,
                    fdes->ordering,
                    fdes->supplement,
                    fwid->default_width);

    if (fwid->warray[0]) {
      dyn_printf(&ret,"  /W [");
      for (iA=0;fwid->warray[iA];) {
        if (fwid->warray[iA]<0) { // c1 (c1-len) w
          dyn_printf(&ret," %d %d %d",
                          fwid->warray[iA+1],
                          fwid->warray[iA+1]-fwid->warray[iA],
                          fwid->warray[iA+2]);
          iA+=3;
        } else { // c [w ... w]
          iB=fwid->warray[iA++]; // len
          dyn_printf(&ret," %d [",fwid->warray[iA++]); // c
          for (;iB>0;iB--) {
            dyn_printf(&ret," %d",fwid->warray[iA++]);
          }
          dyn_printf(&ret,"]");
        }
      }
      dyn_printf(&ret,"]\n");
    }
  } else { // "not std14"
    assert(fwid->widths);
    dyn_printf(&ret,
                    "  /Encoding /MacRomanEncoding\n"  // optional; TODO!!!!!
//                    "  /ToUnicode ?\n"  // optional
                    "  /FirstChar %d\n"
                    "  /LastChar %d\n"
                    "  /Widths [",
                    fwid->first,
                    fwid->last);
    for (iA=0,iB=fwid->first;iB<=fwid->last;iA++,iB++) {
      dyn_printf(&ret," %d",fwid->widths[iA]);
    }
    dyn_printf(&ret,"]\n");
  }
  dyn_printf(&ret,">>\n");
  if (ret.len==-1) {
    dyn_free(&ret);
    assert(0);
    return NULL;
  }

  return ret.buf;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x18, %rsp
testq %rdi, %rdi
je 0x770f
movq %rsi, %r14
testq %rsi, %rsi
je 0x772e
movq %rdx, %rbx
testq %rdx, %rdx
je 0x774d
movl %ecx, %ebp
movq %rdi, %r15
leaq 0x8(%rsp), %rdi
movl $0x1f4, %esi            # imm = 0x1F4
callq 0x79e0
cmpl $-0x1, %eax
je 0x75ca
movl 0x4(%r15), %eax
movl 0xc(%r15), %ecx
andl $0x1, %ecx
shlq $0x4, %rax
leaq 0x77b4(%rip), %rdx      # 0xece0
addq %rax, %rdx
movq (%rdx,%rcx,8), %r12
movq (%r14), %rdi
callq 0x73c6
leaq 0x3e40(%rip), %rsi      # 0xb382
leaq 0x7e67(%rip), %rcx      # 0xf3b0
leaq 0x8(%rsp), %rdi
movq %r12, %rdx
movl %ebp, %r8d
xorl %eax, %eax
callq 0x7c01
testb $0x1, 0xc(%r15)
jne 0x75d1
cmpq $0x0, 0x8(%rbx)
je 0x7795
movl (%rbx), %edx
movl 0x4(%rbx), %ecx
leaq 0x3edd(%rip), %rsi      # 0xb456
leaq 0x8(%rsp), %rdi
xorl %eax, %eax
callq 0x7c01
movl (%rbx), %r12d
cmpl 0x4(%rbx), %r12d
jg 0x76cd
decl %r12d
leaq 0x3ea3(%rip), %r14      # 0xb43f
leaq 0x8(%rsp), %r15
xorl %r13d, %r13d
movq 0x8(%rbx), %rax
movl (%rax,%r13,4), %edx
movq %r15, %rdi
movq %r14, %rsi
xorl %eax, %eax
callq 0x7c01
incq %r13
leal (%r12,%r13), %eax
cmpl 0x4(%rbx), %eax
jl 0x75a4
jmp 0x76cd
xorl %eax, %eax
jmp 0x7700
cmpq $0x0, 0x18(%rbx)
je 0x77b4
movq 0x40(%r14), %rdx
movq 0x48(%r14), %rcx
movl 0x50(%r14), %r8d
movl 0x10(%rbx), %r9d
leaq 0x3de3(%rip), %rsi      # 0xb3d6
leaq 0x8(%rsp), %rdi
xorl %eax, %eax
callq 0x7c01
movq 0x18(%rbx), %rax
cmpl $0x0, (%rax)
je 0x76e0
leaq 0x3e1f(%rip), %rsi      # 0xb432
leaq 0x8(%rsp), %rdi
xorl %eax, %eax
callq 0x7c01
movq 0x18(%rbx), %rax
movl (%rax), %r12d
testl %r12d, %r12d
je 0x76cd
leaq 0x8(%rsp), %r15
leaq 0x3e04(%rip), %r13      # 0xb43f
leaq 0x3034(%rip), %rbp      # 0xa676
xorl %r14d, %r14d
movl 0x4(%rax), %edx
testl %r12d, %r12d
js 0x7698
movq %r15, %rdi
leaq 0x3dec(%rip), %rsi      # 0xb443
xorl %eax, %eax
callq 0x7c01
addl $0x2, %r14d
movslq %r14d, %r14
incl %r12d
movq 0x18(%rbx), %rax
movl (%rax,%r14,4), %edx
incq %r14
movq %r15, %rdi
movq %r13, %rsi
xorl %eax, %eax
callq 0x7c01
decl %r12d
cmpl $0x1, %r12d
ja 0x7668
movq %r15, %rdi
movq %rbp, %rsi
xorl %eax, %eax
callq 0x7c01
jmp 0x76b6
movl %edx, %ecx
subl %r12d, %ecx
movl 0x8(%rax), %r8d
movq %r15, %rdi
leaq 0x3d8e(%rip), %rsi      # 0xb439
xorl %eax, %eax
callq 0x7c01
addl $0x3, %r14d
movq 0x18(%rbx), %rax
movslq %r14d, %rcx
leaq (%rax,%rcx,4), %rax
movl (%rax), %r12d
testl %r12d, %r12d
jne 0x7645
leaq 0x3e7d(%rip), %rsi      # 0xb551
leaq 0x8(%rsp), %rdi
xorl %eax, %eax
callq 0x7c01
leaq 0x3c3f(%rip), %rsi      # 0xb326
leaq 0x8(%rsp), %rbx
movq %rbx, %rdi
xorl %eax, %eax
callq 0x7c01
cmpl $-0x1, (%rbx)
je 0x776c
movq 0x10(%rsp), %rax
addq $0x18, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
leaq 0x2bbe(%rip), %rdi      # 0xa2d4
leaq 0x390b(%rip), %rsi      # 0xb028
leaq 0x3c06(%rip), %rcx      # 0xb32a
movl $0x1bd, %edx            # imm = 0x1BD
callq 0x20e0
leaq 0x29a6(%rip), %rdi      # 0xa0db
leaq 0x38ec(%rip), %rsi      # 0xb028
leaq 0x3be7(%rip), %rcx      # 0xb32a
movl $0x1be, %edx            # imm = 0x1BE
callq 0x20e0
leaq 0x298c(%rip), %rdi      # 0xa0e0
leaq 0x38cd(%rip), %rsi      # 0xb028
leaq 0x3bc8(%rip), %rcx      # 0xb32a
movl $0x1bf, %edx            # imm = 0x1BF
callq 0x20e0
leaq 0x8(%rsp), %rdi
callq 0x7a50
leaq 0x3543(%rip), %rdi      # 0xacc0
leaq 0x38a4(%rip), %rsi      # 0xb028
leaq 0x3b9f(%rip), %rcx      # 0xb32a
movl $0x204, %edx            # imm = 0x204
callq 0x20e0
leaq 0x3cad(%rip), %rdi      # 0xb449
leaq 0x3885(%rip), %rsi      # 0xb028
leaq 0x3b80(%rip), %rcx      # 0xb32a
movl $0x1f3, %edx            # imm = 0x1F3
callq 0x20e0
leaq 0x3c0e(%rip), %rdi      # 0xb3c9
leaq 0x3866(%rip), %rsi      # 0xb028
leaq 0x3b61(%rip), %rcx      # 0xb32a
movl $0x1d1, %edx            # imm = 0x1D1
callq 0x20e0