// File: /workspace/github_cpp_makefile_star2_O2/chhylp123[P]hifiasm/Overlaps.cpp
// Function: rescue_useless_trio_nodes(ma_ug_t*, unsigned int, float, float, unsigned int)
void rescue_useless_trio_nodes(ma_ug_t *ug, uint32_t flag, float flag_rate, float used_rate, uint32_t min_occ)
{
    asg_t* nsg = ug->g; 
    uint32_t v, w, n_vtx = nsg->n_seq<<1, i, k, z;
    long long nodeLen, baseLen, max_stop_nodeLen, max_stop_baseLen;
    buf_t b; memset(&b, 0, sizeof(buf_t));

    for (v = 0; v < n_vtx; v++) {
        if(nsg->seq[v>>1].del) continue;
        if(nsg->seq[v>>1].c != ALTER_LABLE) continue;
        ///check if beg is the tig end
        if(get_real_length(nsg, v^1, NULL) == 1) {
            get_real_length(nsg, v^1, &w);
            if(get_real_length(nsg, w^1, NULL) == 1) continue;
        }

        b.b.n = 0; 
        get_unitig(nsg, ug, v, &w, &nodeLen, &baseLen, &max_stop_nodeLen, &max_stop_baseLen, 1, &b);
        recover_chain_nodes(&b, ug, flag, flag_rate, used_rate, min_occ);
        if(b.b.n > 1) {
            k = b.b.n>>1;
            for (i = 0; i < k; i++) {
                z = b.b.a[i]; b.b.a[i] = b.b.a[b.b.n-i-1]; b.b.a[b.b.n-i-1] = z;
            }
            recover_chain_nodes(&b, ug, flag, flag_rate, used_rate, min_occ);
        }
    }
    
    free(b.b.a);
    asg_cleanup(nsg);
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0xa8, %rsp
movl %edx, 0x18(%rsp)
movss %xmm1, 0x14(%rsp)
movss %xmm0, 0x10(%rsp)
movl %esi, 0xc(%rsp)
movq %rdi, %r15
movq 0x18(%rdi), %rbx
movl 0x14(%rbx), %r14d
addl %r14d, %r14d
xorps %xmm0, %xmm0
leaq 0x40(%rsp), %r12
movaps %xmm0, 0x50(%r12)
movaps %xmm0, 0x40(%r12)
movaps %xmm0, 0x30(%r12)
movaps %xmm0, 0x20(%r12)
andq $0x0, 0x60(%r12)
movaps %xmm0, 0x10(%r12)
movaps %xmm0, (%r12)
xorl %r13d, %r13d
cmpl %r14d, %r13d
je 0x99671
movq 0x20(%rbx), %rax
movl %r13d, %ecx
shrl %ecx
cmpl $0x0, (%rax,%rcx,8)
js 0x99669
cmpb $0x1, 0x4(%rax,%rcx,8)
jne 0x99669
movl %r13d, %ebp
xorl $0x1, %ebp
movq %rbx, %rdi
movl %ebp, %esi
xorl %edx, %edx
callq 0xc2e7a
cmpl $0x1, %eax
jne 0x995b2
movq %rbx, %rdi
movl %ebp, %esi
leaq 0x1c(%rsp), %rdx
callq 0xc2e7a
movl 0x1c(%rsp), %esi
xorl $0x1, %esi
movq %rbx, %rdi
xorl %edx, %edx
callq 0xc2e7a
cmpl $0x1, %eax
je 0x99669
andq $0x0, 0x78(%rsp)
movq %rbx, %rdi
movq %r15, %rsi
movl %r13d, %edx
leaq 0x1c(%rsp), %rcx
leaq 0x38(%rsp), %r8
leaq 0x30(%rsp), %r9
pushq %r12
pushq $0x1
leaq 0x30(%rsp), %rax
pushq %rax
leaq 0x40(%rsp), %rax
pushq %rax
callq 0xc2ebf
addq $0x20, %rsp
movq %r12, %rdi
movq %r15, %rsi
movl 0xc(%rsp), %edx
movss 0x10(%rsp), %xmm0
movss 0x14(%rsp), %xmm1
movl 0x18(%rsp), %ecx
callq 0x992b7
movq 0x78(%rsp), %rdx
cmpq $0x2, %rdx
jb 0x99669
movq %rdx, %rcx
shrq %rcx
movq 0x88(%rsp), %rax
movl %ecx, %ecx
negq %rcx
leaq (%rax,%rdx,4), %rdx
addq $-0x4, %rdx
xorl %esi, %esi
cmpq %rsi, %rcx
je 0x9964a
movl (%rax), %edi
movl (%rdx,%rsi,4), %r8d
movl %r8d, (%rax)
movl %edi, (%rdx,%rsi,4)
decq %rsi
addq $0x4, %rax
jmp 0x99630
movq %r12, %rdi
movq %r15, %rsi
movl 0xc(%rsp), %edx
movss 0x10(%rsp), %xmm0
movss 0x14(%rsp), %xmm1
movl 0x18(%rsp), %ecx
callq 0x992b7
incl %r13d
jmp 0x9954b
movq 0x88(%rsp), %rdi
callq 0x2220
movq %rbx, %rdi
callq 0x694eb
addq $0xa8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq