// File: chhylp123[P]hifiasm/ecovlp.cpp
// Function: is_uncorrected_read(overlap_region_alloc*, asg64_v*, long, long)
uint32_t is_uncorrected_read(overlap_region_alloc* ov, asg64_v *idx, int64_t len, int64_t min_len)
{
    uint64_t k, s, e; int64_t dp, old_dp, st = 0, ed;
    for (k = idx->n = 0; k < ov->length; k++) {
        s = ov->list[k].x_pos_s; e = ov->list[k].x_pos_e + 1;
        kv_push(uint64_t, (*idx), (s<<1));
        kv_push(uint64_t, (*idx), (e<<1)|1);
    }

    radix_sort_ec64(idx->a, idx->a + idx->n);
    for (k = 0, dp = 0, st = ed = 0; k < idx->n; ++k) {
        old_dp = dp;
        ///if a[j] is qe
        if (idx->a[k]&1) --dp;
        else ++dp;

        ed = idx->a[k]>>1;
        if(ed > st) {
            if(old_dp == 0) {
                if((ed - st) >= min_len) return 1;
            }
        }
        st = ed;
    }


    ed = len; old_dp = dp;
    if(ed > st) {
        if(old_dp == 0) {
            if((ed - st) >= min_len) return 1;
            if((ed - st) >= len) return 1;
        }
    }
    
    return 0;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x70, %rsp
movq %rdi, -0x10(%rbp)
movq %rsi, -0x18(%rbp)
movq %rdx, -0x20(%rbp)
movq %rcx, -0x28(%rbp)
movq $0x0, -0x58(%rbp)
movq -0x18(%rbp), %rax
movq $0x0, (%rax)
movq $0x0, -0x30(%rbp)
movq -0x30(%rbp), %rax
movq -0x10(%rbp), %rcx
cmpq 0x10(%rcx), %rax
jae 0x258e7d
movq -0x10(%rbp), %rax
movq (%rax), %rax
imulq $0xa8, -0x30(%rbp), %rcx
addq %rcx, %rax
movl 0x4(%rax), %eax
movq %rax, -0x38(%rbp)
movq -0x10(%rbp), %rax
movq (%rax), %rax
imulq $0xa8, -0x30(%rbp), %rcx
addq %rcx, %rax
movl 0x8(%rax), %eax
addl $0x1, %eax
movl %eax, %eax
movq %rax, -0x40(%rbp)
movq -0x18(%rbp), %rax
movq (%rax), %rax
movq -0x18(%rbp), %rcx
cmpq 0x8(%rcx), %rax
jne 0x258db4
movq -0x18(%rbp), %rax
cmpq $0x0, 0x8(%rax)
je 0x258d79
movq -0x18(%rbp), %rax
movq 0x8(%rax), %rax
shlq %rax
movq %rax, -0x68(%rbp)
jmp 0x258d84
movl $0x2, %eax
movq %rax, -0x68(%rbp)
jmp 0x258d84
movq -0x68(%rbp), %rcx
movq -0x18(%rbp), %rax
movq %rcx, 0x8(%rax)
movq -0x18(%rbp), %rax
movq 0x10(%rax), %rdi
movq -0x18(%rbp), %rax
movq 0x8(%rax), %rsi
shlq $0x3, %rsi
callq 0x2360
movq %rax, %rcx
movq -0x18(%rbp), %rax
movq %rcx, 0x10(%rax)
movq -0x38(%rbp), %rdx
shlq %rdx
movq -0x18(%rbp), %rax
movq 0x10(%rax), %rax
movq -0x18(%rbp), %rsi
movq (%rsi), %rcx
movq %rcx, %rdi
addq $0x1, %rdi
movq %rdi, (%rsi)
movq %rdx, (%rax,%rcx,8)
jmp 0x258dda
movq -0x18(%rbp), %rax
movq (%rax), %rax
movq -0x18(%rbp), %rcx
cmpq 0x8(%rcx), %rax
jne 0x258e42
movq -0x18(%rbp), %rax
cmpq $0x0, 0x8(%rax)
je 0x258e07
movq -0x18(%rbp), %rax
movq 0x8(%rax), %rax
shlq %rax
movq %rax, -0x70(%rbp)
jmp 0x258e12
movl $0x2, %eax
movq %rax, -0x70(%rbp)
jmp 0x258e12
movq -0x70(%rbp), %rcx
movq -0x18(%rbp), %rax
movq %rcx, 0x8(%rax)
movq -0x18(%rbp), %rax
movq 0x10(%rax), %rdi
movq -0x18(%rbp), %rax
movq 0x8(%rax), %rsi
shlq $0x3, %rsi
callq 0x2360
movq %rax, %rcx
movq -0x18(%rbp), %rax
movq %rcx, 0x10(%rax)
movq -0x40(%rbp), %rdx
shlq %rdx
orq $0x1, %rdx
movq -0x18(%rbp), %rax
movq 0x10(%rax), %rax
movq -0x18(%rbp), %rsi
movq (%rsi), %rcx
movq %rcx, %rdi
addq $0x1, %rdi
movq %rdi, (%rsi)
movq %rdx, (%rax,%rcx,8)
jmp 0x258e6c
movq -0x30(%rbp), %rax
addq $0x1, %rax
movq %rax, -0x30(%rbp)
jmp 0x258d03
movq -0x18(%rbp), %rax
movq 0x10(%rax), %rdi
movq -0x18(%rbp), %rax
movq 0x10(%rax), %rsi
movq -0x18(%rbp), %rax
movq (%rax), %rax
shlq $0x3, %rax
addq %rax, %rsi
callq 0x24aba0
movq $0x0, -0x30(%rbp)
movq $0x0, -0x48(%rbp)
movq $0x0, -0x60(%rbp)
movq $0x0, -0x58(%rbp)
movq -0x30(%rbp), %rax
movq -0x18(%rbp), %rcx
cmpq (%rcx), %rax
jae 0x258f69
movq -0x48(%rbp), %rax
movq %rax, -0x50(%rbp)
movq -0x18(%rbp), %rax
movq 0x10(%rax), %rax
movq -0x30(%rbp), %rcx
movq (%rax,%rcx,8), %rax
andq $0x1, %rax
cmpq $0x0, %rax
je 0x258f01
movq -0x48(%rbp), %rax
addq $-0x1, %rax
movq %rax, -0x48(%rbp)
jmp 0x258f0d
movq -0x48(%rbp), %rax
addq $0x1, %rax
movq %rax, -0x48(%rbp)
movq -0x18(%rbp), %rax
movq 0x10(%rax), %rax
movq -0x30(%rbp), %rcx
movq (%rax,%rcx,8), %rax
shrq %rax
movq %rax, -0x60(%rbp)
movq -0x60(%rbp), %rax
cmpq -0x58(%rbp), %rax
jle 0x258f50
cmpq $0x0, -0x50(%rbp)
jne 0x258f4e
movq -0x60(%rbp), %rax
subq -0x58(%rbp), %rax
cmpq -0x28(%rbp), %rax
jl 0x258f4c
movl $0x1, -0x4(%rbp)
jmp 0x258fc3
jmp 0x258f4e
jmp 0x258f50
movq -0x60(%rbp), %rax
movq %rax, -0x58(%rbp)
movq -0x30(%rbp), %rax
addq $0x1, %rax
movq %rax, -0x30(%rbp)
jmp 0x258ec0
movq -0x20(%rbp), %rax
movq %rax, -0x60(%rbp)
movq -0x48(%rbp), %rax
movq %rax, -0x50(%rbp)
movq -0x60(%rbp), %rax
cmpq -0x58(%rbp), %rax
jle 0x258fbc
cmpq $0x0, -0x50(%rbp)
jne 0x258fba
movq -0x60(%rbp), %rax
subq -0x58(%rbp), %rax
cmpq -0x28(%rbp), %rax
jl 0x258fa1
movl $0x1, -0x4(%rbp)
jmp 0x258fc3
movq -0x60(%rbp), %rax
subq -0x58(%rbp), %rax
cmpq -0x20(%rbp), %rax
jl 0x258fb8
movl $0x1, -0x4(%rbp)
jmp 0x258fc3
jmp 0x258fba
jmp 0x258fbc
movl $0x0, -0x4(%rbp)
movl -0x4(%rbp), %eax
addq $0x70, %rsp
popq %rbp
retq
nopl (%rax)