// File: /workspace/github_cpp_makefile_star2_O3/chhylp123[P]hifiasm/Overlaps.cpp
// Function: if_potential_false_node(ma_hit_t_alloc*, unsigned long, ma_sub_t*, ma_sub_t*, int)
int if_potential_false_node(ma_hit_t_alloc* paf, uint64_t rLen, ma_sub_t* max_left, ma_sub_t* max_right, int if_set)
{
    max_left->s = max_right->s = rLen;
    max_left->e = max_right->e = 0;

    long long j;
    uint32_t qs, qe;
    for (j = 0; j < paf->length; j++)
    {
        if(paf->buffer[j].del) continue;
        if(paf->buffer[j].el != 1) continue;

        qs = Get_qs(paf->buffer[j]);
        qe = Get_qe(paf->buffer[j]);

        ///overlaps from left side
        if(qs == 0)
        {
            if(qs < max_left->s) max_left->s = qs;
            if(qe > max_left->e) max_left->e = qe;
        }

        ///overlaps from right side
        if(qe == rLen)
        {
            if(qs < max_right->s) max_right->s = qs;
            if(qe > max_right->e) max_right->e = qe;
        }

        ///note: if (qs == 0 && qe == rLen)
        ///this overlap would be added to both b_left and b_right
        ///that is what we want
    }

    if (max_left->e > max_right->s) return 0;

    long long new_left_e, new_right_s;
    new_left_e = max_left->e;
    new_right_s = max_right->s;

    for (j = 0; j < paf->length; j++)
    {
        if(paf->buffer[j].del) continue;
        if(paf->buffer[j].el != 1) 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)
            {
                ///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)
            {
                ///if(qs < max_right->s) max_right->s = qs;
                if(qs < max_right->s && qs < new_right_s) new_right_s = qs;
            }



            if(if_set)
            {
                max_left->e = new_left_e;
                max_right->s = new_right_s;
            }
        }
    }

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

    if (max_left->e > max_right->s) return 0;

    return 1;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
movl %esi, %eax
andl $0x7fffffff, %eax       # imm = 0x7FFFFFFF
movl $0x80000000, %r9d       # imm = 0x80000000
movl (%rcx), %r10d
andl %r9d, %r10d
orl %eax, %r10d
movl %r10d, (%rcx)
andl (%rdx), %r9d
orl %eax, %r9d
movl %r9d, (%rdx)
xorl %r9d, %r9d
movl %r9d, 0x4(%rcx)
movl %r9d, 0x4(%rdx)
cmpl %r9d, 0xc(%rdi)
je 0xb0927
movl $0x20, %eax
xorl %r9d, %r9d
movq (%rdi), %r10
cmpq $0x0, -0x8(%r10,%rax)
js 0xb0846
cmpb $0x1, (%r10,%rax)
jne 0xb0846
movl -0x20(%r10,%rax), %r11d
movl -0x18(%r10,%rax), %r10d
testl %r11d, %r11d
jne 0xb081d
movl (%rdx), %ebx
testl $0x7fffffff, %ebx       # imm = 0x7FFFFFFF
je 0xb0813
andl $0x80000000, %ebx       # imm = 0x80000000
movl %ebx, (%rdx)
cmpl 0x4(%rdx), %r10d
jbe 0xb081d
movl %r10d, 0x4(%rdx)
cmpq %rsi, %r10
jne 0xb0846
movl (%rcx), %ebx
movl %ebx, %ebp
andl $0x7fffffff, %ebp       # imm = 0x7FFFFFFF
cmpl %r11d, %ebp
jbe 0xb083c
andl $0x80000000, %ebx       # imm = 0x80000000
orl %r11d, %ebx
movl %ebx, (%rcx)
cmpl 0x4(%rcx), %r10d
jbe 0xb0846
movl %r10d, 0x4(%rcx)
incq %r9
movl 0xc(%rdi), %r11d
addq $0x28, %rax
cmpq %r11, %r9
jb 0xb07e0
movl 0x4(%rdx), %r9d
movl (%rcx), %ebx
movl %ebx, %r10d
andl $0x7fffffff, %r10d      # imm = 0x7FFFFFFF
xorl %eax, %eax
cmpl %r10d, %r9d
ja 0xb0949
testl %r11d, %r11d
je 0xb0930
movl $0x20, %eax
xorl %r14d, %r14d
movq (%rdi), %r12
cmpq $0x0, -0x8(%r12,%rax)
js 0xb090b
cmpb $0x1, (%r12,%rax)
jne 0xb090b
movq -0x20(%r12,%rax), %r15
testl %r15d, %r15d
je 0xb090b
movl -0x18(%r12,%rax), %ebp
cmpq %rsi, %rbp
je 0xb090b
movl 0x4(%rdx), %r13d
cmpq %rbp, %r9
movq %rbp, %r12
cmovgq %r9, %r12
cmpl %r13d, %ebp
cmovbeq %r9, %r12
cmpl %r15d, %r13d
cmovaq %r12, %r9
movl %r15d, %r12d
movl %ebx, %r13d
andl $0x7fffffff, %r13d      # imm = 0x7FFFFFFF
cmpq %r10, %r12
cmovgeq %r10, %r12
cmpl %r13d, %ebp
cmovbeq %r10, %r12
cmpl %r15d, %r13d
cmovaq %r12, %r10
testl %r8d, %r8d
je 0xb090b
movl %r9d, 0x4(%rdx)
movl %r10d, %r11d
andl $0x7fffffff, %r11d      # imm = 0x7FFFFFFF
movl (%rcx), %ebx
movl $0x80000000, %ebp       # imm = 0x80000000
andl %ebp, %ebx
orl %r11d, %ebx
movl %ebx, (%rcx)
movl 0xc(%rdi), %r11d
incq %r14
movl %r11d, %r15d
addq $0x28, %rax
cmpq %r15, %r14
jb 0xb0882
andl $0x7fffffff, %r10d      # imm = 0x7FFFFFFF
jmp 0xb0930
movl $0x7fffffff, %r10d      # imm = 0x7FFFFFFF
andl (%rcx), %r10d
movl %r9d, 0x4(%rdx)
movl $0x80000000, %eax       # imm = 0x80000000
andl (%rcx), %eax
orl %r10d, %eax
movl %eax, (%rcx)
xorl %eax, %eax
cmpl %r10d, 0x4(%rdx)
setbe %al
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq