// File: /workspace/github_c_makefile_star2_O0/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
movq %rsp, %rbp
subq $0xc0, %rsp
movl $0x0, -0x4(%rbp)
movl %edi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
leaq 0x5f5f(%rip), %rax      # 0x905f
movq %rax, -0x18(%rbp)
movq 0x9105(%rip), %rax      # 0xc210
movq %rax, -0x38(%rbp)
movq 0x9102(%rip), %rax      # 0xc218
movq %rax, -0x30(%rbp)
movq 0x90ff(%rip), %rax      # 0xc220
movq %rax, -0x28(%rbp)
movq 0x90fc(%rip), %rax      # 0xc228
movq %rax, -0x20(%rbp)
movl $0x0, -0x40(%rbp)
callq 0x6d10
movq 0x8eb5(%rip), %rax      # 0xbff8
movq (%rax), %rax
movq %rax, -0x58(%rbp)
movq 0x8e87(%rip), %rax      # 0xbfd8
movq (%rax), %rax
movq %rax, -0x60(%rbp)
movq $0x0, -0x78(%rbp)
movq $0x0, -0x70(%rbp)
movq $0x0, -0x68(%rbp)
movq $0x0, -0x80(%rbp)
movl $0x0, -0x4c(%rbp)
movl $0xf4240, -0x48(%rbp)   # imm = 0xF4240
movl $0x4, -0x44(%rbp)
leaq 0x5e7c(%rip), %rax      # 0x9010
movq %rax, -0x88(%rbp)
movl -0x8(%rbp), %esi
movq -0x10(%rbp), %rdx
movq -0x18(%rbp), %r8
leaq -0x38(%rbp), %rdi
movl $0x1, %ecx
leaq 0x907a(%rip), %r9       # 0xc230
callq 0x3760
movl %eax, -0x3c(%rbp)
cmpl $0x0, %eax
jl 0x3335
cmpl $0x74, -0x3c(%rbp)
jne 0x31de
movq -0x30(%rbp), %rdi
callq 0x2340
movl %eax, -0x44(%rbp)
jmp 0x3330
cmpl $0x62, -0x3c(%rbp)
jne 0x31f5
movq -0x30(%rbp), %rdi
callq 0x2340
movl %eax, -0x48(%rbp)
jmp 0x332e
cmpl $0x54, -0x3c(%rbp)
jne 0x3208
movq -0x30(%rbp), %rax
movq %rax, -0x78(%rbp)
jmp 0x332c
cmpl $0x12d, -0x3c(%rbp)     # imm = 0x12D
jne 0x3221
movq -0x30(%rbp), %rax
movq %rax, -0x88(%rbp)
jmp 0x332a
cmpl $0x76, -0x3c(%rbp)
jne 0x323b
movq -0x30(%rbp), %rdi
callq 0x2340
movl %eax, 0x905e(%rip)      # 0xc294
jmp 0x3328
cmpl $0x68, -0x3c(%rbp)
jne 0x3254
movq 0x8d90(%rip), %rax      # 0xbfd8
movq (%rax), %rax
movq %rax, -0x58(%rbp)
jmp 0x3326
cmpl $0x6f, -0x3c(%rbp)
jne 0x327c
movq -0x30(%rbp), %rdi
leaq 0x5dc3(%rip), %rsi      # 0x9028
callq 0x2200
cmpl $0x0, %eax
je 0x3277
movq -0x30(%rbp), %rax
movq %rax, -0x68(%rbp)
jmp 0x3324
cmpl $0x56, -0x3c(%rbp)
jne 0x329a
leaq 0x5de3(%rip), %rdi      # 0x906c
callq 0x20c0
movl $0x0, -0x4(%rbp)
jmp 0x374e
cmpl $0x3f, -0x3c(%rbp)
jne 0x32dc
movq 0x8d51(%rip), %rax      # 0xbff8
movq (%rax), %rdi
movq -0x10(%rbp), %rax
movl -0x24(%rbp), %ecx
subl $0x1, %ecx
movslq %ecx, %rcx
movq (%rax,%rcx,8), %rcx
leaq 0x5dae(%rip), %rsi      # 0x9070
leaq 0x5dc5(%rip), %rdx      # 0x908e
movb $0x0, %al
callq 0x2220
movl $0x1, -0x4(%rbp)
jmp 0x374e
cmpl $0x3a, -0x3c(%rbp)
jne 0x331e
movq 0x8d0f(%rip), %rax      # 0xbff8
movq (%rax), %rdi
movq -0x10(%rbp), %rax
movl -0x24(%rbp), %ecx
subl $0x1, %ecx
movslq %ecx, %rcx
movq (%rax,%rcx,8), %rcx
leaq 0x5d8f(%rip), %rsi      # 0x9093
leaq 0x5d83(%rip), %rdx      # 0x908e
movb $0x0, %al
callq 0x2220
movl $0x1, -0x4(%rbp)
jmp 0x374e
jmp 0x3320
jmp 0x3322
jmp 0x3324
jmp 0x3326
jmp 0x3328
jmp 0x332a
jmp 0x332c
jmp 0x332e
jmp 0x3330
jmp 0x319b
movl -0x8(%rbp), %eax
cmpl -0x38(%rbp), %eax
je 0x3351
movq -0x58(%rbp), %rax
movq 0x8c90(%rip), %rcx      # 0xbfd8
cmpq (%rcx), %rax
jne 0x345c
movq -0x58(%rbp), %rdi
leaq 0x5f48(%rip), %rsi      # 0x92a4
movb $0x0, %al
callq 0x2220
movq -0x58(%rbp), %rdi
leaq 0x5d43(%rip), %rsi      # 0x90b1
movb $0x0, %al
callq 0x2220
movq -0x58(%rbp), %rdi
leaq 0x5d75(%rip), %rsi      # 0x90f5
movb $0x0, %al
callq 0x2220
movq -0x58(%rbp), %rdi
movl -0x48(%rbp), %edx
leaq 0x5d6a(%rip), %rsi      # 0x90ff
movb $0x0, %al
callq 0x2220
movq -0x58(%rbp), %rdi
leaq 0x5d7e(%rip), %rsi      # 0x9125
movb $0x0, %al
callq 0x2220
movq -0x58(%rbp), %rdi
leaq 0x5d95(%rip), %rsi      # 0x914e
movb $0x0, %al
callq 0x2220
movq -0x58(%rbp), %rdi
leaq 0x5db4(%rip), %rsi      # 0x917f
movb $0x0, %al
callq 0x2220
movq -0x58(%rbp), %rdi
movq -0x88(%rbp), %rdx
leaq 0x5dd1(%rip), %rsi      # 0x91b5
movb $0x0, %al
callq 0x2220
movq -0x58(%rbp), %rdi
movl 0x8e9f(%rip), %edx      # 0xc294
leaq 0x5ded(%rip), %rsi      # 0x91e9
movb $0x0, %al
callq 0x2220
movq -0x58(%rbp), %rdi
leaq 0x5e04(%rip), %rsi      # 0x9212
movb $0x0, %al
callq 0x2220
movq -0x58(%rbp), %rdi
leaq 0x5e84(%rip), %rsi      # 0x92a4
movb $0x0, %al
callq 0x2220
movq -0x58(%rbp), %rdi
leaq 0x5e0a(%rip), %rsi      # 0x923c
movb $0x0, %al
callq 0x2220
movq -0x58(%rbp), %rdx
movq 0x8b94(%rip), %rax      # 0xbfd8
movq (%rax), %rsi
movl $0x1, %eax
xorl %ecx, %ecx
cmpq %rsi, %rdx
cmovel %ecx, %eax
movl %eax, -0x4(%rbp)
jmp 0x374e
movl -0x8(%rbp), %eax
subl -0x38(%rbp), %eax
cmpl $0x1, %eax
jge 0x3492
movq 0x8b8a(%rip), %rax      # 0xbff8
movq (%rax), %rdi
leaq 0x5e2e(%rip), %rsi      # 0x92a6
leaq 0x5c0f(%rip), %rdx      # 0x908e
movb $0x0, %al
callq 0x2220
movl $0x1, -0x4(%rbp)
jmp 0x374e
movq -0x10(%rbp), %rax
movslq -0x38(%rbp), %rcx
movq (%rax,%rcx,8), %rax
movq %rax, -0x70(%rbp)
movq -0x70(%rbp), %rdi
callq 0x6f00
cmpl $0x0, %eax
jne 0x34dd
movq 0x8b41(%rip), %rax      # 0xbff8
movq (%rax), %rdi
movq -0x70(%rbp), %rcx
leaq 0x5e17(%rip), %rsi      # 0x92dc
leaq 0x5bc2(%rip), %rdx      # 0x908e
movb $0x0, %al
callq 0x2220
movl $0x1, %edi
callq 0x2370
jmp 0x34df
movl -0x8(%rbp), %eax
subl -0x38(%rbp), %eax
cmpl $0x2, %eax
jge 0x3515
movq 0x8b07(%rip), %rax      # 0xbff8
movq (%rax), %rdi
leaq 0x5e11(%rip), %rsi      # 0x930c
leaq 0x5b8c(%rip), %rdx      # 0x908e
movb $0x0, %al
callq 0x2220
movl $0x1, -0x4(%rbp)
jmp 0x374e
movq -0x10(%rbp), %rax
movslq -0x38(%rbp), %rcx
shlq $0x3, %rcx
addq %rcx, %rax
addq $0x8, %rax
movq %rax, -0x80(%rbp)
movl -0x8(%rbp), %eax
subl -0x38(%rbp), %eax
subl $0x1, %eax
movl %eax, -0x4c(%rbp)
movq -0x88(%rbp), %rdi
callq 0x6e60
cmpq $0x0, -0x68(%rbp)
je 0x355f
movq -0x68(%rbp), %rdi
leaq 0x5df5(%rip), %rsi      # 0x934b
callq 0x2310
movq %rax, -0x60(%rbp)
movq -0x80(%rbp), %rdi
movl -0x4c(%rbp), %esi
movq -0x88(%rbp), %rdx
movq -0x70(%rbp), %rcx
movq -0x60(%rbp), %r8
movl -0x48(%rbp), %r9d
imull $0x5, -0x44(%rbp), %r11d
movl -0x44(%rbp), %r10d
movq -0x78(%rbp), %rax
movl %r11d, (%rsp)
movl %r10d, 0x8(%rsp)
movq %rax, 0x10(%rsp)
callq 0x24f0
movl %eax, -0x40(%rbp)
cmpq $0x0, -0x68(%rbp)
je 0x35ac
movq -0x60(%rbp), %rdi
callq 0x2110
cmpl $0x0, -0x40(%rbp)
je 0x35db
movq 0x8a3f(%rip), %rax      # 0xbff8
movq (%rax), %rdi
leaq 0x5d8a(%rip), %rsi      # 0x934d
leaq 0x5ac4(%rip), %rdx      # 0x908e
movb $0x0, %al
callq 0x2220
movl $0x1, %edi
callq 0x2370
movq 0x89f6(%rip), %rax      # 0xbfd8
movq (%rax), %rdi
callq 0x2290
cmpl $-0x1, %eax
jne 0x3618
movq 0x8a02(%rip), %rax      # 0xbff8
movq (%rax), %rdi
leaq 0x5d68(%rip), %rsi      # 0x9368
leaq 0x5a87(%rip), %rdx      # 0x908e
movb $0x0, %al
callq 0x2220
movl $0x1, %edi
callq 0x2370
cmpl $0x0, 0x8c75(%rip)      # 0xc294
jl 0x3747
movq 0x89cc(%rip), %rax      # 0xbff8
movq (%rax), %rdi
leaq 0x5d57(%rip), %rsi      # 0x938d
leaq 0x5a51(%rip), %rdx      # 0x908e
leaq 0x5a28(%rip), %rcx      # 0x906c
movb $0x0, %al
callq 0x2220
movq 0x89a6(%rip), %rax      # 0xbff8
movq (%rax), %rdi
leaq 0x5d46(%rip), %rsi      # 0x93a2
leaq 0x5a2b(%rip), %rdx      # 0x908e
movb $0x0, %al
callq 0x2220
movl $0x0, -0x8c(%rbp)
movl -0x8c(%rbp), %eax
cmpl -0x8(%rbp), %eax
jge 0x36b7
movq 0x8972(%rip), %rax      # 0xbff8
movq (%rax), %rdi
movq -0x10(%rbp), %rax
movslq -0x8c(%rbp), %rcx
movq (%rax,%rcx,8), %rdx
leaq 0x5e76(%rip), %rsi      # 0x9515
movb $0x0, %al
callq 0x2220
movl -0x8c(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x8c(%rbp)
jmp 0x3674
movq 0x893a(%rip), %rax      # 0xbff8
movq (%rax), %rax
movq %rax, -0xa8(%rbp)
callq 0x6c90
leaq 0x8bc4(%rip), %rax      # 0xc298
subsd (%rax), %xmm0
movsd %xmm0, -0xa0(%rbp)
callq 0x6c00
movsd %xmm0, -0x98(%rbp)
callq 0x6c60
movq -0xa8(%rbp), %rdi
movsd -0xa0(%rbp), %xmm0
movsd -0x98(%rbp), %xmm1
cvtsi2sd %rax, %xmm2
movsd 0x58f2(%rip), %xmm3     # 0x9008
divsd %xmm3, %xmm2
movsd 0x58e6(%rip), %xmm3     # 0x9008
divsd %xmm3, %xmm2
movsd 0x58da(%rip), %xmm3     # 0x9008
divsd %xmm3, %xmm2
leaq 0x5c76(%rip), %rsi      # 0x93af
leaq 0x594e(%rip), %rdx      # 0x908e
movb $0x3, %al
callq 0x2220
movl $0x0, -0x4(%rbp)
movl -0x4(%rbp), %eax
addq $0xc0, %rsp
popq %rbp
retq
nopw (%rax,%rax)