// File: /workspace/github_cpp_makefile_star2_O2/chhylp123[P]hifiasm/Correct.cpp
// Function: check_if_fully_covered(overlap_region_alloc*, All_reads*, UC_Read*, Correct_dumy*, Graph*, int*)
int check_if_fully_covered(overlap_region_alloc* overlap_list, 
All_reads* R_INF, UC_Read* g_read, Correct_dumy* dumy, Graph* g, int* abnormal)
{
    long long window_start, window_end;
    int return_flag = 1;
    (*abnormal) = 0;
    
    Window_Pool w_inf;
    init_Window_Pool(&w_inf, g_read->length, WINDOW, (int)(1.0/asm_opt.max_ov_diff_ec));

    int flag = 0;
    long long realLen = 0, tmpLen = 0;
    while(get_Window(&w_inf, &window_start, &window_end) && flag != -2)
    {
        dumy->length = 0;
        dumy->lengthNT = 0;
        
        ///return overlaps that are overlaped with [window_start, window_end]
        flag = get_available_fully_covered_interval(window_start, window_end, 
        overlap_list, dumy, &realLen, &tmpLen);


        switch (flag)
        {
            case 1:    ///match
                break;
            case 0:    ///unmatch
                break;
            case -2: ///unmatch, and cannot match for next window
                break;
        }

        if(realLen < MIN_COVERAGE_THRESHOLD * 2)
        {
            return_flag = 0;
           //return 0;
        }

        if(realLen == 0)
        {
            ///that means this window is a middle window
            if(window_start != 0 && window_end != g_read->length - 1)
            {
                (*abnormal) = 1;
            }
            else if((*abnormal)==0)
            {
                (*abnormal) = 2;
            }
        }
    }

    return return_flag;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x68, %rsp
movq %rcx, %r14
movq %rdi, %r12
movq %r9, (%rsp)
andl $0x0, (%r9)
leaq 0x232c2c(%rip), %rax    # 0x253758
movsd 0x1c276c(%rip), %xmm0   # 0x1e32a0
divsd 0xc0(%rax), %xmm0
movq %rdx, 0x20(%rsp)
movq 0x8(%rdx), %rax
cvttsd2si %xmm0, %ecx
movslq %ecx, %rcx
leaq 0x30(%rsp), %rdi
andl $0x0, 0x30(%rdi)
movq %rax, (%rdi)
movl $0x177, %esi            # imm = 0x177
movq %rsi, 0x8(%rdi)
movq %rcx, 0x28(%rdi)
andq $0x0, 0x18(%rdi)
cmpq %rsi, %rax
movl $0x177, %ecx            # imm = 0x177
cmovlq %rax, %rcx
decq %rcx
movq %rcx, 0x20(%rdi)
addq $0x176, %rax            # imm = 0x176
cqto
idivq %rsi
movq %rax, 0x10(%rdi)
leaq 0x8(%rsp), %rax
andq $0x0, (%rax)
leaq 0x28(%rsp), %rax
andq $0x0, (%rax)
leaq 0x30(%r14), %rbx
pushq $0x1
popq %r13
leaq 0x10(%rsp), %rbp
xorl %r15d, %r15d
leaq 0x30(%rsp), %rdi
leaq 0x18(%rsp), %rsi
movq %rbp, %rdx
callq 0x52721
cmpl $-0x2, %r15d
je 0x20c44
testl %eax, %eax
je 0x20c44
xorpd %xmm0, %xmm0
movapd %xmm0, (%rbx)
movq 0x18(%rsp), %rdi
movq 0x10(%rsp), %rsi
movq %r12, %rdx
movq %r14, %rcx
leaq 0x8(%rsp), %r8
leaq 0x28(%rsp), %r9
callq 0x5320e
movl %eax, %r15d
movq 0x8(%rsp), %rax
cmpq $0x6, %rax
movl $0x0, %ecx
cmovll %ecx, %r13d
testq %rax, %rax
jne 0x20bae
cmpq $0x0, 0x18(%rsp)
je 0x20c29
movq 0x20(%rsp), %rax
movq 0x8(%rax), %rcx
decq %rcx
pushq $0x1
popq %rax
cmpq %rcx, 0x10(%rsp)
jne 0x20c39
movq (%rsp), %rax
cmpl $0x0, (%rax)
pushq $0x2
popq %rax
jne 0x20bae
movq (%rsp), %rcx
movl %eax, (%rcx)
jmp 0x20bae
movl %r13d, %eax
addq $0x68, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq