// File: /workspace/github_cpp_makefile_star2_O3/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 $0x98, %rsp
movl %edx, (%rsp)
movss %xmm1, 0x8(%rsp)
movss %xmm0, 0x4(%rsp)
movq 0x18(%rdi), %rbx
movl 0x14(%rbx), %r13d
xorl %r14d, %r14d
xorps %xmm0, %xmm0
movaps %xmm0, 0x60(%rsp)
movaps %xmm0, 0x50(%rsp)
movaps %xmm0, 0x40(%rsp)
movaps %xmm0, 0x30(%rsp)
movaps %xmm0, 0x20(%rsp)
movaps %xmm0, 0x10(%rsp)
movq $0x0, 0x70(%rsp)
addl %r13d, %r13d
je 0xd65e2
movl %esi, %r15d
movq %rdi, %r12
movq 0x20(%rbx), %rax
movl %r14d, %ecx
shrl %ecx
cmpl $0x0, (%rax,%rcx,8)
js 0xd65d1
cmpb $0x1, 0x4(%rax,%rcx,8)
jne 0xd65d1
movl %r14d, %eax
xorl $0x1, %eax
movq 0x28(%rbx), %rcx
movq (%rcx,%rax,8), %rdx
movq %rdx, %rsi
movl $0xffffffff, %eax       # imm = 0xFFFFFFFF
andq %rax, %rsi
je 0xd650a
movq 0x8(%rbx), %rax
shrq $0x20, %rdx
leaq (%rdx,%rdx,2), %rdx
leaq (%rax,%rdx,8), %rdx
addq $0xc, %rdx
shlq $0x3, %rsi
leaq (%rsi,%rsi,2), %rsi
xorl %edi, %edi
xorl %r8d, %r8d
movl (%rdx,%rdi), %r9d
notl %r9d
shrl $0x1f, %r9d
addl %r9d, %r8d
addq $0x18, %rdi
cmpq %rdi, %rsi
jne 0xd6481
cmpl $0x1, %r8d
jne 0xd650a
xorl %edi, %edi
cmpl $0x0, (%rdx,%rdi)
js 0xd64b0
movl -0x4(%rdx,%rdi), %r8d
movl %r8d, 0xc(%rsp)
addq $0x18, %rdi
cmpq %rdi, %rsi
jne 0xd64a0
movl 0xc(%rsp), %edx
xorq $0x1, %rdx
movq (%rcx,%rdx,8), %rdx
movq %rdx, %rcx
movl $0xffffffff, %esi       # imm = 0xFFFFFFFF
andq %rsi, %rcx
je 0xd650a
shrq $0x20, %rdx
leaq (%rdx,%rdx,2), %rdx
leaq (%rax,%rdx,8), %rax
addq $0xc, %rax
shlq $0x3, %rcx
leaq (%rcx,%rcx,2), %rcx
xorl %edx, %edx
xorl %esi, %esi
movl (%rax,%rdx), %edi
notl %edi
shrl $0x1f, %edi
addl %edi, %esi
addq $0x18, %rdx
cmpq %rdx, %rcx
jne 0xd64ee
cmpl $0x1, %esi
je 0xd65d1
movq $0x0, 0x48(%rsp)
movq %rbx, %rdi
movq %r12, %rsi
movl %r14d, %edx
leaq 0xc(%rsp), %rcx
leaq 0x90(%rsp), %r8
leaq 0x88(%rsp), %r9
leaq 0x10(%rsp), %rbp
pushq %rbp
pushq $0x1
leaq 0x88(%rsp), %rax
pushq %rax
leaq 0x98(%rsp), %rax
pushq %rax
callq 0x1053a7
addq $0x20, %rsp
movq %rbp, %rdi
movq %r12, %rsi
movl %r15d, %edx
movss 0x4(%rsp), %xmm0
movss 0x8(%rsp), %xmm1
movl (%rsp), %ecx
callq 0xd60df
movq 0x48(%rsp), %rdx
cmpq $0x2, %rdx
jb 0xd65d1
movq %rdx, %rcx
shrq %rcx
testl %ecx, %ecx
je 0xd65b2
movq 0x58(%rsp), %rax
movl %ecx, %ecx
leaq (%rax,%rdx,4), %rdx
addq $-0x4, %rdx
negq %rcx
xorl %esi, %esi
movl (%rax), %edi
movl (%rdx,%rsi,4), %r8d
movl %r8d, (%rax)
movl %edi, (%rdx,%rsi,4)
addq $0x4, %rax
decq %rsi
cmpq %rsi, %rcx
jne 0xd659a
leaq 0x10(%rsp), %rdi
movq %r12, %rsi
movl %r15d, %edx
movss 0x4(%rsp), %xmm0
movss 0x8(%rsp), %xmm1
movl (%rsp), %ecx
callq 0xd60df
incl %r14d
cmpl %r13d, %r14d
jne 0xd6423
movq 0x58(%rsp), %r14
movq %r14, %rdi
callq 0x2220
movq %rbx, %rdi
callq 0xa0a7d
addq $0x98, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq