// File: /workspace/github_c_makefile_star2_O2/smilingthax[P]libfontembed/test_ps.c
// Function: main
int main(int argc,char **argv)
{
  const char *fn=TESTFONT;
  if (argc==2) {
    fn=argv[1];
  }
  OTF_FILE *otf=otf_load(fn);
  assert(otf);
  FONTFILE *ff=fontfile_open_sfnt(otf);
  EMB_PARAMS *emb=emb_new(ff,
                          EMB_DEST_PS,
//                          EMB_C_FORCE_MULTIBYTE| // not yet...
                          EMB_C_TAKE_FONTFILE);

  FILE *f=fopen("test.ps","w");
  assert(f);

  fprintf(f,"%%!PS-Adobe-2.0\n");

  char *str="Hallo";

  emb_get(emb,'a');

  int iA;
  for (iA=0;str[iA];iA++) {
    emb_get(emb,(unsigned char)str[iA]);
  }

  emb_embed(emb,example_outfn,f);

  // content
  fprintf(f,"  100 100 moveto\n" // content
            "  /%s findfont 10 scalefont setfont\n",emb_otf_get_fontname(emb->font->sfnt));
  write_string(f,emb,"Hallo");
// Note that write_string sets subset bits, but it's too late
  fprintf(f," show\n"
            "showpage\n");

  fprintf(f,"%%%%EOF\n");
  fclose(f);

  emb_close(emb);

  return 0;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
pushq %rax
cmpl $0x2, %edi
jne 0x2392
movq 0x8(%rsi), %rdi
jmp 0x2399
leaq 0x6c6b(%rip), %rdi      # 0x9004
callq 0x304d
testq %rax, %rax
je 0x2521
movq %rax, %rdi
callq 0x6f8c
pushq $0x1
popq %rsi
movq %rax, %rdi
movl $0x8000, %edx           # imm = 0x8000
callq 0x3f38
movq %rax, %rbx
leaq 0x6c94(%rip), %rdi      # 0x905d
leaq 0x6c95(%rip), %rsi      # 0x9065
callq 0x2190
testq %rax, %rax
je 0x253a
movq %rax, %r14
leaq 0x6c7f(%rip), %rsi      # 0x9067
xorl %r15d, %r15d
movq %rax, %rdi
xorl %eax, %eax
callq 0x21d0
pushq $0x61
popq %rsi
movq %rbx, %rdi
callq 0x2557
leaq 0x6c71(%rip), %r12      # 0x9078
cmpq $0x5, %r15
je 0x241f
movzbl (%r15,%r12), %esi
movq %rbx, %rdi
callq 0x2557
incq %r15
jmp 0x2407
leaq 0x163(%rip), %rsi       # 0x2589
movq %rbx, %rdi
movq %r14, %rdx
callq 0x41f1
movq 0x10(%rbx), %rax
movq (%rax), %rdi
callq 0x4642
leaq 0x6c3a(%rip), %rsi      # 0x907e
movq %r14, %rdi
movq %rax, %rdx
xorl %eax, %eax
callq 0x21d0
testb $0x1, 0xc(%rbx)
jne 0x247d
pushq $0x28
popq %rdi
movq %r14, %rsi
callq 0x2260
xorl %r15d, %r15d
cmpq $0x5, %r15
je 0x24be
movzbl (%r15,%r12), %esi
movq %rbx, %rdi
callq 0x2557
incq %r15
jmp 0x2465
pushq $0x3c
popq %rdi
movq %r14, %rsi
callq 0x2260
pushq $0x3e
popq %rbp
leaq 0x6c7a(%rip), %r15      # 0x910c
xorl %r13d, %r13d
cmpq $0x5, %r13
je 0x24d0
movzbl (%r13,%r12), %esi
movq %rbx, %rdi
callq 0x2557
movzwl %ax, %edx
movq %r14, %rdi
movq %r15, %rsi
xorl %eax, %eax
callq 0x21d0
incq %r13
jmp 0x2495
leaq 0x6bb3(%rip), %rdi      # 0x9078
movq %r14, %rsi
callq 0x2180
pushq $0x29
popq %rbp
movl %ebp, %edi
movq %r14, %rsi
callq 0x2260
leaq 0x6bd3(%rip), %rdi      # 0x90b4
pushq $0xf
popq %rsi
pushq $0x1
popq %rdx
movq %r14, %rcx
callq 0x2270
leaq 0x6bce(%rip), %rsi      # 0x90c4
movq %r14, %rdi
xorl %eax, %eax
callq 0x21d0
movq %r14, %rdi
callq 0x2130
movq %rbx, %rdi
callq 0x41c6
xorl %eax, %eax
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
leaq 0x6b10(%rip), %rdi      # 0x9038
leaq 0x6b0d(%rip), %rsi      # 0x903c
leaq 0x6b10(%rip), %rcx      # 0x9046
pushq $0x37
jmp 0x2551
leaq 0x78c3(%rip), %rdi      # 0x9e04
leaq 0x6af4(%rip), %rsi      # 0x903c
leaq 0x6af7(%rip), %rcx      # 0x9046
pushq $0x3f
popq %rdx
callq 0x20e0