// File: /workspace/github_cpp_makefile_star2_O1/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
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
movl %esi, %ebx
movq 0x10(%rdi), %rsi
movq 0x18(%rdi), %rdi
movq 0x28(%rdi), %r9
leaq 0xa0bdb(%rip), %rax     # 0x28b230
movq 0x28(%rax), %r10
xorl %eax, %eax
movl $0xffffffff, %r13d      # imm = 0xFFFFFFFF
movl %ebx, -0x4(%rsp)
xorl %ecx, %ecx
xorl %edx, %edx
movl %ebx, %r8d
movq (%r9,%r8,8), %r14
xorl %r12d, %r12d
movq %r14, %r15
andq %r13, %r15
je 0x1ea6bf
movq 0x8(%rdi), %r8
movq %r14, %r11
shrq $0x20, %r11
leaq (%r11,%r11,2), %r11
leaq (%r8,%r11,8), %r11
addq $0xc, %r11
leaq (,%r15,8), %r8
leaq (%r8,%r8,2), %r13
xorl %ebp, %ebp
movl (%r11,%rbp), %r8d
notl %r8d
shrl $0x1f, %r8d
addl %r8d, %r12d
addq $0x18, %rbp
cmpq %rbp, %r13
jne 0x1ea6a0
cmpl $0x1, %r12d
sete %r12b
movl %ebx, %r8d
shrl %r8d
leaq (%r8,%r8,4), %r11
movl 0x10(%rsi,%r11,8), %r13d
testq %r13, %r13
je 0x1ea706
leaq (%rsi,%r11,8), %r8
movq 0x18(%r8), %rbp
xorl %r11d, %r11d
movq (%rbp,%r11,8), %r8
shrq $0x21, %r8
movzbl (%r10,%r8), %r8d
cmpl $0x2, %r8d
je 0x1ea6fc
cmpl $0x1, %r8d
jne 0x1ea6fe
incl %ecx
jmp 0x1ea6fe
incl %edx
incq %r11
cmpq %r11, %r13
jne 0x1ea6de
addl %r13d, %eax
testb %r12b, %r12b
movl $0xffffffff, %r13d      # imm = 0xFFFFFFFF
je 0x1ea7b7
testq %r15, %r15
je 0x1ea751
movq 0x8(%rdi), %r8
shrq $0x20, %r14
shlq $0x3, %r15
leaq (%r15,%r15,2), %r11
leaq (%r14,%r14,2), %r14
leaq (%r8,%r14,8), %r14
addq $0xc, %r14
xorl %r15d, %r15d
cmpl $0x0, (%r14,%r15)
js 0x1ea748
movl -0x4(%r14,%r15), %ebx
addq $0x18, %r15
cmpq %r15, %r11
jne 0x1ea73c
movl %ebx, %r8d
xorl $0x1, %r8d
movq (%r9,%r8,8), %r11
movq %r11, %r14
andq %r13, %r14
je 0x1ea7a5
movq 0x8(%rdi), %r8
shrq $0x20, %r11
leaq (%r11,%r11,2), %r11
leaq (%r8,%r11,8), %r11
addq $0xc, %r11
shlq $0x3, %r14
leaq (%r14,%r14,2), %r14
xorl %r15d, %r15d
xorl %ebp, %ebp
movl (%r11,%r15), %r8d
notl %r8d
shrl $0x1f, %r8d
addl %r8d, %ebp
addq $0x18, %r15
cmpq %r15, %r14
jne 0x1ea785
cmpl $0x1, %ebp
setne %r11b
jmp 0x1ea7a8
movb $0x1, %r11b
cmpl -0x4(%rsp), %ebx
je 0x1ea7b7
testb %r11b, %r11b
je 0x1ea669
movl %edx, %esi
addl %ecx, %esi
je 0x1ea81a
movl %esi, %esi
cvtsi2sd %rsi, %xmm0
mulsd 0x3ad2c(%rip), %xmm0    # 0x2254f8
cmpl %edx, %ecx
jae 0x1ea7f3
movl %edx, %ecx
cvtsi2sd %rcx, %xmm1
ucomisd %xmm0, %xmm1
jbe 0x1ea81a
movl %eax, %eax
xorps %xmm0, %xmm0
cvtsi2sd %rax, %xmm0
mulsd 0x3a3e1(%rip), %xmm0    # 0x224bd0
movb $0x2, %al
jmp 0x1ea814
movl %ecx, %ecx
cvtsi2sd %rcx, %xmm1
ucomisd %xmm0, %xmm1
jbe 0x1ea81a
movl %eax, %eax
xorps %xmm0, %xmm0
cvtsi2sd %rax, %xmm0
mulsd 0x3a3be(%rip), %xmm0    # 0x224bd0
movb $0x1, %al
ucomisd %xmm0, %xmm1
jae 0x1ea81c
xorl %eax, %eax
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq