// File: 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
movq %rsp, %rbp
subq $0x60, %rsp
movl 0x18(%rbp), %eax
movq 0x10(%rbp), %rax
movq %rdi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
movq %rdx, -0x18(%rbp)
movq %rcx, -0x20(%rbp)
movq %r8, -0x28(%rbp)
movl %r9d, -0x2c(%rbp)
movl $0x0, -0x4c(%rbp)
movq $0x0, -0x58(%rbp)
movl $0x0, -0x30(%rbp)
movl -0x30(%rbp), %eax
cmpl 0x18(%rbp), %eax
jae 0x272c4a
movq -0x8(%rbp), %rax
movq 0x10(%rax), %rax
movq 0x10(%rbp), %rcx
movl -0x30(%rbp), %edx
movl (%rcx,%rdx,4), %ecx
imulq $0x28, %rcx, %rcx
addq %rcx, %rax
movq %rax, -0x58(%rbp)
movl $0x0, -0x34(%rbp)
movl -0x34(%rbp), %eax
movq -0x58(%rbp), %rcx
cmpl 0x10(%rcx), %eax
jae 0x272c3a
movq -0x58(%rbp), %rax
movq 0x18(%rax), %rax
movl -0x34(%rbp), %ecx
movq (%rax,%rcx,8), %rax
shrq $0x21, %rax
movl %eax, -0x3c(%rbp)
movq -0x20(%rbp), %rdi
movl -0x3c(%rbp), %esi
movq 0x10(%rbp), %rax
movl -0x30(%rbp), %ecx
movl (%rax,%rcx,4), %edx
movl $0x1, %ecx
xorl %eax, %eax
movl %eax, %r8d
callq 0xd0e20
movl -0x34(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x34(%rbp)
jmp 0x272bed
jmp 0x272c3c
movl -0x30(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x30(%rbp)
jmp 0x272bbd
movl $0x0, -0x30(%rbp)
movl -0x30(%rbp), %eax
cmpl -0x2c(%rbp), %eax
jae 0x272da2
movq -0x8(%rbp), %rax
movq 0x10(%rax), %rax
movq -0x28(%rbp), %rcx
movl -0x30(%rbp), %edx
movl (%rcx,%rdx,4), %ecx
imulq $0x28, %rcx, %rcx
addq %rcx, %rax
movq %rax, -0x58(%rbp)
movl $0x0, -0x34(%rbp)
movl -0x34(%rbp), %eax
movq -0x58(%rbp), %rcx
cmpl 0x10(%rcx), %eax
jae 0x272d8a
movq -0x58(%rbp), %rax
movq 0x18(%rax), %rax
movl -0x34(%rbp), %ecx
movq (%rax,%rcx,8), %rax
shrq $0x21, %rax
movl %eax, -0x3c(%rbp)
movl $0x0, -0x38(%rbp)
movl -0x38(%rbp), %eax
movq -0x18(%rbp), %rcx
movl -0x3c(%rbp), %edx
imulq $0x18, %rdx, %rdx
addq %rdx, %rcx
cmpl 0xc(%rcx), %eax
jae 0x272d72
movq -0x18(%rbp), %rax
movl -0x3c(%rbp), %ecx
imulq $0x18, %rcx, %rcx
addq %rcx, %rax
movq (%rax), %rax
movl -0x38(%rbp), %ecx
imulq $0x28, %rcx, %rcx
addq %rcx, %rax
movl 0xc(%rax), %eax
movl %eax, -0x40(%rbp)
movq -0x10(%rbp), %rax
movq 0x20(%rax), %rax
movl -0x40(%rbp), %ecx
movl (%rax,%rcx,8), %eax
shrl $0x1f, %eax
cmpl $0x1, %eax
jne 0x272d39
movq -0x20(%rbp), %rdi
movl -0x40(%rbp), %esi
leaq -0x40(%rbp), %rdx
leaq -0x44(%rbp), %rcx
callq 0xd3d50
cmpl $-0x1, -0x40(%rbp)
je 0x272d35
cmpl $0x1, -0x44(%rbp)
je 0x272d35
movq -0x10(%rbp), %rax
movq 0x20(%rax), %rax
movl -0x40(%rbp), %ecx
movl (%rax,%rcx,8), %eax
shrl $0x1f, %eax
cmpl $0x1, %eax
jne 0x272d37
jmp 0x272d64
jmp 0x272d39
movq -0x20(%rbp), %rdi
movl -0x40(%rbp), %esi
leaq -0x48(%rbp), %rdx
leaq -0x44(%rbp), %rcx
callq 0xd3d50
cmpl $-0x1, -0x48(%rbp)
je 0x272d62
cmpl $0x1, -0x44(%rbp)
jne 0x272d62
movl $0x1, -0x4c(%rbp)
jmp 0x272d72
jmp 0x272d64
movl -0x38(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x38(%rbp)
jmp 0x272cae
cmpl $0x0, -0x4c(%rbp)
je 0x272d7a
jmp 0x272d8a
jmp 0x272d7c
movl -0x34(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x34(%rbp)
jmp 0x272c81
cmpl $0x0, -0x4c(%rbp)
je 0x272d92
jmp 0x272da2
jmp 0x272d94
movl -0x30(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x30(%rbp)
jmp 0x272c51
movl $0x0, -0x30(%rbp)
movl -0x30(%rbp), %eax
cmpl 0x18(%rbp), %eax
jae 0x272e21
movq -0x8(%rbp), %rax
movq 0x10(%rax), %rax
movq 0x10(%rbp), %rcx
movl -0x30(%rbp), %edx
movl (%rcx,%rdx,4), %ecx
imulq $0x28, %rcx, %rcx
addq %rcx, %rax
movq %rax, -0x58(%rbp)
movl $0x0, -0x34(%rbp)
movl -0x34(%rbp), %eax
movq -0x58(%rbp), %rcx
cmpl 0x10(%rcx), %eax
jae 0x272e14
movq -0x58(%rbp), %rax
movq 0x18(%rax), %rax
movl -0x34(%rbp), %ecx
movq (%rax,%rcx,8), %rax
shrq $0x21, %rax
movl %eax, -0x3c(%rbp)
movq -0x20(%rbp), %rax
movq 0x8(%rax), %rax
movl -0x3c(%rbp), %ecx
movl $0xffffffff, (%rax,%rcx,4) # imm = 0xFFFFFFFF
movl -0x34(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x34(%rbp)
jmp 0x272dd5
jmp 0x272e16
movl -0x30(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x30(%rbp)
jmp 0x272da9
movl -0x4c(%rbp), %eax
addq $0x60, %rsp
popq %rbp
retq
nopw (%rax,%rax)