// File: /workspace/github_c_makefile_star2_O0/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
movq %rsp, %rbp
subq $0x50, %rsp
movq %rdi, -0x10(%rbp)
movq %rsi, -0x18(%rbp)
movq %rdx, -0x20(%rbp)
movl %ecx, -0x24(%rbp)
cmpq $0x0, -0x10(%rbp)
je 0x9620
jmp 0x963f
leaq 0x4cad(%rip), %rdi      # 0xe2d4
leaq 0x5a42(%rip), %rsi      # 0xf070
movl $0x1bd, %edx            # imm = 0x1BD
leaq 0x5d38(%rip), %rcx      # 0xf372
callq 0x2100
cmpq $0x0, -0x18(%rbp)
je 0x9648
jmp 0x9667
leaq 0x4a8c(%rip), %rdi      # 0xe0db
leaq 0x5a1a(%rip), %rsi      # 0xf070
movl $0x1be, %edx            # imm = 0x1BE
leaq 0x5d10(%rip), %rcx      # 0xf372
callq 0x2100
cmpq $0x0, -0x20(%rbp)
je 0x9670
jmp 0x968f
leaq 0x4a69(%rip), %rdi      # 0xe0e0
leaq 0x59f2(%rip), %rsi      # 0xf070
movl $0x1bf, %edx            # imm = 0x1BF
leaq 0x5ce8(%rip), %rcx      # 0xf372
callq 0x2100
leaq -0x40(%rbp), %rdi
movl $0x1f4, %esi            # imm = 0x1F4
callq 0x9d60
cmpl $-0x1, %eax
jne 0x96af
movq $0x0, -0x8(%rbp)
jmp 0x99c0
movq -0x10(%rbp), %rdi
callq 0x8240
movq %rax, -0x48(%rbp)
movq -0x18(%rbp), %rax
movq (%rax), %rdi
movl $0xffffffff, %esi       # imm = 0xFFFFFFFF
callq 0x9450
movq -0x48(%rbp), %rdx
movq %rax, %rcx
movl -0x24(%rbp), %r8d
leaq -0x40(%rbp), %rdi
leaq 0x5ce7(%rip), %rsi      # 0xf3ca
movb $0x0, %al
callq 0xa120
movq -0x10(%rbp), %rax
movl 0xc(%rax), %eax
andl $0x1, %eax
cmpl $0x0, %eax
je 0x98ca
movq -0x20(%rbp), %rax
cmpq $0x0, 0x18(%rax)
je 0x970a
jmp 0x9729
leaq 0x5d00(%rip), %rdi      # 0xf411
leaq 0x5958(%rip), %rsi      # 0xf070
movl $0x1d1, %edx            # imm = 0x1D1
leaq 0x5c4e(%rip), %rcx      # 0xf372
callq 0x2100
movq -0x18(%rbp), %rax
movq 0x40(%rax), %rdx
movq -0x18(%rbp), %rax
movq 0x48(%rax), %rcx
movq -0x18(%rbp), %rax
movl 0x50(%rax), %r8d
movq -0x20(%rbp), %rax
movl 0x10(%rax), %r9d
leaq -0x40(%rbp), %rdi
leaq 0x5cca(%rip), %rsi      # 0xf41e
movb $0x0, %al
callq 0xa120
movq -0x20(%rbp), %rax
movq 0x18(%rax), %rax
cmpl $0x0, (%rax)
je 0x98c5
leaq -0x40(%rbp), %rdi
leaq 0x5d03(%rip), %rsi      # 0xf47a
movb $0x0, %al
callq 0xa120
movl $0x0, -0x28(%rbp)
movq -0x20(%rbp), %rax
movq 0x18(%rax), %rax
movslq -0x28(%rbp), %rcx
cmpl $0x0, (%rax,%rcx,4)
je 0x98b3
movq -0x20(%rbp), %rax
movq 0x18(%rax), %rax
movslq -0x28(%rbp), %rcx
cmpl $0x0, (%rax,%rcx,4)
jge 0x9819
movq -0x20(%rbp), %rax
movq 0x18(%rax), %rax
movl -0x28(%rbp), %ecx
addl $0x1, %ecx
movslq %ecx, %rcx
movl (%rax,%rcx,4), %edx
movq -0x20(%rbp), %rax
movq 0x18(%rax), %rax
movl -0x28(%rbp), %ecx
addl $0x1, %ecx
movslq %ecx, %rcx
movl (%rax,%rcx,4), %ecx
movq -0x20(%rbp), %rax
movq 0x18(%rax), %rax
movslq -0x28(%rbp), %rsi
subl (%rax,%rsi,4), %ecx
movq -0x20(%rbp), %rax
movq 0x18(%rax), %rax
movl -0x28(%rbp), %esi
addl $0x2, %esi
movslq %esi, %rsi
movl (%rax,%rsi,4), %r8d
leaq -0x40(%rbp), %rdi
leaq 0x5c7d(%rip), %rsi      # 0xf481
movb $0x0, %al
callq 0xa120
movl -0x28(%rbp), %eax
addl $0x3, %eax
movl %eax, -0x28(%rbp)
jmp 0x98ae
movq -0x20(%rbp), %rax
movq 0x18(%rax), %rax
movl -0x28(%rbp), %ecx
movl %ecx, %edx
addl $0x1, %edx
movl %edx, -0x28(%rbp)
movslq %ecx, %rcx
movl (%rax,%rcx,4), %eax
movl %eax, -0x2c(%rbp)
movq -0x20(%rbp), %rax
movq 0x18(%rax), %rax
movl -0x28(%rbp), %ecx
movl %ecx, %edx
addl $0x1, %edx
movl %edx, -0x28(%rbp)
movslq %ecx, %rcx
movl (%rax,%rcx,4), %edx
leaq -0x40(%rbp), %rdi
leaq 0x5c32(%rip), %rsi      # 0xf48b
movb $0x0, %al
callq 0xa120
cmpl $0x0, -0x2c(%rbp)
jle 0x989c
movq -0x20(%rbp), %rax
movq 0x18(%rax), %rax
movl -0x28(%rbp), %ecx
movl %ecx, %edx
addl $0x1, %edx
movl %edx, -0x28(%rbp)
movslq %ecx, %rcx
movl (%rax,%rcx,4), %edx
leaq -0x40(%rbp), %rdi
leaq 0x5bfd(%rip), %rsi      # 0xf487
movb $0x0, %al
callq 0xa120
movl -0x2c(%rbp), %eax
addl $-0x1, %eax
movl %eax, -0x2c(%rbp)
jmp 0x9860
leaq -0x40(%rbp), %rdi
leaq 0x4dd2(%rip), %rsi      # 0xe679
movb $0x0, %al
callq 0xa120
jmp 0x9785
leaq -0x40(%rbp), %rdi
leaq 0x5cdb(%rip), %rsi      # 0xf599
movb $0x0, %al
callq 0xa120
jmp 0x9978
movq -0x20(%rbp), %rax
cmpq $0x0, 0x8(%rax)
je 0x98d7
jmp 0x98f6
leaq 0x5bb3(%rip), %rdi      # 0xf491
leaq 0x578b(%rip), %rsi      # 0xf070
movl $0x1f3, %edx            # imm = 0x1F3
leaq 0x5a81(%rip), %rcx      # 0xf372
callq 0x2100
movq -0x20(%rbp), %rax
movl (%rax), %edx
movq -0x20(%rbp), %rax
movl 0x4(%rax), %ecx
leaq -0x40(%rbp), %rdi
leaq 0x5b90(%rip), %rsi      # 0xf49e
movb $0x0, %al
callq 0xa120
movl $0x0, -0x28(%rbp)
movq -0x20(%rbp), %rax
movl (%rax), %eax
movl %eax, -0x2c(%rbp)
movl -0x2c(%rbp), %eax
movq -0x20(%rbp), %rcx
cmpl 0x4(%rcx), %eax
jg 0x9966
movq -0x20(%rbp), %rax
movq 0x8(%rax), %rax
movslq -0x28(%rbp), %rcx
movl (%rax,%rcx,4), %edx
leaq -0x40(%rbp), %rdi
leaq 0x5b3c(%rip), %rsi      # 0xf487
movb $0x0, %al
callq 0xa120
movl -0x28(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x28(%rbp)
movl -0x2c(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x2c(%rbp)
jmp 0x9925
leaq -0x40(%rbp), %rdi
leaq 0x5c28(%rip), %rsi      # 0xf599
movb $0x0, %al
callq 0xa120
leaq -0x40(%rbp), %rdi
leaq 0x59eb(%rip), %rsi      # 0xf36e
movb $0x0, %al
callq 0xa120
cmpl $-0x1, -0x40(%rbp)
jne 0x99b8
leaq -0x40(%rbp), %rdi
callq 0x9e50
leaq 0x5360(%rip), %rdi      # 0xed00
leaq 0x56c9(%rip), %rsi      # 0xf070
movl $0x204, %edx            # imm = 0x204
leaq 0x59bf(%rip), %rcx      # 0xf372
callq 0x2100
movq -0x38(%rbp), %rax
movq %rax, -0x8(%rbp)
movq -0x8(%rbp), %rax
addq $0x50, %rsp
popq %rbp
retq
nopw (%rax,%rax)