// File: /workspace/github_cpp_makefile_star2_O3/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 %rdi, %r11
movq %r9, -0x28(%rsp)
movl $0x0, (%r9)
movq 0x8(%rdx), %r14
movl $0x177, %ebx            # imm = 0x177
cmpq %rbx, %r14
movl $0x177, %r12d           # imm = 0x177
cmovlq %r14, %r12
decq %r12
leaq -0x1(%r14), %r8
leaq -0x8(%rsp), %rax
movq $0x0, (%rax)
leaq 0x30(%rcx), %rax
movq %rax, -0x10(%rsp)
movl $0x1, -0x38(%rsp)
movb $0x1, %al
movl %eax, -0x34(%rsp)
xorps %xmm0, %xmm0
xorl %r9d, %r9d
xorl %esi, %esi
xorl %eax, %eax
xorl %r10d, %r10d
movq %rdi, -0x18(%rsp)
movq %r14, -0x20(%rsp)
movq %r12, %r13
movq %rsi, %rbp
cmpq %r8, %r12
jne 0x4e80d
testq %r14, %r14
je 0x4e977
cmpl $0x1, %eax
movl $0x1, %eax
je 0x4e977
leaq (%rbx,%r13), %r12
cmpq %r14, %r12
cmovgeq %r8, %r12
cmpl $-0x2, %r10d
je 0x4e977
movq -0x10(%rsp), %rdx
movaps %xmm0, (%rdx)
testq %rbp, %rbp
je 0x4e835
movq 0x48(%rcx), %r10
jmp 0x4e840
movq $0x0, 0x48(%rcx)
xorl %r10d, %r10d
movq 0x10(%r11), %rbx
cmpq %rbx, %r10
jge 0x4e86c
movq (%r11), %rdx
imulq $0xa8, %r10, %rsi
movl 0x4(%rdx,%rsi), %edi
cmpq %rdi, %r13
jge 0x4e87b
movq $0x0, 0x48(%rcx)
xorl %r10d, %r10d
jmp 0x4e914
movq %rbx, 0x48(%rcx)
movl $0xfffffffe, %r10d      # imm = 0xFFFFFFFE
jmp 0x4e914
movq %r13, %r9
subq %rbp, %r9
movq $0x0, -0x30(%rsp)
addq %rdx, %rsi
addq $0x4, %rsi
decq %rbx
xorl %r11d, %r11d
xorl %r14d, %r14d
movl (%rsi), %edx
movl 0x4(%rsi), %edi
cmpq %r13, %rdi
cmovaeq %r13, %rdi
cmpq %rbp, %rdx
movq %rbp, %r15
cmovgq %rdx, %r15
subq %r15, %rdi
js 0x4e8e7
cmpq %rdi, %r9
jne 0x4e8d5
movzbl 0x28(%rsi), %edi
leaq -0x30(%rsp), %r15
cmpl $0x1, %edi
je 0x4e8d2
cmpl $0x64, %edi
jne 0x4e8d5
leaq -0x8(%rsp), %r15
incq (%r15)
incq %r11
testq %r14, %r14
jne 0x4e8e1
movq %r10, 0x48(%rcx)
movl $0x1, %r14d
cmpq %r10, %rbx
je 0x4e8fb
incq %r10
addq $0xa8, %rsi
cmpq %rdx, %r13
jge 0x4e89a
xorl %r10d, %r10d
testq %r11, %r11
setne %r10b
movq -0x30(%rsp), %r9
movq -0x18(%rsp), %r11
movq -0x20(%rsp), %r14
movl $0x177, %ebx            # imm = 0x177
leaq (%rbx,%rbp), %rsi
cmpq $0x6, %r9
movl -0x38(%rsp), %edx
movl $0x0, %edi
cmovll %edi, %edx
movl %edx, -0x38(%rsp)
testq %r9, %r9
jne 0x4e7eb
testq %rbp, %rbp
sete %dil
cmpq %r8, %r13
sete %dl
orb %dil, %dl
movl %edx, %edi
notb %dil
orb -0x34(%rsp), %dil
testb $0x1, %dil
je 0x4e7eb
movzbl %dl, %edx
incl %edx
movq -0x28(%rsp), %rdi
movl %edx, (%rdi)
movl $0x0, -0x34(%rsp)
jmp 0x4e7eb
movl -0x38(%rsp), %eax
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq