// File: /workspace/github_c_makefile_star2_O1/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 %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
cmpl $0x2, %edi
jne 0x2060
movq 0x8(%rsi), %rdi
jmp 0x2067
leaq 0x6f9d(%rip), %rdi      # 0x9004
callq 0x2bc3
testq %rax, %rax
je 0x22aa
movq %rax, %rdi
callq 0x67ec
movq %rax, %rdi
movl $0x1, %esi
movl $0x8000, %edx           # imm = 0x8000
callq 0x38e8
movq %rax, %rbx
leaq 0x6fc4(%rip), %rdi      # 0x905d
leaq 0x6fc5(%rip), %rsi      # 0x9065
callq 0x1180
testq %rax, %rax
je 0x22c9
movq %rax, %r14
leaq 0x6faf(%rip), %rsi      # 0x9067
movq %rax, %rdi
xorl %eax, %eax
callq 0x11c0
movq 0x10(%rbx), %rax
movq (%rax), %rdi
movl $0x61, %esi
callq 0x3728
movq 0x20(%rbx), %rdx
testq %rdx, %rdx
je 0x20f5
testb $0x1, 0xc(%rbx)
je 0x20f5
movzwl %ax, %esi
movl $0x1, %edi
movl %eax, %ecx
shll %cl, %edi
shrq $0x5, %rsi
orl %edi, (%rdx,%rsi,4)
movb $0x48, %al
movl $0x1, %r15d
leaq 0x6f74(%rip), %r12      # 0x9078
movzbl %al, %esi
movq 0x10(%rbx), %rax
movq (%rax), %rdi
callq 0x3728
movq 0x20(%rbx), %rdx
testq %rdx, %rdx
je 0x2135
testb $0x1, 0xc(%rbx)
je 0x2135
movzwl %ax, %esi
movl $0x1, %edi
movl %eax, %ecx
shll %cl, %edi
shrq $0x5, %rsi
orl %edi, (%rdx,%rsi,4)
movb (%r15,%r12), %al
incq %r15
cmpq $0x6, %r15
jne 0x2104
leaq 0x1be(%rip), %rsi       # 0x2307
movq %rbx, %rdi
movq %r14, %rdx
callq 0x3b15
movq 0x10(%rbx), %rax
movq (%rax), %rdi
callq 0x3fb0
leaq 0x6f17(%rip), %rsi      # 0x907e
movq %r14, %rdi
movq %rax, %rdx
xorl %eax, %eax
callq 0x11c0
testq %rbx, %rbx
je 0x22e8
testb $0x1, 0xc(%rbx)
jne 0x21ec
movl $0x28, %edi
movq %r14, %rsi
callq 0x1250
movb $0x48, %al
movl $0x1, %r15d
movzbl %al, %esi
movq 0x10(%rbx), %rax
movq (%rax), %rdi
callq 0x3728
movq 0x20(%rbx), %rdx
testq %rdx, %rdx
je 0x21c9
testb $0x1, 0xc(%rbx)
je 0x21c9
movzwl %ax, %esi
movl $0x1, %edi
movl %eax, %ecx
shll %cl, %edi
shrq $0x5, %rsi
orl %edi, (%rdx,%rsi,4)
movb (%r15,%r12), %al
incq %r15
cmpq $0x6, %r15
jne 0x2198
leaq 0x6e9b(%rip), %rdi      # 0x9078
movq %r14, %rsi
callq 0x1170
movl $0x29, %edi
jmp 0x225c
movl $0x3c, %edi
movq %r14, %rsi
callq 0x1250
movb $0x48, %al
movl $0x1, %r13d
leaq 0x6f3e(%rip), %r15      # 0x9146
movzbl %al, %esi
movq 0x10(%rbx), %rax
movq (%rax), %rdi
callq 0x3728
movq 0x20(%rbx), %rsi
movzwl %ax, %edx
testq %rsi, %rsi
je 0x223c
testb $0x1, 0xc(%rbx)
je 0x223c
movl $0x1, %eax
movl %edx, %ecx
shll %cl, %eax
movq %rdx, %rcx
shrq $0x5, %rcx
orl %eax, (%rsi,%rcx,4)
movq %r14, %rdi
movq %r15, %rsi
xorl %eax, %eax
callq 0x11c0
movb (%r13,%r12), %al
incq %r13
cmpq $0x6, %r13
jne 0x2208
movl $0x3e, %edi
movq %r14, %rsi
callq 0x1250
leaq 0x6e49(%rip), %rdi      # 0x90b4
movl $0xf, %esi
movl $0x1, %edx
movq %r14, %rcx
callq 0x1260
leaq 0x6e40(%rip), %rsi      # 0x90c4
movq %r14, %rdi
xorl %eax, %eax
callq 0x11c0
movq %r14, %rdi
callq 0x1120
movq %rbx, %rdi
callq 0x3aea
xorl %eax, %eax
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
retq
leaq 0x6d87(%rip), %rdi      # 0x9038
leaq 0x6d84(%rip), %rsi      # 0x903c
leaq 0x6d87(%rip), %rcx      # 0x9046
movl $0x37, %edx
callq 0x10d0
leaq 0x7b64(%rip), %rdi      # 0x9e34
leaq 0x6d65(%rip), %rsi      # 0x903c
leaq 0x6d68(%rip), %rcx      # 0x9046
movl $0x3f, %edx
callq 0x10d0
leaq 0x6e53(%rip), %rdi      # 0x9142
leaq 0x6d46(%rip), %rsi      # 0x903c
leaq 0x6e0f(%rip), %rcx      # 0x910c
movl $0x1b, %edx
callq 0x10d0