// File: /workspace/github_cpp_makefile_star2_O3/chhylp123[P]hifiasm/hic.cpp
// Function: get_related_bub_nodes(kvec_t_u32_warp*, bubble_type*, pdq*, asg_t*, unsigned int*, unsigned int, unsigned int, unsigned char*)
void get_related_bub_nodes(kvec_t_u32_warp* broken, bubble_type* bub, pdq* pq, asg_t *unitig_g, 
                                        uint32_t *pre, uint32_t src, uint32_t dest, uint8_t *bsg_idx)
{
    uint32_t j_i, pre_id, adjecent;
    src ^= 1;
    get_shortest_path(src, pq, unitig_g, pre);
            
    for (j_i = 0; j_i < pq->dis.n; j_i++)
    {
        if(pq->dis.a[j_i] == (uint64_t)-1) continue;
        ///if(IF_HOM(j_i>>1, *bub)) continue;
        if((j_i>>1) == (src>>1)) continue;
        if((dest != (uint32_t)-1) && ((j_i>>1) == (dest>>1))) continue;

        pre_id = pre[j_i];
        adjecent = 0;
        while (pre_id != src)
        { 
            if(((dest != (uint32_t)-1) && ((pre_id>>1) == (dest>>1))) 
                                                || ((pre_id>>1) == (src>>1)))
            {
                adjecent = 1;
                break;
            }
            pre_id = pre[pre_id];
        }
        
        if(adjecent == 0)
        {
            if(broken->a.n == 0 || (broken->a.n > 0 && (j_i>>1) != (broken->a.a[broken->a.n - 1]>>1)))
            {
                if(bsg_idx && bsg_idx[(j_i>>1)])
                {
                    broken->a.n = 0;
                    return;
                }
                kv_push(uint32_t, broken->a, j_i);
            }
        }
    }
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x18, %rsp
movl %r9d, %ebx
movq %r8, %r14
movq %rdx, %r12
movq %rdi, 0x10(%rsp)
movl %r9d, %ebp
xorl $0x1, %ebp
movl %ebp, %edi
movq %rdx, %rsi
movq %rcx, %rdx
movq %r8, %rcx
callq 0x141c64
movq 0x30(%r12), %rcx
testq %rcx, %rcx
je 0x14cbf7
movq 0x58(%rsp), %r9
movl 0x50(%rsp), %r13d
shrl %ebx
movl %r13d, %r10d
shrl %r10d
xorl %r15d, %r15d
movl %r10d, 0xc(%rsp)
movq 0x40(%r12), %rax
cmpq $-0x1, (%rax,%r15,8)
je 0x14cbeb
cmpl $-0x1, %r13d
setne %dl
movl %r15d, %eax
shrl %eax
cmpl %r10d, %eax
sete %sil
cmpl %ebx, %eax
je 0x14cbeb
andb %sil, %dl
jne 0x14cbeb
movl (%r14,%r15,4), %edx
cmpl %ebp, %edx
je 0x14cb74
cmpl $-0x1, %r13d
setne %sil
movl %edx, %edi
xorl %r13d, %edi
cmpl $0x2, %edi
setb %dil
movl %edx, %r8d
shrl %r8d
cmpl %ebx, %r8d
je 0x14cbeb
andb %dil, %sil
jne 0x14cbeb
movl %edx, %edx
movl (%r14,%rdx,4), %edx
jmp 0x14cb40
movq 0x10(%rsp), %rdi
movq (%rdi), %rdx
testq %rdx, %rdx
je 0x14cb8f
movq 0x10(%rdi), %rsi
movl -0x4(%rsi,%rdx,4), %esi
shrl %esi
cmpl %esi, %eax
je 0x14cbeb
testq %r9, %r9
je 0x14cb9b
cmpb $0x0, (%r9,%rax)
jne 0x14cc06
movq 0x10(%rdi), %rax
cmpq 0x8(%rdi), %rdx
jne 0x14cbe0
leaq (%rdx,%rdx), %rsi
testq %rdx, %rdx
movl $0x2, %ecx
cmoveq %rcx, %rsi
movq %rsi, 0x8(%rdi)
shlq $0x2, %rsi
movq %rax, %rdi
callq 0x2370
movl 0xc(%rsp), %r10d
movq 0x58(%rsp), %r9
movq 0x10(%rsp), %rdi
movq %rax, 0x10(%rdi)
movq (%rdi), %rdx
movq 0x30(%r12), %rcx
leaq 0x1(%rdx), %rsi
movq %rsi, (%rdi)
movl %r15d, (%rax,%rdx,4)
incl %r15d
cmpq %r15, %rcx
ja 0x14cb08
addq $0x18, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq $0x0, (%rdi)
jmp 0x14cbf7