// File: /workspace/github_cpp_makefile_star2_O2/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
movq %rcx, %rbx
decq %rbx
movq %rsi, %r15
shlq $0x5, %r15
orq $0x18, %r15
xorl %r10d, %r10d
xorl %r11d, %r11d
cmpq %rdx, %rsi
jae 0x136a6e
movq 0x10(%rdi), %r13
movq -0x18(%r13,%r15), %r14
leaq (%r14,%r14), %r12
movb 0x48(%rdi), %al
xorl %ecx, %ecx
subb %al, %cl
shrq %cl, %r12
movq -0x10(%r13,%r15), %rax
leaq (%rax,%rax), %rbp
shrq %cl, %rbp
cmpq %rbp, %r12
jne 0x136a62
cmpl $0x0, 0x50(%rsp)
je 0x136999
cmpq $0x0, -0x8(%r13,%r15)
je 0x136a62
movq 0x50(%rdi), %r12
movq %r12, %rcx
andq %r14, %rcx
testq %r14, %r14
js 0x1369bc
movq (%r13,%r15), %r14
movq %r14, %r13
shrq $0x20, %r13
addq %rcx, %r13
decq %r13
jmp 0x1369d9
leaq 0x1(%rcx), %rbp
movq (%r13,%r15), %r14
movq %r14, %r13
shrq $0x20, %r13
subq %r13, %rbp
movl $0x0, %r13d
cmovaeq %rbp, %r13
andq %rax, %r12
testq %rax, %rax
js 0x1369ec
movl %r14d, %eax
addq %r12, %rax
decq %rax
jmp 0x136a00
leaq 0x1(%r12), %rbp
movl %r14d, %eax
subq %rax, %rbp
movl $0x0, %eax
cmovaeq %rbp, %rax
cmpq %rax, %r12
movq %rax, %r14
cmovbq %r12, %r14
cmovaq %r12, %rax
cmpq %r13, %rcx
movq %r13, %r12
cmovbq %rcx, %r12
cmovaq %rcx, %r13
cmpq %r14, %r12
cmovaeq %r14, %r12
cmpq %rbx, %r12
jb 0x136a2b
movq %rbx, %r12
cmpq %rax, %r13
cmovaq %r13, %rax
cmpq %rbx, %rax
jb 0x136a3a
movq %rbx, %rax
cmpq %r8, %r12
ja 0x136a62
incq %rax
cmpq %r9, %rax
jb 0x136a62
incq %r11
cmpq 0x40(%rsp), %r12
setae %cl
cmpq 0x48(%rsp), %rax
setbe %al
andb %cl, %al
movzbl %al, %eax
addq %rax, %r10
incq %rsi
addq $0x20, %r15
jmp 0x136951
movq 0x11c56b(%rip), %rax    # 0x252fe0
movq (%rax), %rdi
leaq 0xb8db4(%rip), %rsi     # 0x1ef833
movq %r10, %rdx
movq %r11, %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