// File: /workspace/github_cpp_makefile_star2_O3/chhylp123[P]hifiasm/CommandLines.cpp
// Function: check_option(hifiasm_opt_t*)
int check_option(hifiasm_opt_t* asm_opt)
{
    if(asm_opt->read_file_names == NULL || asm_opt->num_reads == 0)
    {
        fprintf(stderr, "[ERROR] missing input: please specify a read file\n");
        return 0;
    }

    if(asm_opt->output_file_name == NULL)
    {
        fprintf(stderr, "[ERROR] missing output: please specify the output name (-o)\n");
        return 0;
    }

    if(asm_opt->thread_num < 1)
    {
        fprintf(stderr, "[ERROR] the number of threads must be > 0 (-t)\n");
        return 0;
    }


    if(asm_opt->number_of_round < 1)
    {
        fprintf(stderr, "[ERROR] the number of rounds for correction must be > 0 (-r)\n");
        return 0;
    }

    if(asm_opt->clean_round < 1)
    {
        fprintf(stderr, "[ERROR] the number of rounds for assembly cleaning must be > 0 (-a)\n");
        return 0;
    }

    if(asm_opt->adapterLen < 0)
    {
        fprintf(stderr, "[ERROR] the length of removed adapters must be >= 0 (-z)\n");
        return 0;
    }


    if(asm_opt->k_mer_length >= 64)
    {
        fprintf(stderr, "[ERROR] the length of k_mer must be < 64 (-k)\n");
        return 0;
    }


    if(asm_opt->max_drop_rate < 0 || asm_opt->max_drop_rate >= 1 ) 
    {
        fprintf(stderr, "[ERROR] max overlap drop ratio must be [0.0, 1.0) (-x)\n");
        return 0;
    }

    
    if(asm_opt->min_drop_rate < 0 || asm_opt->min_drop_rate >= 1)
    {
        fprintf(stderr, "[ERROR] min overlap drop ratio must be [0.0, 1.0) (-y)\n");
        return 0;
    }

    if(asm_opt->max_drop_rate <= asm_opt->min_drop_rate)
    {
        fprintf(stderr, "[ERROR] min overlap drop ratio must be less than max overlap drop ratio (-x/-y)\n");
        return 0;
    }

    if(asm_opt->small_pop_bubble_size < 0)
    {
        fprintf(stderr, "[ERROR] the size of popped small bubbles must be >= 0 (-p)\n");
        return 0;
    }

    if(asm_opt->large_pop_bubble_size < 0)
    {
        fprintf(stderr, "[ERROR] the size of popped large bubbles must be >= 0 (-m)\n");
        return 0;
    }

    if(asm_opt->max_hang_Len < 0)
    {
        fprintf(stderr, "[ERROR] max_hang_Len must be >= 0\n");
        return 0;
    }

    if(asm_opt->max_hang_rate < 0)
    {
        fprintf(stderr, "[ERROR] max_hang_rate must be >= 0\n");
        return 0;
    }

    if(asm_opt->gap_fuzz < 0)
    {
        fprintf(stderr, "[ERROR] gap_fuzz must be >= 0\n");
        return 0;
    }

    if(asm_opt->min_overlap_Len < 0)
    {
        fprintf(stderr, "[ERROR] min_overlap_Len must be >= 0\n");
        return 0;
    }

    if(asm_opt->min_overlap_coverage < 0)
    {
        fprintf(stderr, "[ERROR] min_overlap_coverage must be >= 0\n");
        return 0;
    }

	if (asm_opt->max_ov_diff_ec < asm_opt->max_ov_diff_final) {
		fprintf(stderr, "[ERROR] max_ov_diff_ec shouldn't be smaller than max_ov_diff_final\n");
		return 0;
	}

	if (asm_opt->max_ov_diff_ec < HA_MIN_OV_DIFF) {
		fprintf(stderr, "[ERROR] max_ov_diff_ec shouldn't be smaller than %g\n", HA_MIN_OV_DIFF);
		return 0;
	}

    if(asm_opt->max_short_tip < 0)
    {
        fprintf(stderr, "[ERROR] the length of removal tips must be >= 0 (-n)\n");
        return 0;
    }

    if(asm_opt->purge_level_primary < 0 || asm_opt->purge_level_primary > 3)
    {
        fprintf(stderr, "[ERROR] the level of purge-dup should be [0, 3] (-l)\n");
        return 0;
    }

    if(ha_opt_triobin(asm_opt) && ((asm_opt->purge_level_trio < 0 || asm_opt->purge_level_trio > 1)))
    {
        fprintf(stderr, "[ERROR] the level of purge-dup for trio should be [0, 1] (-l)\n");
        return 0;
    }

    if(asm_opt->hom_global_coverage < 0 && asm_opt->hom_global_coverage != -1)
    {
        fprintf(stderr, "[ERROR] homozygous read coverage should be >= 0 (--hom-cov)\n");
        return 0;
    }

    if(asm_opt->pur_global_coverage < 0 && asm_opt->pur_global_coverage != -1)
    {
        fprintf(stderr, "[ERROR] purge duplication coverage threshold should be >= 0 (--purge-max)\n");
        return 0;
    }

    if(asm_opt->bed_inconsist_rate < 0 || asm_opt->bed_inconsist_rate > 100)
    {
        fprintf(stderr, "[ERROR] inconsistency rate should be [0, 100] (--lowQ)\n");
        return 0;
    }


    if(asm_opt->fn_bin_yak[0] != NULL && check_file(asm_opt->fn_bin_yak[0], "YAK1") == 0) return 0;
    if(asm_opt->fn_bin_yak[1] != NULL && check_file(asm_opt->fn_bin_yak[1], "YAK2") == 0) return 0;
    if(asm_opt->fn_bin_list[0] != NULL && check_file(asm_opt->fn_bin_list[0], "LIST1") == 0) return 0;
    if(asm_opt->fn_bin_list[1] != NULL && check_file(asm_opt->fn_bin_list[1], "LIST2") == 0) return 0;
    if(asm_opt->required_read_name != NULL && check_file(asm_opt->required_read_name, "b") == 0) return 0;
    
    if(asm_opt->hic_reads[0] != NULL && check_hic_reads(asm_opt->hic_reads[0], "HIC1") == 0) return 0;
    if(asm_opt->hic_reads[1] != NULL && check_hic_reads(asm_opt->hic_reads[1], "HIC2") == 0) return 0;
    if(asm_opt->hic_reads[0] != NULL && asm_opt->hic_reads[1] == NULL)
    {
        fprintf(stderr, "[ERROR] lack r2 of HiC reads (--h2)\n");
        return 0;
    }
    if(asm_opt->hic_reads[1] != NULL && asm_opt->hic_reads[0] == NULL)
    {
        fprintf(stderr, "[ERROR] lack r1 of HiC reads (--h1)\n");
        return 0;
    }

    if(asm_opt->hic_reads[0] != NULL && asm_opt->hic_reads[1] != NULL && 
                            asm_opt->hic_reads[0]->n != asm_opt->hic_reads[1]->n)
    {
        fprintf(stderr, "[ERROR] wrong r1 and r2 of HiC reads (--h1 && --h2)\n");
        return 0;
    }

    if(asm_opt->hic_enzymes != NULL && asm_opt->hic_enzymes->n == 0)
    {
        fprintf(stderr, "[ERROR] wrong HiC enzymes (--enzyme)\n");
        return 0;
    }

    if(asm_opt->hic_reads[0] != NULL && asm_opt->hic_reads[0]->n == 0)
    {
        fprintf(stderr, "[ERROR] wrong r1 of HiC reads (--h1)\n");
        return 0;
    }

    if(asm_opt->hic_reads[1] != NULL && asm_opt->hic_reads[1]->n == 0)
    {
        fprintf(stderr, "[ERROR] wrong r2 of HiC reads (--h2)\n");
        return 0;
    }

    if(asm_opt->ar != NULL && check_fq_files(asm_opt->ar, "--ul", asm_opt->ul_mod) == 0) return 0;
    if(asm_opt->ar != NULL && asm_opt->ar->n == 0)
    {
        fprintf(stderr, "[ERROR] wrong UL reads (--ul)\n");
        return 0;
    }

    if(asm_opt->b_low_cov < 0)
    {
        fprintf(stderr, "[ERROR] must >= 0 (--b-cov)\n");
        return 0;
    }

    if(asm_opt->b_high_cov != -1 && asm_opt->b_high_cov < 0)
    {
        fprintf(stderr, "[ERROR] must >= 0 (--h-cov)\n");
        return 0;
    }

    if(asm_opt->m_rate < 0)
    {
        fprintf(stderr, "[ERROR] must >= 0 (--m-rate)\n");
        return 0;
    }

    if(asm_opt->b_high_cov != -1 && asm_opt->b_high_cov <= asm_opt->b_low_cov)
    {
        fprintf(stderr, "[ERROR] [--h-cov] must >= [--b-cov]\n");
        return 0;
    }

    if(asm_opt->purge_simi_thres < 0)
    {
        fprintf(stderr, "[ERROR] [-s] must >= 0\n");
        return 0;
    }

    if(asm_opt->max_kmer_cnt < 0)
    {
        fprintf(stderr, "[ERROR] [--max-kocc] must >= 0\n");
        return 0;
    }

    if(asm_opt->hg_size < -1)
    {
        fprintf(stderr, "[ERROR] [--hg-size] wrong genome size\n");
        return 0;
    }

    if(asm_opt->ul_mod != 0 && asm_opt->ul_mod != 1) {
        fprintf(stderr, "[ERROR] must be 0 or 1 (--ul-m)\n");
        return 0;
    }

    if(asm_opt->telo_motif) {
        uint64_t k, tlen = strlen((asm_opt->telo_motif)); char c;
        if(tlen > 32) {
            fprintf(stderr, "[ERROR] [--telo-m] must be no longer than 32\n");
            return 0;
        }
        for (k = 0; k < tlen; k++) {
            c = asm_opt->telo_motif[k];
            if(c != 'A' && c != 'C' && c != 'G' && c != 'T' &&
                c != 'a' && c != 'c' && c != 'g' && c != 't') {
                fprintf(stderr, "[ERROR] [--telo-m] must be A/C/G/T\n");
                return 0;
            }
        }
    }

    return 1;
}

// Assembly:
pushq %r14
pushq %rbx
pushq %rax
cmpq $0x0, 0x8(%rdi)
je 0x2fa9d
movq %rdi, %rbx
cmpl $0x0, 0x4(%rdi)
je 0x2fa9d
cmpq $0x0, 0x10(%rbx)
je 0x2faa7
cmpl $0x0, 0x7c(%rbx)
jle 0x2fab1
cmpl $0x0, 0xf8(%rbx)
jle 0x2fabb
cmpl $0x0, 0x104(%rbx)
jle 0x2fac5
cmpl $0x0, 0x100(%rbx)
js 0x2facf
cmpl $0x40, 0x80(%rbx)
jge 0x2fad9
movss 0x160(%rbx), %xmm0
xorps %xmm1, %xmm1
ucomiss %xmm0, %xmm1
ja 0x2fae3
ucomiss 0x1fe852(%rip), %xmm0   # 0x22e0d0
jae 0x2fae3
movss 0x15c(%rbx), %xmm1
xorps %xmm2, %xmm2
ucomiss %xmm1, %xmm2
ja 0x2faed
ucomiss 0x1fe831(%rip), %xmm1   # 0x22e0d0
jae 0x2faed
ucomiss %xmm0, %xmm1
jae 0x2faf7
cmpq $0x0, 0x180(%rbx)
js 0x2fb01
cmpq $0x0, 0x188(%rbx)
js 0x2fb0b
cmpl $0x0, 0x10c(%rbx)
js 0x2fb15
xorps %xmm0, %xmm0
ucomiss 0x158(%rbx), %xmm0
ja 0x2fb1f
cmpl $0x0, 0x110(%rbx)
js 0x2fb29
cmpl $0x0, 0x114(%rbx)
js 0x2fb33
cmpl $0x0, 0x118(%rbx)
js 0x2fb3d
movsd 0xc0(%rbx), %xmm0
movsd 0xc8(%rbx), %xmm1
ucomisd %xmm0, %xmm1
ja 0x2fb47
movsd 0x1fe6e8(%rip), %xmm1   # 0x22e018
ucomisd %xmm0, %xmm1
ja 0x2fb51
cmpl $0x0, 0x11c(%rbx)
js 0x2fb5b
cmpl $0x4, 0x130(%rbx)
jae 0x2fb65
movq 0x20(%rbx), %rdi
testq %rdi, %rdi
je 0x2f964
cmpq $0x0, 0x28(%rbx)
jne 0x2f972
cmpq $0x0, 0x30(%rbx)
je 0x2f97f
cmpq $0x0, 0x38(%rbx)
je 0x2f97f
cmpl $0x2, 0x134(%rbx)
jae 0x2fccd
cmpl $-0x2, 0x144(%rbx)
jle 0x2fb6f
cmpl $-0x2, 0x14c(%rbx)
jle 0x2fb79
cmpl $0x65, 0x150(%rbx)
jae 0x2fb83
testq %rdi, %rdi
je 0x2f9bf
leaq 0x2005d2(%rip), %rsi    # 0x22ff84
callq 0x2fd50
testl %eax, %eax
je 0x2fcd2
movq 0x28(%rbx), %rdi
testq %rdi, %rdi
je 0x2f9dc
leaq 0x2005ba(%rip), %rsi    # 0x22ff89
callq 0x2fd50
testl %eax, %eax
je 0x2fcd2
movq 0x30(%rbx), %rdi
testq %rdi, %rdi
je 0x2f9f9
leaq 0x2005a2(%rip), %rsi    # 0x22ff8e
callq 0x2fd50
testl %eax, %eax
je 0x2fcd2
movq 0x38(%rbx), %rdi
testq %rdi, %rdi
je 0x2fa16
leaq 0x20058b(%rip), %rsi    # 0x22ff94
callq 0x2fd50
testl %eax, %eax
je 0x2fcd2
movq 0x18(%rbx), %rdi
testq %rdi, %rdi
je 0x2fa33
leaq 0x21a80d(%rip), %rsi    # 0x24a233
callq 0x2fd50
testl %eax, %eax
je 0x2fcd2
movq 0x50(%rbx), %rdi
testq %rdi, %rdi
je 0x2fa50
leaq 0x200557(%rip), %rsi    # 0x22ff9a
callq 0x2fdc5
testl %eax, %eax
je 0x2fcd2
movq 0x58(%rbx), %rdi
testq %rdi, %rdi
je 0x2fa6d
leaq 0x20053f(%rip), %rsi    # 0x22ff9f
callq 0x2fdc5
testl %eax, %eax
je 0x2fcd2
movq 0x50(%rbx), %rax
movq 0x58(%rbx), %rcx
testq %rax, %rax
je 0x2fb8d
testq %rcx, %rcx
je 0x2fce0
movl 0x8(%rax), %edx
cmpl 0x8(%rcx), %edx
je 0x2fb9b
callq 0x3098
jmp 0x2fcd2
callq 0x3470
jmp 0x2fcd2
callq 0x3454
jmp 0x2fcd2
callq 0x3438
jmp 0x2fcd2
callq 0x341c
jmp 0x2fcd2
callq 0x3400
jmp 0x2fcd2
callq 0x33e4
jmp 0x2fcd2
callq 0x33c8
jmp 0x2fcd2
callq 0x2ff0
jmp 0x2fcd2
callq 0x300c
jmp 0x2fcd2
callq 0x3028
jmp 0x2fcd2
callq 0x33ac
jmp 0x2fcd2
callq 0x3390
jmp 0x2fcd2
callq 0x3374
jmp 0x2fcd2
callq 0x3358
jmp 0x2fcd2
callq 0x333c
jmp 0x2fcd2
callq 0x3320
jmp 0x2fcd2
callq 0x3304
jmp 0x2fcd2
callq 0x32e8
jmp 0x2fcd2
callq 0x32c8
jmp 0x2fcd2
callq 0x32ac
jmp 0x2fcd2
callq 0x3290
jmp 0x2fcd2
callq 0x3060
jmp 0x2fcd2
callq 0x307c
jmp 0x2fcd2
callq 0x3274
jmp 0x2fcd2
xorl %r14d, %r14d
testq %rcx, %rcx
jne 0x2fd34
xorl %ecx, %ecx
movq 0x60(%rbx), %rdx
testq %rdx, %rdx
je 0x2fbae
cmpl $0x0, 0x8(%rdx)
je 0x2fcf5
testq %rax, %rax
je 0x2fbc7
cmpl $0x0, 0x8(%rax)
je 0x2fcfc
cmpl $0x0, 0x8(%rcx)
je 0x2fd0a
movq 0x68(%rbx), %rdi
testq %rdi, %rdi
je 0x2fbf9
movl 0x244(%rbx), %esi
callq 0x2fe13
xorl %r14d, %r14d
testl %eax, %eax
je 0x2fcd5
movq 0x68(%rbx), %rax
testq %rax, %rax
je 0x2fbf9
cmpl $0x0, 0x8(%rax)
je 0x2fd42
movl 0xd8(%rbx), %eax
testl %eax, %eax
js 0x2fce7
movl 0xdc(%rbx), %ecx
cmpl $-0x2, %ecx
jle 0x2fcee
xorpd %xmm0, %xmm0
ucomisd 0xe0(%rbx), %xmm0
ja 0x2fd03
cmpl $-0x1, %ecx
sete %dl
cmpl %eax, %ecx
seta %al
orb %dl, %al
je 0x2fd11
xorpd %xmm0, %xmm0
ucomiss 0x16c(%rbx), %xmm0
ja 0x2fd18
cmpl $0x0, 0xb0(%rbx)
js 0x2fd1f
cmpq $-0x2, 0x200(%rbx)
jle 0x2fd26
cmpl $0x2, 0x244(%rbx)
jae 0x2fd2d
movq 0x288(%rbx), %rbx
movl $0x1, %r14d
testq %rbx, %rbx
je 0x2fcd5
movq %rbx, %rdi
callq 0x2090
cmpq $0x20, %rax
ja 0x2fd3b
testq %rax, %rax
je 0x2fcd5
xorl %ecx, %ecx
movabsq $0x8004500080045, %rdx  # imm = 0x8004500080045
movzbl (%rbx,%rcx), %esi
addl $-0x41, %esi
cmpl $0x33, %esi
ja 0x2fd49
btq %rsi, %rdx
jae 0x2fd49
incq %rcx
cmpq %rcx, %rax
jne 0x2fca9
jmp 0x2fcd5
callq 0x3044
xorl %r14d, %r14d
movl %r14d, %eax
addq $0x8, %rsp
popq %rbx
popq %r14
retq
callq 0x30b4
jmp 0x2fcd2
callq 0x3258
jmp 0x2fcd2
callq 0x323c
jmp 0x2fcd2
callq 0x30ec
jmp 0x2fcd2
callq 0x3124
jmp 0x2fcd2
callq 0x3220
jmp 0x2fcd2
callq 0x3108
jmp 0x2fcd2
callq 0x315c
jmp 0x2fcd2
callq 0x3204
jmp 0x2fcd2
callq 0x31e8
jmp 0x2fcd2
callq 0x31cc
jmp 0x2fcd2
callq 0x3178
jmp 0x2fcd2
callq 0x30d0
jmp 0x2fcd5
callq 0x31b0
jmp 0x2fcd2
callq 0x3140
jmp 0x2fcd5
callq 0x3194
jmp 0x2fcd2