// File: /workspace/github_c_makefile_star2_O2/c-zhou[P]yahs/agp_to_fasta.c
// Function: main
int main(int argc, char *argv[])
{
    if (argc < 2) {
        print_help(stderr);
        return 1;
    }

    liftrlimit();
    af_realtime0 = realtime();

    FILE *fo;
    char *fa, *agp, *out;
    int line_wd, allow_unknown_oris;

    const char *opt_str = "o:ul:Vh";
    ketopt_t opt = KETOPT_INIT;
    int c;
    FILE *fp_help = stderr;
    fa = agp = out = 0;
    line_wd = 60;
    allow_unknown_oris = 0;

    while ((c = ketopt(&opt, argc, argv, 1, opt_str, long_options)) >= 0) {
        if (c == 'l') {
            line_wd = atoi(opt.arg);
        } else if (c == 'u') {
            allow_unknown_oris = 1;
        } else if (c == 'o') {
            out = opt.arg;
        } else if (c == 'h') {
            fp_help = stdout;
        } else if (c == 'V') {
            puts(AF_VERSION);
            return 0;
        } else if (c == '?') {
            fprintf(stderr, "[E::%s] unknown option: \"%s\"\n", __func__, argv[opt.i - 1]);
            return 1;
        } else if (c == ':') {
            fprintf(stderr, "[E::%s] missing option: \"%s\"\n", __func__, argv[opt.i - 1]);
            return 1;
        }
    }

    if (fp_help == stdout) {
        print_help(stdout);
        return 0;
    }

    if (argc - opt.ind < 2) {
        fprintf(stderr, "[E::%s] missing input: two positional options required\n", __func__);
        print_help(stderr);
        return 1;
    }

    agp = argv[opt.ind];
    fa = argv[opt.ind + 1];

    fo = out == 0? stdout : fopen(out, "w");
    if (fo == 0) {
        fprintf(stderr, "[E::%s] cannot open file %s for writing\n", __func__, out);
        exit(EXIT_FAILURE);
    }
    
    write_fasta_file_from_agp(fa, agp, fo, line_wd, allow_unknown_oris);

    if (out != 0)
        fclose(fo);

    fprintf(stderr, "[I::%s] Version: %s\n", __func__, AF_VERSION);
    fprintf(stderr, "[I::%s] CMD:", __func__);
    int i;
    for (i = 0; i < argc; ++i)
        fprintf(stderr, " %s", argv[i]);
    fprintf(stderr, "\n[I::%s] Real time: %.3f sec; CPU: %.3f sec; Peak RSS: %.3f GB\n", __func__, realtime() - af_realtime0, cputime(), peakrss() / 1024.0 / 1024.0 / 1024.0);
 
    return 0;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x88, %rsp
cmpl $0x1, %edi
jg 0x7d21
movq 0x52df(%rip), %rax      # 0xcff0
movq (%rax), %rdi
callq 0x839e
pushq $0x1
popq %rax
jmp 0x815b
movl %edi, %ebx
movq %rsi, 0x28(%rsp)
pushq $0x1
popq %r14
xorl %eax, %eax
callq 0x254f
callq 0x25a7
movsd %xmm0, 0x5608(%rip)     # 0xd348
movq 0x52a9(%rip), %rax      # 0xcff0
movq (%rax), %rax
movq %rax, 0x78(%rsp)
movl %ebx, %ebp
movq %rbx, 0x80(%rsp)
leal -0x1(%rbx), %eax
movl %eax, 0x50(%rsp)
pushq $0x3c
popq %rax
movl %eax, 0x4c(%rsp)
movq $0x0, 0x30(%rsp)
movq $0x0, 0x18(%rsp)
xorl %ebx, %ebx
movl %r14d, %r13d
movl $0x0, 0x48(%rsp)
movq %rbp, 0x58(%rsp)
movl %ebx, %r12d
movq %r13, 0x38(%rsp)
movslq %r13d, %rax
movq %rax, %r15
shlq $0x20, %r15
movq 0x28(%rsp), %rcx
leaq (%rcx,%rax,8), %rcx
xorl %r14d, %r14d
movq %rax, %r13
movabsq $0x100000000, %rsi      # imm = 0x100000000
leaq (%rax,%r14), %rdx
cmpq %rbp, %rdx
jge 0x8136
movq (%rcx,%r14,8), %rdx
cmpb $0x2d, (%rdx)
jne 0x7dd2
cmpb $0x0, 0x1(%rdx)
jne 0x7ddd
incq %r13
incq %r14
addq %rsi, %r15
jmp 0x7db6
sarq $0x1d, %r15
movq 0x28(%rsp), %rax
movq (%rax,%r15), %rcx
cmpb $0x2d, (%rcx)
jne 0x82ea
movl 0x38(%rsp), %ebp
addq %r14, %rbp
movl 0x18(%rsp), %eax
addq %r14, %rax
movq %rax, 0x40(%rsp)
movzbl 0x1(%rcx), %eax
cmpl $0x2d, %eax
je 0x7e6e
testl %eax, %eax
je 0x8140
cmpl $0x1, %r12d
adcl $0x0, %r12d
movslq %r12d, %rbx
movq %rcx, %r13
movsbl (%rcx,%rbx), %esi
incq %rbx
leaq 0x1edd(%rip), %rdi      # 0x9d10
movl %esi, 0x10(%rsp)
pushq $0x8
popq %rdx
callq 0x21b0
pushq $0x3f
popq %rcx
testq %rax, %rax
je 0x7fbd
cmpb $0x3a, 0x1(%rax)
jne 0x7fb9
cmpb $0x0, (%r13,%rbx)
je 0x8013
addq %rbx, %r13
movq %r13, 0x20(%rsp)
jmp 0x7fd0
movb 0x2(%rcx), %dl
testb %dl, %dl
je 0x8308
leaq 0x2(%rcx), %rax
movq %rax, 0x10(%rsp)
addq $0x3, %rcx
xorl %r15d, %r15d
testb %dl, %dl
je 0x7e9f
movzbl %dl, %eax
cmpl $0x3d, %eax
je 0x7e9f
movb (%rcx), %dl
incq %rcx
addq %rsi, %r15
jmp 0x7e89
movb %dl, 0xf(%rsp)
movq %rcx, 0x20(%rsp)
sarq $0x20, %r15
movq $0x0, 0x60(%rsp)
leaq 0x4ed4(%rip), %r12      # 0xcd90
movl $0x0, 0x54(%rsp)
movq $0x0, 0x68(%rsp)
movq $0x0, 0x70(%rsp)
movq (%r12), %rbx
testq %rbx, %rbx
je 0x7f1c
movq 0x10(%rsp), %rdi
movq %rbx, %rsi
movq %r15, %rdx
callq 0x2090
testl %eax, %eax
jne 0x7f16
cmpb $0x0, (%rbx,%r15)
je 0x7f05
incl 0x54(%rsp)
movq %r12, 0x70(%rsp)
jmp 0x7f16
movq 0x60(%rsp), %rax
incl %eax
movq %rax, 0x60(%rsp)
movq %r12, 0x68(%rsp)
addq $0x10, %r12
jmp 0x7ed6
movq 0x60(%rsp), %rdx
cmpl $0x1, %edx
movq 0x28(%rsp), %r12
jg 0x834c
testl %edx, %edx
sete %al
movl 0x54(%rsp), %esi
cmpl $0x2, %esi
setge %cl
andb %al, %cl
cmpb $0x1, %cl
je 0x8344
cmpl $0x1, %esi
movl $0x0, %eax
movq 0x70(%rsp), %rcx
cmovneq %rax, %rcx
cmpl $0x1, %edx
cmoveq 0x68(%rsp), %rcx
testq %rcx, %rcx
je 0x7fac
movl 0xc(%rcx), %eax
movl %eax, 0x10(%rsp)
movb 0xf(%rsp), %al
cmpb $0x3d, %al
je 0x8034
testb %al, %al
jne 0x7ff9
cmpl $0x1, 0x8(%rcx)
jne 0x7ff9
cmpl %ebp, 0x50(%rsp)
jle 0x8022
movq 0x38(%rsp), %rax
leal (%rax,%r14), %r15d
incl %r15d
movslq %r15d, %rax
movq (%r12,%rax,8), %rax
movq %rax, 0x20(%rsp)
jmp 0x8037
movq $0x0, 0x20(%rsp)
pushq $0x3f
jmp 0x802d
movl 0x10(%rsp), %ecx
cmpl $-0x2, %r12d
jg 0x7fda
movq $0x0, 0x20(%rsp)
movl %ecx, 0x10(%rsp)
movl %ebp, %r15d
movq 0x28(%rsp), %r12
jmp 0x8037
movq 0x28(%rsp), %r12
movq (%r12,%r15), %rax
movl %ebx, %edx
cmpb $0x0, (%rax,%rdx)
je 0x8004
movl %ebp, %r13d
movq $0x0, 0x20(%rsp)
jmp 0x8060
movq $0x0, 0x20(%rsp)
jmp 0x8034
movq $0x0, 0x20(%rsp)
movl %ecx, 0x10(%rsp)
jmp 0x8034
cmpl %ebp, 0x50(%rsp)
movq 0x28(%rsp), %r12
jg 0x7f8f
movq $0x0, 0x20(%rsp)
pushq $0x3a
popq %r13
movl %r13d, 0x10(%rsp)
movl %ebp, %r15d
leal 0x1(%r15), %r13d
xorl %ebx, %ebx
cmpl $0x0, 0x40(%rsp)
jle 0x805c
cmpl %r15d, %ebp
jg 0x805c
movq %r12, %rdi
movl %ebp, %esi
movq 0x40(%rsp), %rdx
callq 0x842e
incl %ebp
jmp 0x8044
movl 0x10(%rsp), %ecx
testl %ecx, %ecx
js 0x82f2
cmpl $0x56, %ecx
je 0x82f7
cmpl $0x68, %ecx
je 0x80bb
cmpl $0x6c, %ecx
movq 0x4f70(%rip), %rax      # 0xcff0
movq 0x58(%rsp), %rbp
je 0x80fd
cmpl $0x6f, %ecx
movq 0x28(%rsp), %r12
je 0x80e1
cmpl $0x75, %ecx
je 0x811d
cmpl $0x3a, %ecx
je 0x8330
cmpl $0x3f, %ecx
je 0x834c
movq 0x40(%rsp), %rax
movq %rax, 0x18(%rsp)
jmp 0x7d8b
movq 0x4f0e(%rip), %rax      # 0xcfd0
movq (%rax), %rax
movq %rax, 0x78(%rsp)
movq 0x18(%rsp), %rax
addl %r14d, %eax
movq %rax, 0x18(%rsp)
movq 0x58(%rsp), %rbp
jmp 0x7d8b
movq 0x18(%rsp), %rax
addl %r14d, %eax
movq %rax, 0x18(%rsp)
movq 0x20(%rsp), %rax
movq %rax, 0x30(%rsp)
jmp 0x7d8b
movq 0x20(%rsp), %rdi
callq 0x2340
movl %eax, 0x4c(%rsp)
movq 0x18(%rsp), %rax
addl %r14d, %eax
movq %rax, 0x18(%rsp)
jmp 0x7d8b
movq 0x18(%rsp), %rax
addl %r14d, %eax
movq %rax, 0x18(%rsp)
pushq $0x1
popq %rax
movl %eax, 0x48(%rsp)
jmp 0x7d8b
cmpq %rbp, %rax
cmovleq %rbp, %rax
movl %eax, %r13d
movq 0x4e89(%rip), %rax      # 0xcfd0
movq (%rax), %rbx
cmpq %rbx, 0x78(%rsp)
jne 0x816d
movq %rbx, %rdi
callq 0x839e
xorl %eax, %eax
addq $0x88, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq 0x80(%rsp), %rax
movq 0x18(%rsp), %rcx
addl %ecx, %eax
subl %r13d, %eax
addl %r14d, %eax
cmpl $0x1, %eax
jg 0x81ae
movq 0x4e62(%rip), %rbx      # 0xcff0
movq (%rbx), %rdi
leaq 0x1bc7(%rip), %rsi      # 0x9d5f
leaq 0x1b9d(%rip), %rdx      # 0x9d3c
xorl %eax, %eax
callq 0x2200
movq (%rbx), %rdi
jmp 0x7d14
movslq %r13d, %rax
movslq %ecx, %rcx
subq %rcx, %rax
subq %r14, %rax
movq 0x28(%rsp), %rcx
movq (%rcx,%rax,8), %r15
movq 0x8(%rcx,%rax,8), %r12
cmpq $0x0, 0x30(%rsp)
movq 0x4e1b(%rip), %r13      # 0xcff0
je 0x81eb
leaq 0xe32(%rip), %rsi       # 0x9010
movq 0x30(%rsp), %rdi
callq 0x22c0
movq %rax, %rbx
testq %rbx, %rbx
movq 0x58(%rsp), %rbp
je 0x8378
movq %r12, %rdi
movq %r15, %rsi
movq %rbx, %rdx
movl 0x4c(%rsp), %ecx
movl 0x48(%rsp), %r8d
callq 0x72b4
cmpq $0x0, 0x30(%rsp)
je 0x8220
movq %rbx, %rdi
callq 0x2100
movq (%r13), %rdi
leaq 0x1b95(%rip), %rsi      # 0x9dc0
leaq 0x1b0a(%rip), %rbx      # 0x9d3c
leaq 0x1adf(%rip), %rcx      # 0x9d18
movq %rbx, %rdx
xorl %eax, %eax
callq 0x2200
movq (%r13), %rdi
leaq 0x1b87(%rip), %rsi      # 0x9dd5
movq %rbx, %rdx
xorl %eax, %eax
callq 0x2200
leaq 0x11be(%rip), %r15      # 0x941d
xorl %ebx, %ebx
movq 0x28(%rsp), %r12
movq (%r13), %r14
cmpq %rbx, %rbp
je 0x8285
movq (%r12,%rbx,8), %rdx
movq %r14, %rdi
movq %r15, %rsi
xorl %eax, %eax
callq 0x2200
incq %rbx
jmp 0x8266
callq 0x25a7
subsd 0x50b6(%rip), %xmm0     # 0xd348
movsd %xmm0, 0x40(%rsp)
callq 0x250c
movsd %xmm0, 0x10(%rsp)
callq 0x2581
cvtsi2sd %rax, %xmm2
movsd 0x1a53(%rip), %xmm0     # 0x9d08
mulsd %xmm0, %xmm2
mulsd %xmm0, %xmm2
mulsd %xmm0, %xmm2
leaq 0x1b1a(%rip), %rsi      # 0x9de2
leaq 0x1a6d(%rip), %rdx      # 0x9d3c
movq %r14, %rdi
movsd 0x40(%rsp), %xmm0
movsd 0x10(%rsp), %xmm1
movb $0x3, %al
callq 0x2200
jmp 0x8159
movq 0x38(%rsp), %r13
addl %r14d, %r13d
jmp 0x8140
leaq 0x1a1a(%rip), %rdi      # 0x9d18
callq 0x20a0
jmp 0x8159
movq 0x18(%rsp), %rax
leal (%rax,%r14), %edx
movq 0x38(%rsp), %rbx
leal (%rbx,%r14), %esi
movq 0x28(%rsp), %rdi
callq 0x842e
leal (%rbx,%r14), %r13d
incl %r13d
jmp 0x8140
movq (%rax), %rdi
movslq %r13d, %rax
movq -0x8(%r12,%rax,8), %rcx
leaq 0x19ff(%rip), %rsi      # 0x9d41
jmp 0x8365
movq 0x38(%rsp), %r13
addl %r14d, %r13d
movq 0x4c9d(%rip), %rax      # 0xcff0
movq (%rax), %rdi
movslq %r13d, %rax
movq -0x8(%r12,%rax,8), %rcx
leaq 0x19b9(%rip), %rsi      # 0x9d1e
leaq 0x19d0(%rip), %rdx      # 0x9d3c
xorl %eax, %eax
callq 0x2200
jmp 0x7d19
movq (%r13), %rdi
leaq 0x1a14(%rip), %rsi      # 0x9d97
leaq 0x19b2(%rip), %rdx      # 0x9d3c
movq 0x30(%rsp), %rcx
xorl %eax, %eax
callq 0x2200
pushq $0x1
popq %rdi
callq 0x2360