// File: /workspace/github_cpp_makefile_star2_O1/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, 0x48(%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 0x190918
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 0x190910
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 0xa1cd4
incq %r15
movl 0x10(%r13), %eax
cmpq %rax, %r15
jb 0x1908e4
incq %r14
cmpq %rbp, %r14
jne 0x1908c5
movl 0x10(%rsp), %eax
testl %eax, %eax
je 0x190a4a
movl %eax, %eax
movq %rax, 0x38(%rsp)
xorl %edx, %edx
movq 0x18(%rsp), %rax
movq 0x10(%rax), %rax
movq 0x48(%rsp), %rcx
movq %rdx, 0x40(%rsp)
movl (%rcx,%rdx,4), %ecx
leaq (%rcx,%rcx,4), %rcx
cmpl $0x0, 0x10(%rax,%rcx,8)
je 0x190a37
leaq (%rax,%rcx,8), %rcx
xorl %edx, %edx
movq %rcx, 0x50(%rsp)
movq 0x18(%rcx), %rax
movq %rdx, 0x10(%rsp)
movq (%rax,%rdx,8), %rax
shrq $0x21, %rax
leaq (%rax,%rax,2), %rax
movq 0x28(%rsp), %rcx
cmpl $0x0, 0xc(%rcx,%rax,8)
je 0x190a1e
movq 0x28(%rsp), %rcx
leaq (%rcx,%rax,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 0x1909d4
movl 0xc(%rsp), %esi
movq %rbx, %rdi
leaq 0x24(%rsp), %rdx
leaq 0x8(%rsp), %rcx
callq 0xa306f
cmpl $-0x1, 0x24(%rsp)
je 0x190a0a
cmpl $0x1, 0x8(%rsp)
jne 0x190a0a
jmp 0x190a4e
movq %rbx, %rdi
leaq 0xc(%rsp), %rdx
leaq 0x8(%rsp), %rcx
callq 0xa306f
movl 0xc(%rsp), %eax
movl $0xffffffff, %ecx       # imm = 0xFFFFFFFF
cmpq %rcx, %rax
je 0x190a0a
cmpl $0x1, 0x8(%rsp)
je 0x190a0a
movq 0x30(%rsp), %rcx
movq 0x20(%rcx), %rcx
cmpl $0x0, (%rcx,%rax,8)
jns 0x1909ae
incq %r13
movl 0xc(%r15), %eax
addq $0x28, %r14
cmpq %rax, %r13
jb 0x190994
movq 0x10(%rsp), %rdx
incq %rdx
movq 0x50(%rsp), %rcx
movl 0x10(%rcx), %eax
cmpq %rax, %rdx
jb 0x19095d
movq 0x40(%rsp), %rdx
incq %rdx
cmpq 0x38(%rsp), %rdx
jne 0x19092d
xorl %eax, %eax
jmp 0x190a53
movl $0x1, %eax
cmpl $0x0, 0x98(%rsp)
je 0x190aaa
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 0x190aa2
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 0x190a86
incq %rdx
cmpq %rbp, %rdx
jne 0x190a68
addq $0x58, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq