// File: /workspace/github_c_makefile_star2_O2/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 %r15d, %r15d
leaq 0x1d0a(%rip), %r12      # 0x3004
pushq $0x1
popq %rbp
xorl %r13d, %r13d
movl %r13d, %ecx
movl %ecx, %r13d
movl %r14d, %edi
movq %rbx, %rsi
movq %r12, %rdx
callq 0x1060
cmpl $-0x1, %eax
je 0x136f
movl %ebp, %ecx
cmpl $0x74, %eax
jne 0x1303
movq 0x4ca1(%rip), %rax      # 0x5fc8
movq (%rax), %r15
testq %r15, %r15
je 0x159b
movq %r15, %rdi
callq 0x10a0
cmpq $0x4, %rax
jne 0x1586
movzbl (%r15), %eax
shll $0x18, %eax
movsbl 0x1(%r15), %ecx
shll $0x10, %ecx
orl %eax, %ecx
movsbl 0x2(%r15), %eax
shll $0x8, %eax
orl %ecx, %eax
movsbl 0x3(%r15), %r15d
orl %eax, %r15d
jne 0x1300
jmp 0x1574
movq 0x4c6a(%rip), %rax      # 0x5fe0
movslq (%rax), %rax
leal 0x1(%rax), %ecx
cmpl %r14d, %ecx
jne 0x14d1
testl %r13d, %r13d
jne 0x14ed
movq (%rbx,%rax,8), %rdi
callq 0x202d
testq %rax, %rax
je 0x150c
movq %rax, %r14
movq %rax, %rdi
callq 0x2f18
testq %rax, %rax
je 0x152a
testl %r15d, %r15d
movq %rax, 0x10(%rsp)
je 0x1412
leaq 0xc(%rsp), %rdx
movq %r14, %rdi
movl %r15d, %esi
callq 0x21a4
testq %rax, %rax
je 0x1558
movq %rax, %r14
movq 0x4bd7(%rip), %rbx      # 0x5fb8
movq (%rbx), %rdi
callq 0x1110
movl %eax, %edi
callq 0x11b0
movslq 0xc(%rsp), %rdx
testl %eax, %eax
je 0x14aa
leaq 0x1ca7(%rip), %rdi      # 0x30ab
movl %edx, %esi
xorl %eax, %eax
callq 0x1040
jmp 0x14b8
movzwl 0x38(%r14), %esi
leaq 0x1d02(%rip), %rdi      # 0x3120
xorl %eax, %eax
callq 0x1040
pushq $0x10
popq %r13
movl $0xff, %ebp
leaq 0x1d1a(%rip), %r15      # 0x314f
leaq 0x1cf9(%rip), %r12      # 0x3135
xorl %ebx, %ebx
movzwl 0x38(%r14), %eax
cmpq %rax, %rbx
jae 0x14c0
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 0x1488
movl -0x8(%rax,%r13), %r10d
subq $0x8, %rsp
movq %r15, %rdi
xorl %eax, %eax
pushq %r10
jmp 0x149a
movl -0x8(%rax,%r13), %r10d
movl (%rax,%r13), %r11d
movq %r12, %rdi
xorl %eax, %eax
pushq %r10
pushq %r11
callq 0x1040
popq %rcx
popq %rdx
incq %rbx
addq $0x14, %r13
jmp 0x143e
movq (%rbx), %rcx
pushq $0x1
popq %rsi
movq %r14, %rdi
callq 0x11d0
movq %r14, %rdi
callq 0x1150
movq 0x10(%rsp), %rdi
callq 0x2f9c
xorl %eax, %eax
jmp 0x1577
movq 0x4b00(%rip), %rax      # 0x5fd8
movq (%rax), %rcx
leaq 0x1b26(%rip), %rdi      # 0x3008
pushq $0x19
popq %rsi
pushq $0x1
popq %rdx
callq 0x11d0
movq 0x4ae4(%rip), %rax      # 0x5fd8
movq (%rax), %rdi
movq (%rbx), %rdx
leaq 0x1b21(%rip), %rsi      # 0x3022
xorl %eax, %eax
callq 0x1180
pushq $0x1
jmp 0x1576
movq 0x4ac5(%rip), %rax      # 0x5fd8
movq (%rax), %rcx
leaq 0x1b42(%rip), %rdi      # 0x305f
pushq $0x1f
popq %rsi
pushq $0x1
popq %rdx
callq 0x11d0
jmp 0x1554
movq 0x4aa7(%rip), %rax      # 0x5fd8
movq (%rax), %rbx
callq 0x1030
movl (%rax), %edi
callq 0x1080
leaq 0x1b38(%rip), %rsi      # 0x307f
movq %rbx, %rdi
movq %rax, %rdx
xorl %eax, %eax
callq 0x1180
pushq $0x2
jmp 0x1576
movq 0x4a79(%rip), %rax      # 0x5fd8
movq (%rax), %rcx
leaq 0x1b25(%rip), %rdi      # 0x308e
pushq $0x1c
popq %rsi
pushq $0x1
popq %rdx
callq 0x11d0
pushq $0x3
popq %rax
addq $0x18, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq 0x4a4b(%rip), %rax      # 0x5fd8
movq (%rax), %rcx
leaq 0x1b5d(%rip), %rdi      # 0x30f4
pushq $0x2b
jmp 0x156b
leaq 0x1b1d(%rip), %rdi      # 0x30bf
leaq 0x1b1b(%rip), %rsi      # 0x30c4
leaq 0x1b1f(%rip), %rcx      # 0x30cf
pushq $0xc
popq %rdx
callq 0x10e0