// File: /workspace/github_c_makefile_star2_O3/smilingthax[P]libfontembed/font_get.c
// Function: main
int main(int argc,char **argv)
{
  int opt;
  int usage=0;
  unsigned int tag=0;
  const char *fontfile=NULL;

  while ((opt=getopt(argc, argv, "ht:"))!=-1) {
    switch (opt) {
    case 't':
      tag=parse_tag(optarg);
      if (!tag) {
        return 3;
      }
      break;
    case 'h':
    default:
      usage=1;
      break;
    }
  }
  if (optind+1==argc) {
    fontfile=argv[optind];
  } else {
    fprintf(stderr,"Error: Expected fontfile\n");
    usage=1;
  }

  if (usage) {
    fprintf(stderr,"\nUsage: %s fontfile\n"
                   "  -h: Help\n"
                   "  -t [table tag]: Dump table\n",
                   argv[0]);
    return 1;
  }

  OTF_FILE *otf=otf_load(fontfile);
  if (!otf) {
    fprintf(stderr,"Error: Could not load fontfile\n");
    return 2;
  }

  FONTFILE *ff=fontfile_open_sfnt(otf);
  if (!ff) {
    fprintf(stderr,"Bad alloc: %s\n", strerror(errno));
    return 2;
  }

  if (tag) {
    int len;
    char *data=otf_get_table(otf,tag,&len);
    if (!data) {
      fprintf(stderr,"Error: Could not find table\n");
      return 3;
    }
    if (isatty(fileno(stdout))) {
      printf("Table has %d bytes\n",len);
    } else {
      fwrite(data,1,len,stdout);
    }
    free(data);
  } else {
    list_tables(otf);
  }

  fontfile_close(ff);

  return 0;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x18, %rsp
movq %rsi, %rbx
movl %edi, %r14d
xorl %ebp, %ebp
leaq 0x25fb(%rip), %r15      # 0x4004
movq 0x55b8(%rip), %r12      # 0x6fc8
xorl %r13d, %r13d
movl %r13d, %ecx
movl %ecx, %r13d
movl %r14d, %edi
movq %rbx, %rsi
movq %r15, %rdx
callq 0x1060
cmpl $-0x1, %eax
je 0x1a89
movl $0x1, %ecx
cmpl $0x74, %eax
jne 0x1a16
movq (%r12), %r12
testq %r12, %r12
je 0x1c44
movq %r12, %rdi
callq 0x10a0
cmpq $0x4, %rax
jne 0x1c3d
movzbl (%r12), %eax
shll $0x18, %eax
movsbl 0x1(%r12), %ecx
shll $0x10, %ecx
orl %eax, %ecx
movsbl 0x2(%r12), %eax
shll $0x8, %eax
orl %ecx, %eax
movsbl 0x3(%r12), %ebp
orl %eax, %ebp
movq 0x5546(%rip), %r12      # 0x6fc8
jne 0x1a13
jmp 0x1c36
movq 0x5550(%rip), %rax      # 0x6fe0
movslq (%rax), %rax
leal 0x1(%rax), %ecx
cmpl %r14d, %ecx
jne 0x1c05
testl %r13d, %r13d
jne 0x1c0a
movq (%rbx,%rax,8), %rdi
callq 0x2512
testq %rax, %rax
je 0x1c19
movq %rax, %r14
movq %rax, %rdi
callq 0x31f4
testq %rax, %rax
je 0x1c20
testl %ebp, %ebp
movq %rax, 0x10(%rsp)
je 0x1b2a
leaq 0xc(%rsp), %rdx
movq %r14, %rdi
movl %ebp, %esi
callq 0x2648
testq %rax, %rax
je 0x1c2c
movq %rax, %r14
movq 0x54bf(%rip), %rbx      # 0x6fb8
movq (%rbx), %rdi
callq 0x1100
movl %eax, %edi
callq 0x11a0
movslq 0xc(%rsp), %rdx
testl %eax, %eax
je 0x1bd2
leaq 0x258f(%rip), %rdi      # 0x40ab
movl %edx, %esi
xorl %eax, %eax
callq 0x1040
jmp 0x1be2
movzwl 0x38(%r14), %esi
leaq 0x25ea(%rip), %rdi      # 0x4120
xorl %eax, %eax
callq 0x1040
cmpw $0x0, 0x38(%r14)
je 0x1bea
movl $0x10, %r13d
movl $0xff, %ebp
leaq 0x25f4(%rip), %r15      # 0x414f
leaq 0x25d3(%rip), %r12      # 0x4135
xorl %ebx, %ebx
movq 0x40(%r14), %rax
movl -0x10(%rax,%r13), %r8d
movl -0x4(%rax,%r13), %r9d
movl %r8d, %esi
shrl $0x18, %esi
movl %r8d, %edx
shrl $0x10, %edx
andl %ebp, %edx
movl %r8d, %ecx
shrl $0x8, %ecx
andl %ebp, %ecx
andl %ebp, %r8d
testb $-0x80, 0x9(%r14)
jne 0x1ba4
movl -0x8(%rax,%r13), %r10d
subq $0x8, %rsp
movq %r15, %rdi
xorl %eax, %eax
pushq %r10
jmp 0x1bb6
movl -0x8(%rax,%r13), %r10d
movl (%rax,%r13), %r11d
movq %r12, %rdi
xorl %eax, %eax
pushq %r10
pushq %r11
callq 0x1040
addq $0x10, %rsp
incq %rbx
movzwl 0x38(%r14), %eax
addq $0x14, %r13
cmpq %rax, %rbx
jb 0x1b64
jmp 0x1bea
movq (%rbx), %rcx
movl $0x1, %esi
movq %r14, %rdi
callq 0x11c0
movq %r14, %rdi
callq 0x1140
movq 0x10(%rsp), %rdi
callq 0x3284
xorl %eax, %eax
addq $0x18, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
callq 0x11fc
movq %rbx, %rdi
callq 0x1218
movl $0x1, %eax
jmp 0x1bf6
callq 0x1284
jmp 0x1c25
callq 0x1258
movl $0x2, %eax
jmp 0x1bf6
leaq 0xc(%rsp), %rdi
callq 0x1236
movl $0x3, %eax
jmp 0x1bf6
callq 0x11e0
jmp 0x1c36
leaq 0x2474(%rip), %rdi      # 0x40bf
leaq 0x2472(%rip), %rsi      # 0x40c4
leaq 0x2476(%rip), %rcx      # 0x40cf
movl $0xc, %edx
callq 0x10d0
nop