// File: /workspace/github_cpp_makefile_star2_O3/chhylp123[P]hifiasm/Overlaps.cpp
// Function: ovlp_rocc(u_trans_t*, ma_ug_t*, asg_t*, double, unsigned int)
uint32_t ovlp_rocc(u_trans_t *p, ma_ug_t *ug, asg_t *rg, double cov_rate, uint32_t cov_cutoff)
{
    ma_utg_t *u = NULL; uint32_t s, e, rs, re, occ, k, l;
    u = &(ug->u.a[p->qn]); s = p->qs; e = p->qe;
    if((e-s) >= (u->len*cov_rate)) return 1;
    for (k = l = occ = 0; k < u->n && occ < cov_cutoff; k++) {
        rs = l; re = l + rg->seq[u->a[k]>>33].len;
        if(rs >= e) break;
        if(s <= rs && e >= re) occ++;
        l += (uint32_t)u->a[k];
    }
    if(occ >= cov_cutoff) return 1;

    u = &(ug->u.a[p->tn]); s = p->ts; e = p->te;
    if((e-s) >= (u->len*cov_rate)) return 1;
    for (k = l = occ = 0; k < u->n && occ < cov_cutoff; k++) {
        rs = l; re = l + rg->seq[u->a[k]>>33].len;
        if(rs >= e) break;
        if(s <= rs && e >= re) occ++;
        l += (uint32_t)u->a[k];
    }
    if(occ >= cov_cutoff) return 1;
    return 0;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
movq 0x10(%rsi), %r8
movl 0x8(%rdi), %eax
leaq (%rax,%rax,4), %rsi
movl (%rdi), %r9d
movl 0x4(%rdi), %r10d
movl %r10d, %eax
subl %r9d, %eax
cvtsi2sd %rax, %xmm1
movl $0x7fffffff, %eax       # imm = 0x7FFFFFFF
andl (%r8,%rsi,8), %eax
cvtsi2sd %eax, %xmm2
mulsd %xmm0, %xmm2
movl $0x1, %eax
ucomisd %xmm2, %xmm1
jae 0xc3e17
movq %rdx, -0x10(%rsp)
movq %r8, -0x8(%rsp)
leaq (%r8,%rsi,8), %r8
movl 0x10(%r8), %r11d
testq %r11, %r11
setne %bl
testl %ecx, %ecx
setne %sil
testl %r10d, %r10d
setne %bpl
andb %sil, %bpl
andb %bl, %bpl
movl %esi, %r12d
cmpb $0x1, %bpl
jne 0xc3d43
movq -0x10(%rsp), %rdx
movq 0x20(%rdx), %rbx
movq 0x18(%r8), %r14
xorl %ebp, %ebp
movl $0x1, %r15d
xorl %r8d, %r8d
movl %r8d, %r12d
movq -0x8(%r14,%r15,8), %r13
movq %r13, %r8
shrq $0x21, %r8
movl (%rbx,%r8,8), %r8d
andl $0x7fffffff, %r8d       # imm = 0x7FFFFFFF
addl %ebp, %r8d
cmpl %ebp, %r9d
setbe %dl
cmpl %r8d, %r10d
setae %r8b
andb %dl, %r8b
movzbl %r8b, %r8d
addl %r12d, %r8d
cmpl %ecx, %r8d
setb %r12b
cmpq %r11, %r15
jae 0xc3d43
cmpl %ecx, %r8d
jae 0xc3d43
addl %r13d, %ebp
incq %r15
cmpl %r10d, %ebp
jb 0xc3cf3
testb %r12b, %r12b
je 0xc3e17
movl 0x14(%rdi), %edx
leaq (%rdx,%rdx,4), %r8
movl 0xc(%rdi), %r9d
movl 0x10(%rdi), %edi
movl %edi, %edx
subl %r9d, %edx
xorps %xmm1, %xmm1
cvtsi2sd %rdx, %xmm1
movl $0x7fffffff, %edx       # imm = 0x7FFFFFFF
movq -0x8(%rsp), %r10
andl (%r10,%r8,8), %edx
xorps %xmm2, %xmm2
cvtsi2sd %edx, %xmm2
mulsd %xmm0, %xmm2
ucomisd %xmm2, %xmm1
jae 0xc3e17
leaq (%r10,%r8,8), %r8
testl %ecx, %ecx
sete %dl
movl 0x10(%r8), %eax
testq %rax, %rax
sete %r10b
testl %edi, %edi
sete %r11b
orb %dl, %r11b
orb %r10b, %r11b
jne 0xc3e0f
movq -0x10(%rsp), %rdx
movq 0x20(%rdx), %rdx
movq 0x18(%r8), %r8
xorl %r10d, %r10d
movl $0x1, %r11d
xorl %ebp, %ebp
movl %ebp, %esi
movq -0x8(%r8,%r11,8), %rbx
movq %rbx, %r14
shrq $0x21, %r14
movl (%rdx,%r14,8), %ebp
andl $0x7fffffff, %ebp       # imm = 0x7FFFFFFF
addl %r10d, %ebp
cmpl %r10d, %r9d
setbe %r14b
cmpl %ebp, %edi
setae %bpl
andb %r14b, %bpl
movzbl %bpl, %ebp
addl %esi, %ebp
cmpl %ecx, %ebp
setb %sil
cmpq %rax, %r11
jae 0xc3e0f
cmpl %ecx, %ebp
jae 0xc3e0f
addl %ebx, %r10d
incq %r11
cmpl %edi, %r10d
jb 0xc3dc4
xorb $0x1, %sil
movzbl %sil, %eax
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq