// File: /workspace/github_cpp_makefile_star2_O2/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, 0x38(%rsp)
movq %rcx, %rbx
movq %rdx, 0x50(%rsp)
movq %rsi, 0x28(%rsp)
movq %rdi, 0x18(%rsp)
movq 0x90(%rsp), %r15
xorl %r14d, %r14d
pushq $0x1
popq %rbp
movl 0x98(%rsp), %eax
cmpq %rax, %r14
je 0x1521ac
movl (%r15,%r14,4), %eax
imulq $0x28, %rax, %r13
movq 0x18(%rsp), %rax
addq 0x10(%rax), %r13
xorl %r12d, %r12d
movl 0x10(%r13), %eax
cmpq %rax, %r12
jae 0x1521a7
movq 0x18(%r13), %rax
movq (%rax,%r12,8), %rsi
shrq $0x21, %rsi
movl (%r15,%r14,4), %edx
movq %rbx, %rdi
movl %ebp, %ecx
xorl %r8d, %r8d
callq 0x6ab56
incq %r12
jmp 0x15217c
incq %r14
jmp 0x15215c
movl 0x10(%rsp), %eax
xorl %ecx, %ecx
movq %rax, 0x30(%rsp)
cmpq %rax, %rcx
je 0x152314
movq 0x38(%rsp), %rax
movl (%rax,%rcx,4), %eax
imulq $0x28, %rax, %rdx
movq 0x18(%rsp), %rax
addq 0x10(%rax), %rdx
xorl %esi, %esi
movq %rcx, 0x48(%rsp)
movq %rdx, 0x40(%rsp)
movl 0x10(%rdx), %eax
cmpq %rax, %rsi
jae 0x1522ae
movq 0x18(%rdx), %rax
movq %rsi, 0x10(%rsp)
movq (%rax,%rsi,8), %rax
shrq $0x21, %rax
imulq $0x18, %rax, %r12
addq 0x50(%rsp), %r12
pushq $0xc
popq %r13
xorl %r14d, %r14d
movl 0xc(%r12), %eax
cmpq %rax, %r14
jae 0x152297
movq (%r12), %rax
movl (%rax,%r13), %esi
movl %esi, 0xc(%rsp)
movq 0x28(%rsp), %rax
movq 0x20(%rax), %rax
cmpl $0x0, (%rax,%rsi,8)
js 0x152255
movq %rbx, %rdi
leaq 0x24(%rsp), %rdx
leaq 0x8(%rsp), %rcx
callq 0x6c2a2
cmpl $-0x1, 0x24(%rsp)
je 0x15228b
cmpl $0x1, 0x8(%rsp)
jne 0x15228b
jmp 0x1522bb
movq %rbx, %rdi
leaq 0xc(%rsp), %rdx
leaq 0x8(%rsp), %rcx
callq 0x6c2a2
movl 0xc(%rsp), %esi
movl $0xffffffff, %eax       # imm = 0xFFFFFFFF
cmpq %rax, %rsi
je 0x15228b
cmpl $0x1, 0x8(%rsp)
je 0x15228b
movq 0x28(%rsp), %rax
movq 0x20(%rax), %rax
cmpl $0x0, (%rax,%rsi,8)
jns 0x152233
incq %r14
addq $0x28, %r13
jmp 0x15220e
movq 0x10(%rsp), %rsi
incq %rsi
movq 0x48(%rsp), %rcx
movq 0x40(%rsp), %rdx
jmp 0x1521e1
incq %rcx
movq 0x30(%rsp), %rax
jmp 0x1521b7
movl %ebp, %eax
xorl %r8d, %r8d
movl 0x98(%rsp), %ecx
cmpq %rcx, %r8
je 0x152305
movl (%r15,%r8,4), %ecx
imulq $0x28, %rcx, %rcx
movq 0x18(%rsp), %rdx
addq 0x10(%rdx), %rcx
xorl %edx, %edx
movl 0x10(%rcx), %esi
cmpq %rsi, %rdx
jae 0x152300
movq 0x18(%rcx), %rsi
movq (%rsi,%rdx,8), %rsi
movq 0x8(%rbx), %rdi
shrq $0x21, %rsi
orl $-0x1, (%rdi,%rsi,4)
incq %rdx
jmp 0x1522df
incq %r8
jmp 0x1522c0
addq $0x58, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
xorl %eax, %eax
jmp 0x1522bd