// File: 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
movq %rsp, %rbp
subq $0x50, %rsp
movq %rdi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
movq %rdx, -0x18(%rbp)
movq %rcx, -0x20(%rbp)
movq %r8, -0x28(%rbp)
movq -0x18(%rbp), %rax
movq $0x0, (%rax)
movq -0x10(%rbp), %rax
cmpl $0x0, 0xc(%rax)
jne 0x11f436
jmp 0x11f69d
movl $0x0, -0x2c(%rbp)
movl -0x2c(%rbp), %eax
movq -0x10(%rbp), %rcx
cmpl 0x10(%rcx), %eax
jae 0x11f5c5
movq -0x10(%rbp), %rax
movq 0x18(%rax), %rax
movl -0x2c(%rbp), %ecx
movq (%rax,%rcx,8), %rax
shrq $0x21, %rax
movl %eax, -0x34(%rbp)
movl $0x0, -0x30(%rbp)
movl -0x30(%rbp), %eax
movq -0x20(%rbp), %rcx
movl -0x34(%rbp), %edx
imulq $0x18, %rdx, %rdx
addq %rdx, %rcx
cmpl 0xc(%rcx), %eax
jae 0x11f5b5
movq -0x28(%rbp), %rdi
movq -0x20(%rbp), %rax
movl -0x34(%rbp), %ecx
imulq $0x18, %rcx, %rcx
addq %rcx, %rax
movq (%rax), %rax
movl -0x30(%rbp), %ecx
imulq $0x28, %rcx, %rcx
addq %rcx, %rax
movl 0xc(%rax), %esi
leaq -0x38(%rbp), %rdx
leaq -0x3c(%rbp), %rcx
callq 0xd3d50
cmpl $-0x1, -0x38(%rbp)
jne 0x11f4be
jmp 0x11f5a7
cmpl $0x0, -0x3c(%rbp)
jne 0x11f4d8
movq -0x28(%rbp), %rdi
movl -0x38(%rbp), %esi
leaq -0x38(%rbp), %rdx
leaq -0x3c(%rbp), %rcx
callq 0xd3d50
cmpl $-0x1, -0x38(%rbp)
je 0x11f4e4
cmpl $0x0, -0x3c(%rbp)
jne 0x11f4e9
jmp 0x11f5a7
movq -0x8(%rbp), %rax
movq 0x20(%rax), %rax
movl -0x38(%rbp), %ecx
movzbl 0x4(%rax,%rcx,8), %eax
cmpl $0x1, %eax
jne 0x11f503
jmp 0x11f5a7
movl -0x38(%rbp), %eax
movq %rax, -0x48(%rbp)
movabsq $0x100000000, %rax      # imm = 0x100000000
orq -0x48(%rbp), %rax
movq %rax, -0x48(%rbp)
movq -0x18(%rbp), %rax
movq (%rax), %rax
movq -0x18(%rbp), %rcx
cmpq 0x8(%rcx), %rax
jne 0x11f584
movq -0x18(%rbp), %rax
cmpq $0x0, 0x8(%rax)
je 0x11f549
movq -0x18(%rbp), %rax
movq 0x8(%rax), %rax
shlq %rax
movq %rax, -0x50(%rbp)
jmp 0x11f554
movl $0x2, %eax
movq %rax, -0x50(%rbp)
jmp 0x11f554
movq -0x50(%rbp), %rcx
movq -0x18(%rbp), %rax
movq %rcx, 0x8(%rax)
movq -0x18(%rbp), %rax
movq 0x10(%rax), %rdi
movq -0x18(%rbp), %rax
movq 0x8(%rax), %rsi
shlq $0x3, %rsi
callq 0x2360
movq %rax, %rcx
movq -0x18(%rbp), %rax
movq %rcx, 0x10(%rax)
movq -0x48(%rbp), %rdx
movq -0x18(%rbp), %rax
movq 0x10(%rax), %rax
movq -0x18(%rbp), %rsi
movq (%rsi), %rcx
movq %rcx, %rdi
addq $0x1, %rdi
movq %rdi, (%rsi)
movq %rdx, (%rax,%rcx,8)
jmp 0x11f5a7
movl -0x30(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x30(%rbp)
jmp 0x11f46a
jmp 0x11f5b7
movl -0x2c(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x2c(%rbp)
jmp 0x11f43d
movq -0x18(%rbp), %rax
cmpq $0x0, (%rax)
jne 0x11f5d4
jmp 0x11f69d
movq -0x18(%rbp), %rax
movq 0x10(%rax), %rdi
movq -0x18(%rbp), %rax
movq 0x10(%rax), %rsi
movq -0x18(%rbp), %rax
movq (%rax), %rax
shlq $0x3, %rax
addq %rax, %rsi
callq 0xc90e0
movl $0x0, -0x40(%rbp)
movl $0x1, -0x2c(%rbp)
movl -0x2c(%rbp), %eax
movq -0x18(%rbp), %rcx
cmpq (%rcx), %rax
jae 0x11f68c
movq -0x18(%rbp), %rax
movq 0x10(%rax), %rax
movl -0x2c(%rbp), %ecx
movq (%rax,%rcx,8), %rax
movq -0x18(%rbp), %rcx
movq 0x10(%rcx), %rcx
movl -0x2c(%rbp), %edx
subl $0x1, %edx
movl %edx, %edx
cmpq (%rcx,%rdx,8), %rax
jne 0x11f655
movq -0x18(%rbp), %rax
movq 0x10(%rax), %rax
movl -0x40(%rbp), %ecx
movabsq $0x100000000, %rdx      # imm = 0x100000000
addq (%rax,%rcx,8), %rdx
movq %rdx, (%rax,%rcx,8)
jmp 0x11f67c
movl -0x40(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x40(%rbp)
movq -0x18(%rbp), %rax
movq 0x10(%rax), %rax
movl -0x2c(%rbp), %ecx
movq (%rax,%rcx,8), %rdx
movq -0x18(%rbp), %rax
movq 0x10(%rax), %rax
movl -0x40(%rbp), %ecx
movq %rdx, (%rax,%rcx,8)
jmp 0x11f67e
movl -0x2c(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x2c(%rbp)
jmp 0x11f605
movl -0x40(%rbp), %eax
addl $0x1, %eax
movl %eax, %eax
movl %eax, %ecx
movq -0x18(%rbp), %rax
movq %rcx, (%rax)
addq $0x50, %rsp
popq %rbp
retq
nopw %cs:(%rax,%rax)