// File: /workspace/github_c_makefile_star2_O0/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
movq %rsp, %rbp
subq $0x60, %rsp
movl $0x0, -0x4(%rbp)
movl %edi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
movl $0x0, -0x18(%rbp)
movl $0x0, -0x1c(%rbp)
movq $0x0, -0x28(%rbp)
movl -0x8(%rbp), %edi
movq -0x10(%rbp), %rsi
leaq 0x3cea(%rip), %rdx      # 0x5004
callq 0x1060
movl %eax, -0x14(%rbp)
cmpl $-0x1, %eax
je 0x136f
movl -0x14(%rbp), %eax
movl %eax, -0x4c(%rbp)
subl $0x68, %eax
je 0x1364
jmp 0x1334
movl -0x4c(%rbp), %eax
subl $0x74, %eax
jne 0x1366
jmp 0x133e
movq 0x6c83(%rip), %rax      # 0x7fc8
movq (%rax), %rdi
callq 0x1530
movl %eax, -0x1c(%rbp)
cmpl $0x0, -0x1c(%rbp)
jne 0x1362
movl $0x3, -0x4(%rbp)
jmp 0x1523
jmp 0x136d
jmp 0x1366
movl $0x1, -0x18(%rbp)
jmp 0x130c
movq 0x6c6a(%rip), %rax      # 0x7fe0
movl (%rax), %eax
addl $0x1, %eax
cmpl -0x8(%rbp), %eax
jne 0x1398
movq -0x10(%rbp), %rax
movq 0x6c55(%rip), %rcx      # 0x7fe0
movslq (%rcx), %rcx
movq (%rax,%rcx,8), %rax
movq %rax, -0x28(%rbp)
jmp 0x13b7
movq 0x6c39(%rip), %rax      # 0x7fd8
movq (%rax), %rdi
leaq 0x3c5f(%rip), %rsi      # 0x5008
movb $0x0, %al
callq 0x1180
movl $0x1, -0x18(%rbp)
cmpl $0x0, -0x18(%rbp)
je 0x13e8
movq 0x6c14(%rip), %rax      # 0x7fd8
movq (%rax), %rdi
movq -0x10(%rbp), %rax
movq (%rax), %rdx
leaq 0x3c4d(%rip), %rsi      # 0x5022
movb $0x0, %al
callq 0x1180
movl $0x1, -0x4(%rbp)
jmp 0x1523
movq -0x28(%rbp), %rdi
callq 0x26f0
movq %rax, -0x30(%rbp)
cmpq $0x0, -0x30(%rbp)
jne 0x1420
movq 0x6bd5(%rip), %rax      # 0x7fd8
movq (%rax), %rdi
leaq 0x3c52(%rip), %rsi      # 0x505f
movb $0x0, %al
callq 0x1180
movl $0x2, -0x4(%rbp)
jmp 0x1523
movq -0x30(%rbp), %rdi
callq 0x4270
movq %rax, -0x38(%rbp)
cmpq $0x0, -0x38(%rbp)
jne 0x146f
movq 0x6b9d(%rip), %rax      # 0x7fd8
movq (%rax), %rax
movq %rax, -0x58(%rbp)
callq 0x1030
movl (%rax), %edi
callq 0x1080
movq -0x58(%rbp), %rdi
movq %rax, %rdx
leaq 0x3c23(%rip), %rsi      # 0x507f
movb $0x0, %al
callq 0x1180
movl $0x2, -0x4(%rbp)
jmp 0x1523
cmpl $0x0, -0x1c(%rbp)
je 0x150a
movq -0x30(%rbp), %rdi
movl -0x1c(%rbp), %esi
leaq -0x3c(%rbp), %rdx
callq 0x2960
movq %rax, -0x48(%rbp)
cmpq $0x0, -0x48(%rbp)
jne 0x14b5
movq 0x6b3d(%rip), %rax      # 0x7fd8
movq (%rax), %rdi
leaq 0x3be9(%rip), %rsi      # 0x508e
movb $0x0, %al
callq 0x1180
movl $0x3, -0x4(%rbp)
jmp 0x1523
movq 0x6afc(%rip), %rax      # 0x7fb8
movq (%rax), %rdi
callq 0x1110
movl %eax, %edi
callq 0x11b0
cmpl $0x0, %eax
je 0x14e3
movl -0x3c(%rbp), %esi
leaq 0x3bd1(%rip), %rdi      # 0x50ab
movb $0x0, %al
callq 0x1040
jmp 0x14ff
movq -0x48(%rbp), %rdi
movslq -0x3c(%rbp), %rdx
movq 0x6ac6(%rip), %rax      # 0x7fb8
movq (%rax), %rcx
movl $0x1, %esi
callq 0x11d0
movq -0x48(%rbp), %rdi
callq 0x1150
jmp 0x1513
movq -0x30(%rbp), %rdi
callq 0x15d0
movq -0x38(%rbp), %rdi
callq 0x4340
movl $0x0, -0x4(%rbp)
movl -0x4(%rbp), %eax
addq $0x60, %rsp
popq %rbp
retq
nopl (%rax)