// File: /workspace/github_cpp_makefile_star2_O1/chhylp123[P]hifiasm/hic.cpp
// Function: label_unitigs(G_partition*, ma_ug_t*)
void label_unitigs(G_partition* g_p, ma_ug_t* ug)
{
    memset(R_INF.trio_flag, AMBIGU, R_INF.total_reads * sizeof(uint8_t));
    uint32_t i, k, j, *h0, h0_n, *h1, h1_n, uID, *h = NULL, h_n, flag = AMBIGU;
    int status;
    ma_utg_t *u = NULL;

    for (i = 0; i < g_p->n; i++)
    {
        if(g_p->a[i].h[0] > 0 && g_p->a[i].status[0] != 1 && g_p->a[i].status[0] != -1) continue;
        if(g_p->a[i].h[1] > 0 && g_p->a[i].status[1] != 1 && g_p->a[i].status[1] != -1) continue;
        get_phased_block(g_p, NULL, i, NULL, NULL, &h0, &h0_n, &h1, &h1_n, NULL, NULL);

        status = g_p->a[i].status[0];
        h = h0; h_n = h0_n;
        if(status == 1)
        {
            flag = FATHER;
        }
        else if (status == -1)
        {
            flag = MOTHER;
        }
        for (j = 0; j < h_n; j++)
        {
            uID = h[j];
            u = &ug->u.a[uID];
            if(u->m == 0) continue;
            for (k = 0; k < u->n; k++)
            {
                R_INF.trio_flag[u->a[k]>>33] = flag;
            }
        }



        status = g_p->a[i].status[1];
        h = h1; h_n = h1_n;
        if(status == 1)
        {
            flag = FATHER;
        }
        else if (status == -1)
        {
            flag = MOTHER;
        }
        for (j = 0; j < h_n; j++)
        {
            uID = h[j];
            u = &ug->u.a[uID];
            if(u->m == 0) continue;
            for (k = 0; k < u->n; k++)
            {
                R_INF.trio_flag[u->a[k]>>33] = flag;
            }
        }
    }


    uint64_t occ = 0; 
    for (i = 0; i < ug->u.n; i++)
    {
        occ += ug->u.a[i].n;
    }

    ///fprintf(stderr, "# reads: %lu\n", occ);

    for (i = occ = 0; i < R_INF.total_reads; i++)
    {
        if(R_INF.trio_flag[i] == FATHER) occ++;
    }

    ///fprintf(stderr, "# Father reads: %lu\n", occ);

    for (i = occ = 0; i < R_INF.total_reads; i++)
    {
        if(R_INF.trio_flag[i] == MOTHER) occ++;
    }
    
    ///fprintf(stderr, "# Mother reads: %lu\n", occ);
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
pushq %rax
movq %rsi, %rbx
movq %rdi, %r14
leaq 0x13575c(%rip), %r15    # 0x28b230
movq 0x28(%r15), %rdi
movq 0x50(%r15), %rdx
xorl %r12d, %r12d
xorl %esi, %esi
callq 0x20e0
cmpq $0x0, (%r14)
je 0x155c45
xorl %ecx, %ecx
xorl %eax, %eax
movq 0x10(%r14), %r9
leaq (%rcx,%rcx,8), %rsi
leaq (%r9,%rsi,8), %r10
movl 0x18(%r10), %ecx
testq %rcx, %rcx
je 0x155b1b
movl 0x24(%r10), %edx
cmpl $0x1, %edx
je 0x155b1b
cmpl $-0x1, %edx
jne 0x155c37
cmpl $0x0, 0x1c(%r10)
je 0x155b34
movl 0x28(%r10), %edx
cmpl $0x1, %edx
je 0x155b34
cmpl $-0x1, %edx
jne 0x155c37
movl 0x18(%r9,%rsi,8), %edi
movq %rdi, %r8
testq %rdi, %rdi
je 0x155b46
movq 0x10(%r9,%rsi,8), %r8
movl 0x1c(%r9,%rsi,8), %edx
shlq $0x2, %rcx
addq 0x10(%r10), %rcx
testq %rdx, %rdx
cmoveq %rdx, %rcx
movl 0x24(%r9,%rsi,8), %r9d
cmpl $0x1, %r9d
je 0x155b73
cmpl $-0x1, %r9d
jne 0x155b76
movl $0x2, %r12d
jmp 0x155b76
movl %r9d, %r12d
testq %rdi, %rdi
je 0x155bca
xorl %r9d, %r9d
movl (%r8,%r9,4), %r11d
movq 0x10(%rbx), %r10
leaq (%r11,%r11,4), %r11
cmpl $0x0, 0xc(%r10,%r11,8)
je 0x155bc2
leaq (%r10,%r11,8), %r10
cmpl $0x0, 0x10(%r10)
je 0x155bc2
xorl %r11d, %r11d
movq 0x28(%r15), %r13
movq 0x18(%r10), %rbp
movq (%rbp,%r11,8), %rbp
shrq $0x21, %rbp
movb %r12b, (%r13,%rbp)
incq %r11
movl 0x10(%r10), %r13d
cmpq %r13, %r11
jb 0x155ba0
incq %r9
cmpq %rdi, %r9
jne 0x155b7e
movq 0x10(%r14), %rdi
movl 0x28(%rdi,%rsi,8), %esi
cmpl $0x1, %esi
je 0x155be4
cmpl $-0x1, %esi
jne 0x155be7
movl $0x2, %r12d
jmp 0x155be7
movl %esi, %r12d
testq %rdx, %rdx
je 0x155c37
xorl %esi, %esi
movl (%rcx,%rsi,4), %r8d
movq 0x10(%rbx), %rdi
leaq (%r8,%r8,4), %r8
cmpl $0x0, 0xc(%rdi,%r8,8)
je 0x155c2f
leaq (%rdi,%r8,8), %rdi
cmpl $0x0, 0x10(%rdi)
je 0x155c2f
xorl %r8d, %r8d
movq 0x28(%r15), %r9
movq 0x18(%rdi), %r10
movq (%r10,%r8,8), %r10
shrq $0x21, %r10
movb %r12b, (%r9,%r10)
incq %r8
movl 0x10(%rdi), %r9d
cmpq %r9, %r8
jb 0x155c0f
incq %rsi
cmpq %rdx, %rsi
jne 0x155bee
incl %eax
movq %rax, %rcx
cmpq %rax, (%r14)
ja 0x155af4
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq