// File: 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
movq %rsp, %rbp
subq $0xa0, %rsp
movq %rdi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
movq %rdx, -0x18(%rbp)
movq %rcx, -0x20(%rbp)
movq %r8, -0x28(%rbp)
movq %r9, -0x30(%rbp)
movl $0x1, -0x44(%rbp)
movq -0x30(%rbp), %rax
movl $0x0, (%rax)
movq -0x18(%rbp), %rax
movq 0x8(%rax), %rsi
movsd 0x346a5c(%rip), %xmm0   # 0x382000
leaq 0x38924d(%rip), %rax    # 0x3c47f8
divsd 0xc0(%rax), %xmm0
cvttsd2si %xmm0, %eax
movslq %eax, %rcx
leaq -0x80(%rbp), %rdi
movl $0x177, %edx            # imm = 0x177
callq 0x9f470
movl $0x0, -0x84(%rbp)
movq $0x0, -0x90(%rbp)
movq $0x0, -0x98(%rbp)
leaq -0x80(%rbp), %rdi
leaq -0x38(%rbp), %rsi
leaq -0x40(%rbp), %rdx
callq 0x9f520
movl %eax, %ecx
xorl %eax, %eax
cmpl $0x0, %ecx
movb %al, -0x99(%rbp)
je 0x3b618
cmpl $-0x2, -0x84(%rbp)
setne %al
movb %al, -0x99(%rbp)
movb -0x99(%rbp), %al
testb $0x1, %al
jne 0x3b627
jmp 0x3b6f9
movq -0x20(%rbp), %rax
movq $0x0, 0x30(%rax)
movq -0x20(%rbp), %rax
movq $0x0, 0x38(%rax)
movq -0x38(%rbp), %rdi
movq -0x40(%rbp), %rsi
movq -0x8(%rbp), %rdx
movq -0x20(%rbp), %rcx
leaq -0x90(%rbp), %r8
leaq -0x98(%rbp), %r9
callq 0xa0c10
movl %eax, -0x84(%rbp)
movl -0x84(%rbp), %eax
movl %eax, -0xa0(%rbp)
subl $-0x2, %eax
je 0x3b698
jmp 0x3b67b
movl -0xa0(%rbp), %eax
testl %eax, %eax
je 0x3b696
jmp 0x3b687
movl -0xa0(%rbp), %eax
subl $0x1, %eax
jne 0x3b69a
jmp 0x3b694
jmp 0x3b69a
jmp 0x3b69a
jmp 0x3b69a
cmpq $0x6, -0x90(%rbp)
jge 0x3b6ab
movl $0x0, -0x44(%rbp)
cmpq $0x0, -0x90(%rbp)
jne 0x3b6f4
cmpq $0x0, -0x38(%rbp)
je 0x3b6dd
movq -0x40(%rbp), %rax
movq -0x18(%rbp), %rcx
movq 0x8(%rcx), %rcx
subq $0x1, %rcx
cmpq %rcx, %rax
je 0x3b6dd
movq -0x30(%rbp), %rax
movl $0x1, (%rax)
jmp 0x3b6f2
movq -0x30(%rbp), %rax
cmpl $0x0, (%rax)
jne 0x3b6f0
movq -0x30(%rbp), %rax
movl $0x2, (%rax)
jmp 0x3b6f2
jmp 0x3b6f4
jmp 0x3b5e8
movl -0x44(%rbp), %eax
addq $0xa0, %rsp
popq %rbp
retq
nopw %cs:(%rax,%rax)