// File: chhylp123[P]hifiasm/Correct.cpp
// Function: get_available_fully_covered_interval(long long, long long, overlap_region_alloc*, Correct_dumy*, long long*, long long*)
inline int get_available_fully_covered_interval(long long window_start, long long window_end, 
overlap_region_alloc* overlap_list, Correct_dumy* dumy, long long* real_length, long long* real_length_100)
{
    long long i, fud = 0;
    long long Len;
    long long overlap_length;

    if(window_start == 0) dumy->start_i = 0;
    for (i = dumy->start_i; i < (long long)overlap_list->length; i++)
    {
        if (window_end < (long long)overlap_list->list[i].x_pos_s)
        {
            dumy->start_i = 0;
            return 0;
        }
        else 
        {
            dumy->start_i = i;
            break;
        }
    }


    if (i >= (long long)overlap_list->length)
    {
        dumy->start_i = overlap_list->length;
        return -2;
    }
    



    
    long long fake_length = 0;
    overlap_length = window_end - window_start + 1;
    (*real_length) = 0; fud = 0;

    for (; i < (long long)overlap_list->length; i++)
    {
        if((Len = OVERLAP(window_start, window_end, (long long)overlap_list->list[i].x_pos_s, (long long)overlap_list->list[i].x_pos_e)) > 0)
        {
            fake_length++;

            if (overlap_length == Len && overlap_list->list[i].is_match == 1)
            {
                (*real_length)++;
            }

            if (overlap_length == Len && overlap_list->list[i].is_match == 100)
            {
                (*real_length_100)++;
            }
            if(fud == 0) fud = 1, dumy->start_i = i;
        }
        
        if((long long)overlap_list->list[i].x_pos_s > window_end)
        {
            break;
        }
    }

    if (fake_length == 0)
    {
        return 0;
    }
    else
    {
        return 1;
    }
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
movq %rdi, -0x10(%rbp)
movq %rsi, -0x18(%rbp)
movq %rdx, -0x20(%rbp)
movq %rcx, -0x28(%rbp)
movq %r8, -0x30(%rbp)
movq %r9, -0x38(%rbp)
movq $0x0, -0x48(%rbp)
cmpq $0x0, -0x10(%rbp)
jne 0xa0c47
movq -0x28(%rbp), %rax
movq $0x0, 0x48(%rax)
movq -0x28(%rbp), %rax
movq 0x48(%rax), %rax
movq %rax, -0x40(%rbp)
movq -0x40(%rbp), %rax
movq -0x20(%rbp), %rcx
cmpq 0x10(%rcx), %rax
jge 0xa0ca3
movq -0x18(%rbp), %rax
movq -0x20(%rbp), %rcx
movq (%rcx), %rcx
imulq $0xa8, -0x40(%rbp), %rdx
addq %rdx, %rcx
movl 0x4(%rcx), %ecx
cmpq %rcx, %rax
jge 0xa0c97
movq -0x28(%rbp), %rax
movq $0x0, 0x48(%rax)
movl $0x0, -0x4(%rbp)
jmp 0xa0e87
movq -0x40(%rbp), %rcx
movq -0x28(%rbp), %rax
movq %rcx, 0x48(%rax)
movq -0x40(%rbp), %rax
movq -0x20(%rbp), %rcx
cmpq 0x10(%rcx), %rax
jl 0xa0ccd
movq -0x20(%rbp), %rax
movq 0x10(%rax), %rcx
movq -0x28(%rbp), %rax
movq %rcx, 0x48(%rax)
movl $0xfffffffe, -0x4(%rbp) # imm = 0xFFFFFFFE
jmp 0xa0e87
movq $0x0, -0x60(%rbp)
movq -0x18(%rbp), %rax
subq -0x10(%rbp), %rax
addq $0x1, %rax
movq %rax, -0x58(%rbp)
movq -0x30(%rbp), %rax
movq $0x0, (%rax)
movq $0x0, -0x48(%rbp)
movq -0x40(%rbp), %rax
movq -0x20(%rbp), %rcx
cmpq 0x10(%rcx), %rax
jge 0xa0e70
movq -0x18(%rbp), %rax
movq -0x20(%rbp), %rcx
movq (%rcx), %rcx
imulq $0xa8, -0x40(%rbp), %rdx
addq %rdx, %rcx
movl 0x8(%rcx), %ecx
cmpq %rcx, %rax
jg 0xa0d32
movq -0x18(%rbp), %rax
movq %rax, -0x68(%rbp)
jmp 0xa0d4b
movq -0x20(%rbp), %rax
movq (%rax), %rax
imulq $0xa8, -0x40(%rbp), %rcx
addq %rcx, %rax
movl 0x8(%rax), %eax
movq %rax, -0x68(%rbp)
movq -0x68(%rbp), %rax
movq %rax, -0x70(%rbp)
movq -0x10(%rbp), %rax
movq -0x20(%rbp), %rcx
movq (%rcx), %rcx
imulq $0xa8, -0x40(%rbp), %rdx
addq %rdx, %rcx
movl 0x4(%rcx), %ecx
cmpq %rcx, %rax
jl 0xa0d7b
movq -0x10(%rbp), %rax
movq %rax, -0x78(%rbp)
jmp 0xa0d94
movq -0x20(%rbp), %rax
movq (%rax), %rax
imulq $0xa8, -0x40(%rbp), %rcx
addq %rcx, %rax
movl 0x4(%rax), %eax
movq %rax, -0x78(%rbp)
movq -0x70(%rbp), %rax
movq -0x78(%rbp), %rcx
subq %rcx, %rax
addq $0x1, %rax
movq %rax, -0x50(%rbp)
cmpq $0x0, %rax
jle 0xa0e40
movq -0x60(%rbp), %rax
addq $0x1, %rax
movq %rax, -0x60(%rbp)
movq -0x58(%rbp), %rax
cmpq -0x50(%rbp), %rax
jne 0xa0df0
movq -0x20(%rbp), %rax
movq (%rax), %rax
imulq $0xa8, -0x40(%rbp), %rcx
addq %rcx, %rax
movzbl 0x2c(%rax), %eax
cmpl $0x1, %eax
jne 0xa0df0
movq -0x30(%rbp), %rax
movq (%rax), %rcx
addq $0x1, %rcx
movq %rcx, (%rax)
movq -0x58(%rbp), %rax
cmpq -0x50(%rbp), %rax
jne 0xa0e23
movq -0x20(%rbp), %rax
movq (%rax), %rax
imulq $0xa8, -0x40(%rbp), %rcx
addq %rcx, %rax
movzbl 0x2c(%rax), %eax
cmpl $0x64, %eax
jne 0xa0e23
movq -0x38(%rbp), %rax
movq (%rax), %rcx
addq $0x1, %rcx
movq %rcx, (%rax)
cmpq $0x0, -0x48(%rbp)
jne 0xa0e3e
movq $0x1, -0x48(%rbp)
movq -0x40(%rbp), %rcx
movq -0x28(%rbp), %rax
movq %rcx, 0x48(%rax)
jmp 0xa0e40
movq -0x20(%rbp), %rax
movq (%rax), %rax
imulq $0xa8, -0x40(%rbp), %rcx
addq %rcx, %rax
movl 0x4(%rax), %eax
cmpq -0x18(%rbp), %rax
jle 0xa0e5d
jmp 0xa0e70
jmp 0xa0e5f
movq -0x40(%rbp), %rax
addq $0x1, %rax
movq %rax, -0x40(%rbp)
jmp 0xa0cf8
cmpq $0x0, -0x60(%rbp)
jne 0xa0e80
movl $0x0, -0x4(%rbp)
jmp 0xa0e87
movl $0x1, -0x4(%rbp)
movl -0x4(%rbp), %eax
popq %rbp
retq
nopl (%rax)