// File: /workspace/github_cpp_makefile_star2_O3/chhylp123[P]hifiasm/tovlp.cpp
// Function: is_hap_ovlp(ma_ug_t*, asg_t*, ma_hit_t_alloc*, R_to_U*, unsigned int*, unsigned int, unsigned int*, unsigned int)
int is_hap_ovlp(ma_ug_t *ug, asg_t *read_sg, ma_hit_t_alloc* reverse_sources, R_to_U* ruIndex, 
 uint32_t *a, uint32_t a_n, uint32_t *b, uint32_t b_n)
{
    uint32_t i, k, j, qn, tn, is_Unitig, uId, found = 0;
    ma_utg_t *u = NULL;
    for (i = 0; i < b_n; i++)
    {
        u = &(ug->u.a[b[i]]);
        for (k = 0; k < u->n; k++)
        {
            qn = (u->a[k]>>33);
            set_R_to_U(ruIndex, qn, b[i], 1, NULL);
        }
    }


    for (i = 0; i < a_n; i++)
    {
        u = &(ug->u.a[a[i]]);
        for (k = 0; k < u->n; k++)
        {
            qn = (u->a[k]>>33);
            for (j = 0; j < reverse_sources[qn].length; j++)
            {
                tn = Get_tn(reverse_sources[qn].buffer[j]);
                if(read_sg->seq[tn].del == 1)
                {
                    get_R_to_U(ruIndex, tn, &tn, &is_Unitig);
                    if(tn == (uint32_t)-1 || is_Unitig == 1 || read_sg->seq[tn].del == 1) continue;
                }

                get_R_to_U(ruIndex, tn, &uId, &is_Unitig);
                if(uId!=(uint32_t)-1 && is_Unitig == 1)
                {
                    found = 1;
                    break;
                }
            }
            if(found) break;
        }
        if(found) break;
    }




    for (i = 0; i < b_n; i++)
    {
        u = &(ug->u.a[b[i]]);
        for (k = 0; k < u->n; k++)
        {
            qn = (u->a[k]>>33);
            ruIndex->index[qn] = (uint32_t)-1;
        }
    }

    return found;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x58, %rsp
movl %r9d, 0x10(%rsp)
movq %r8, 0x50(%rsp)
movq %rcx, %rbx
movq %rdx, 0x28(%rsp)
movq %rsi, 0x30(%rsp)
movq %rdi, 0x18(%rsp)
movl 0x98(%rsp), %eax
movq 0x90(%rsp), %r12
movl %eax, %ebp
testl %eax, %eax
je 0x1996d3
xorl %r14d, %r14d
movq 0x18(%rsp), %rax
movq 0x10(%rax), %rax
movl (%r12,%r14,4), %ecx
leaq (%rcx,%rcx,4), %rcx
cmpl $0x0, 0x10(%rax,%rcx,8)
je 0x1996cb
leaq (%rax,%rcx,8), %r13
xorl %r15d, %r15d
movq 0x18(%r13), %rax
movq (%rax,%r15,8), %rsi
shrq $0x21, %rsi
movl (%r12,%r14,4), %edx
movq %rbx, %rdi
movl $0x1, %ecx
xorl %r8d, %r8d
callq 0xa27e9
incq %r15
movl 0x10(%r13), %eax
cmpq %rax, %r15
jb 0x19969f
incq %r14
cmpq %rbp, %r14
jne 0x199680
movl 0x10(%rsp), %eax
testl %eax, %eax
je 0x199807
movl %eax, %eax
movq %rax, 0x38(%rsp)
xorl %edx, %edx
movq 0x28(%rsp), %rsi
movq 0x18(%rsp), %rax
movq 0x10(%rax), %rcx
movq 0x50(%rsp), %rax
movq %rdx, 0x48(%rsp)
movl (%rax,%rdx,4), %eax
leaq (%rax,%rax,4), %rdx
movl 0x10(%rcx,%rdx,8), %eax
testl %eax, %eax
je 0x1997f4
leaq (%rcx,%rdx,8), %rdx
xorl %edi, %edi
movq %rdx, 0x40(%rsp)
movq 0x18(%rdx), %rcx
movq (%rcx,%rdi,8), %rcx
shrq $0x21, %rcx
leaq (%rcx,%rcx,2), %rcx
cmpl $0x0, 0xc(%rsi,%rcx,8)
je 0x1997e6
movq %rdi, 0x10(%rsp)
leaq (%rsi,%rcx,8), %r15
movl $0xc, %r14d
xorl %r13d, %r13d
movq (%r15), %rax
movl (%rax,%r14), %esi
movl %esi, 0xc(%rsp)
movq 0x30(%rsp), %rax
movq 0x20(%rax), %rax
cmpl $0x0, (%rax,%rsi,8)
js 0x19978a
movq %rbx, %rdi
leaq 0x24(%rsp), %rdx
leaq 0x8(%rsp), %rcx
callq 0xa3c62
cmpl $-0x1, 0x24(%rsp)
je 0x1997c0
cmpl $0x1, 0x8(%rsp)
jne 0x1997c0
jmp 0x19980b
movq %rbx, %rdi
leaq 0xc(%rsp), %rdx
leaq 0x8(%rsp), %rcx
callq 0xa3c62
movl 0xc(%rsp), %esi
movl $0xffffffff, %eax       # imm = 0xFFFFFFFF
cmpq %rax, %rsi
je 0x1997c0
cmpl $0x1, 0x8(%rsp)
je 0x1997c0
movq 0x30(%rsp), %rax
movq 0x20(%rax), %rax
cmpl $0x0, (%rax,%rsi,8)
jns 0x199765
incq %r13
movl 0xc(%r15), %eax
addq $0x28, %r14
cmpq %rax, %r13
jb 0x19974b
movq 0x40(%rsp), %rdx
movl 0x10(%rdx), %eax
movq 0x28(%rsp), %rsi
movq 0x10(%rsp), %rdi
incq %rdi
movl %eax, %ecx
cmpq %rcx, %rdi
jb 0x19971e
movq 0x48(%rsp), %rdx
incq %rdx
cmpq 0x38(%rsp), %rdx
jne 0x1996ed
xorl %eax, %eax
jmp 0x199810
movl $0x1, %eax
cmpl $0x0, 0x98(%rsp)
je 0x199867
movq 0x18(%rsp), %rcx
movq 0x10(%rcx), %rcx
xorl %edx, %edx
movl (%r12,%rdx,4), %esi
leaq (%rsi,%rsi,4), %rsi
cmpl $0x0, 0x10(%rcx,%rsi,8)
je 0x19985f
leaq (%rcx,%rsi,8), %rsi
movq 0x18(%rsi), %rdi
movq 0x8(%rbx), %r8
xorl %r9d, %r9d
movq (%rdi,%r9,8), %r10
shrq $0x21, %r10
movl $0xffffffff, (%r8,%r10,4) # imm = 0xFFFFFFFF
incq %r9
movl 0x10(%rsi), %r10d
cmpq %r10, %r9
jb 0x199843
incq %rdx
cmpq %rbp, %rdx
jne 0x199825
addq $0x58, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq