// File: /workspace/github_cpp_makefile_star2_O2/chhylp123[P]hifiasm/Overlaps.cpp
// Function: collect_contain(ma_hit_t_alloc*, ma_hit_t_alloc*, unsigned long, ma_sub_t*, ma_sub_t*, float)
void collect_contain(ma_hit_t_alloc* paf1, ma_hit_t_alloc* paf2, uint64_t rLen, 
ma_sub_t* max_left, ma_sub_t* max_right, float overlap_rate)
{
    long long j, new_left_e, new_right_s;
    new_left_e = max_left->e;
    new_right_s = max_right->s;
    uint32_t qs, qe;
    ma_hit_t_alloc* paf;

    if(paf1 != NULL)
    {
        paf = paf1;
        for (j = 0; j < paf->length; j++)
        {
            if(paf->buffer[j].del) continue;

            qs = Get_qs(paf->buffer[j]);
            qe = Get_qe(paf->buffer[j]);
            ///check contained overlaps
            if(qs != 0 && qe != rLen)
            {
                ///[qs, qe), [max_left.s, max_left.e)
                if(qs < max_left->e && qe > max_left->e && max_left->e - qs > (overlap_rate * (qe -qs)))
                {
                    ///if(qe > max_left->e) max_left->e = qe;
                    if(qe > max_left->e && qe > new_left_e) new_left_e = qe;
                }

                ///[qs, qe), [max_right.s, max_right.e)
                if(qs < max_right->s && qe > max_right->s && qe - max_right->s > (overlap_rate * (qe -qs)))
                {
                    ///if(qs < max_right->s) max_right->s = qs;
                    if(qs < max_right->s && qs < new_right_s) new_right_s = qs;
                }
            }
        }
    }

    if(paf2 != NULL)
    {
        paf = paf2;
        for (j = 0; j < paf->length; j++)
        {
            if(paf->buffer[j].del) continue;

            qs = Get_qs(paf->buffer[j]);
            qe = Get_qe(paf->buffer[j]);
            ///check contained overlaps
            if(qs != 0 && qe != rLen)
            {
                ///[qs, qe), [max_left.s, max_left.e)
                if(qs < max_left->e && qe > max_left->e && max_left->e - qs > (overlap_rate * (qe -qs)))
                {
                    ///if(qe > max_left->e) max_left->e = qe;
                    if(qe > max_left->e && qe > new_left_e) new_left_e = qe;
                }

                ///[qs, qe), [max_right.s, max_right.e)
                if(qs < max_right->s && qe > max_right->s && qe - max_right->s > (overlap_rate * (qe -qs)))
                {
                    ///if(qs < max_right->s) max_right->s = qs;
                    if(qs < max_right->s && qs < new_right_s) new_right_s = qs;
                }
            }
        }
    }

    max_left->e = new_left_e;
    max_right->s = new_right_s;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
movl 0x4(%rcx), %eax
movl (%r8), %r10d
andl $0x7fffffff, %r10d      # imm = 0x7FFFFFFF
testq %rdi, %rdi
je 0x6b5bc
movl 0xc(%rdi), %r9d
imulq $0x28, %r9, %rbx
xorl %r14d, %r14d
movq %rax, %r11
movq %r10, %r9
cmpq %r14, %rbx
je 0x6b5c2
movq (%rdi), %r12
cmpq $0x0, 0x18(%r12,%r14)
js 0x6b54f
movq (%r12,%r14), %r15
testl %r15d, %r15d
je 0x6b54f
movl 0x8(%r12,%r14), %r12d
cmpq %rdx, %r12
jne 0x6b555
addq $0x28, %r14
jmp 0x6b528
cmpl %r15d, %eax
jbe 0x6b58a
cmpl %eax, %r12d
jbe 0x6b58a
movq %r11, %r13
cmpq %r12, %r11
jg 0x6b56a
movq %r12, %r13
movl %eax, %ebp
subl %r15d, %ebp
cvtsi2ss %rbp, %xmm1
movl %r12d, %ebp
subl %r15d, %ebp
cvtsi2ss %rbp, %xmm2
mulss %xmm0, %xmm2
ucomiss %xmm2, %xmm1
cmovaq %r13, %r11
cmpl %r15d, %r10d
jbe 0x6b54f
cmpl %r10d, %r12d
jbe 0x6b54f
movl %r12d, %r13d
subl %r10d, %r13d
cvtsi2ss %r13, %xmm1
subl %r15d, %r12d
cvtsi2ss %r12, %xmm2
mulss %xmm0, %xmm2
ucomiss %xmm2, %xmm1
jbe 0x6b54f
movl %r15d, %r15d
cmpq %r9, %r15
cmovlq %r15, %r9
jmp 0x6b54f
movq %rax, %r11
movq %r10, %r9
testq %rsi, %rsi
je 0x6b669
movl 0xc(%rsi), %edi
imulq $0x28, %rdi, %rdi
xorl %ebx, %ebx
cmpq %rbx, %rdi
je 0x6b669
movq (%rsi), %r15
cmpq $0x0, 0x18(%r15,%rbx)
js 0x6b5fb
movq (%r15,%rbx), %r14
testl %r14d, %r14d
je 0x6b5fb
movl 0x8(%r15,%rbx), %r15d
cmpq %rdx, %r15
jne 0x6b601
addq $0x28, %rbx
jmp 0x6b5d4
cmpl %r14d, %eax
jbe 0x6b637
cmpl %eax, %r15d
jbe 0x6b637
movq %r11, %r12
cmpq %r15, %r11
jg 0x6b616
movq %r15, %r12
movl %eax, %r13d
subl %r14d, %r13d
cvtsi2ss %r13, %xmm1
movl %r15d, %r13d
subl %r14d, %r13d
cvtsi2ss %r13, %xmm2
mulss %xmm0, %xmm2
ucomiss %xmm2, %xmm1
cmovaq %r12, %r11
cmpl %r14d, %r10d
jbe 0x6b5fb
cmpl %r10d, %r15d
jbe 0x6b5fb
movl %r15d, %r12d
subl %r10d, %r12d
cvtsi2ss %r12, %xmm1
subl %r14d, %r15d
cvtsi2ss %r15, %xmm2
mulss %xmm0, %xmm2
ucomiss %xmm2, %xmm1
jbe 0x6b5fb
movl %r14d, %r14d
cmpq %r9, %r14
cmovlq %r14, %r9
jmp 0x6b5fb
movl %r11d, 0x4(%rcx)
andl $0x7fffffff, %r9d       # imm = 0x7FFFFFFF
movl $0x80000000, %eax       # imm = 0x80000000
andl (%r8), %eax
orl %r9d, %eax
movl %eax, (%r8)
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq