// File: /workspace/github_cpp_makefile_star2_O1/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
movq %r9, -0x30(%rsp)
movl $0x0, (%r9)
movq 0x8(%rdx), %r10
movl $0x177, %r13d           # imm = 0x177
cmpq %r13, %r10
movl $0x177, %r14d           # imm = 0x177
cmovlq %r10, %r14
decq %r14
leaq -0x1(%r10), %rbp
leaq 0x30(%rcx), %r8
movl $0x1, %eax
xorps %xmm0, %xmm0
xorl %r9d, %r9d
movl $0x0, -0x34(%rsp)
xorl %ebx, %ebx
xorl %r11d, %r11d
movq %rdi, -0x10(%rsp)
movq %r10, -0x18(%rsp)
movq %rbp, -0x20(%rsp)
movq %r8, -0x28(%rsp)
movq %r14, %r12
movq %r9, %r15
cmpq %rbp, %r14
jne 0x4f6ba
testq %r10, %r10
sete %dl
cmpl $0x1, -0x34(%rsp)
sete %sil
orb %dl, %sil
movl $0x1, %esi
je 0x4f6be
xorl %edx, %edx
movq %r15, %r9
movq %r12, %r14
jmp 0x4f6d3
movl -0x34(%rsp), %esi
leaq (%r15,%r13), %r9
leaq (%r12,%r13), %r14
cmpq %r10, %r14
cmovgeq %rbp, %r14
movb $0x1, %dl
movl %esi, -0x34(%rsp)
cmpl $-0x2, %r11d
je 0x4f814
testb %dl, %dl
je 0x4f814
movq %r9, -0x8(%rsp)
movaps %xmm0, (%r8)
testq %r15, %r15
jne 0x4f6fb
movq $0x0, 0x48(%rcx)
movq 0x48(%rcx), %r9
movq 0x10(%rdi), %r11
cmpq %r11, %r9
jge 0x4f72c
movq (%rdi), %rdx
imulq $0xa8, %r9, %r8
movl 0x4(%rdx,%r8), %esi
cmpq %rsi, %r12
jge 0x4f73b
movq $0x0, 0x48(%rcx)
xorl %r11d, %r11d
jmp 0x4f7c7
movq %r11, 0x48(%rcx)
movl $0xfffffffe, %r11d      # imm = 0xFFFFFFFE
jmp 0x4f7cc
movq %r12, %rsi
subq %r15, %rsi
leaq (%rdx,%r8), %r10
addq $0x4, %r10
decq %r11
xorl %ebx, %ebx
xorl %edx, %edx
xorl %ebp, %ebp
movl (%r10), %edi
movl 0x4(%r10), %r8d
cmpq %r12, %r8
cmovgeq %r12, %r8
cmpq %r15, %rdi
movq %r15, %r13
cmovgq %rdi, %r13
subq %r13, %r8
js 0x4f794
cmpq %r8, %rsi
jne 0x4f783
xorl %r8d, %r8d
cmpb $0x1, 0x28(%r10)
sete %r8b
addq %r8, %rbx
incq %rdx
testq %rbp, %rbp
jne 0x4f78f
movq %r9, 0x48(%rcx)
movl $0x1, %ebp
cmpq %r9, %r11
je 0x4f7a8
incq %r9
addq $0xa8, %r10
cmpq %rdi, %r12
jge 0x4f752
xorl %r11d, %r11d
testq %rdx, %rdx
setne %r11b
movq -0x10(%rsp), %rdi
movq -0x18(%rsp), %r10
movl $0x177, %r13d           # imm = 0x177
movq -0x20(%rsp), %rbp
movq -0x28(%rsp), %r8
cmpq $0x6, %rbx
movl $0x0, %edx
cmovll %edx, %eax
testq %rbx, %rbx
movq -0x8(%rsp), %r9
jne 0x4f68c
testq %r15, %r15
je 0x4f7f5
movl $0x1, %edx
cmpq %rbp, %r12
jne 0x4f808
movq -0x30(%rsp), %rdx
cmpl $0x0, (%rdx)
jne 0x4f68c
movl $0x2, %edx
movq -0x30(%rsp), %rsi
movl %edx, (%rsi)
jmp 0x4f68c
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq