// File: /workspace/github_cpp_makefile_star2_O2/chhylp123[P]hifiasm/Overlaps.cpp
// Function: recover_chain_nodes(buf_t*, ma_ug_t*, unsigned int, float, float, unsigned int)
void recover_chain_nodes(buf_t *in, ma_ug_t *ug, uint32_t flag, float flag_rate, float used_rate, uint32_t min_occ)
{
    ma_utg_t *u = NULL; uint32_t flag_occ, non_flag_occ, drop_occ, rid;
    uint32_t tot_flag_occ, tot_non_flag_occ, tot_drop_occ, tot_occ, i, k, z;
    tot_flag_occ = tot_non_flag_occ = tot_drop_occ = tot_occ = 0;

    for (i = 0; i < in->b.n; i++) {
        u = &(ug->u.a[in->b.a[i]>>1]);
        flag_occ = non_flag_occ = drop_occ = 0; 
        for (k = 0; k < u->n; k++) {
            rid = u->a[k]>>33;
            if(R_INF.trio_flag[rid] == AMBIGU) continue;
            else if(R_INF.trio_flag[rid] == DROP) drop_occ++;
            else if(R_INF.trio_flag[rid] == flag) flag_occ++;
            else if(R_INF.trio_flag[rid] != flag) non_flag_occ++;
        }

        if(is_useful_node(flag_occ, non_flag_occ, drop_occ, u->n, flag_rate, used_rate, min_occ)) {
            ug->g->seq[in->b.a[i]>>1].c = PRIMARY_LABLE;
        }
        tot_flag_occ += flag_occ;
        tot_non_flag_occ += non_flag_occ;
        tot_drop_occ += drop_occ;
        tot_occ += u->n;
        if(is_useful_node(tot_flag_occ, tot_non_flag_occ, tot_drop_occ, tot_occ, flag_rate, used_rate, min_occ)) {
            for (z = 0; z <= i; z++) {
                if(ug->g->seq[in->b.a[z]>>1].c == ALTER_LABLE) {
                    u = &(ug->u.a[in->b.a[z]>>1]);
                    flag_occ = non_flag_occ = drop_occ = 0; 
                    for (k = 0; k < u->n; k++) {
                        rid = u->a[k]>>33;
                        if(R_INF.trio_flag[rid] == AMBIGU) continue;
                        else if(R_INF.trio_flag[rid] == DROP) drop_occ++;
                        else if(R_INF.trio_flag[rid] == flag) flag_occ++;
                        else if(R_INF.trio_flag[rid] != flag) non_flag_occ++;
                    }
                    if(is_useful_node(flag_occ, non_flag_occ, drop_occ, u->n, flag_rate, used_rate, 0/**min_occ**/)) {
                        ug->g->seq[in->b.a[z]>>1].c = PRIMARY_LABLE;
                    }
                }
            }
        }
    }
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x38, %rsp
movl %ecx, 0x24(%rsp)
movss %xmm1, 0x10(%rsp)
movss %xmm0, 0xc(%rsp)
movl %edx, %ebp
movq %rsi, %r14
movq %rdi, %r12
movl $0x0, 0x20(%rsp)
leaq 0x1baf44(%rip), %r13    # 0x254230
movl $0x0, 0x1c(%rsp)
movl $0x0, 0x18(%rsp)
movl $0x0, 0x14(%rsp)
xorl %edx, %edx
movq %rdi, 0x30(%rsp)
movl %edx, %edx
cmpq %rdx, 0x38(%r12)
jbe 0x994d5
movq 0x10(%r14), %rax
movq 0x48(%r12), %rcx
movq %rdx, 0x28(%rsp)
movl (%rcx,%rdx,4), %ecx
shrl %ecx
imulq $0x28, %rcx, %rcx
leaq (%rax,%rcx), %r15
movl 0x10(%rax,%rcx), %ecx
movq 0x28(%r13), %rax
xorl %edx, %edx
xorl %r12d, %r12d
xorl %ebx, %ebx
xorl %r13d, %r13d
cmpq %rdx, %rcx
je 0x99378
movq 0x18(%r15), %rsi
movq (%rsi,%rdx,8), %rsi
shrq $0x21, %rsi
movzbl (%rax,%rsi), %esi
testl %esi, %esi
je 0x99373
cmpl $0x5, %esi
jne 0x99368
incl %r13d
jmp 0x99373
cmpl %ebp, %esi
jne 0x99371
incl %r12d
jmp 0x99373
incl %ebx
incq %rdx
jmp 0x99345
movl %r12d, %edi
movl %ebx, %esi
movl %r13d, %edx
movss 0xc(%rsp), %xmm0
movss 0x10(%rsp), %xmm1
movl 0x24(%rsp), %r8d
callq 0xc389e
testl %eax, %eax
je 0x993ba
movq 0x18(%r14), %rax
movq 0x20(%rax), %rax
movq 0x30(%rsp), %rcx
movq 0x48(%rcx), %rcx
movq 0x28(%rsp), %rdx
movl (%rcx,%rdx,4), %ecx
shrl %ecx
movb $0x0, 0x4(%rax,%rcx,8)
movl 0x20(%rsp), %edi
addl %r12d, %edi
movl 0x1c(%rsp), %esi
addl %ebx, %esi
movl 0x18(%rsp), %edx
addl %r13d, %edx
movl 0x14(%rsp), %ecx
addl 0x10(%r15), %ecx
movl %edi, 0x20(%rsp)
movl %esi, 0x1c(%rsp)
movl %edx, 0x18(%rsp)
movl %ecx, 0x14(%rsp)
movss 0xc(%rsp), %xmm0
movss 0x10(%rsp), %xmm1
movl 0x24(%rsp), %r8d
callq 0xc389e
testl %eax, %eax
movq 0x30(%rsp), %r12
leaq 0x1bae26(%rip), %r13    # 0x254230
movq 0x28(%rsp), %rdx
je 0x994ce
xorl %ebx, %ebx
cmpl %edx, %ebx
ja 0x994ce
movq 0x18(%r14), %rax
movq 0x20(%rax), %rcx
movq 0x48(%r12), %rax
movl %ebx, %r15d
movl (%rax,%r15,4), %eax
shrl %eax
cmpb $0x1, 0x4(%rcx,%rax,8)
jne 0x994c7
movq 0x10(%r14), %rcx
imulq $0x28, %rax, %rdx
leaq (%rcx,%rdx), %rax
movl 0x10(%rcx,%rdx), %ecx
movq 0x28(%r13), %r8
xorl %r9d, %r9d
xorl %edi, %edi
xorl %esi, %esi
xorl %edx, %edx
cmpq %r9, %rcx
je 0x99492
movq 0x18(%rax), %r10
movq (%r10,%r9,8), %r10
shrq $0x21, %r10
movzbl (%r8,%r10), %r10d
testl %r10d, %r10d
je 0x9948d
cmpl $0x5, %r10d
jne 0x99482
incl %edx
jmp 0x9948d
cmpl %ebp, %r10d
jne 0x9948b
incl %edi
jmp 0x9948d
incl %esi
incq %r9
jmp 0x9945d
movss 0xc(%rsp), %xmm0
movss 0x10(%rsp), %xmm1
xorl %r8d, %r8d
callq 0xc389e
testl %eax, %eax
movq 0x28(%rsp), %rdx
je 0x994c7
movq 0x18(%r14), %rax
movq 0x20(%rax), %rax
movq 0x48(%r12), %rcx
movl (%rcx,%r15,4), %ecx
shrl %ecx
movb $0x0, 0x4(%rax,%rcx,8)
incl %ebx
jmp 0x99417
incl %edx
jmp 0x9930b
addq $0x38, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq