// File: chhylp123[P]hifiasm/gfa_ut.cpp
// Function: get_ug_tip_trio_infor(ma_ug_t*, unsigned int)
uint8_t get_ug_tip_trio_infor(ma_ug_t *ug, uint32_t begNode)
{
    uint32_t v = begNode, w, k, s;
    uint32_t kv;
    uint32_t eLen = 0, uLen = 0;
    uint32_t father_occ = 0, mother_occ = 0, ambigious_occ = 0;
    ma_utg_t *u;

    while (1) {
        kv = get_real_length(ug->g, v, NULL);
        u = &(ug->u.a[v>>1]); eLen += u->n; 

        for (k = 0; k < u->n; k++) {
            s = u->a[k]>>33;
            if(R_INF.trio_flag[s]==FATHER) father_occ++;
            else if(R_INF.trio_flag[s]==MOTHER) mother_occ++;
            else if((R_INF.trio_flag[s]==AMBIGU) || (R_INF.trio_flag[s]==DROP)) ambigious_occ++;
        }
        if(kv!=1) break;
        ///kv must be 1 here
        kv = get_real_length(ug->g, v, &w);
        if(get_real_length(ug->g, w^1, NULL)!=1) break;
        v = w;
        if(v == begNode) break;
    }

    uLen = eLen;///how many nodes
    eLen = father_occ + mother_occ;///haplotype-sepcific nodes
    if(eLen == 0) return AMBIGU;
    if(father_occ >= mother_occ) {
        if((father_occ > TRIO_THRES*eLen) && (father_occ >= DOUBLE_CHECK_THRES*uLen)) return FATHER;
    } else {
        if((mother_occ > TRIO_THRES*eLen) && (mother_occ >= DOUBLE_CHECK_THRES*uLen)) return MOTHER;
    }
    return AMBIGU;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x50, %rsp
movq %rdi, -0x10(%rbp)
movl %esi, -0x14(%rbp)
movl -0x14(%rbp), %eax
movl %eax, -0x18(%rbp)
movl $0x0, -0x2c(%rbp)
movl $0x0, -0x30(%rbp)
movl $0x0, -0x34(%rbp)
movl $0x0, -0x38(%rbp)
movl $0x0, -0x3c(%rbp)
movq -0x10(%rbp), %rax
movq 0x18(%rax), %rdi
movl -0x18(%rbp), %esi
xorl %eax, %eax
movl %eax, %edx
callq 0x166b50
movl %eax, -0x28(%rbp)
movq -0x10(%rbp), %rax
movq 0x10(%rax), %rax
movl -0x18(%rbp), %ecx
shrl %ecx
movl %ecx, %ecx
imulq $0x28, %rcx, %rcx
addq %rcx, %rax
movq %rax, -0x48(%rbp)
movq -0x48(%rbp), %rax
movl 0x10(%rax), %eax
addl -0x2c(%rbp), %eax
movl %eax, -0x2c(%rbp)
movl $0x0, -0x20(%rbp)
movl -0x20(%rbp), %eax
movq -0x48(%rbp), %rcx
cmpl 0x10(%rcx), %eax
jae 0x318fa2
movq -0x48(%rbp), %rax
movq 0x18(%rax), %rax
movl -0x20(%rbp), %ecx
movq (%rax,%rcx,8), %rax
shrq $0x21, %rax
movl %eax, -0x24(%rbp)
leaq 0xac3b6(%rip), %rax     # 0x3c52d0
movq 0x28(%rax), %rax
movl -0x24(%rbp), %ecx
movzbl (%rax,%rcx), %eax
cmpl $0x1, %eax
jne 0x318f35
movl -0x34(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x34(%rbp)
jmp 0x318f92
leaq 0xac394(%rip), %rax     # 0x3c52d0
movq 0x28(%rax), %rax
movl -0x24(%rbp), %ecx
movzbl (%rax,%rcx), %eax
cmpl $0x2, %eax
jne 0x318f57
movl -0x38(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x38(%rbp)
jmp 0x318f90
leaq 0xac372(%rip), %rax     # 0x3c52d0
movq 0x28(%rax), %rax
movl -0x24(%rbp), %ecx
movzbl (%rax,%rcx), %eax
cmpl $0x0, %eax
je 0x318f85
leaq 0xac35b(%rip), %rax     # 0x3c52d0
movq 0x28(%rax), %rax
movl -0x24(%rbp), %ecx
movzbl (%rax,%rcx), %eax
cmpl $0x5, %eax
jne 0x318f8e
movl -0x3c(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x3c(%rbp)
jmp 0x318f90
jmp 0x318f92
jmp 0x318f94
movl -0x20(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x20(%rbp)
jmp 0x318eed
cmpl $0x1, -0x28(%rbp)
je 0x318faa
jmp 0x318ff4
movq -0x10(%rbp), %rax
movq 0x18(%rax), %rdi
movl -0x18(%rbp), %esi
leaq -0x1c(%rbp), %rdx
callq 0x166b50
movl %eax, -0x28(%rbp)
movq -0x10(%rbp), %rax
movq 0x18(%rax), %rdi
movl -0x1c(%rbp), %esi
xorl $0x1, %esi
xorl %eax, %eax
movl %eax, %edx
callq 0x166b50
cmpl $0x1, %eax
je 0x318fdf
jmp 0x318ff4
movl -0x1c(%rbp), %eax
movl %eax, -0x18(%rbp)
movl -0x18(%rbp), %eax
cmpl -0x14(%rbp), %eax
jne 0x318fef
jmp 0x318ff4
jmp 0x318ea8
movl -0x2c(%rbp), %eax
movl %eax, -0x30(%rbp)
movl -0x34(%rbp), %eax
addl -0x38(%rbp), %eax
movl %eax, -0x2c(%rbp)
cmpl $0x0, -0x2c(%rbp)
jne 0x319012
movb $0x0, -0x1(%rbp)
jmp 0x3190b6
movl -0x34(%rbp), %eax
cmpl -0x38(%rbp), %eax
jb 0x319066
movl -0x34(%rbp), %eax
cvtsi2sd %rax, %xmm0
movl -0x2c(%rbp), %eax
cvtsi2sd %rax, %xmm2
movsd 0x69236(%rip), %xmm1    # 0x382268
mulsd %xmm2, %xmm1
ucomisd %xmm1, %xmm0
jbe 0x319064
movl -0x34(%rbp), %eax
cvtsi2sd %rax, %xmm0
movl -0x30(%rbp), %eax
cvtsi2sd %rax, %xmm2
movsd 0x65fc4(%rip), %xmm1    # 0x37f018
mulsd %xmm2, %xmm1
ucomisd %xmm1, %xmm0
jb 0x319064
movb $0x1, -0x1(%rbp)
jmp 0x3190b6
jmp 0x3190b2
movl -0x38(%rbp), %eax
cvtsi2sd %rax, %xmm0
movl -0x2c(%rbp), %eax
cvtsi2sd %rax, %xmm2
movsd 0x691ea(%rip), %xmm1    # 0x382268
mulsd %xmm2, %xmm1
ucomisd %xmm1, %xmm0
jbe 0x3190b0
movl -0x38(%rbp), %eax
cvtsi2sd %rax, %xmm0
movl -0x30(%rbp), %eax
cvtsi2sd %rax, %xmm2
movsd 0x65f78(%rip), %xmm1    # 0x37f018
mulsd %xmm2, %xmm1
ucomisd %xmm1, %xmm0
jb 0x3190b0
movb $0x2, -0x1(%rbp)
jmp 0x3190b6
jmp 0x3190b2
movb $0x0, -0x1(%rbp)
movb -0x1(%rbp), %al
addq $0x50, %rsp
popq %rbp
retq
nop