// File: /workspace/github_c_makefile_star2_O0/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
movq %rsp, %rbp
subq $0x50, %rsp
movl $0x0, -0x4(%rbp)
movl %edi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
leaq 0xac87(%rip), %rax      # 0xc004
movq %rax, -0x18(%rbp)
cmpl $0x2, -0x8(%rbp)
jne 0x1393
movq -0x10(%rbp), %rax
movq 0x8(%rax), %rax
movq %rax, -0x18(%rbp)
movq -0x18(%rbp), %rdi
callq 0x26b0
movq %rax, -0x20(%rbp)
cmpq $0x0, -0x20(%rbp)
je 0x13a9
jmp 0x13c8
leaq 0xac88(%rip), %rdi      # 0xc038
leaq 0xac85(%rip), %rsi      # 0xc03c
movl $0x37, %edx
leaq 0xac83(%rip), %rcx      # 0xc046
callq 0x10f0
movq -0x20(%rbp), %rdi
callq 0x8ae0
movq %rax, -0x28(%rbp)
movq -0x28(%rbp), %rdi
movl $0x1, %esi
movl $0x8000, %edx           # imm = 0x8000
callq 0x4230
movq %rax, -0x30(%rbp)
leaq 0xac6a(%rip), %rdi      # 0xc05d
leaq 0xac6b(%rip), %rsi      # 0xc065
callq 0x1180
movq %rax, -0x38(%rbp)
cmpq $0x0, -0x38(%rbp)
je 0x140c
jmp 0x142b
leaq 0xba69(%rip), %rdi      # 0xce7c
leaq 0xac22(%rip), %rsi      # 0xc03c
movl $0x3f, %edx
leaq 0xac20(%rip), %rcx      # 0xc046
callq 0x10f0
movq -0x38(%rbp), %rdi
leaq 0xac31(%rip), %rsi      # 0xc067
movb $0x0, %al
callq 0x11c0
leaq 0xac34(%rip), %rax      # 0xc078
movq %rax, -0x40(%rbp)
movq -0x30(%rbp), %rdi
movl $0x61, %esi
callq 0x1520
movl $0x0, -0x44(%rbp)
movq -0x40(%rbp), %rax
movslq -0x44(%rbp), %rcx
cmpb $0x0, (%rax,%rcx)
je 0x148b
movq -0x30(%rbp), %rdi
movq -0x40(%rbp), %rax
movslq -0x44(%rbp), %rcx
movzbl (%rax,%rcx), %esi
callq 0x1520
movl -0x44(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x44(%rbp)
jmp 0x145d
movq -0x30(%rbp), %rdi
movq -0x38(%rbp), %rdx
leaq 0xc6(%rip), %rsi        # 0x1560
callq 0x4710
movq -0x38(%rbp), %rax
movq %rax, -0x50(%rbp)
movq -0x30(%rbp), %rax
movq 0x10(%rax), %rax
movq (%rax), %rdi
callq 0x4d90
movq -0x50(%rbp), %rdi
movq %rax, %rdx
leaq 0xabb9(%rip), %rsi      # 0xc07e
movb $0x0, %al
callq 0x11c0
movq -0x38(%rbp), %rdi
movq -0x30(%rbp), %rsi
leaq 0xab9d(%rip), %rdx      # 0xc078
callq 0x15e0
movq -0x38(%rbp), %rdi
leaq 0xabc9(%rip), %rsi      # 0xc0b4
movb $0x0, %al
callq 0x11c0
movq -0x38(%rbp), %rdi
leaq 0xabc7(%rip), %rsi      # 0xc0c4
movb $0x0, %al
callq 0x11c0
movq -0x38(%rbp), %rdi
callq 0x1140
movq -0x30(%rbp), %rdi
callq 0x4690
xorl %eax, %eax
addq $0x50, %rsp
popq %rbp
retq
nop