// File: /workspace/github_cpp_makefile_star2_O3/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 0x1fe2c
movq %rcx, %rbx
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), %r14
leaq (%r14,%r14), %r15
shrq %cl, %r15
movq -0x10(%rsi), %rax
leaq (%rax,%rax), %r12
shrq %cl, %r12
cmpq %r12, %r15
jne 0x1fe1d
cmpl $0x0, 0x50(%rsp)
je 0x1fd56
cmpq $0x0, -0x8(%rsi)
je 0x1fe1d
movq 0x50(%rdi), %r12
movq %r12, %r15
andq %r14, %r15
testq %r14, %r14
js 0x1fd77
movq (%rsi), %r14
movq %r14, %r13
shrq $0x20, %r13
addq %r15, %r13
decq %r13
jmp 0x1fd92
leaq 0x1(%r15), %rbp
movq (%rsi), %r14
movq %r14, %r13
shrq $0x20, %r13
subq %r13, %rbp
movl $0x0, %r13d
cmovaeq %rbp, %r13
andq %rax, %r12
testq %rax, %rax
js 0x1fda5
movl %r14d, %eax
addq %r12, %rax
decq %rax
jmp 0x1fdb9
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, %r15
movq %r13, %r12
cmovbq %r15, %r12
cmovaq %r15, %r13
cmpq %r14, %r12
cmovaeq %r14, %r12
cmpq %rbx, %r12
jb 0x1fde4
movq %rbx, %r12
cmpq %rax, %r13
cmovaq %r13, %rax
cmpq %rbx, %rax
jb 0x1fdf3
movq %rbx, %rax
cmpq %r8, %r12
ja 0x1fe1d
incq %rax
cmpq %r9, %rax
jb 0x1fe1d
incq %r10
cmpq 0x40(%rsp), %r12
setae %bpl
cmpq 0x48(%rsp), %rax
setbe %al
andb %bpl, %al
movzbl %al, %eax
addq %rax, %r11
addq $0x20, %rsi
decq %rdx
jne 0x1fd25
jmp 0x1fe32
xorl %r11d, %r11d
xorl %r10d, %r10d
movq 0x2751a7(%rip), %rax    # 0x294fe0
movq (%rax), %rdi
leaq 0x21db30(%rip), %rsi    # 0x23d973
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