// File: chhylp123[P]hifiasm/Overlaps.cpp
// Function: update_trio_mmhap(unsigned int, ma_ug_t*, mmhap_t*, asg_t*, unsigned int)
void update_trio_mmhap(uint32_t hapid, ma_ug_t *mm_ug, mmhap_t *rh, asg_t *sg, uint32_t n_hap)
{
    uint64_t k, z, m, rid; ma_utg_t *u;
    for (k = 0; k < sg->n_seq; k++) {
        if(R_INF.trio_flag[k] == DROP) continue;
        R_INF.trio_flag[k] = AMBIGU;
    }
    
    for (k = 0; k < mm_ug->u.n; k++) { 
        if(rh->h.a[k].m == n_hap || rh->h.a[k].n == 0) {
            m = AMBIGU;
        } else {
            for (z = 0, m = MOTHER; z < rh->h.a[k].n; z++) {
                if(rh->a.a[rh->h.a[k].a+z] == hapid) {m = FATHER; break;}
            }
        }
        
        u = &(mm_ug->u.a[k]);
        for (z = 0; z < u->n; z++) {
            rid = u->a[z]>>33;
            if(R_INF.trio_flag[rid] == DROP) continue;
            R_INF.trio_flag[rid] = m;
        }
        fprintf(stderr, "utg%.6lu%c\tm::%lu\n", k+1, "lc"[mm_ug->u.a[k].circ], m);
    }
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x50, %rsp
movl %edi, -0x4(%rbp)
movq %rsi, -0x10(%rbp)
movq %rdx, -0x18(%rbp)
movq %rcx, -0x20(%rbp)
movl %r8d, -0x24(%rbp)
movq $0x0, -0x30(%rbp)
movq -0x30(%rbp), %rax
movq -0x20(%rbp), %rcx
movl 0x14(%rcx), %ecx
andl $0x7fffffff, %ecx       # imm = 0x7FFFFFFF
movl %ecx, %ecx
cmpq %rcx, %rax
jae 0x10d7c6
leaq 0x2b7b3e(%rip), %rax    # 0x3c52d0
movq 0x28(%rax), %rax
movq -0x30(%rbp), %rcx
movzbl (%rax,%rcx), %eax
cmpl $0x5, %eax
jne 0x10d7a5
jmp 0x10d7b8
leaq 0x2b7b24(%rip), %rax    # 0x3c52d0
movq 0x28(%rax), %rax
movq -0x30(%rbp), %rcx
movb $0x0, (%rax,%rcx)
movq -0x30(%rbp), %rax
addq $0x1, %rax
movq %rax, -0x30(%rbp)
jmp 0x10d773
movq $0x0, -0x30(%rbp)
movq -0x30(%rbp), %rax
movq -0x10(%rbp), %rcx
cmpq (%rcx), %rax
jae 0x10d961
movq -0x18(%rbp), %rax
movq 0x10(%rax), %rax
imulq $0xc, -0x30(%rbp), %rcx
addq %rcx, %rax
movl 0x4(%rax), %eax
cmpl -0x24(%rbp), %eax
je 0x10d80c
movq -0x18(%rbp), %rax
movq 0x10(%rax), %rax
imulq $0xc, -0x30(%rbp), %rcx
addq %rcx, %rax
cmpl $0x0, (%rax)
jne 0x10d816
movq $0x0, -0x40(%rbp)
jmp 0x10d884
movq $0x0, -0x38(%rbp)
movq $0x2, -0x40(%rbp)
movq -0x38(%rbp), %rax
movq -0x18(%rbp), %rcx
movq 0x10(%rcx), %rcx
imulq $0xc, -0x30(%rbp), %rdx
addq %rdx, %rcx
movl (%rcx), %ecx
cmpq %rcx, %rax
jae 0x10d882
movq -0x18(%rbp), %rax
movq 0x28(%rax), %rax
movq -0x18(%rbp), %rcx
movq 0x10(%rcx), %rcx
imulq $0xc, -0x30(%rbp), %rdx
addq %rdx, %rcx
movl 0x8(%rcx), %ecx
addq -0x38(%rbp), %rcx
movl (%rax,%rcx,4), %eax
cmpl -0x4(%rbp), %eax
jne 0x10d872
movq $0x1, -0x40(%rbp)
jmp 0x10d882
jmp 0x10d874
movq -0x38(%rbp), %rax
addq $0x1, %rax
movq %rax, -0x38(%rbp)
jmp 0x10d826
jmp 0x10d884
movq -0x10(%rbp), %rax
movq 0x10(%rax), %rax
imulq $0x28, -0x30(%rbp), %rcx
addq %rcx, %rax
movq %rax, -0x50(%rbp)
movq $0x0, -0x38(%rbp)
movq -0x38(%rbp), %rax
movq -0x50(%rbp), %rcx
movl 0x10(%rcx), %ecx
cmpq %rcx, %rax
jae 0x10d908
movq -0x50(%rbp), %rax
movq 0x18(%rax), %rax
movq -0x38(%rbp), %rcx
movq (%rax,%rcx,8), %rax
shrq $0x21, %rax
movq %rax, -0x48(%rbp)
leaq 0x2b7a01(%rip), %rax    # 0x3c52d0
movq 0x28(%rax), %rax
movq -0x48(%rbp), %rcx
movzbl (%rax,%rcx), %eax
cmpl $0x5, %eax
jne 0x10d8e2
jmp 0x10d8fa
movq -0x40(%rbp), %rax
movb %al, %dl
leaq 0x2b79e1(%rip), %rax    # 0x3c52d0
movq 0x28(%rax), %rax
movq -0x48(%rbp), %rcx
movb %dl, (%rax,%rcx)
movq -0x38(%rbp), %rax
addq $0x1, %rax
movq %rax, -0x38(%rbp)
jmp 0x10d8a0
movq 0x2b66d1(%rip), %rax    # 0x3c3fe0
movq (%rax), %rdi
movq -0x30(%rbp), %rdx
addq $0x1, %rdx
movq -0x10(%rbp), %rax
movq 0x10(%rax), %rax
imulq $0x28, -0x30(%rbp), %rcx
addq %rcx, %rax
movl (%rax), %eax
shrl $0x1f, %eax
movl %eax, %eax
movl %eax, %ecx
leaq 0x2779c9(%rip), %rax    # 0x385303
movsbl (%rax,%rcx), %ecx
movq -0x40(%rbp), %r8
leaq 0x27a24b(%rip), %rsi    # 0x387b94
movb $0x0, %al
callq 0x22a0
movq -0x30(%rbp), %rax
addq $0x1, %rax
movq %rax, -0x30(%rbp)
jmp 0x10d7ce
addq $0x50, %rsp
popq %rbp
retq
nopw (%rax,%rax)