// 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, ma_utg_t*, asg_t*, unsigned long, unsigned long)
void debug_sub_cov(kvec_pe_hit *hits, uint64_t sidx, uint64_t eidx, uint64_t ulen, ma_utg_t *u, asg_t* r_g,
uint64_t rid, uint64_t i_cnt)
{
    uint64_t i, offset, beg, end, rs, re;
    uint64_t p0s, p0e, p1s, p1e, span_s, span_e, cnt = 0;
    rs = re = (uint64_t)-1;
    for (i = offset = 0; i < u->n; i++)
    {
        end = offset + ((u->a[i] != (uint64_t)-1?r_g->seq[u->a[i]>>33].len:GAP_LEN));
        offset += (u->a[i] != (uint64_t)-1? (uint32_t)u->a[i]:GAP_LEN);
        beg = offset;

        if(u->a[i] == (uint64_t)-1) beg -= GAP_LEN;
        if(end <= beg && i + 1 < u->n && u->a[i+1] == (uint64_t)-1)
        {
            end = beg + GAP_LEN;
        }
        if(rid == i)
        {
            rs = beg;
            re = end;
        }
    }

    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;
        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++;
        }
    }

    // if(cnt != i_cnt) fprintf(stderr, "cnt-%lu, i_cnt-%lu\n", cnt, i_cnt);
    fprintf(stderr, "******cnt-%lu, i_cnt-%lu\n", cnt, i_cnt);
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
movq %r9, -0x10(%rsp)
movq %rcx, -0x20(%rsp)
movq %rdx, -0x28(%rsp)
movq 0x40(%rsp), %rax
movq %rax, -0x18(%rsp)
movq 0x38(%rsp), %rax
movq %rax, -0x8(%rsp)
movl 0x10(%r8), %r14d
movabsq $-0x1, %r11
xorl %r13d, %r13d
movabsq $0x64, %r15
movq %r11, %rbp
xorl %edx, %edx
cmpq %rdx, %r14
je 0x133cc2
movq %rbp, %rcx
movq 0x18(%r8), %rax
movq (%rax,%rdx,8), %rbx
movq %r15, %rbp
cmpq $-0x1, %rbx
je 0x133c5a
movq -0x10(%rsp), %r9
movq 0x20(%r9), %r10
movq %rbx, %r12
shrq $0x21, %r12
movl (%r10,%r12,8), %ebp
andl $0x7fffffff, %ebp       # imm = 0x7FFFFFFF
cmpq $-0x1, %rbx
movl %ebx, %r12d
cmoveq %r15, %r12
leaq (%r12,%r13), %r10
cmpq $-0x1, %rbx
leaq -0x64(%r12,%r13), %rbx
cmovneq %r10, %rbx
addq %r13, %rbp
cmpq %rbx, %rbp
setbe %r13b
leaq 0x1(%rdx), %r12
cmpq %r14, %r12
setb %r9b
andb %r13b, %r9b
cmpb $0x1, %r9b
jne 0x133ca2
leaq 0x64(%rbx), %r9
cmpq $-0x1, 0x8(%rax,%rdx,8)
cmoveq %r9, %rbp
leaq -0x1(%r12), %rax
cmpq -0x8(%rsp), %rax
cmoveq %rbx, %r11
cmoveq %rbp, %rcx
movq %rcx, %rbp
movq %r10, %r13
movq %r12, %rdx
jmp 0x133c23
movq -0x20(%rsp), %r12
decq %r12
movq %rsi, %r8
shlq $0x5, %r8
orq $0x18, %r8
xorl %edx, %edx
movq -0x28(%rsp), %r13
cmpq %r13, %rsi
jae 0x133dd1
movq 0x10(%rdi), %r10
movq -0x18(%r10,%r8), %rbx
leaq (%rbx,%rbx), %r9
movb 0x48(%rdi), %al
xorl %ecx, %ecx
subb %al, %cl
shrq %cl, %r9
movq -0x10(%r10,%r8), %rax
leaq (%rax,%rax), %r14
shrq %cl, %r14
cmpq %r14, %r9
jne 0x133dc5
movq 0x50(%rdi), %r14
movq %r14, %rcx
andq %rbx, %rcx
testq %rbx, %rbx
js 0x133d34
movq (%r10,%r8), %r10
movq %r10, %r9
shrq $0x20, %r9
leaq (%rcx,%r9), %r15
decq %r15
jmp 0x133d50
leaq 0x1(%rcx), %r9
movq (%r10,%r8), %r10
movq %r10, %rbx
shrq $0x20, %rbx
subq %rbx, %r9
movl $0x0, %r15d
cmovaeq %r9, %r15
andq %rax, %r14
testq %rax, %rax
js 0x133d63
movl %r10d, %eax
addq %r14, %rax
decq %rax
jmp 0x133d76
leaq 0x1(%r14), %r9
movl %r10d, %eax
subq %rax, %r9
movl $0x0, %eax
cmovaeq %r9, %rax
cmpq %r15, %rcx
movq %r15, %r9
cmovbq %rcx, %r9
cmpq %rax, %r14
movq %rax, %r10
cmovbq %r14, %r10
cmpq %r10, %r9
cmovbq %r9, %r10
cmpq %r12, %r10
jb 0x133d99
movq %r12, %r10
cmpq %r11, %r10
ja 0x133dc5
cmpq %rax, %r14
cmovaq %r14, %rax
cmpq %r15, %rcx
cmovaq %rcx, %r15
cmpq %rax, %r15
cmovbeq %rax, %r15
cmpq %r12, %r15
jb 0x133dbb
movq %r12, %r15
incq %r15
cmpq %rbp, %r15
sbbq $-0x1, %rdx
incq %rsi
addq $0x20, %r8
jmp 0x133cdc
movq 0x11f208(%rip), %rax    # 0x252fe0
movq (%rax), %rdi
leaq 0xbb9d7(%rip), %rsi     # 0x1ef7b9
movq -0x18(%rsp), %rcx
xorl %eax, %eax
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
jmp 0x22b0