// File: /workspace/github_c_makefile_star2_O0/smilingthax[P]libfontembed/woffer.c
// Function: main
int main(int argc,char **argv)
{
  int opt;
  int usage=0;
  const char *fontfile=NULL;
  const char *woffout=NULL,*sfntout=NULL;

  BITSET subset=NULL;
  const char *subsetstr=NULL;

  while ((opt=getopt(argc, argv, "hw:t:s:"))!=-1) {
    switch (opt) {
    case 'w':
      woffout=optarg;
      break;
    case 't':
      sfntout=optarg;
      break;
    case 's':
      subsetstr=optarg;
      break;
    case 'h':
    default:
      usage=1;
      break;
    }
  }
  if (optind+1==argc) {
    fontfile=argv[optind];
  } else {
    fprintf(stderr,"Error: Expected fontfile\n");
    usage=1;
  }
  if ( (woffout)&&(sfntout) ) {
    fprintf(stderr,"Error: Only one of -w and -t may be given\n");
    usage=1;
  }

  if (usage) {
    fprintf(stderr,"\nUsage: %s infile [-w|-t] outfile\n"
                   "  -h: Help\n"
                   "  -w wofffile: Output as WOFF (compressed) to file\n"
                   "  -t sfntfile: Output as SFNT (uncompressed) to file\n"
                   "  -s [subset-ranges]: e.g. U+0-0d,U+5fa4,U+23??\n",  // TODO? ,'asdf'
                   argv[0]);
    return 1;
  }

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

  if (subsetstr) {
    subset=parse_ranges(otf,subsetstr);
    if (!subset) {
      fprintf(stderr,"Error: Bad subset range\n");
      return 2;
    }
  }

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

  FILE *f=NULL;
  struct _OTF_WRITE_WOFF woff={0,0},*woffptr=NULL; // version; no metaData, no privData
  if (woffout) {
    f=fopen(woffout,"wb");
    woffptr=&woff;
  } else if (sfntout) {
    f=fopen(sfntout,"wb");
  } else {
    // NO-OP: no output file given
    fprintf(stderr,"Nothing to do\n");
    fontfile_close(ff);
    free(subset);
    return 3;
  }
  if (!f) {
    fprintf(stderr,"Error: Could not open output fontfile\n");
    fontfile_close(ff);
    free(subset);
    return 2;
  }

  int res;
  if (subset) {
    if (is_CFF(otf)) {
      fprintf(stderr,"Note: Glyph subsetting not implemented yet for CFF-type files\n");
      res=otf_subset_cff2(otf,subset,SUBSET_DST_BROWSER,woffptr,file_outfn,f);
    } else {
      res=otf_subset2(otf,subset,SUBSET_DST_BROWSER,woffptr,file_outfn,f);
    }
  } else {
    res=otf_copy_sfnt(otf,woffptr,file_outfn,f);
  }

  fclose(f);
  fontfile_close(ff);
  free(subset);

  if (res<0) {
    return 4;
  }
  return 0;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0xb0, %rsp
movl $0x0, -0x4(%rbp)
movl %edi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
movl $0x0, -0x18(%rbp)
movq $0x0, -0x20(%rbp)
movq $0x0, -0x28(%rbp)
movq $0x0, -0x30(%rbp)
movq $0x0, -0x38(%rbp)
movq $0x0, -0x40(%rbp)
movl -0x8(%rbp), %edi
movq -0x10(%rbp), %rsi
leaq 0x6d0e(%rip), %rdx      # 0x8044
callq 0x1050
movl %eax, -0x14(%rbp)
cmpl $-0x1, %eax
je 0x13ac
movl -0x14(%rbp), %eax
addl $-0x68, %eax
movl %eax, %ecx
movq %rcx, -0xa0(%rbp)
subl $0xf, %eax
ja 0x13a0
movq -0xa0(%rbp), %rax
leaq 0x6c9f(%rip), %rcx      # 0x8004
movslq (%rcx,%rax,4), %rax
addq %rcx, %rax
jmpq *%rax
movq 0x9c53(%rip), %rax      # 0xafc8
movq (%rax), %rax
movq %rax, -0x28(%rbp)
jmp 0x13a7
movq 0x9c43(%rip), %rax      # 0xafc8
movq (%rax), %rax
movq %rax, -0x30(%rbp)
jmp 0x13a7
movq 0x9c33(%rip), %rax      # 0xafc8
movq (%rax), %rax
movq %rax, -0x40(%rbp)
jmp 0x13a7
jmp 0x13a0
movl $0x1, -0x18(%rbp)
jmp 0x1328
movq 0x9c2d(%rip), %rax      # 0xafe0
movl (%rax), %eax
addl $0x1, %eax
cmpl -0x8(%rbp), %eax
jne 0x13d5
movq -0x10(%rbp), %rax
movq 0x9c18(%rip), %rcx      # 0xafe0
movslq (%rcx), %rcx
movq (%rax,%rcx,8), %rax
movq %rax, -0x20(%rbp)
jmp 0x13f4
movq 0x9bfc(%rip), %rax      # 0xafd8
movq (%rax), %rdi
leaq 0x6c66(%rip), %rsi      # 0x804c
movb $0x0, %al
callq 0x1170
movl $0x1, -0x18(%rbp)
cmpq $0x0, -0x28(%rbp)
je 0x1421
cmpq $0x0, -0x30(%rbp)
je 0x1421
movq 0x9bcf(%rip), %rax      # 0xafd8
movq (%rax), %rdi
leaq 0x6c53(%rip), %rsi      # 0x8066
movb $0x0, %al
callq 0x1170
movl $0x1, -0x18(%rbp)
cmpl $0x0, -0x18(%rbp)
je 0x1452
movq 0x9baa(%rip), %rax      # 0xafd8
movq (%rax), %rdi
movq -0x10(%rbp), %rax
movq (%rax), %rdx
leaq 0x6c52(%rip), %rsi      # 0x8091
movb $0x0, %al
callq 0x1170
movl $0x1, -0x4(%rbp)
jmp 0x16ea
movq -0x20(%rbp), %rdi
callq 0x2b50
movq %rax, -0x48(%rbp)
cmpq $0x0, -0x48(%rbp)
jne 0x148a
movq 0x9b6b(%rip), %rax      # 0xafd8
movq (%rax), %rdi
leaq 0x6ce0(%rip), %rsi      # 0x8157
movb $0x0, %al
callq 0x1170
movl $0x2, -0x4(%rbp)
jmp 0x16ea
cmpq $0x0, -0x40(%rbp)
je 0x14cf
movq -0x48(%rbp), %rdi
movq -0x40(%rbp), %rsi
callq 0x1700
movq %rax, -0x38(%rbp)
cmpq $0x0, -0x38(%rbp)
jne 0x14cd
movq 0x9b28(%rip), %rax      # 0xafd8
movq (%rax), %rdi
leaq 0x6cbd(%rip), %rsi      # 0x8177
movb $0x0, %al
callq 0x1170
movl $0x2, -0x4(%rbp)
jmp 0x16ea
jmp 0x14cf
movq -0x48(%rbp), %rdi
callq 0x7370
movq %rax, -0x50(%rbp)
cmpq $0x0, -0x50(%rbp)
jne 0x152d
movq 0x9aee(%rip), %rax      # 0xafd8
movq (%rax), %rax
movq %rax, -0xa8(%rbp)
callq 0x1030
movl (%rax), %edi
callq 0x1070
movq -0xa8(%rbp), %rdi
movq %rax, %rdx
leaq 0x6c7f(%rip), %rsi      # 0x8190
movb $0x0, %al
callq 0x1170
movq -0x38(%rbp), %rdi
callq 0x1140
movl $0x2, -0x4(%rbp)
jmp 0x16ea
movq $0x0, -0x58(%rbp)
leaq -0x88(%rbp), %rdi
xorl %esi, %esi
movl $0x30, %edx
callq 0x10c0
movq $0x0, -0x90(%rbp)
cmpq $0x0, -0x28(%rbp)
je 0x157e
movq -0x28(%rbp), %rdi
leaq 0x6c3a(%rip), %rsi      # 0x819f
callq 0x1130
movq %rax, -0x58(%rbp)
leaq -0x88(%rbp), %rax
movq %rax, -0x90(%rbp)
jmp 0x15d3
cmpq $0x0, -0x30(%rbp)
je 0x159b
movq -0x30(%rbp), %rdi
leaq 0x6c0f(%rip), %rsi      # 0x819f
callq 0x1130
movq %rax, -0x58(%rbp)
jmp 0x15d1
movq 0x9a36(%rip), %rax      # 0xafd8
movq (%rax), %rdi
leaq 0x6bf6(%rip), %rsi      # 0x81a2
movb $0x0, %al
callq 0x1170
movq -0x50(%rbp), %rdi
callq 0x7440
movq -0x38(%rbp), %rdi
callq 0x1140
movl $0x3, -0x4(%rbp)
jmp 0x16ea
jmp 0x15d3
cmpq $0x0, -0x58(%rbp)
jne 0x1610
movq 0x99f7(%rip), %rax      # 0xafd8
movq (%rax), %rdi
leaq 0x6bc6(%rip), %rsi      # 0x81b1
movb $0x0, %al
callq 0x1170
movq -0x50(%rbp), %rdi
callq 0x7440
movq -0x38(%rbp), %rdi
callq 0x1140
movl $0x2, -0x4(%rbp)
jmp 0x16ea
cmpq $0x0, -0x38(%rbp)
je 0x1695
movq -0x48(%rbp), %rdi
callq 0x1900
cmpl $0x0, %eax
je 0x1669
movq 0x99ac(%rip), %rax      # 0xafd8
movq (%rax), %rdi
leaq 0x6ba2(%rip), %rsi      # 0x81d8
movb $0x0, %al
callq 0x1170
movq -0x48(%rbp), %rdi
movq -0x38(%rbp), %rsi
movq -0x90(%rbp), %rcx
movq -0x58(%rbp), %r9
movl $0x1, %edx
leaq 0x2d4(%rip), %r8        # 0x1930
callq 0x56d0
movl %eax, -0x94(%rbp)
jmp 0x1693
movq -0x48(%rbp), %rdi
movq -0x38(%rbp), %rsi
movq -0x90(%rbp), %rcx
movq -0x58(%rbp), %r9
movl $0x1, %edx
leaq 0x2a8(%rip), %r8        # 0x1930
callq 0x4b10
movl %eax, -0x94(%rbp)
jmp 0x16b6
movq -0x48(%rbp), %rdi
movq -0x90(%rbp), %rsi
movq -0x58(%rbp), %rcx
leaq 0x285(%rip), %rdx       # 0x1930
callq 0x46d0
movl %eax, -0x94(%rbp)
movq -0x58(%rbp), %rdi
callq 0x1100
movq -0x50(%rbp), %rdi
callq 0x7440
movq -0x38(%rbp), %rdi
callq 0x1140
cmpl $0x0, -0x94(%rbp)
jge 0x16e3
movl $0x4, -0x4(%rbp)
jmp 0x16ea
movl $0x0, -0x4(%rbp)
movl -0x4(%rbp), %eax
addq $0xb0, %rsp
popq %rbp
retq
nopw %cs:(%rax,%rax)