// File: /workspace/github_c_makefile_star2_O2/c-zhou[P]oatk/run_hmmannot.c
// Function: main
int main(int argc, char *argv[])
{
    const char *opt_str = "t:b:T:o:Vv:h";
    ketopt_t opt = KETOPT_INIT;
    int c, ret = 0;
    int n_threads, batch_size, n_file;
    FILE *fp_help, *out_fp;
    char *out, *nhmmdb, *tmpdir;
    char **file_in;

    sys_init();
    
    fp_help = stderr;
    out_fp = stdout;
    out = nhmmdb = tmpdir = 0;
    file_in = 0;
    n_file = 0;
    batch_size = 1000000;
    n_threads = 4;
    char *nhmmscan = "nhmmscan";

    while ((c = ketopt(&opt, argc, argv, 1, opt_str, long_options)) >=0 ) {
        if (c == 't') n_threads = atoi(opt.arg);
        else if (c == 'b') batch_size = atoi(opt.arg);
        else if (c == 'T') tmpdir = opt.arg;
        else if (c == 301) nhmmscan = opt.arg;
        else if (c == 'v') VERBOSE = atoi(opt.arg);
        else if (c == 'h') fp_help = stdout;
        else if (c == 'o') {
            if (strcmp(opt.arg, "-") != 0) {
                out = opt.arg;
            }
        }
        else if (c == 'V') {
            puts(HMMANNOTATION_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 (argc == opt.ind || fp_help == stdout) {
        fprintf(fp_help, "\n");
        fprintf(fp_help, "Usage: hmmannot [options] <hmmdb> <query>[.gfa|.fa|.fq][.gz] [...]\n");
        fprintf(fp_help, "Options:\n");
        fprintf(fp_help, "    -b INT           batch size [%d]\n", batch_size);
        fprintf(fp_help, "    -t INT           number threads [4]\n");
        fprintf(fp_help, "    -T STR           temporary directory [NULL]\n");
        fprintf(fp_help, "    -o FILE          output results to FILE [stdout]\n");
        fprintf(fp_help, "    --nhmmscan STR   nhmmscan executable path [%s]\n", nhmmscan);
        fprintf(fp_help, "    -v INT           verbose level [%d]\n", VERBOSE);
        fprintf(fp_help, "    --version        show version number\n");
        fprintf(fp_help, "\n");
        fprintf(fp_help, "Example: ./hmmannot -t 8 --nhmmscan /usr/bin/nhmmscan -o asm_annot.mito.txt angiosperm_mito.fam asm.gfa\n\n");
        return fp_help == stdout? 0 : 1;
    }

    if (argc - opt.ind < 1) {
        fprintf(stderr, "[E::%s] missing input: please specify the hmmdb file\n", __func__);
        return 1;
    } else {
        nhmmdb = argv[opt.ind];
        if (!is_file(nhmmdb)) {
            fprintf(stderr, "[E::%s] input database file does not exist: %s\n", __func__, nhmmdb);
            exit(EXIT_FAILURE);
        }
    }

    if (argc - opt.ind < 2) {
        fprintf(stderr, "[E::%s] missing input: please specify at least one query file\n", __func__);
        return 1;
    } else {
        file_in = argv + opt.ind + 1;
        n_file = argc - opt.ind - 1;
    }

    // check if nhmmscan executable is available
    check_executable(nhmmscan);

    if (out) out_fp = fopen(out, "w");

    ret = hmm_annotate(file_in, n_file, nhmmscan, nhmmdb, out_fp, batch_size, n_threads * 5, n_threads, tmpdir);

    if (out) fclose(out_fp);

    if (ret) {
        fprintf(stderr, "[E::%s] annotation failed\n", __func__);
        exit(EXIT_FAILURE);
    }

    if (fflush(stdout) == EOF) {
        fprintf(stderr, "[E::%s] failed to write the results\n", __func__);
        exit(EXIT_FAILURE);
    }

    if (VERBOSE >= 0) {
        fprintf(stderr, "[M::%s] Version: %s\n", __func__, HMMANNOTATION_VERSION);
        fprintf(stderr, "[M::%s] CMD:", __func__);
        int i;
        for (i = 0; i < argc; ++i)
            fprintf(stderr, " %s", argv[i]);
        fprintf(stderr, "\n[M::%s] Real time: %.3f sec; CPU: %.3f sec; Peak RSS: %.3f GB\n", __func__, realtime() - 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
movq %rsi, %rbx
movl %edi, %r15d
movabsq $0x100000000, %rbp      # imm = 0x100000000
callq 0x4d16
movq 0x6228(%rip), %rax      # 0x8ff0
movq (%rax), %r13
movq 0x61fe(%rip), %rax      # 0x8fd0
movq (%rax), %rax
movq %rax, 0x78(%rsp)
movslq %r15d, %rdi
leal -0x1(%rdi), %eax
movl %eax, 0x4c(%rsp)
leaq 0x3225(%rip), %rax      # 0x6010
movq %rax, 0x60(%rsp)
movl $0xf4240, 0x34(%rsp)    # imm = 0xF4240
pushq $0x4
popq %rax
movq %rax, 0x70(%rsp)
pushq $0x1
popq %rax
movq $0x0, 0x38(%rsp)
movl $0x0, 0x28(%rsp)
xorl %r8d, %r8d
movq $0x0, 0x68(%rsp)
movq %rdi, (%rsp)
movq %rbx, 0x18(%rsp)
movq %rax, 0x20(%rsp)
movslq %eax, %rcx
movq %rcx, %r12
shlq $0x20, %r12
leaq (%rbx,%rcx,8), %rdx
xorl %ebx, %ebx
movq %rcx, %rax
movq %r8, 0x80(%rsp)
leaq (%rcx,%rbx), %rsi
cmpq %rdi, %rsi
jge 0x31e7
movq (%rdx,%rbx,8), %rsi
cmpb $0x2d, (%rsi)
jne 0x2e65
cmpb $0x0, 0x1(%rsi)
jne 0x2e70
incq %rax
incq %rbx
addq %rbp, %r12
jmp 0x2e49
sarq $0x1d, %r12
movq 0x18(%rsp), %rcx
movq (%rcx,%r12), %r14
cmpb $0x2d, (%r14)
jne 0x3544
movq %r15, 0x58(%rsp)
movq 0x20(%rsp), %r15
movl %r15d, %ebp
addq %rbx, %rbp
movl 0x38(%rsp), %ecx
addq %rbx, %rcx
movq %rcx, 0x40(%rsp)
movzbl 0x1(%r14), %ecx
cmpl $0x2d, %ecx
je 0x2f1e
testl %ecx, %ecx
je 0x355a
movl 0x28(%rsp), %eax
cmpl $0x1, %eax
adcl $0x0, %eax
movl %eax, 0x28(%rsp)
movslq %eax, %r15
movsbl (%r14,%r15), %esi
incq %r15
leaq 0x3188(%rip), %rdi      # 0x605d
movl %esi, 0x10(%rsp)
pushq $0xd
popq %rdx
callq 0x21d0
pushq $0x3f
popq %rcx
testq %rax, %rax
je 0x2fec
cmpb $0x3a, 0x1(%rax)
jne 0x2fe8
cmpb $0x0, (%r14,%r15)
je 0x3076
movq %r14, %rax
addq %r15, %rax
movl %ebp, %r15d
movq 0x18(%rsp), %r12
movq (%rsp), %rdi
movl 0x10(%rsp), %r14d
jmp 0x3093
movb 0x2(%r14), %dl
testb %dl, %dl
je 0x3563
leaq 0x2(%r14), %rax
movq %rax, 0x28(%rsp)
addq $0x3, %r14
xorl %r12d, %r12d
testb %dl, %dl
je 0x2f5b
movzbl %dl, %eax
cmpl $0x3d, %eax
je 0x2f5b
movb (%r14), %dl
incq %r14
movabsq $0x100000000, %rax      # imm = 0x100000000
addq %rax, %r12
jmp 0x2f3a
movb %dl, 0xf(%rsp)
movq %r14, 0x10(%rsp)
movq %r13, 0x50(%rsp)
sarq $0x20, %r12
xorl %r14d, %r14d
leaq 0x5db9(%rip), %r15      # 0x8d30
xorl %r13d, %r13d
movq (%r15), %rsi
testq %rsi, %rsi
je 0x2fa7
movq 0x28(%rsp), %rdi
movq %r12, %rdx
callq 0x2090
movq (%rsp), %rdi
xorl %ecx, %ecx
testl %eax, %eax
sete %cl
cmoveq %r15, %r13
addl %ecx, %r14d
addq $0x10, %r15
jmp 0x2f7a
cmpl $0x1, %r14d
jne 0x2fd0
movl 0xc(%r13), %r14d
movb 0xf(%rsp), %al
cmpb $0x3d, %al
movq 0x18(%rsp), %r12
jne 0x303a
movl %ebp, %r15d
movq 0x50(%rsp), %r13
movq 0x10(%rsp), %rax
jmp 0x3093
xorl %eax, %eax
pushq $0x3f
popq %r14
movl %ebp, %r15d
movq 0x18(%rsp), %r12
movq 0x50(%rsp), %r13
jmp 0x3093
movl 0x10(%rsp), %ecx
cmpl $-0x2, 0x28(%rsp)
jg 0x3009
movl %ecx, %r14d
xorl %eax, %eax
movl %ebp, %r15d
movq 0x18(%rsp), %r12
movq (%rsp), %rdi
jmp 0x3093
movq 0x18(%rsp), %rdx
movq (%rdx,%r12), %rax
movq %rdx, %r12
movl %r15d, %edx
cmpb $0x0, (%rax,%rdx)
movq (%rsp), %rdi
je 0x3065
movl %r15d, 0x28(%rsp)
movq %rbp, 0x20(%rsp)
movq $0x0, 0x10(%rsp)
jmp 0x30cf
testb %al, %al
jne 0x306c
cmpl $0x1, 0x8(%r13)
jne 0x306c
cmpl %ebp, 0x4c(%rsp)
movq 0x50(%rsp), %r13
jle 0x308a
movq 0x20(%rsp), %rax
leal (%rax,%rbx), %r15d
incl %r15d
movslq %r15d, %rax
movq (%r12,%rax,8), %rax
jmp 0x3093
movl %ecx, %r14d
xorl %eax, %eax
jmp 0x3090
xorl %eax, %eax
movl %ebp, %r15d
jmp 0x2fde
cmpl %ebp, 0x4c(%rsp)
movq 0x18(%rsp), %r12
movq (%rsp), %rdi
movl 0x10(%rsp), %r14d
jg 0x3050
xorl %eax, %eax
pushq $0x3a
popq %r14
movl %ebp, %r15d
movq %rax, 0x10(%rsp)
leal 0x1(%r15), %eax
movq %rax, 0x20(%rsp)
movl $0x0, 0x28(%rsp)
cmpl $0x0, 0x40(%rsp)
jle 0x30cc
cmpl %r15d, %ebp
jg 0x30cc
movq %r12, %rdi
movl %ebp, %esi
movq 0x40(%rsp), %rdx
callq 0x38cd
movq (%rsp), %rdi
incl %ebp
jmp 0x30b0
movl %r14d, %ecx
testl %ecx, %ecx
movq 0x58(%rsp), %r15
movq 0x80(%rsp), %r8
movabsq $0x100000000, %rbp      # imm = 0x100000000
js 0x3550
cmpl $0x54, %ecx
je 0x3183
cmpl $0x62, %ecx
je 0x318f
cmpl $0x68, %ecx
je 0x3148
cmpl $0x6f, %ecx
je 0x31a5
cmpl $0x74, %ecx
je 0x3154
cmpl $0x76, %ecx
je 0x316b
cmpl $0x12d, %ecx            # imm = 0x12D
je 0x31bd
cmpl $0x56, %ecx
movq (%rsp), %rdi
je 0x358f
cmpl $0x3a, %ecx
je 0x35ba
cmpl $0x3f, %ecx
jne 0x31cb
jmp 0x359d
movq 0x5e81(%rip), %rax      # 0x8fd0
movq (%rax), %r13
jmp 0x31c7
movq 0x10(%rsp), %rdi
movq %r8, %rbx
callq 0x2340
movq %rbx, %r8
movq %rax, 0x70(%rsp)
jmp 0x31c7
movq 0x10(%rsp), %rdi
movq %r8, %rbx
callq 0x2340
movq %rbx, %r8
movl %eax, 0x6093(%rip)      # 0x9214
jmp 0x31c7
movq 0x10(%rsp), %rax
movq %rax, 0x68(%rsp)
jmp 0x31cb
movq 0x10(%rsp), %rdi
movq %r8, %rbx
callq 0x2340
movq %rbx, %r8
movl %eax, 0x34(%rsp)
jmp 0x31c7
movq 0x10(%rsp), %rax
cmpb $0x2d, (%rax)
movq (%rsp), %rdi
jne 0x31e2
cmpb $0x0, 0x1(%rax)
cmovneq %rax, %r8
jmp 0x31cb
movq 0x10(%rsp), %rax
movq %rax, 0x60(%rsp)
movq (%rsp), %rdi
movq 0x40(%rsp), %rax
movq %rax, 0x38(%rsp)
movq %r12, %rbx
movq 0x20(%rsp), %rax
jmp 0x2e29
movq %rax, %r8
jmp 0x31cb
cmpq %rdi, %rcx
cmovgq %rcx, %rdi
movl %edi, %edx
movq 0x18(%rsp), %r12
movq 0x38(%rsp), %rsi
leal (%r15,%rsi), %ebp
subl %edx, %ebp
movl %ebx, %eax
addl %ebp, %eax
je 0x3395
movq 0x5dbf(%rip), %rax      # 0x8fd0
cmpq (%rax), %r13
je 0x3395
movq %r15, %r14
movl %edx, %eax
movl %esi, %ecx
negl %ecx
addq %rax, %rcx
subq %rbx, %rcx
cmpl %r14d, %ecx
jge 0x34a5
movq %rdx, %r13
movslq %edx, %r15
movslq %esi, %rax
subq %rax, %r15
subq %rbx, %r15
movq (%r12,%r15,8), %rdi
movq %rdi, (%rsp)
callq 0x4e46
testl %eax, %eax
je 0x35e8
addl %ebx, %ebp
cmpl $0x1, %ebp
jle 0x34b8
leaq (%r12,%r15,8), %r15
addq $0x8, %r15
negl %r13d
movq %r14, %rbp
movq 0x38(%rsp), %rax
leal (%r14,%rax), %r12d
decl %r12d
addq %rbx, %r12
addq %r13, %r12
movq 0x60(%rsp), %rbx
movq %rbx, %rdi
callq 0x4ddc
movq 0x80(%rsp), %r14
testq %r14, %r14
je 0x32af
leaq 0x30a7(%rip), %rsi      # 0x6349
movq %r14, %rdi
callq 0x2310
movq %rax, 0x78(%rsp)
movq 0x70(%rsp), %r10
leal (%r10,%r10,4), %eax
subq $0x8, %rsp
movq %r15, %rdi
movl %r12d, %esi
movq %rbx, %rdx
movq 0x8(%rsp), %rcx
movq 0x80(%rsp), %rbx
movq %rbx, %r8
movl 0x3c(%rsp), %r9d
pushq 0x70(%rsp)
pushq %r10
pushq %rax
callq 0x24fc
addq $0x20, %rsp
testq %r14, %r14
je 0x32f7
movq %rbx, %rdi
callq 0x2110
movq 0x5cd2(%rip), %rax      # 0x8fd0
movq (%rax), %rdi
callq 0x2290
cmpl $-0x1, %eax
movq 0x18(%rsp), %r12
je 0x360d
xorl %eax, %eax
cmpl $0x0, 0x5ef7(%rip)      # 0x9214
movq 0x5ccc(%rip), %r13      # 0x8ff0
js 0x3493
movq (%r13), %rdi
leaq 0x303b(%rip), %rsi      # 0x6370
leaq 0x2d50(%rip), %r14      # 0x608c
leaq 0x2d27(%rip), %rcx      # 0x606a
xorl %ebx, %ebx
movq %r14, %rdx
xorl %eax, %eax
callq 0x2220
movq (%r13), %rdi
leaq 0x302b(%rip), %rsi      # 0x6385
movq %r14, %rdx
xorl %eax, %eax
callq 0x2220
testl %ebp, %ebp
cmovlel %ebx, %ebp
leaq 0x3188(%rip), %r15      # 0x64f8
xorl %ebx, %ebx
movq (%r13), %r14
cmpq %rbx, %rbp
je 0x34dc
movq (%r12,%rbx,8), %rdx
movq %r14, %rdi
movq %r15, %rsi
xorl %eax, %eax
callq 0x2220
incq %rbx
jmp 0x3372
pushq $0xa
popq %rbp
movl %ebp, %edi
movq %r13, %rsi
callq 0x21c0
leaq 0x2d06(%rip), %rdi      # 0x60af
pushq $0x43
popq %rsi
pushq $0x1
popq %rbx
movq %rbx, %rdx
movq %r13, %rcx
callq 0x2380
leaq 0x2d32(%rip), %rdi      # 0x60f3
pushq $0x9
popq %rsi
movq %rbx, %rdx
movq %r13, %rcx
callq 0x2380
leaq 0x2d27(%rip), %rsi      # 0x60fd
movq %r13, %rdi
movl 0x34(%rsp), %edx
xorl %eax, %eax
callq 0x2220
leaq 0x2d38(%rip), %rdi      # 0x6123
pushq $0x28
popq %rsi
movq %rbx, %rdx
movq %r13, %rcx
callq 0x2380
leaq 0x2d4c(%rip), %rdi      # 0x614c
pushq $0x30
popq %rsi
movq %rbx, %rdx
movq %r13, %rcx
callq 0x2380
leaq 0x2d68(%rip), %rdi      # 0x617d
pushq $0x35
popq %rsi
movq %rbx, %rdx
movq %r13, %rcx
callq 0x2380
leaq 0x2d89(%rip), %rsi      # 0x61b3
movq %r13, %rdi
movq 0x60(%rsp), %rdx
xorl %eax, %eax
callq 0x2220
movl 0x5dd5(%rip), %edx      # 0x9214
leaq 0x2da1(%rip), %rsi      # 0x61e7
movq %r13, %rdi
xorl %eax, %eax
callq 0x2220
leaq 0x2db9(%rip), %rdi      # 0x6210
pushq $0x29
popq %rsi
movq %rbx, %rdx
movq %r13, %rcx
callq 0x2380
movl %ebp, %edi
movq %r13, %rsi
callq 0x21c0
leaq 0x2dc4(%rip), %rdi      # 0x623a
pushq $0x69
popq %rsi
movq %rbx, %rdx
movq %r13, %rcx
callq 0x2380
xorl %eax, %eax
movq 0x5b43(%rip), %rcx      # 0x8fd0
cmpq (%rcx), %r13
setne %al
addq $0x88, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq 0x5b44(%rip), %rax      # 0x8ff0
movq (%rax), %rdi
leaq 0x2dee(%rip), %rsi      # 0x62a4
jmp 0x34c9
movq 0x5b31(%rip), %rax      # 0x8ff0
movq (%rax), %rdi
leaq 0x2e41(%rip), %rsi      # 0x630a
leaq 0x2bbc(%rip), %rdx      # 0x608c
xorl %eax, %eax
callq 0x2220
pushq $0x1
popq %rax
jmp 0x3493
callq 0x4cb5
leaq 0x5d30(%rip), %rax      # 0x9218
subsd (%rax), %xmm0
movsd %xmm0, (%rsp)
callq 0x4c4c
movsd %xmm0, 0x40(%rsp)
callq 0x4c8f
cvtsi2sd %rax, %xmm2
movsd 0x2afa(%rip), %xmm0     # 0x6008
mulsd %xmm0, %xmm2
mulsd %xmm0, %xmm2
mulsd %xmm0, %xmm2
leaq 0x2e71(%rip), %rsi      # 0x6392
leaq 0x2b64(%rip), %rdx      # 0x608c
movq %r14, %rdi
movsd (%rsp), %xmm0
movsd 0x40(%rsp), %xmm1
movb $0x3, %al
callq 0x2220
xorl %eax, %eax
jmp 0x3493
movq 0x20(%rsp), %rdx
addl %ebx, %edx
jmp 0x31f0
movq 0x20(%rsp), %rdx
jmp 0x31f5
movl %eax, %edx
movq 0x18(%rsp), %r12
jmp 0x3585
movq 0x38(%rsp), %rax
leal (%rax,%rbx), %edx
leal (%r15,%rbx), %esi
movq 0x18(%rsp), %r12
movq %r12, %rdi
callq 0x38cd
addl %ebx, %r15d
incl %r15d
movq %r15, %rdx
movq 0x58(%rsp), %r15
jmp 0x31f5
leaq 0x2ad4(%rip), %rdi      # 0x606a
callq 0x20c0
jmp 0x353d
movq 0x5a4c(%rip), %rax      # 0x8ff0
movq (%rax), %rdi
movslq 0x20(%rsp), %rax
movq -0x8(%r12,%rax,8), %rcx
leaq 0x2ab6(%rip), %rsi      # 0x606e
jmp 0x35d5
movq 0x5a2f(%rip), %rax      # 0x8ff0
movq (%rax), %rdi
movslq 0x20(%rsp), %rax
movq -0x8(%r12,%rax,8), %rcx
leaq 0x2abc(%rip), %rsi      # 0x6091
leaq 0x2ab0(%rip), %rdx      # 0x608c
xorl %eax, %eax
callq 0x2220
jmp 0x34d7
movq 0x5a01(%rip), %rax      # 0x8ff0
movq (%rax), %rdi
leaq 0x2ce1(%rip), %rsi      # 0x62da
leaq 0x2a8c(%rip), %rdx      # 0x608c
movq (%rsp), %rcx
xorl %eax, %eax
callq 0x2220
jmp 0x362c
movq 0x59dc(%rip), %rax      # 0x8ff0
movq (%rax), %rdi
leaq 0x2d2d(%rip), %rsi      # 0x634b
leaq 0x2a67(%rip), %rdx      # 0x608c
xorl %eax, %eax
callq 0x2220
pushq $0x1
popq %rdi
callq 0x2370