// File: /workspace/github_cpp_makefile_star2_O2/chhylp123[P]hifiasm/Overlaps.cpp
// Function: get_candidate_uids(asg_t*, ma_utg_t*, kvec_t_u64_warp*, ma_hit_t_alloc*, R_to_U*)
void get_candidate_uids(asg_t* nsg, ma_utg_t* nsu, kvec_t_u64_warp* u_vecs, 
ma_hit_t_alloc* reverse_sources, R_to_U* ruIndex)
{
    uint32_t k, j, rId, uId, is_Unitig, m;
    uint64_t pre;
    u_vecs->a.n = 0;
    if(nsu->m == 0) return;
    for (k = 0; k < nsu->n; k++)
    {
        rId = nsu->a[k]>>33;
        for (j = 0; j < reverse_sources[rId].length; j++)
        {
            get_R_to_U(ruIndex, Get_tn(reverse_sources[rId].buffer[j]), &uId, &is_Unitig);
            if(uId==(uint32_t)-1) continue;
            ///contained read
            if(is_Unitig == 0) get_R_to_U(ruIndex, uId, &uId, &is_Unitig);
            if(uId == (uint32_t)-1 || is_Unitig == 0) continue;
            ///need this line
            if(nsg->seq[uId].c == ALTER_LABLE) continue;
            pre = uId; 
            pre = pre | (uint64_t)(0x100000000);
            kv_push(uint64_t, u_vecs->a, pre);
        }
    }
    if(u_vecs->a.n == 0) return;
    radix_sort_arch64(u_vecs->a.a, u_vecs->a.a + u_vecs->a.n);
    for (m = 0, k = 1; k < u_vecs->a.n; k++)
    {
        if(u_vecs->a.a[k] == u_vecs->a.a[k-1])
        {
            u_vecs->a.a[m] += (uint64_t)(0x100000000);
        }
        else
        {
            m++;
            u_vecs->a.a[m] = u_vecs->a.a[k];
        }
    }

    u_vecs->a.n = m + 1;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x28, %rsp
movq %rcx, 0x10(%rsp)
andq $0x0, (%rdx)
cmpl $0x0, 0xc(%rsi)
je 0x99127
movq %r8, %r14
movq %rdi, %r8
movabsq $0x100000000, %rbx      # imm = 0x100000000
xorl %ecx, %ecx
movl $0xffffffff, %r9d       # imm = 0xFFFFFFFF
movq %rsi, 0x8(%rsp)
movq %rdi, 0x18(%rsp)
movl 0x10(%rsi), %eax
cmpq %rax, %rcx
jae 0x990d6
movq 0x18(%rsi), %rax
movq %rcx, 0x20(%rsp)
movq (%rax,%rcx,8), %rax
shrq $0x21, %rax
imulq $0x18, %rax, %r12
addq 0x10(%rsp), %r12
pushq $0xc
popq %r15
xorl %r13d, %r13d
movl 0xc(%r12), %eax
cmpq %rax, %r13
jae 0x990c4
movq (%r12), %rax
movl (%rax,%r15), %eax
movq (%r14), %rcx
cmpq %rax, %rcx
jbe 0x990b8
movq 0x8(%r14), %rdi
movl (%rdi,%rax,4), %esi
cmpq %r9, %rsi
je 0x990b8
movl %esi, %eax
andl $0x7fffffff, %eax       # imm = 0x7FFFFFFF
testl %esi, %esi
js 0x99050
cmpq %rax, %rcx
jbe 0x990b8
movl (%rdi,%rax,4), %eax
cmpl $-0x2, %eax
jg 0x990b8
andl $0x7fffffff, %eax       # imm = 0x7FFFFFFF
movq 0x20(%r8), %rcx
movl %eax, %ebp
cmpb $0x1, 0x4(%rcx,%rbp,8)
je 0x990b8
movq (%rdx), %rcx
movq 0x10(%rdx), %rax
cmpq 0x8(%rdx), %rcx
jne 0x990aa
leaq (%rcx,%rcx), %rsi
testq %rcx, %rcx
pushq $0x2
popq %rcx
cmoveq %rcx, %rsi
movq %rsi, 0x8(%rdx)
shlq $0x3, %rsi
movq %rax, %rdi
movq %rdx, %rbx
callq 0x2370
movl $0xffffffff, %r9d       # imm = 0xFFFFFFFF
movq 0x18(%rsp), %r8
movq %rbx, %rdx
movabsq $0x100000000, %rbx      # imm = 0x100000000
movq %rax, 0x10(%rdx)
movq (%rdx), %rcx
orq %rbx, %rbp
leaq 0x1(%rcx), %rsi
movq %rsi, (%rdx)
movq %rbp, (%rax,%rcx,8)
incq %r13
addq $0x28, %r15
jmp 0x99001
movq 0x20(%rsp), %rcx
incq %rcx
movq 0x8(%rsp), %rsi
jmp 0x98fd4
movq (%rdx), %rax
testq %rax, %rax
je 0x99127
movq 0x10(%rdx), %rdi
leaq (%rdi,%rax,8), %rsi
movq %rdx, %r14
callq 0x66c25
movq %r14, %r9
movq %rbx, %r8
xorl %edx, %edx
xorl %eax, %eax
leal 0x1(%rdx), %ecx
cmpq %rcx, (%r9)
jbe 0x99122
movq 0x10(%r9), %rsi
movq (%rsi,%rcx,8), %rdi
movl %edx, %edx
cmpq (%rsi,%rdx,8), %rdi
jne 0x99118
movl %eax, %edx
addq %r8, (%rsi,%rdx,8)
jmp 0x9911e
incl %eax
movq %rdi, (%rsi,%rax,8)
movl %ecx, %edx
jmp 0x990f8
incl %eax
movq %rax, (%r9)
addq $0x28, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq