// File: chhylp123[P]hifiasm/hic.cpp
// Function: init_mul_block_phase_type(mul_block_phase_type*, G_partition*, bubble_type*, unsigned int, H_partition*)
void init_mul_block_phase_type(mul_block_phase_type* x, G_partition* g_p, bubble_type* bub, uint32_t n_thread, H_partition* hap)
{
    ma_utg_t *u = NULL;
    uint32_t i, n;
    block_phase_type b;
    x->bub = bub;
    x->n_thread = n_thread;
    CALLOC(x->res, x->n_thread);
    CALLOC(x->x, x->n_thread);
    for (i = 0; i < x->n_thread; i++)
    {
        kv_init(x->x[i].vis);
        kv_malloc(x->x[i].vis, hap->n); 
        x->x[i].vis.n = hap->n;
    }

    x->chain_idx_n = 0;
    MALLOC(x->chain_idx, bub->chain_weight.n+1);
    for (i = n = 0; i < bub->chain_weight.n; i++)
    {
        x->chain_idx[i] = n;
        if(bub->chain_weight.a[i].del) continue;
        u = &(bub->b_ug->u.a[bub->chain_weight.a[i].id]);
        n += shift_block_phase_type(u, g_p, bub, &b, (uint32_t)-1);
        x->chain_idx_n++;
    }
    x->chain_idx[i] = n;///index of chain
    x->chain_ele_occ = n;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x70, %rsp
movq %rdi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
movq %rdx, -0x18(%rbp)
movl %ecx, -0x1c(%rbp)
movq %r8, -0x28(%rbp)
movq $0x0, -0x30(%rbp)
movq -0x18(%rbp), %rcx
movq -0x8(%rbp), %rax
movq %rcx, 0x10(%rax)
movl -0x1c(%rbp), %ecx
movq -0x8(%rbp), %rax
movl %ecx, 0x8(%rax)
movq -0x8(%rbp), %rax
movl 0x8(%rax), %eax
movl %eax, %edi
movl $0x38, %esi
callq 0x2140
movq %rax, %rcx
movq -0x8(%rbp), %rax
movq %rcx, 0x30(%rax)
movq -0x8(%rbp), %rax
movl 0x8(%rax), %eax
movl %eax, %edi
movl $0x38, %esi
callq 0x2140
movq %rax, %rcx
movq -0x8(%rbp), %rax
movq %rcx, (%rax)
movl $0x0, -0x34(%rbp)
movl -0x34(%rbp), %eax
movq -0x8(%rbp), %rcx
cmpl 0x8(%rcx), %eax
jae 0x1f1eca
movq -0x8(%rbp), %rax
movq (%rax), %rax
movl -0x34(%rbp), %ecx
imulq $0x38, %rcx, %rcx
addq %rcx, %rax
movq $0x0, 0x8(%rax)
movq -0x8(%rbp), %rax
movq (%rax), %rax
movl -0x34(%rbp), %ecx
imulq $0x38, %rcx, %rcx
addq %rcx, %rax
movq $0x0, (%rax)
movq -0x8(%rbp), %rax
movq (%rax), %rax
movl -0x34(%rbp), %ecx
imulq $0x38, %rcx, %rcx
addq %rcx, %rax
movq $0x0, 0x10(%rax)
movq -0x8(%rbp), %rax
movq (%rax), %rax
movl -0x34(%rbp), %ecx
imulq $0x38, %rcx, %rcx
addq %rcx, %rax
movq $0x0, (%rax)
movq -0x28(%rbp), %rax
movq (%rax), %rcx
movq -0x8(%rbp), %rax
movq (%rax), %rax
movl -0x34(%rbp), %edx
imulq $0x38, %rdx, %rdx
addq %rdx, %rax
movq %rcx, 0x8(%rax)
movq -0x28(%rbp), %rax
movq (%rax), %rdi
shlq $0x0, %rdi
callq 0x2270
movq %rax, %rcx
movq -0x8(%rbp), %rax
movq (%rax), %rax
movl -0x34(%rbp), %edx
imulq $0x38, %rdx, %rdx
addq %rdx, %rax
movq %rcx, 0x10(%rax)
movq -0x28(%rbp), %rax
movq (%rax), %rcx
movq -0x8(%rbp), %rax
movq (%rax), %rax
movl -0x34(%rbp), %edx
imulq $0x38, %rdx, %rdx
addq %rdx, %rax
movq %rcx, (%rax)
movl -0x34(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x34(%rbp)
jmp 0x1f1deb
movq -0x8(%rbp), %rax
movq $0x0, 0x20(%rax)
movq -0x18(%rbp), %rax
movq 0xc8(%rax), %rdi
addq $0x1, %rdi
shlq $0x3, %rdi
callq 0x2270
movq %rax, %rcx
movq -0x8(%rbp), %rax
movq %rcx, 0x18(%rax)
movl $0x0, -0x38(%rbp)
movl $0x0, -0x34(%rbp)
movl -0x34(%rbp), %eax
movq -0x18(%rbp), %rcx
cmpq 0xc8(%rcx), %rax
jae 0x1f1fbb
movl -0x38(%rbp), %eax
movl %eax, %edx
movq -0x8(%rbp), %rax
movq 0x18(%rax), %rax
movl -0x34(%rbp), %ecx
movq %rdx, (%rax,%rcx,8)
movq -0x18(%rbp), %rax
movq 0xd8(%rax), %rax
movl -0x34(%rbp), %ecx
shlq $0x5, %rcx
addq %rcx, %rax
cmpb $0x0, 0x18(%rax)
je 0x1f1f4c
jmp 0x1f1fad
movq -0x18(%rbp), %rax
movq 0xc0(%rax), %rax
movq 0x10(%rax), %rax
movq -0x18(%rbp), %rcx
movq 0xd8(%rcx), %rcx
movl -0x34(%rbp), %edx
shlq $0x5, %rdx
addq %rdx, %rcx
imulq $0x28, 0x10(%rcx), %rcx
addq %rcx, %rax
movq %rax, -0x30(%rbp)
movq -0x30(%rbp), %rdi
movq -0x10(%rbp), %rsi
movq -0x18(%rbp), %rdx
leaq -0x70(%rbp), %rcx
movl $0xffffffff, %r8d       # imm = 0xFFFFFFFF
callq 0x1f1be0
addl -0x38(%rbp), %eax
movl %eax, -0x38(%rbp)
movq -0x8(%rbp), %rax
movq 0x20(%rax), %rcx
addq $0x1, %rcx
movq %rcx, 0x20(%rax)
movl -0x34(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x34(%rbp)
jmp 0x1f1f07
movl -0x38(%rbp), %eax
movl %eax, %edx
movq -0x8(%rbp), %rax
movq 0x18(%rax), %rax
movl -0x34(%rbp), %ecx
movq %rdx, (%rax,%rcx,8)
movl -0x38(%rbp), %eax
movl %eax, %ecx
movq -0x8(%rbp), %rax
movq %rcx, 0x28(%rax)
addq $0x70, %rsp
popq %rbp
retq
nopw %cs:(%rax,%rax)