// File: /workspace/github_cpp_makefile_star2_O1/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 0x3092c
movq %rdi, %rbx
cmpl $0x0, 0x4(%rdi)
je 0x3092c
cmpq $0x0, 0x10(%rbx)
je 0x30936
cmpl $0x0, 0x7c(%rbx)
jle 0x30940
cmpl $0x0, 0xf8(%rbx)
jle 0x3094a
cmpl $0x0, 0x104(%rbx)
jle 0x30954
cmpl $0x0, 0x100(%rbx)
js 0x3095e
cmpl $0x40, 0x80(%rbx)
jge 0x30968
movss 0x160(%rbx), %xmm0
xorps %xmm1, %xmm1
ucomiss %xmm0, %xmm1
ja 0x3096f
ucomiss 0x1f1b0e(%rip), %xmm0   # 0x2220c0
jae 0x3096f
movss 0x15c(%rbx), %xmm1
xorps %xmm2, %xmm2
ucomiss %xmm1, %xmm2
ja 0x30976
ucomiss 0x1f1aed(%rip), %xmm1   # 0x2220c0
jae 0x30976
ucomiss %xmm0, %xmm1
jae 0x3097d
cmpq $0x0, 0x180(%rbx)
js 0x30984
cmpq $0x0, 0x188(%rbx)
js 0x3098b
cmpl $0x0, 0x10c(%rbx)
js 0x30992
xorps %xmm0, %xmm0
ucomiss 0x158(%rbx), %xmm0
ja 0x30999
cmpl $0x0, 0x110(%rbx)
js 0x309a0
cmpl $0x0, 0x114(%rbx)
js 0x309a7
cmpl $0x0, 0x118(%rbx)
js 0x309ae
movsd 0xc0(%rbx), %xmm0
movsd 0xc8(%rbx), %xmm1
ucomisd %xmm0, %xmm1
ja 0x309b5
movsd 0x1f19b4(%rip), %xmm1   # 0x222018
ucomisd %xmm0, %xmm1
ja 0x309bc
cmpl $0x0, 0x11c(%rbx)
js 0x309c3
cmpl $0x4, 0x130(%rbx)
jae 0x309ca
movq 0x20(%rbx), %rdi
testq %rdi, %rdi
je 0x30698
cmpq $0x0, 0x28(%rbx)
jne 0x306a6
cmpq $0x0, 0x30(%rbx)
je 0x306b3
cmpq $0x0, 0x38(%rbx)
je 0x306b3
cmpl $0x2, 0x134(%rbx)
jae 0x309e6
cmpl $-0x2, 0x144(%rbx)
jle 0x309d1
cmpl $-0x2, 0x14c(%rbx)
jle 0x309d8
cmpl $0x65, 0x150(%rbx)
jae 0x309df
testq %rdi, %rdi
je 0x306f3
leaq 0x1f388e(%rip), %rsi    # 0x223f74
callq 0x30a71
testl %eax, %eax
je 0x309eb
movq 0x28(%rbx), %rdi
testq %rdi, %rdi
je 0x30710
leaq 0x1f3876(%rip), %rsi    # 0x223f79
callq 0x30a71
testl %eax, %eax
je 0x309eb
movq 0x30(%rbx), %rdi
testq %rdi, %rdi
je 0x3072d
leaq 0x1f385e(%rip), %rsi    # 0x223f7e
callq 0x30a71
testl %eax, %eax
je 0x309eb
movq 0x38(%rbx), %rdi
testq %rdi, %rdi
je 0x3074a
leaq 0x1f3847(%rip), %rsi    # 0x223f84
callq 0x30a71
testl %eax, %eax
je 0x309eb
movq 0x18(%rbx), %rdi
testq %rdi, %rdi
je 0x30767
leaq 0x20d7f5(%rip), %rsi    # 0x23df4f
callq 0x30a71
testl %eax, %eax
je 0x309eb
movq 0x50(%rbx), %rdi
testq %rdi, %rdi
je 0x30784
leaq 0x1f3813(%rip), %rsi    # 0x223f8a
callq 0x30ae6
testl %eax, %eax
je 0x309eb
movq 0x58(%rbx), %rdi
testq %rdi, %rdi
je 0x307a1
leaq 0x1f37fb(%rip), %rsi    # 0x223f8f
callq 0x30ae6
testl %eax, %eax
je 0x309eb
movq 0x50(%rbx), %rax
testq %rax, %rax
je 0x307b5
cmpq $0x0, 0x58(%rbx)
je 0x309fe
testq %rax, %rax
setne %dl
movq 0x58(%rbx), %rcx
testq %rcx, %rcx
sete %sil
orb %dl, %sil
je 0x309f7
testq %rcx, %rcx
sete %dl
testq %rax, %rax
sete %sil
orb %dl, %sil
jne 0x307ed
movl 0x8(%rax), %edx
cmpl 0x8(%rcx), %edx
jne 0x30a3d
movq 0x60(%rbx), %rdx
testq %rdx, %rdx
je 0x30800
cmpl $0x0, 0x8(%rdx)
je 0x30a0c
testq %rax, %rax
je 0x3080f
cmpl $0x0, 0x8(%rax)
je 0x30a1a
testq %rcx, %rcx
je 0x3081e
cmpl $0x0, 0x8(%rcx)
je 0x30a28
movq 0x68(%rbx), %rdi
testq %rdi, %rdi
je 0x3083a
movl 0x244(%rbx), %esi
callq 0x30b34
testl %eax, %eax
je 0x309eb
movq 0x68(%rbx), %rax
testq %rax, %rax
je 0x3084d
cmpl $0x0, 0x8(%rax)
je 0x30a59
movl 0xd8(%rbx), %eax
testl %eax, %eax
js 0x30a05
movl 0xdc(%rbx), %ecx
cmpl $-0x2, %ecx
jle 0x30a13
xorpd %xmm0, %xmm0
ucomisd 0xe0(%rbx), %xmm0
ja 0x30a21
cmpl $-0x1, %ecx
sete %dl
cmpl %eax, %ecx
setg %al
orb %dl, %al
je 0x30a2f
xorpd %xmm0, %xmm0
ucomiss 0x16c(%rbx), %xmm0
ja 0x30a36
cmpl $0x0, 0xb0(%rbx)
js 0x30a44
cmpq $-0x2, 0x200(%rbx)
jle 0x30a4b
cmpl $0x2, 0x244(%rbx)
jae 0x30a52
movq 0x288(%rbx), %r14
movl $0x1, %ebx
testq %r14, %r14
je 0x309ed
movq %r14, %rdi
callq 0x2090
cmpq $0x20, %rax
ja 0x30a60
testq %rax, %rax
je 0x309ed
xorl %ecx, %ecx
movabsq $0x8004500080045, %rdx  # imm = 0x8004500080045
movzbl (%r14,%rcx), %esi
addl $-0x41, %esi
cmpl $0x33, %esi
ja 0x30a67
btq %rsi, %rdx
jae 0x30a67
incq %rcx
cmpq %rcx, %rax
jne 0x30904
jmp 0x309ed
callq 0x3475
jmp 0x309eb
callq 0x3459
jmp 0x309eb
callq 0x343d
jmp 0x309eb
callq 0x3421
jmp 0x309eb
callq 0x3405
jmp 0x309eb
callq 0x33e9
jmp 0x309eb
callq 0x33cd
jmp 0x309eb
callq 0x2ff5
jmp 0x309eb
callq 0x3011
jmp 0x309eb
callq 0x302d
jmp 0x309eb
callq 0x33b1
jmp 0x309eb
callq 0x3395
jmp 0x309eb
callq 0x3379
jmp 0x309eb
callq 0x335d
jmp 0x309eb
callq 0x3341
jmp 0x309eb
callq 0x3325
jmp 0x309eb
callq 0x3309
jmp 0x309eb
callq 0x32ed
jmp 0x309eb
callq 0x32cd
jmp 0x309eb
callq 0x32b1
jmp 0x309eb
callq 0x3295
jmp 0x309eb
callq 0x3065
jmp 0x309eb
callq 0x3081
jmp 0x309eb
callq 0x3279
jmp 0x309eb
callq 0x3049
xorl %ebx, %ebx
movl %ebx, %eax
addq $0x8, %rsp
popq %rbx
popq %r14
retq
callq 0x30b9
jmp 0x309eb
callq 0x309d
jmp 0x309eb
callq 0x325d
jmp 0x309eb
callq 0x30f1
jmp 0x309eb
callq 0x3241
jmp 0x309eb
callq 0x310d
jmp 0x309eb
callq 0x3225
jmp 0x309eb
callq 0x3129
jmp 0x309eb
callq 0x3161
jmp 0x309eb
callq 0x3209
jmp 0x309eb
callq 0x30d5
jmp 0x309eb
callq 0x31ed
jmp 0x309eb
callq 0x31d1
jmp 0x309eb
callq 0x317d
jmp 0x309eb
callq 0x3145
jmp 0x309eb
callq 0x31b5
jmp 0x309eb
callq 0x3199
jmp 0x309eb