// File: chhylp123[P]hifiasm/hic.cpp
// Function: init_contig_H_partition(bubble_type*, ha_ug_index*, H_partition*)
void init_contig_H_partition(bubble_type* bub, ha_ug_index* idx, H_partition* hap)
{
    uint32_t i, k_i, k_j, uID, *a = NULL, n, *h0, h0_n, *h1, h1_n;
    destory_G_partition(&(hap->group_g_p)); memset(&(hap->group_g_p), 0, sizeof(G_partition));
    init_G_partition(&(hap->group_g_p), hap->n);
    partition_warp *res = NULL;
    ma_utg_t *u_x = NULL;
    chain_hic_warp *c_w = &(bub->c_w);

    for (i = 0; i < bub->c_w.n; i++)
    {
        kv_pushp(partition_warp, hap->group_g_p, &res);
        kv_init(res->a);
        res->full_bub = 0;
        res->h[0] = res->h[1] = 0;

        res->status[0] = 1; res->status[1] = -1;
        res->weight[0] = res->weight[1] = res->weight_convex = 0;


        u_x = (*c_w).a[(*c_w).a[i].id].u;
        for (k_i = 0; k_i < u_x->n; k_i++)
        {
            get_bubbles(bub, u_x->a[k_i]>>33, NULL, NULL, &a, &n, NULL);
            for (k_j = 0; k_j < n; k_j++)
            {
                uID = a[k_j]>>1;
                if((*c_w).chain_idx[uID] != (*c_w).a[i].id) continue;
                if(get_phase_status(hap, uID)==1)
                {
                    kv_push(uint32_t, res->a, uID);
                    res->h[0]++;
                }
            }
        }

        for (k_i = 0; k_i < u_x->n; k_i++)
        {
            get_bubbles(bub, u_x->a[k_i]>>33, NULL, NULL, &a, &n, NULL);
            for (k_j = 0; k_j < n; k_j++)
            {
                uID = a[k_j]>>1;
                if((*c_w).chain_idx[uID] != (*c_w).a[i].id) continue;
                if(get_phase_status(hap, uID)==-1)
                {
                    kv_push(uint32_t, res->a, uID);
                    res->h[1]++;
                }
            }
        }


        for (k_i = 0; k_i < res->h[0]; k_i++)
        {
            ///if(hap->group_g_p.index[res->a.a[k_i]] != (uint32_t)-1) fprintf(stderr, "ERROR---00\n");
            hap->group_g_p.index[res->a.a[k_i]] = hap->group_g_p.n-1;
            hap->group_g_p.index[res->a.a[k_i]] = hap->group_g_p.index[res->a.a[k_i]] << 1;
        } 

        for (; k_i < res->a.n; k_i++)
        {
            ///if(hap->group_g_p.index[res->a.a[k_i]] != (uint32_t)-1) fprintf(stderr, "ERROR---11\n");
            hap->group_g_p.index[res->a.a[k_i]] = hap->group_g_p.n-1;
            hap->group_g_p.index[res->a.a[k_i]] = (hap->group_g_p.index[res->a.a[k_i]] << 1) + 1;
        }

        get_phased_block(&(hap->group_g_p), NULL, i, NULL, NULL, &h0, &h0_n, &h1, &h1_n, NULL, NULL);
        if(h0_n >0) res->weight[0] = get_cluster_weight(hap, hap->link, h0, h0_n); 
        if(h1_n >0) res->weight[1] = get_cluster_weight(hap, hap->link, h1, h1_n); 
        res->weight_convex = get_cluster_inner_weight(hap, hap->link, h0, h0_n, h1, h1_n);
    }

    flip_by_node(hap, &(hap->group_g_p), bub);
    label_unitigs(&(hap->group_g_p), idx->ug);
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0xb0, %rsp
movq %rdi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
movq %rdx, -0x18(%rbp)
movq $0x0, -0x30(%rbp)
movq -0x18(%rbp), %rdi
addq $0x58, %rdi
callq 0x1d9b40
movq -0x18(%rbp), %rdi
addq $0x58, %rdi
xorl %esi, %esi
movl $0x20, %edx
callq 0x2100
movq -0x18(%rbp), %rdi
addq $0x58, %rdi
movq -0x18(%rbp), %rax
movq (%rax), %rsi
callq 0x1d9a60
movq $0x0, -0x60(%rbp)
movq $0x0, -0x68(%rbp)
movq -0x8(%rbp), %rax
addq $0xe0, %rax
movq %rax, -0x70(%rbp)
movl $0x0, -0x1c(%rbp)
movl -0x1c(%rbp), %eax
movq -0x8(%rbp), %rcx
cmpq 0xe0(%rcx), %rax
jae 0x200c9f
jmp 0x2006df
movq -0x18(%rbp), %rax
movq 0x58(%rax), %rax
movq -0x18(%rbp), %rcx
cmpq 0x60(%rcx), %rax
jne 0x200745
movq -0x18(%rbp), %rax
cmpq $0x0, 0x60(%rax)
je 0x20070d
movq -0x18(%rbp), %rax
movq 0x60(%rax), %rax
shlq %rax
movq %rax, -0x78(%rbp)
jmp 0x200718
movl $0x2, %eax
movq %rax, -0x78(%rbp)
jmp 0x200718
movq -0x78(%rbp), %rcx
movq -0x18(%rbp), %rax
movq %rcx, 0x60(%rax)
movq -0x18(%rbp), %rax
movq 0x68(%rax), %rdi
movq -0x18(%rbp), %rax
imulq $0x48, 0x60(%rax), %rsi
callq 0x2360
movq %rax, %rcx
movq -0x18(%rbp), %rax
movq %rcx, 0x68(%rax)
movq -0x18(%rbp), %rax
movq 0x68(%rax), %rax
movq -0x18(%rbp), %rdx
movq 0x58(%rdx), %rcx
movq %rcx, %rsi
addq $0x1, %rsi
movq %rsi, 0x58(%rdx)
imulq $0x48, %rcx, %rcx
addq %rcx, %rax
movq %rax, -0x60(%rbp)
movq -0x60(%rbp), %rax
movq $0x0, 0x8(%rax)
movq -0x60(%rbp), %rax
movq $0x0, (%rax)
movq -0x60(%rbp), %rax
movq $0x0, 0x10(%rax)
movq -0x60(%rbp), %rax
movb $0x0, 0x20(%rax)
movq -0x60(%rbp), %rax
movl $0x0, 0x1c(%rax)
movq -0x60(%rbp), %rax
movl $0x0, 0x18(%rax)
movq -0x60(%rbp), %rax
movl $0x1, 0x24(%rax)
movq -0x60(%rbp), %rax
movl $0xffffffff, 0x28(%rax) # imm = 0xFFFFFFFF
movq -0x60(%rbp), %rax
xorps %xmm0, %xmm0
movsd %xmm0, 0x40(%rax)
movq -0x60(%rbp), %rax
xorps %xmm0, %xmm0
movsd %xmm0, 0x38(%rax)
movq -0x60(%rbp), %rax
xorps %xmm0, %xmm0
movsd %xmm0, 0x30(%rax)
movq -0x70(%rbp), %rax
movq 0x10(%rax), %rax
movq -0x70(%rbp), %rcx
movq 0x10(%rcx), %rcx
movl -0x1c(%rbp), %edx
imulq $0x28, %rdx, %rdx
addq %rdx, %rcx
movl 0x8(%rcx), %ecx
imulq $0x28, %rcx, %rcx
addq %rcx, %rax
movq 0x10(%rax), %rax
movq %rax, -0x68(%rbp)
movl $0x0, -0x20(%rbp)
movl -0x20(%rbp), %eax
movq -0x68(%rbp), %rcx
cmpl 0x10(%rcx), %eax
jae 0x200973
movq -0x8(%rbp), %rdi
movq -0x68(%rbp), %rax
movq 0x18(%rax), %rax
movl -0x20(%rbp), %ecx
movq (%rax,%rcx,8), %rsi
shrq $0x21, %rsi
xorl %eax, %eax
movl %eax, %ecx
leaq -0x30(%rbp), %r8
leaq -0x34(%rbp), %r9
movq %rcx, %rdx
movq $0x0, (%rsp)
callq 0x1c4b20
movl $0x0, -0x24(%rbp)
movl -0x24(%rbp), %eax
cmpl -0x34(%rbp), %eax
jae 0x200963
movq -0x30(%rbp), %rax
movl -0x24(%rbp), %ecx
movl (%rax,%rcx,4), %eax
shrl %eax
movl %eax, -0x28(%rbp)
movq -0x70(%rbp), %rax
movq 0x20(%rax), %rax
movl -0x28(%rbp), %ecx
movl (%rax,%rcx,4), %eax
movq -0x70(%rbp), %rcx
movq 0x10(%rcx), %rcx
movl -0x1c(%rbp), %edx
imulq $0x28, %rdx, %rdx
addq %rdx, %rcx
cmpl 0x8(%rcx), %eax
je 0x2008a8
jmp 0x200955
movq -0x18(%rbp), %rdi
movl -0x28(%rbp), %esi
callq 0x2145e0
cmpl $0x1, %eax
jne 0x200953
jmp 0x2008bf
movq -0x60(%rbp), %rax
movq (%rax), %rax
movq -0x60(%rbp), %rcx
cmpq 0x8(%rcx), %rax
jne 0x200927
movq -0x60(%rbp), %rax
cmpq $0x0, 0x8(%rax)
je 0x2008ec
movq -0x60(%rbp), %rax
movq 0x8(%rax), %rax
shlq %rax
movq %rax, -0x80(%rbp)
jmp 0x2008f7
movl $0x2, %eax
movq %rax, -0x80(%rbp)
jmp 0x2008f7
movq -0x80(%rbp), %rcx
movq -0x60(%rbp), %rax
movq %rcx, 0x8(%rax)
movq -0x60(%rbp), %rax
movq 0x10(%rax), %rdi
movq -0x60(%rbp), %rax
movq 0x8(%rax), %rsi
shlq $0x2, %rsi
callq 0x2360
movq %rax, %rcx
movq -0x60(%rbp), %rax
movq %rcx, 0x10(%rax)
movl -0x28(%rbp), %edx
movq -0x60(%rbp), %rax
movq 0x10(%rax), %rax
movq -0x60(%rbp), %rsi
movq (%rsi), %rcx
movq %rcx, %rdi
addq $0x1, %rdi
movq %rdi, (%rsi)
movl %edx, (%rax,%rcx,4)
movq -0x60(%rbp), %rax
movl 0x18(%rax), %ecx
addl $0x1, %ecx
movl %ecx, 0x18(%rax)
jmp 0x200955
movl -0x24(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x24(%rbp)
jmp 0x200863
jmp 0x200965
movl -0x20(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x20(%rbp)
jmp 0x200819
movl $0x0, -0x20(%rbp)
movl -0x20(%rbp), %eax
movq -0x68(%rbp), %rcx
cmpl 0x10(%rcx), %eax
jae 0x200add
movq -0x8(%rbp), %rdi
movq -0x68(%rbp), %rax
movq 0x18(%rax), %rax
movl -0x20(%rbp), %ecx
movq (%rax,%rcx,8), %rsi
shrq $0x21, %rsi
xorl %eax, %eax
movl %eax, %ecx
leaq -0x30(%rbp), %r8
leaq -0x34(%rbp), %r9
movq %rcx, %rdx
movq $0x0, (%rsp)
callq 0x1c4b20
movl $0x0, -0x24(%rbp)
movl -0x24(%rbp), %eax
cmpl -0x34(%rbp), %eax
jae 0x200acd
movq -0x30(%rbp), %rax
movl -0x24(%rbp), %ecx
movl (%rax,%rcx,4), %eax
shrl %eax
movl %eax, -0x28(%rbp)
movq -0x70(%rbp), %rax
movq 0x20(%rax), %rax
movl -0x28(%rbp), %ecx
movl (%rax,%rcx,4), %eax
movq -0x70(%rbp), %rcx
movq 0x10(%rcx), %rcx
movl -0x1c(%rbp), %edx
imulq $0x28, %rdx, %rdx
addq %rdx, %rcx
cmpl 0x8(%rcx), %eax
je 0x200a09
jmp 0x200abf
movq -0x18(%rbp), %rdi
movl -0x28(%rbp), %esi
callq 0x2145e0
cmpl $-0x1, %eax
jne 0x200abd
jmp 0x200a20
movq -0x60(%rbp), %rax
movq (%rax), %rax
movq -0x60(%rbp), %rcx
cmpq 0x8(%rcx), %rax
jne 0x200a91
movq -0x60(%rbp), %rax
cmpq $0x0, 0x8(%rax)
je 0x200a50
movq -0x60(%rbp), %rax
movq 0x8(%rax), %rax
shlq %rax
movq %rax, -0x88(%rbp)
jmp 0x200a5e
movl $0x2, %eax
movq %rax, -0x88(%rbp)
jmp 0x200a5e
movq -0x88(%rbp), %rcx
movq -0x60(%rbp), %rax
movq %rcx, 0x8(%rax)
movq -0x60(%rbp), %rax
movq 0x10(%rax), %rdi
movq -0x60(%rbp), %rax
movq 0x8(%rax), %rsi
shlq $0x2, %rsi
callq 0x2360
movq %rax, %rcx
movq -0x60(%rbp), %rax
movq %rcx, 0x10(%rax)
movl -0x28(%rbp), %edx
movq -0x60(%rbp), %rax
movq 0x10(%rax), %rax
movq -0x60(%rbp), %rsi
movq (%rsi), %rcx
movq %rcx, %rdi
addq $0x1, %rdi
movq %rdi, (%rsi)
movl %edx, (%rax,%rcx,4)
movq -0x60(%rbp), %rax
movl 0x1c(%rax), %ecx
addl $0x1, %ecx
movl %ecx, 0x1c(%rax)
jmp 0x200abf
movl -0x24(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x24(%rbp)
jmp 0x2009c4
jmp 0x200acf
movl -0x20(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x20(%rbp)
jmp 0x20097a
movl $0x0, -0x20(%rbp)
movl -0x20(%rbp), %eax
movq -0x60(%rbp), %rcx
cmpl 0x18(%rcx), %eax
jae 0x200b56
movq -0x18(%rbp), %rax
movq 0x58(%rax), %rax
subq $0x1, %rax
movl %eax, %edx
movq -0x18(%rbp), %rax
movq 0x70(%rax), %rax
movq -0x60(%rbp), %rcx
movq 0x10(%rcx), %rcx
movl -0x20(%rbp), %esi
movl (%rcx,%rsi,4), %ecx
movl %edx, (%rax,%rcx,4)
movq -0x18(%rbp), %rax
movq 0x70(%rax), %rax
movq -0x60(%rbp), %rcx
movq 0x10(%rcx), %rcx
movl -0x20(%rbp), %edx
movl (%rcx,%rdx,4), %ecx
movl (%rax,%rcx,4), %edx
shll %edx
movq -0x18(%rbp), %rax
movq 0x70(%rax), %rax
movq -0x60(%rbp), %rcx
movq 0x10(%rcx), %rcx
movl -0x20(%rbp), %esi
movl (%rcx,%rsi,4), %ecx
movl %edx, (%rax,%rcx,4)
movl -0x20(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x20(%rbp)
jmp 0x200ae4
jmp 0x200b58
movl -0x20(%rbp), %eax
movq -0x60(%rbp), %rcx
cmpq (%rcx), %rax
jae 0x200bcd
movq -0x18(%rbp), %rax
movq 0x58(%rax), %rax
subq $0x1, %rax
movl %eax, %edx
movq -0x18(%rbp), %rax
movq 0x70(%rax), %rax
movq -0x60(%rbp), %rcx
movq 0x10(%rcx), %rcx
movl -0x20(%rbp), %esi
movl (%rcx,%rsi,4), %ecx
movl %edx, (%rax,%rcx,4)
movq -0x18(%rbp), %rax
movq 0x70(%rax), %rax
movq -0x60(%rbp), %rcx
movq 0x10(%rcx), %rcx
movl -0x20(%rbp), %edx
movl (%rcx,%rdx,4), %ecx
movl (%rax,%rcx,4), %edx
shll %edx
addl $0x1, %edx
movq -0x18(%rbp), %rax
movq 0x70(%rax), %rax
movq -0x60(%rbp), %rcx
movq 0x10(%rcx), %rcx
movl -0x20(%rbp), %esi
movl (%rcx,%rsi,4), %ecx
movl %edx, (%rax,%rcx,4)
movl -0x20(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x20(%rbp)
jmp 0x200b58
movq -0x18(%rbp), %rdi
addq $0x58, %rdi
movl -0x1c(%rbp), %eax
movl %eax, %edx
xorl %eax, %eax
movl %eax, %r8d
leaq -0x40(%rbp), %r9
leaq -0x44(%rbp), %r11
leaq -0x50(%rbp), %r10
leaq -0x54(%rbp), %rax
movq %r8, %rsi
movq %r8, %rcx
movq %r11, (%rsp)
movq %r10, 0x8(%rsp)
movq %rax, 0x10(%rsp)
movq $0x0, 0x18(%rsp)
movq $0x0, 0x20(%rsp)
callq 0x214690
cmpl $0x0, -0x44(%rbp)
jbe 0x200c41
movq -0x18(%rbp), %rdi
movq -0x18(%rbp), %rax
movq 0x30(%rax), %rsi
movq -0x40(%rbp), %rdx
movl -0x44(%rbp), %ecx
callq 0x1edfb0
movq -0x60(%rbp), %rax
movsd %xmm0, 0x30(%rax)
cmpl $0x0, -0x54(%rbp)
jbe 0x200c68
movq -0x18(%rbp), %rdi
movq -0x18(%rbp), %rax
movq 0x30(%rax), %rsi
movq -0x50(%rbp), %rdx
movl -0x54(%rbp), %ecx
callq 0x1edfb0
movq -0x60(%rbp), %rax
movsd %xmm0, 0x38(%rax)
movq -0x18(%rbp), %rdi
movq -0x18(%rbp), %rax
movq 0x30(%rax), %rsi
movq -0x40(%rbp), %rdx
movl -0x44(%rbp), %ecx
movq -0x50(%rbp), %r8
movl -0x54(%rbp), %r9d
callq 0x1ee160
movq -0x60(%rbp), %rax
movsd %xmm0, 0x40(%rax)
movl -0x1c(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x1c(%rbp)
jmp 0x2006c9
movq -0x18(%rbp), %rdi
movq -0x18(%rbp), %rsi
addq $0x58, %rsi
movq -0x8(%rbp), %rdx
callq 0x1f30e0
movq -0x18(%rbp), %rdi
addq $0x58, %rdi
movq -0x10(%rbp), %rax
movq (%rax), %rsi
callq 0x1fefd0
addq $0xb0, %rsp
popq %rbp
retq
nopw %cs:(%rax,%rax)