// File: /workspace/github_cpp_makefile_star2_O3/chhylp123[P]hifiasm/Overlaps.cpp
// Function: delete_useless_trio_nodes(ma_ug_t**, asg_t*, ma_sub_t*, ma_hit_t_alloc*, R_to_U*, unsigned int, float, float, unsigned int)
void delete_useless_trio_nodes(ma_ug_t **ug, asg_t* read_g, ma_sub_t* coverage_cut, 
ma_hit_t_alloc* sources, R_to_U* ruIndex, uint32_t flag, float flag_rate, float used_rate, uint32_t min_occ)
{
    asg_t* nsg = (*ug)->g;
    uint32_t v, n_vtx = nsg->n_seq;
    uint8_t* primary_flag = (uint8_t*)calloc(read_g->n_seq, sizeof(uint8_t));

    if(flag_rate > 0 && used_rate > 0 && min_occ > 0) {
        rescue_useless_trio_nodes(*ug, flag, flag_rate, used_rate, min_occ);
    }

    for (v = 0; v < n_vtx; ++v) 
    {
        if(nsg->seq[v].del) continue;
        if(nsg->seq[v].c == ALTER_LABLE &&
          (if_primary_unitig(&((*ug)->u.a[v]), read_g, coverage_cut, sources, 
          ruIndex, primary_flag) == 0))
        {
            asg_seq_del(nsg, v);
            if((*ug)->u.a[v].m!=0)
            {
                (*ug)->u.a[v].m = (*ug)->u.a[v].n = 0;
                free((*ug)->u.a[v].a);
                (*ug)->u.a[v].a = NULL;
            }

            continue;
        }

        //note: after cleaning, some cirle might be gone, or we have some new circles
        //so need to renew .circ
        /**
        if(get_unitig(nsg, NULL, (v<<1), &convex, &nodeLen, &baseLen, 
                                        &max_stop_nodeLen, &max_stop_baseLen, 1, NULL)==LOOP)
        {
            (*ug)->u.a[v].circ = 1;
            (*ug)->u.a[v].start = (*ug)->u.a[v].end = UINT32_MAX;
        }
        else
        {
            (*ug)->u.a[v].circ = 0;

            (*ug)->u.a[v].start = (*ug)->u.a[v].a[0]>>32;
            (*ug)->u.a[v].end = ((*ug)->u.a[v].a[(*ug)->u.a[v].n-1]>>32)^1;
        }
        **/        
    }

    asg_cleanup(nsg);
    free(primary_flag);
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x68, %rsp
movaps %xmm1, 0x50(%rsp)
movaps %xmm0, 0x40(%rsp)
movl %r9d, %ebx
movq %r8, 0x38(%rsp)
movq %rcx, 0x30(%rsp)
movq %rdx, 0x28(%rsp)
movl 0xa0(%rsp), %r14d
movq %rdi, 0x8(%rsp)
movq (%rdi), %r15
movq 0x18(%r15), %rbp
movl 0x14(%rbp), %ecx
movl $0x7fffffff, %eax       # imm = 0x7FFFFFFF
andq %rax, %rcx
movq %rcx, 0x18(%rsp)
movq %rsi, 0x20(%rsp)
movl 0x14(%rsi), %edi
andq %rax, %rdi
movl $0x1, %esi
callq 0x2120
movaps 0x40(%rsp), %xmm0
movaps 0x50(%rsp), %xmm1
movq %rax, 0x10(%rsp)
xorps %xmm3, %xmm3
xorps %xmm2, %xmm2
cmpnltps %xmm1, %xmm2
cmpnltps %xmm0, %xmm3
orps %xmm2, %xmm3
movd %xmm3, %eax
testl %r14d, %r14d
sete %cl
orb %al, %cl
testb $0x1, %cl
jne 0xd66a5
movq %r15, %rdi
movl %ebx, %esi
movl %r14d, %edx
callq 0xd63bf
cmpl $0x0, 0x18(%rsp)
je 0xd6822
movl $0xffffffff, %r15d      # imm = 0xFFFFFFFF
xorl %r14d, %r14d
movq 0x20(%rbp), %r13
movl (%r13,%r14,8), %r12d
testl %r12d, %r12d
js 0xd6814
cmpb $0x1, 0x4(%r13,%r14,8)
jne 0xd6814
movq 0x8(%rsp), %rax
movq (%rax), %rax
leaq (%r14,%r14,4), %rbx
leaq (,%rbx,8), %rdi
addq 0x10(%rax), %rdi
movq 0x20(%rsp), %rsi
movq 0x28(%rsp), %rdx
movq 0x30(%rsp), %rcx
movq 0x38(%rsp), %r8
movq 0x10(%rsp), %r9
callq 0xcffc4
testb %al, %al
jne 0xd6814
orl $0x80000000, %r12d      # imm = 0x80000000
movl %r12d, (%r13,%r14,8)
leaq (%r14,%r14), %rax
movb $0x1, %cl
xorl %edx, %edx
orq %rax, %rdx
movq 0x28(%rbp), %rsi
movq (%rsi,%rdx,8), %rdi
movq %rdi, %rsi
andq %r15, %rsi
je 0xd67b6
shrq $0x20, %rdi
leaq (%rdi,%rdi,2), %rdi
shlq $0x3, %rdi
addq 0x8(%rbp), %rdi
xorl %r8d, %r8d
leaq (%r8,%r8,2), %r9
orb $-0x80, 0xf(%rdi,%r9,8)
movl 0x8(%rdi,%r9,8), %r9d
xorq $0x1, %r9
movq 0x28(%rbp), %r10
movq (%r10,%r9,8), %r10
movq %r10, %r9
andq %r15, %r9
je 0xd67ae
movq 0x8(%rbp), %r11
shrq $0x20, %r10
shlq $0x3, %r9
leaq (%r9,%r9,2), %r9
leaq (%r10,%r10,2), %r10
leaq (%r11,%r10,8), %r10
addq $0xc, %r10
xorl %r11d, %r11d
movl -0x4(%r10,%r11), %r12d
xorl %edx, %r12d
cmpl $0x1, %r12d
jne 0xd67a5
orb $-0x80, 0x3(%r10,%r11)
addq $0x18, %r11
cmpq %r11, %r9
jne 0xd6791
incq %r8
cmpq %rsi, %r8
jne 0xd674f
movl $0x1, %edx
testb $0x1, %cl
movl $0x0, %ecx
jne 0xd6729
movq 0x8(%rsp), %rax
movq (%rax), %rax
movq 0x10(%rax), %rax
cmpl $0x0, 0xc(%rax,%rbx,8)
je 0xd6814
leaq (%rax,%rbx,8), %rcx
xorl %edx, %edx
movl %edx, 0x10(%rcx)
leaq (,%r14,8), %rcx
leaq (%rcx,%rcx,4), %rbx
movl %edx, 0xc(%rax,%rbx)
movq 0x18(%rax,%rbx), %rdi
callq 0x2220
movq 0x8(%rsp), %rax
movq (%rax), %rax
movq 0x10(%rax), %rax
movq $0x0, 0x18(%rax,%rbx)
incq %r14
cmpq 0x18(%rsp), %r14
jne 0xd66b9
movq %rbp, %rdi
callq 0xa0a7d
movq 0x10(%rsp), %rdi
addq $0x68, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
jmp 0x2220