// File: /workspace/github_c_makefile_star2_O3/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 $0xa8, %rsp
movq %rsi, %rbp
movl %edi, %r12d
callq 0x54bb
movq 0x6dfd(%rip), %rax      # 0x9ff0
movq (%rax), %rbx
movq 0x6dd3(%rip), %r13      # 0x9fd0
movq (%r13), %rax
cmpl $0x2, %r12d
movq %r12, 0x48(%rsp)
movq %rax, 0xa0(%rsp)
jl 0x37d2
movq %rbx, 0x68(%rsp)
movabsq $0x100000000, %r11      # imm = 0x100000000
leal -0x1(%r12), %eax
movl %eax, 0x7c(%rsp)
movl %r12d, %ebx
negl %ebx
movq $0x0, 0x88(%rsp)
movl $0x1, %ecx
movl $0x4, %r9d
movl $0xf4240, 0x2c(%rsp)    # imm = 0xF4240
leaq 0x3db5(%rip), %rax      # 0x7010
movq %rax, 0x60(%rsp)
movq $0x0, 0x70(%rsp)
xorl %edx, %edx
movl $0x0, 0x40(%rsp)
movq %rbx, 0x10(%rsp)
movl %edx, %r10d
movq %rcx, 0x38(%rsp)
movslq %ecx, %rdx
leal (%r10,%r12), %ecx
subl %edx, %ecx
movl %edx, %eax
leaq (%rbx,%rax), %rsi
movq %rdx, %rbx
shlq $0x20, %rbx
leaq (,%rdx,8), %rdi
addq %rbp, %rdi
movq %rdi, %r12
xorl %r14d, %r14d
movl %r10d, %r15d
movq %rdx, 0x98(%rsp)
movq (%rdi,%r14,8), %r8
cmpb $0x2d, (%r8)
jne 0x32c3
cmpb $0x0, 0x1(%r8)
jne 0x32e0
incq %rdx
incl %r15d
incq %r14
addq %r11, %rbx
addq $0x8, %r12
movl %esi, %r8d
addl %r14d, %r8d
jne 0x32b2
jmp 0x3805
sarq $0x1d, %rbx
movq (%rbp,%rbx), %rsi
cmpb $0x2d, (%rsi)
jne 0x3a82
leaq (%rax,%r14), %r8
movl %r10d, %ecx
leaq (%rcx,%r14), %rdx
movq %rdx, 0x30(%rsp)
movzbl 0x1(%rsi), %edx
cmpl $0x2d, %edx
movq %r9, 0x20(%rsp)
movq %rbp, 0x18(%rsp)
movq %r10, 0x50(%rsp)
movq %r8, 0x80(%rsp)
je 0x33ad
testl %edx, %edx
je 0x3a94
movl 0x40(%rsp), %eax
cmpl $0x1, %eax
adcl $0x0, %eax
movl %eax, 0x40(%rsp)
movslq %eax, %r13
movq %rsi, 0x58(%rsp)
movsbl (%rsi,%r13), %esi
incq %r13
movl $0xd, %edx
leaq 0x3d05(%rip), %rdi      # 0x705d
movl %esi, %ebp
callq 0x21d0
testq %rax, %rax
je 0x34cc
cmpb $0x3a, 0x1(%rax)
movq 0x80(%rsp), %r8
jne 0x34f4
movq 0x58(%rsp), %rdi
cmpb $0x0, (%rdi,%r13)
movq 0x20(%rsp), %r9
movq 0x50(%rsp), %r10
movabsq $0x100000000, %r11      # imm = 0x100000000
movq 0x30(%rsp), %rdx
movl %ebp, %esi
je 0x3589
addq %r13, %rdi
jmp 0x354a
movb 0x2(%rsi), %bl
testb %bl, %bl
je 0x3aac
leaq 0x2(%rsi), %rdi
addq $0x3, %rsi
xorl %edx, %edx
testb %bl, %bl
je 0x33d8
movzbl %bl, %eax
cmpl $0x3d, %eax
je 0x33d8
movb (%rsi), %bl
incq %rsi
addq %r11, %rdx
jmp 0x33c2
movq %r14, 0x90(%rsp)
movb %bl, 0xf(%rsp)
movq %rsi, 0x58(%rsp)
sarq $0x20, %rdx
xorl %ebx, %ebx
leaq 0x693a(%rip), %r13      # 0x9d30
leaq 0x3c13(%rip), %rsi      # 0x7010
xorl %ebp, %ebp
movq %rdi, 0x40(%rsp)
movq %rdx, %r14
callq 0x2090
xorl %ecx, %ecx
testl %eax, %eax
sete %cl
cmoveq %r13, %rbx
addl %ecx, %ebp
movq %r14, %rdx
movq 0x40(%rsp), %rdi
movq 0x10(%r13), %rsi
addq $0x10, %r13
testq %rsi, %rsi
jne 0x3404
cmpl $0x1, %ebp
jne 0x3486
movl 0xc(%rbx), %esi
movb 0xf(%rsp), %al
cmpb $0x3d, %al
movq 0x6b8d(%rip), %r13      # 0x9fd0
movq 0x18(%rsp), %rbp
movq 0x20(%rsp), %r9
movq 0x50(%rsp), %r10
movq 0x30(%rsp), %rdx
movq 0x80(%rsp), %r8
movq 0x90(%rsp), %r14
jne 0x3558
movabsq $0x100000000, %r11      # imm = 0x100000000
movq 0x10(%rsp), %rbx
movq 0x58(%rsp), %rdi
jmp 0x35c7
movl $0x3f, %esi
xorl %edi, %edi
movq 0x6b3c(%rip), %r13      # 0x9fd0
movq 0x18(%rsp), %rbp
movq 0x20(%rsp), %r9
movq 0x50(%rsp), %r10
movabsq $0x100000000, %r11      # imm = 0x100000000
movq 0x10(%rsp), %rbx
movq 0x30(%rsp), %rdx
movq 0x80(%rsp), %r8
movq 0x90(%rsp), %r14
jmp 0x35c7
movl $0x3f, %esi
movq 0x20(%rsp), %r9
movq 0x50(%rsp), %r10
movabsq $0x100000000, %r11      # imm = 0x100000000
movq 0x30(%rsp), %rdx
movq 0x80(%rsp), %r8
jmp 0x350f
movq 0x20(%rsp), %r9
movq 0x50(%rsp), %r10
movabsq $0x100000000, %r11      # imm = 0x100000000
movq 0x30(%rsp), %rdx
movl %ebp, %esi
cmpl $-0x2, 0x40(%rsp)
jle 0x3548
movq 0x18(%rsp), %rax
movq (%rax,%rbx), %rax
movl %r13d, %ecx
cmpb $0x0, (%rax,%rcx)
je 0x3548
movl %r13d, 0x40(%rsp)
movl %r8d, %ecx
xorl %edi, %edi
movq 0x6a97(%rip), %r13      # 0x9fd0
movq 0x18(%rsp), %rbp
movq 0x10(%rsp), %rbx
jmp 0x3645
xorl %edi, %edi
movq 0x6a7f(%rip), %r13      # 0x9fd0
movq 0x18(%rsp), %rbp
jmp 0x35c2
testb %al, %al
movabsq $0x100000000, %r11      # imm = 0x100000000
jne 0x35c0
cmpl $0x1, 0x8(%rbx)
jne 0x35c0
cmpl %r8d, 0x7c(%rsp)
jle 0x35bb
movq 0x38(%rsp), %rax
leal (%rax,%r14), %r8d
incl %r8d
movslq %r8d, %rax
movq (%rbp,%rax,8), %rdi
jmp 0x35c2
cmpl %r8d, 0x7c(%rsp)
movq 0x10(%rsp), %rbx
jle 0x3784
movq 0x38(%rsp), %rax
leal (%rax,%r14), %r8d
incl %r8d
movslq %r8d, %rax
movq 0x18(%rsp), %rbp
movq (%rbp,%rax,8), %rdi
movq 0x6a17(%rip), %r13      # 0x9fd0
jmp 0x35c7
movl $0x3a, %esi
xorl %edi, %edi
movq 0x10(%rsp), %rbx
leal 0x1(%r8), %ecx
movl $0x0, 0x40(%rsp)
testl %edx, %edx
jle 0x3645
movl %esi, 0x38(%rsp)
movq %rdi, 0x58(%rsp)
movq %rcx, %r9
movq 0x98(%rsp), %rsi
addq %r14, %rsi
movl %edx, %eax
movslq %r8d, %rcx
movl %r15d, %edx
movq %rsi, %r15
negq %rdx
movq (%rbp,%r15,8), %rsi
xorl %edi, %edi
movq -0x8(%r12,%rdi,8), %r8
movq %r8, (%r12,%rdi,8)
decq %rdi
cmpq %rdi, %rdx
jne 0x3603
movq %r15, %rdi
subq %rax, %rdi
movq %rsi, (%rbp,%rdi,8)
leaq 0x1(%r15), %rsi
addq $0x8, %r12
cmpq %rcx, %r15
movq %rsi, %r15
jl 0x35fc
movq %r9, %rcx
movq 0x20(%rsp), %r9
movq 0x30(%rsp), %rdx
movq 0x58(%rsp), %rdi
movl 0x38(%rsp), %esi
testl %esi, %esi
movq 0x48(%rsp), %r12
js 0x3a86
cmpl $0x6e, %esi
jle 0x369b
cmpl $0x75, %esi
jg 0x36bc
cmpl $0x6f, %esi
je 0x3726
cmpl $0x74, %esi
jne 0x3776
movq %r10, %rbx
movq %r11, %r15
movq %rcx, 0x38(%rsp)
callq 0x2340
movq 0x30(%rsp), %rdx
movq 0x38(%rsp), %rcx
movq %r15, %r11
movq %rbx, %r10
movq 0x10(%rsp), %rbx
movl %eax, %r9d
jmp 0x3776
cmpl $0x61, %esi
jle 0x36d7
cmpl $0x62, %esi
je 0x36f6
cmpl $0x68, %esi
jne 0x3776
movq (%r13), %rax
movq %rax, 0x68(%rsp)
jmp 0x3776
cmpl $0x76, %esi
je 0x373f
cmpl $0x12d, %esi            # imm = 0x12D
jne 0x3776
movq %rdi, 0x60(%rsp)
jmp 0x3776
cmpl $0x55, %esi
jg 0x379c
cmpl $0x54, %esi
jne 0x37a6
movq %rdi, 0x88(%rsp)
jmp 0x3776
movq %r10, %rbx
movq %rcx, %r15
callq 0x2340
movq 0x30(%rsp), %rdx
movq %r15, %rcx
movabsq $0x100000000, %r11      # imm = 0x100000000
movq %rbx, %r10
movq 0x10(%rsp), %rbx
movq 0x20(%rsp), %r9
movl %eax, 0x2c(%rsp)
jmp 0x3776
cmpb $0x2d, (%rdi)
jne 0x3771
cmpb $0x0, 0x1(%rdi)
movq 0x70(%rsp), %rax
cmovneq %rdi, %rax
movq %rax, 0x70(%rsp)
jmp 0x3776
movq %r10, %rbx
movq %rcx, %r15
callq 0x2340
movq 0x30(%rsp), %rdx
movq %r15, %rcx
movabsq $0x100000000, %r11      # imm = 0x100000000
movq %rbx, %r10
movq 0x10(%rsp), %rbx
movq 0x20(%rsp), %r9
movl %eax, 0x6aa5(%rip)      # 0xa214
jmp 0x3776
movq %rdi, 0x70(%rsp)
cmpl %r12d, %ecx
jl 0x3278
jmp 0x3a90
movl $0x3a, %esi
xorl %edi, %edi
movq 0x683e(%rip), %r13      # 0x9fd0
movq 0x18(%rsp), %rbp
jmp 0x35c7
cmpl $0x56, %esi
jne 0x3776
jmp 0x3b12
cmpl $0x3a, %esi
je 0x3b25
cmpl $0x3f, %esi
jne 0x3776
movq 0x6835(%rip), %rax      # 0x9ff0
movq (%rax), %rdi
movslq %ecx, %rax
movq -0x8(%rbp,%rax,8), %rcx
leaq 0x38a1(%rip), %rsi      # 0x706e
jmp 0x3b3e
movl $0x1, %eax
movq $0x0, 0x70(%rsp)
leaq 0x3829(%rip), %r14      # 0x7010
movl $0xf4240, 0x2c(%rsp)    # imm = 0xF4240
movl $0x4, %r9d
movq $0x0, 0x88(%rsp)
xorl %ecx, %ecx
jmp 0x3817
movq 0x48(%rsp), %r12
movl %r12d, %eax
movq 0x68(%rsp), %rbx
movq 0x60(%rsp), %r14
subl %ecx, %eax
cmpl %eax, %r12d
je 0x38e0
cmpq (%r13), %rbx
je 0x38e0
movq %rbp, 0x18(%rsp)
movl %r12d, %ebp
subl %eax, %ebp
jle 0x3a63
movq %r9, 0x20(%rsp)
movslq %eax, %rbx
movq 0x18(%rsp), %rax
movq (%rax,%rbx,8), %r15
movq %r15, %rdi
callq 0x5624
testl %eax, %eax
je 0x3b51
cmpl $0x1, %ebp
jle 0x3a6a
movq 0x18(%rsp), %rax
leaq (%rax,%rbx,8), %r12
addq $0x8, %r12
decl %ebp
movq %r14, %rdi
callq 0x55de
movq 0x70(%rsp), %rdi
testq %rdi, %rdi
je 0x39f5
leaq 0x3ab7(%rip), %rsi      # 0x7349
callq 0x2310
movq %r13, %rbx
movq %rax, %r13
movq 0x20(%rsp), %r10
leal (%r10,%r10,4), %eax
subq $0x8, %rsp
movq %r12, %rdi
movl %ebp, %esi
movq %r14, %rdx
movq %r15, %rcx
movq %r13, %r8
movl 0x34(%rsp), %r9d
pushq 0x90(%rsp)
pushq %r10
pushq %rax
callq 0x28cc
addq $0x20, %rsp
movq %r13, %rdi
movq %rbx, %r13
callq 0x2110
jmp 0x3a2d
movl $0xa, %edi
movq %rbx, %rsi
callq 0x21c0
leaq 0x37bb(%rip), %rdi      # 0x70af
movl $0x43, %esi
movl $0x1, %edx
movq %rbx, %rcx
callq 0x2380
leaq 0x37e6(%rip), %rdi      # 0x70f3
movl $0x9, %esi
movl $0x1, %edx
movq %rbx, %rcx
callq 0x2380
leaq 0x37d7(%rip), %rsi      # 0x70fd
movq %rbx, %rdi
movl 0x2c(%rsp), %edx
xorl %eax, %eax
callq 0x2220
leaq 0x37e8(%rip), %rdi      # 0x7123
movl $0x28, %esi
movl $0x1, %edx
movq %rbx, %rcx
callq 0x2380
leaq 0x37f8(%rip), %rdi      # 0x714c
movl $0x30, %esi
movl $0x1, %edx
movq %rbx, %rcx
callq 0x2380
leaq 0x3810(%rip), %rdi      # 0x717d
movl $0x35, %esi
movl $0x1, %edx
movq %rbx, %rcx
callq 0x2380
leaq 0x382d(%rip), %rsi      # 0x71b3
movq %rbx, %rdi
movq %r14, %rdx
xorl %eax, %eax
callq 0x2220
movl 0x687b(%rip), %edx      # 0xa214
leaq 0x3847(%rip), %rsi      # 0x71e7
movq %rbx, %rdi
xorl %eax, %eax
callq 0x2220
leaq 0x385f(%rip), %rdi      # 0x7210
movl $0x29, %esi
movl $0x1, %edx
movq %rbx, %rcx
callq 0x2380
movl $0xa, %edi
movq %rbx, %rsi
callq 0x21c0
leaq 0x3863(%rip), %rdi      # 0x723a
movl $0x69, %esi
movl $0x1, %edx
movq %rbx, %rcx
callq 0x2380
xorl %ebp, %ebp
cmpq (%r13), %rbx
setne %bpl
jmp 0x3a4f
movq 0x20(%rsp), %r10
leal (%r10,%r10,4), %eax
subq $0x8, %rsp
movq %r12, %rdi
movl %ebp, %esi
movq %r14, %rdx
movq %r15, %rcx
movq 0xa8(%rsp), %r8
movl 0x34(%rsp), %r9d
pushq 0x90(%rsp)
pushq %r10
pushq %rax
callq 0x28cc
addq $0x20, %rsp
movq (%r13), %rdi
callq 0x2290
cmpl $-0x1, %eax
movq 0x48(%rsp), %rdi
je 0x3b59
xorl %ebp, %ebp
cmpl $0x0, 0x67c7(%rip)      # 0xa214
jns 0x3a76
movl %ebp, %eax
addq $0xa8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
callq 0x243f
jmp 0x3a6f
callq 0x2574
movl $0x1, %ebp
jmp 0x3a4f
movq 0x18(%rsp), %rsi
callq 0x245e
jmp 0x3a4f
movl %edx, %eax
jmp 0x3a9c
subl %r10d, %ecx
subl %r14d, %ecx
movl %ecx, %eax
jmp 0x3b03
movl %ecx, %eax
jmp 0x3aa1
movq 0x38(%rsp), %rax
addl %r14d, %eax
movq 0x48(%rsp), %r12
addl %r14d, %r10d
movl %r10d, %ecx
jmp 0x380d
movq %rsi, %r10
addq %r14, %rcx
addq %r14, %rax
testl %ecx, %ecx
jle 0x3adf
movl %ecx, %edx
negq %rdx
movslq %eax, %rsi
leaq (,%rsi,8), %rsi
addq %rbp, %rsi
xorl %edi, %edi
movq -0x8(%rsi,%rdi,8), %r8
movq %r8, (%rsi,%rdi,8)
decq %rdi
cmpq %rdi, %rdx
jne 0x3ace
xorl %edx, %edx
testl %r15d, %r15d
cmovgl %r15d, %edx
movq 0x38(%rsp), %rsi
subl %edx, %esi
addl %esi, %r14d
movslq %r14d, %rdx
movq %r10, (%rbp,%rdx,8)
subl %ecx, %eax
incl %eax
movq 0x48(%rsp), %r12
movq 0x68(%rsp), %rbx
movq 0x60(%rsp), %r14
jmp 0x3819
leaq 0x3551(%rip), %rdi      # 0x706a
callq 0x20c0
xorl %ebp, %ebp
jmp 0x3a4f
movq 0x64c4(%rip), %rax      # 0x9ff0
movq (%rax), %rdi
movslq %ecx, %rax
movq -0x8(%rbp,%rax,8), %rcx
leaq 0x3553(%rip), %rsi      # 0x7091
leaq 0x3547(%rip), %rdx      # 0x708c
xorl %eax, %eax
callq 0x2220
jmp 0x3a6f
movq %r15, %rdi
callq 0x2593
callq 0x254c