// File: /workspace/github_c_makefile_star2_O1/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 0x1a90
movl $0x1, %ecx
cmpl $0x74, %eax
jne 0x1a16
movq (%r12), %r12
testq %r12, %r12
je 0x1c5b
movq %r12, %rdi
callq 0x10a0
cmpq $0x4, %rax
jne 0x1a87
movzbl (%r12), %eax
shll $0x18, %eax
movsbl 0x1(%r12), %ecx
shll $0x10, %ecx
orl %eax, %ecx
movsbl 0x2(%r12), %eax
shll $0x8, %eax
movsbl 0x3(%r12), %ebp
orl %eax, %ebp
orl %ecx, %ebp
movq 0x554a(%rip), %r12      # 0x6fc8
testl %ebp, %ebp
jne 0x1a13
jmp 0x1c48
callq 0x11e0
xorl %ebp, %ebp
jmp 0x1a77
movq 0x5549(%rip), %rax      # 0x6fe0
movslq (%rax), %rax
leal 0x1(%rax), %ecx
cmpl %r14d, %ecx
jne 0x1c18
movq (%rbx,%rax,8), %rdi
testl %r13d, %r13d
sete %al
testb %al, %al
je 0x1c26
callq 0x2517
testq %rax, %rax
je 0x1c35
movq %rax, %r14
movq %rax, %rdi
callq 0x323c
testq %rax, %rax
je 0x1c3c
testl %ebp, %ebp
movq %rax, 0x10(%rsp)
je 0x1b36
leaq 0xc(%rsp), %rdx
movq %r14, %rdi
movl %ebp, %esi
callq 0x266d
movq %rax, %r14
testq %rax, %rax
je 0x1c4f
movq 0x54b3(%rip), %rbx      # 0x6fb8
movq (%rbx), %rdi
callq 0x1100
movl %eax, %edi
callq 0x11a0
movslq 0xc(%rsp), %rdx
testl %eax, %eax
je 0x1bde
leaq 0x2583(%rip), %rdi      # 0x40ab
movl %edx, %esi
xorl %eax, %eax
callq 0x1040
jmp 0x1bee
movzwl 0x38(%r14), %esi
leaq 0x25de(%rip), %rdi      # 0x4120
xorl %eax, %eax
callq 0x1040
cmpw $0x0, 0x38(%r14)
je 0x1bfd
movl $0x10, %r13d
movl $0xff, %ebp
leaq 0x25e8(%rip), %r15      # 0x414f
leaq 0x25c7(%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 0x1bb0
movl -0x8(%rax,%r13), %r10d
subq $0x8, %rsp
movq %r15, %rdi
xorl %eax, %eax
pushq %r10
jmp 0x1bc2
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 0x1b70
jmp 0x1bfd
movq (%rbx), %rcx
movl $0x1, %esi
movq %r14, %rdi
callq 0x11c0
movq %r14, %rdi
callq 0x1140
xorl %eax, %eax
testq %r14, %r14
je 0x1c09
movq 0x10(%rsp), %rdi
callq 0x32cc
xorl %eax, %eax
addq $0x18, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
callq 0x11fc
xorl %edi, %edi
xorl %eax, %eax
jmp 0x1ab0
movq %rbx, %rdi
callq 0x1218
movl $0x1, %eax
jmp 0x1c09
callq 0x1284
jmp 0x1c41
callq 0x1258
movl $0x2, %eax
jmp 0x1c09
movl $0x3, %eax
jmp 0x1c09
callq 0x1236
movl $0x3, %eax
jmp 0x1bf8
leaq 0x245d(%rip), %rdi      # 0x40bf
leaq 0x245b(%rip), %rsi      # 0x40c4
leaq 0x245f(%rip), %rcx      # 0x40cf
movl $0xc, %edx
callq 0x10d0
nop