// File: /workspace/github_cpp_makefile_star2_O2/chhylp123[P]hifiasm/Purge_Dups.cpp
// Function: link_unitigs(asg_t*, ma_ug_t*, hap_overlaps_list*, R_to_U*, ma_hit_t_alloc*, ma_sub_t*, asg_t*, unsigned long*, kvec_asg_arc_t_offset*, kvec_t_i32_warp*, kvec_t_i32_warp*, int, int, kvec_asg_arc_t_warp*, unsigned char*, hap_cov_t*)
void link_unitigs(asg_t *purge_g, ma_ug_t *ug, hap_overlaps_list* all_ovlp,
R_to_U* ruIndex, ma_hit_t_alloc* reverse_sources, ma_sub_t *coverage_cut, asg_t *read_g, 
uint64_t* position_index, kvec_asg_arc_t_offset* u_buffer, kvec_t_i32_warp* tailIndex, 
kvec_t_i32_warp* prevIndex, int max_hang, int min_ovlp, kvec_asg_arc_t_warp* edge, uint8_t* visit,
hap_cov_t *cov)
{
    uint32_t v, n_vtx = purge_g->n_seq * 2, beg, end;
    long long nodeLen, baseLen, max_stop_nodeLen, max_stop_baseLen;
    buf_t b_0;
    memset(&b_0, 0, sizeof(buf_t));
    memset(visit, 0, purge_g->n_seq);
    for (v = 0; v < n_vtx; ++v) 
    {
        if(purge_g->seq[v>>1].c == ALTER_LABLE || purge_g->seq[v>>1].del || visit[v>>1]) continue;
        if(get_real_length(purge_g, v, NULL) != 1) continue;
        if(get_real_length(purge_g, v^1, NULL) != 0) continue;

        beg = v;
        b_0.b.n = 0;
        if(get_unitig(purge_g, NULL, beg, &end, &nodeLen, &baseLen, &max_stop_nodeLen, 
                    &max_stop_baseLen, 1, &b_0) == LOOP)
        {
            continue;
        }

        ///if(cov->link) collect_reverse_unitigs_purge(&b_0, cov->link, ug, all_ovlp);
        purge_merge(purge_g, ug, all_ovlp, &b_0, ruIndex, reverse_sources, coverage_cut, 
        read_g, position_index, u_buffer, tailIndex, prevIndex,max_hang, min_ovlp, edge, visit, cov);
    }
    free(b_0.b.a);
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0xb8, %rsp
movq %r9, 0x20(%rsp)
movq %r8, 0x18(%rsp)
movq %rcx, 0x10(%rsp)
movq %rdx, 0x8(%rsp)
movq %rsi, %r13
movq %rdi, %rbp
movq 0x130(%rsp), %rbx
movl 0x14(%rdi), %edx
leal (%rdx,%rdx), %r12d
xorps %xmm0, %xmm0
leaq 0x50(%rsp), %r14
movaps %xmm0, 0x50(%r14)
movaps %xmm0, 0x40(%r14)
movaps %xmm0, 0x30(%r14)
movaps %xmm0, 0x20(%r14)
movaps %xmm0, 0x10(%r14)
movaps %xmm0, (%r14)
andq $0x0, 0x60(%r14)
andl $0x7fffffff, %edx       # imm = 0x7FFFFFFF
xorl %r15d, %r15d
movq %rbx, %rdi
xorl %esi, %esi
callq 0x20e0
cmpl %r15d, %r12d
je 0xd0e36
movq 0x20(%rbp), %rcx
movl %r15d, %eax
shrl %eax
cmpb $0x1, 0x4(%rcx,%rax,8)
je 0xd0e2e
cmpl $0x0, (%rcx,%rax,8)
js 0xd0e2e
cmpb $0x0, (%rbx,%rax)
jne 0xd0e2e
movq %rbp, %rdi
movl %r15d, %esi
xorl %edx, %edx
callq 0xc2e7a
cmpl $0x1, %eax
jne 0xd0e2e
movl %r15d, %esi
xorl $0x1, %esi
movq %rbp, %rdi
xorl %edx, %edx
callq 0xc2e7a
testl %eax, %eax
jne 0xd0e2e
andq $0x0, 0x88(%rsp)
movq %rbp, %rdi
xorl %esi, %esi
movl %r15d, %edx
leaq 0x2c(%rsp), %rcx
leaq 0x48(%rsp), %r8
leaq 0x40(%rsp), %r9
pushq %r14
pushq $0x1
leaq 0x40(%rsp), %rax
pushq %rax
leaq 0x50(%rsp), %rax
pushq %rax
callq 0xc2ebf
addq $0x20, %rsp
cmpl $0x7, %eax
je 0xd0e2e
subq $0x8, %rsp
movq %rbp, %rdi
movq %r13, %rsi
movq 0x10(%rsp), %rdx
movq %r14, %rcx
movq 0x18(%rsp), %r8
movq 0x20(%rsp), %r9
pushq 0x140(%rsp)
pushq %rbx
pushq 0x140(%rsp)
movl 0x140(%rsp), %eax
pushq %rax
movl 0x140(%rsp), %eax
pushq %rax
pushq 0x140(%rsp)
pushq 0x140(%rsp)
pushq 0x140(%rsp)
pushq 0x140(%rsp)
pushq 0x140(%rsp)
pushq 0x78(%rsp)
callq 0xcff84
addq $0x60, %rsp
incl %r15d
jmp 0xd0d26
movq 0x98(%rsp), %rdi
callq 0x2220
addq $0xb8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq