// File: /workspace/github_cpp_makefile_star2_O1/chhylp123[P]hifiasm/horder.cpp
// Function: debug_sub_cov(kvec_pe_hit*, unsigned long, unsigned long, unsigned long, unsigned long, unsigned long, unsigned long, unsigned long, int)
void debug_sub_cov(kvec_pe_hit *hits, uint64_t sidx, uint64_t eidx, uint64_t ulen, 
uint64_t rs, uint64_t re, uint64_t limit_s, uint64_t limit_e, int unique_only)
{
    uint64_t i, p0s, p0e, p1s, p1e, span_s, span_e, cnt = 0, cnt_no_lim = 0;


    for (i = sidx; i < eidx; i++)///keep all hic hits that contain interval we want
    {
        if(get_hit_suid(*hits, i) != get_hit_euid(*hits, i)) continue;
        if(unique_only && hits->a.a[i].id == 0) continue;
        p0s = get_hit_spos(*hits, i);
        p0e = get_hit_spos_e(*hits, i);
        p1s = get_hit_epos(*hits, i);
        p1e = get_hit_epos_e(*hits, i);

        span_s = MIN(MIN(p0s, p0e), MIN(p1s, p1e));
        span_s = MIN(span_s, ulen-1);
        span_e = MAX(MAX(p0s, p0e), MAX(p1s, p1e));
        span_e = MIN(span_e, ulen-1) + 1;

        //if(span_e - span_s <= ulen*BREAK_CUTOFF)//need it or not?
        if(span_s <= rs && span_e >= re)
        {
            cnt_no_lim++;
            if(span_s >= limit_s && span_e <= limit_e) cnt++;
        } 
    }

    fprintf(stderr, "******cnt-%lu, cnt_no_lim-%lu, rs-%lu, re-%lu, limit_s-%lu, limit_e-%lu\n", cnt, cnt_no_lim, rs, re, limit_s, limit_e);
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
pushq %rax
subq %rsi, %rdx
jbe 0x20a09
movq %rcx, %rbx
movl 0x50(%rsp), %ebp
movq 0x10(%rdi), %rax
pushq $0x40
popq %rcx
subq 0x48(%rdi), %rcx
decq %rbx
shlq $0x5, %rsi
addq %rax, %rsi
addq $0x18, %rsi
xorl %r10d, %r10d
xorl %r11d, %r11d
movq -0x18(%rsi), %r12
leaq (%r12,%r12), %r15
shrq %cl, %r15
movq -0x10(%rsi), %rax
leaq (%rax,%rax), %r13
shrq %cl, %r13
cmpq %r13, %r15
jne 0x209fa
testl %ebp, %ebp
je 0x20941
cmpq $0x0, -0x8(%rsi)
je 0x209fa
movq 0x50(%rdi), %r13
movq %r13, %r15
andq %r12, %r15
testq %r12, %r12
js 0x2095d
movl 0x4(%rsi), %r14d
leaq (%r15,%r14), %r12
decq %r12
jmp 0x20972
leaq 0x1(%r15), %r14
movl 0x4(%rsi), %r12d
subq %r12, %r14
movl $0x0, %r12d
cmovaeq %r14, %r12
andq %rax, %r13
testq %rax, %rax
js 0x20984
movl (%rsi), %eax
addq %r13, %rax
decq %rax
jmp 0x20996
leaq 0x1(%r13), %r14
movl (%rsi), %eax
subq %rax, %r14
movl $0x0, %eax
cmovaeq %r14, %rax
cmpq %rax, %r13
movq %rax, %r14
cmovbq %r13, %r14
cmovaq %r13, %rax
cmpq %r12, %r15
movq %r12, %r13
cmovbq %r15, %r13
cmovaq %r15, %r12
cmpq %r14, %r13
cmovaeq %r14, %r13
cmpq %rbx, %r13
jb 0x209c1
movq %rbx, %r13
cmpq %rax, %r12
cmovaq %r12, %rax
cmpq %rbx, %rax
jb 0x209d0
movq %rbx, %rax
cmpq %r8, %r13
ja 0x209fa
incq %rax
cmpq %r9, %rax
jb 0x209fa
incq %r10
cmpq 0x40(%rsp), %r13
setae %r14b
cmpq 0x48(%rsp), %rax
setbe %al
andb %r14b, %al
movzbl %al, %eax
addq %rax, %r11
addq $0x20, %rsi
decq %rdx
jne 0x20913
jmp 0x20a0f
xorl %r11d, %r11d
xorl %r10d, %r10d
movq 0x2695ca(%rip), %rax    # 0x289fe0
movq (%rax), %rdi
leaq 0x210d03(%rip), %rsi    # 0x231723
movq %r11, %rdx
movq %r10, %rcx
xorl %eax, %eax
pushq 0x48(%rsp)
pushq 0x48(%rsp)
callq 0x22b0
addq $0x18, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq