// File: /workspace/github_c_makefile_star2_O3/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 0x2bae
testq %rax, %rax
je 0x22a1
movq %rax, %rdi
callq 0x6730
movq %rax, %rdi
movl $0x1, %esi
movl $0x8000, %edx           # imm = 0x8000
callq 0x3890
movq %rax, %rbx
leaq 0x6fc4(%rip), %rdi      # 0x905d
leaq 0x6fc5(%rip), %rsi      # 0x9065
callq 0x1180
testq %rax, %rax
je 0x22c0
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 0x36d0
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 0x36d0
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 0x196(%rip), %rsi       # 0x22df
movq %rbx, %rdi
movq %r14, %rdx
callq 0x3acb
movq 0x10(%rbx), %rax
movq (%rax), %rdi
callq 0x3f60
leaq 0x6f17(%rip), %rsi      # 0x907e
movq %r14, %rdi
movq %rax, %rdx
xorl %eax, %eax
callq 0x11c0
testb $0x1, 0xc(%rbx)
jne 0x21e3
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 0x36d0
movq 0x20(%rbx), %rdx
testq %rdx, %rdx
je 0x21c0
testb $0x1, 0xc(%rbx)
je 0x21c0
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 0x218f
leaq 0x6ea4(%rip), %rdi      # 0x9078
movq %r14, %rsi
callq 0x1170
movl $0x29, %edi
jmp 0x2253
movl $0x3c, %edi
movq %r14, %rsi
callq 0x1250
movb $0x48, %al
movl $0x1, %r13d
leaq 0x6f0d(%rip), %r15      # 0x910c
movzbl %al, %esi
movq 0x10(%rbx), %rax
movq (%rax), %rdi
callq 0x36d0
movq 0x20(%rbx), %rsi
movzwl %ax, %edx
testq %rsi, %rsi
je 0x2233
testb $0x1, 0xc(%rbx)
je 0x2233
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 0x21ff
movl $0x3e, %edi
movq %r14, %rsi
callq 0x1250
leaq 0x6e52(%rip), %rdi      # 0x90b4
movl $0xf, %esi
movl $0x1, %edx
movq %r14, %rcx
callq 0x1260
leaq 0x6e49(%rip), %rsi      # 0x90c4
movq %r14, %rdi
xorl %eax, %eax
callq 0x11c0
movq %r14, %rdi
callq 0x1120
movq %rbx, %rdi
callq 0x3aa0
xorl %eax, %eax
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
retq
leaq 0x6d90(%rip), %rdi      # 0x9038
leaq 0x6d8d(%rip), %rsi      # 0x903c
leaq 0x6d90(%rip), %rcx      # 0x9046
movl $0x37, %edx
callq 0x10d0
leaq 0x7b3d(%rip), %rdi      # 0x9e04
leaq 0x6d6e(%rip), %rsi      # 0x903c
leaq 0x6d71(%rip), %rcx      # 0x9046
movl $0x3f, %edx
callq 0x10d0