// File: 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
movq %rsp, %rbp
subq $0x120, %rsp            # imm = 0x120
movl 0x20(%rbp), %eax
movq 0x18(%rbp), %rax
movq 0x10(%rbp), %rax
movq %rdi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
movq %rdx, -0x18(%rbp)
movq %rcx, -0x20(%rbp)
movq %r8, -0x28(%rbp)
movq %r9, -0x30(%rbp)
movq $0x0, -0x70(%rbp)
movq $0x0, -0x78(%rbp)
movq -0x10(%rbp), %rax
movq %rax, -0x38(%rbp)
movq -0x38(%rbp), %rax
cmpq -0x18(%rbp), %rax
jae 0x23da08
movq -0x8(%rbp), %rax
movq 0x10(%rax), %rax
movq -0x38(%rbp), %rcx
shlq $0x5, %rcx
addq %rcx, %rax
movq (%rax), %rax
shlq %rax
movq -0x8(%rbp), %rdx
movl $0x40, %ecx
subq 0x48(%rdx), %rcx
shrq %cl, %rax
movq -0x8(%rbp), %rcx
movq 0x10(%rcx), %rcx
movq -0x38(%rbp), %rdx
shlq $0x5, %rdx
addq %rdx, %rcx
movq 0x8(%rcx), %rdx
shlq %rdx
movq -0x8(%rbp), %rsi
movl $0x40, %ecx
subq 0x48(%rsi), %rcx
shrq %cl, %rdx
movq %rdx, %rcx
cmpq %rcx, %rax
je 0x23d504
jmp 0x23d9f7
cmpl $0x0, 0x20(%rbp)
je 0x23d529
movq -0x8(%rbp), %rax
movq 0x10(%rax), %rax
movq -0x38(%rbp), %rcx
shlq $0x5, %rcx
addq %rcx, %rax
cmpq $0x0, 0x10(%rax)
jne 0x23d529
jmp 0x23d9f7
movq -0x8(%rbp), %rax
movq 0x10(%rax), %rax
movq -0x38(%rbp), %rcx
shlq $0x5, %rcx
addq %rcx, %rax
movq (%rax), %rax
movq -0x8(%rbp), %rcx
andq 0x50(%rcx), %rax
movq %rax, -0x40(%rbp)
movq -0x8(%rbp), %rax
movq 0x10(%rax), %rax
movq -0x38(%rbp), %rcx
shlq $0x5, %rcx
addq %rcx, %rax
movq (%rax), %rax
shrq $0x3f, %rax
cmpq $0x0, %rax
je 0x23d60c
movq -0x8(%rbp), %rax
movq 0x10(%rax), %rax
movq -0x38(%rbp), %rcx
shlq $0x5, %rcx
addq %rcx, %rax
movq (%rax), %rax
movq -0x8(%rbp), %rcx
andq 0x50(%rcx), %rax
addq $0x1, %rax
movq -0x8(%rbp), %rcx
movq 0x10(%rcx), %rcx
movq -0x38(%rbp), %rdx
shlq $0x5, %rdx
addq %rdx, %rcx
movq 0x18(%rcx), %rcx
shrq $0x20, %rcx
cmpq %rcx, %rax
jb 0x23d5f7
movq -0x8(%rbp), %rax
movq 0x10(%rax), %rax
movq -0x38(%rbp), %rcx
shlq $0x5, %rcx
addq %rcx, %rax
movq (%rax), %rax
movq -0x8(%rbp), %rcx
andq 0x50(%rcx), %rax
addq $0x1, %rax
movq -0x8(%rbp), %rcx
movq 0x10(%rcx), %rcx
movq -0x38(%rbp), %rdx
shlq $0x5, %rdx
addq %rdx, %rcx
movq 0x18(%rcx), %rcx
shrq $0x20, %rcx
subq %rcx, %rax
movq %rax, -0x80(%rbp)
jmp 0x23d5ff
xorl %eax, %eax
movq %rax, -0x80(%rbp)
jmp 0x23d5ff
movq -0x80(%rbp), %rax
movq %rax, -0x88(%rbp)
jmp 0x23d653
movq -0x8(%rbp), %rax
movq 0x10(%rax), %rax
movq -0x38(%rbp), %rcx
shlq $0x5, %rcx
addq %rcx, %rax
movq (%rax), %rax
movq -0x8(%rbp), %rcx
andq 0x50(%rcx), %rax
movq -0x8(%rbp), %rcx
movq 0x10(%rcx), %rcx
movq -0x38(%rbp), %rdx
shlq $0x5, %rdx
addq %rdx, %rcx
movq 0x18(%rcx), %rcx
shrq $0x20, %rcx
addq %rcx, %rax
subq $0x1, %rax
movq %rax, -0x88(%rbp)
movq -0x88(%rbp), %rax
movq %rax, -0x48(%rbp)
movq -0x8(%rbp), %rax
movq 0x10(%rax), %rax
movq -0x38(%rbp), %rcx
shlq $0x5, %rcx
addq %rcx, %rax
movq 0x8(%rax), %rax
movq -0x8(%rbp), %rcx
andq 0x50(%rcx), %rax
movq %rax, -0x50(%rbp)
movq -0x8(%rbp), %rax
movq 0x10(%rax), %rax
movq -0x38(%rbp), %rcx
shlq $0x5, %rcx
addq %rcx, %rax
movq 0x8(%rax), %rax
shrq $0x3f, %rax
cmpq $0x0, %rax
je 0x23d74a
movq -0x8(%rbp), %rax
movq 0x10(%rax), %rax
movq -0x38(%rbp), %rcx
shlq $0x5, %rcx
addq %rcx, %rax
movq 0x8(%rax), %rax
movq -0x8(%rbp), %rcx
andq 0x50(%rcx), %rax
addq $0x1, %rax
movq -0x8(%rbp), %rcx
movq 0x10(%rcx), %rcx
movq -0x38(%rbp), %rdx
shlq $0x5, %rdx
addq %rdx, %rcx
movq 0x18(%rcx), %rcx
movl %ecx, %ecx
cmpq %rcx, %rax
jb 0x23d72f
movq -0x8(%rbp), %rax
movq 0x10(%rax), %rax
movq -0x38(%rbp), %rcx
shlq $0x5, %rcx
addq %rcx, %rax
movq 0x8(%rax), %rax
movq -0x8(%rbp), %rcx
andq 0x50(%rcx), %rax
addq $0x1, %rax
movq -0x8(%rbp), %rcx
movq 0x10(%rcx), %rcx
movq -0x38(%rbp), %rdx
shlq $0x5, %rdx
addq %rdx, %rcx
movq 0x18(%rcx), %rcx
movl %ecx, %ecx
subq %rcx, %rax
movq %rax, -0x90(%rbp)
jmp 0x23d73a
xorl %eax, %eax
movq %rax, -0x90(%rbp)
jmp 0x23d73a
movq -0x90(%rbp), %rax
movq %rax, -0x98(%rbp)
jmp 0x23d790
movq -0x8(%rbp), %rax
movq 0x10(%rax), %rax
movq -0x38(%rbp), %rcx
shlq $0x5, %rcx
addq %rcx, %rax
movq 0x8(%rax), %rax
movq -0x8(%rbp), %rcx
andq 0x50(%rcx), %rax
movq -0x8(%rbp), %rcx
movq 0x10(%rcx), %rcx
movq -0x38(%rbp), %rdx
shlq $0x5, %rdx
addq %rdx, %rcx
movq 0x18(%rcx), %rcx
movl %ecx, %ecx
addq %rcx, %rax
subq $0x1, %rax
movq %rax, -0x98(%rbp)
movq -0x98(%rbp), %rax
movq %rax, -0x58(%rbp)
movq -0x40(%rbp), %rax
cmpq -0x48(%rbp), %rax
ja 0x23d7b2
movq -0x40(%rbp), %rax
movq %rax, -0xa0(%rbp)
jmp 0x23d7bd
movq -0x48(%rbp), %rax
movq %rax, -0xa0(%rbp)
movq -0xa0(%rbp), %rax
movq %rax, -0xa8(%rbp)
movq -0x50(%rbp), %rax
cmpq -0x58(%rbp), %rax
ja 0x23d7e2
movq -0x50(%rbp), %rax
movq %rax, -0xb0(%rbp)
jmp 0x23d7ed
movq -0x58(%rbp), %rax
movq %rax, -0xb0(%rbp)
movq -0xa8(%rbp), %rax
movq -0xb0(%rbp), %rcx
cmpq %rcx, %rax
ja 0x23d832
movq -0x40(%rbp), %rax
cmpq -0x48(%rbp), %rax
ja 0x23d817
movq -0x40(%rbp), %rax
movq %rax, -0xb8(%rbp)
jmp 0x23d822
movq -0x48(%rbp), %rax
movq %rax, -0xb8(%rbp)
movq -0xb8(%rbp), %rax
movq %rax, -0xc0(%rbp)
jmp 0x23d862
movq -0x50(%rbp), %rax
cmpq -0x58(%rbp), %rax
ja 0x23d849
movq -0x50(%rbp), %rax
movq %rax, -0xc8(%rbp)
jmp 0x23d854
movq -0x58(%rbp), %rax
movq %rax, -0xc8(%rbp)
movq -0xc8(%rbp), %rax
movq %rax, -0xc0(%rbp)
movq -0xc0(%rbp), %rax
movq %rax, -0x60(%rbp)
movq -0x60(%rbp), %rax
movq -0x20(%rbp), %rcx
subq $0x1, %rcx
cmpq %rcx, %rax
ja 0x23d88b
movq -0x60(%rbp), %rax
movq %rax, -0xd0(%rbp)
jmp 0x23d89a
movq -0x20(%rbp), %rax
subq $0x1, %rax
movq %rax, -0xd0(%rbp)
movq -0xd0(%rbp), %rax
movq %rax, -0x60(%rbp)
movq -0x40(%rbp), %rax
cmpq -0x48(%rbp), %rax
jb 0x23d8bc
movq -0x40(%rbp), %rax
movq %rax, -0xd8(%rbp)
jmp 0x23d8c7
movq -0x48(%rbp), %rax
movq %rax, -0xd8(%rbp)
movq -0xd8(%rbp), %rax
movq %rax, -0xe0(%rbp)
movq -0x50(%rbp), %rax
cmpq -0x58(%rbp), %rax
jb 0x23d8ec
movq -0x50(%rbp), %rax
movq %rax, -0xe8(%rbp)
jmp 0x23d8f7
movq -0x58(%rbp), %rax
movq %rax, -0xe8(%rbp)
movq -0xe0(%rbp), %rax
movq -0xe8(%rbp), %rcx
cmpq %rcx, %rax
jb 0x23d93c
movq -0x40(%rbp), %rax
cmpq -0x48(%rbp), %rax
jb 0x23d921
movq -0x40(%rbp), %rax
movq %rax, -0xf0(%rbp)
jmp 0x23d92c
movq -0x48(%rbp), %rax
movq %rax, -0xf0(%rbp)
movq -0xf0(%rbp), %rax
movq %rax, -0xf8(%rbp)
jmp 0x23d96c
movq -0x50(%rbp), %rax
cmpq -0x58(%rbp), %rax
jb 0x23d953
movq -0x50(%rbp), %rax
movq %rax, -0x100(%rbp)
jmp 0x23d95e
movq -0x58(%rbp), %rax
movq %rax, -0x100(%rbp)
movq -0x100(%rbp), %rax
movq %rax, -0xf8(%rbp)
movq -0xf8(%rbp), %rax
movq %rax, -0x68(%rbp)
movq -0x68(%rbp), %rax
movq -0x20(%rbp), %rcx
subq $0x1, %rcx
cmpq %rcx, %rax
ja 0x23d995
movq -0x68(%rbp), %rax
movq %rax, -0x108(%rbp)
jmp 0x23d9a4
movq -0x20(%rbp), %rax
subq $0x1, %rax
movq %rax, -0x108(%rbp)
movq -0x108(%rbp), %rax
addq $0x1, %rax
movq %rax, -0x68(%rbp)
movq -0x60(%rbp), %rax
cmpq -0x28(%rbp), %rax
ja 0x23d9f5
movq -0x68(%rbp), %rax
cmpq -0x30(%rbp), %rax
jb 0x23d9f5
movq -0x78(%rbp), %rax
addq $0x1, %rax
movq %rax, -0x78(%rbp)
movq -0x60(%rbp), %rax
cmpq 0x10(%rbp), %rax
jb 0x23d9f3
movq -0x68(%rbp), %rax
cmpq 0x18(%rbp), %rax
ja 0x23d9f3
movq -0x70(%rbp), %rax
addq $0x1, %rax
movq %rax, -0x70(%rbp)
jmp 0x23d9f5
jmp 0x23d9f7
movq -0x38(%rbp), %rax
addq $0x1, %rax
movq %rax, -0x38(%rbp)
jmp 0x23d496
movq 0x1865d1(%rip), %rax    # 0x3c3fe0
movq (%rax), %rdi
movq -0x70(%rbp), %rdx
movq -0x78(%rbp), %rcx
movq -0x28(%rbp), %r8
movq -0x30(%rbp), %r9
movq 0x10(%rbp), %r10
movq 0x18(%rbp), %rax
leaq 0x150b92(%rip), %rsi    # 0x38e5c3
movq %r10, (%rsp)
movq %rax, 0x8(%rsp)
movb $0x0, %al
callq 0x22a0
addq $0x120, %rsp            # imm = 0x120
popq %rbp
retq
nopw (%rax,%rax)