// File: chhylp123[P]hifiasm/rcut.cpp
// Function: mcgg_svaux_init(mc_gg_t const*, unsigned long, unsigned int)
mcgg_svaux_t *mcgg_svaux_init(const mc_gg_t *mg, uint64_t x, uint32_t hapN)
{
    uint32_t st, i, max_cc = 0;
    mc_match_t *ma = mg->e;
    mcgg_svaux_t *b;
    CALLOC(b, 1);
    b->x = x;
    for (st = 0, i = 1; i <= ma->n_seq; ++i)
        if (i == ma->n_seq || ma->cc[st]>>32 != ma->cc[i]>>32)
            max_cc = max_cc > i - st? max_cc : i - st, st = i;
    kv_init(b->cc_edge);
    MALLOC(b->cc_node, max_cc);
    b->s = mg->s->a;
    CALLOC(b->s_opt, ma->n_seq);
    MALLOC(b->bfs, ma->n_seq);

    MALLOC(b->bfs_mark, ma->n_seq); 
    memset(b->bfs_mark, -1, ma->n_seq*sizeof(uint32_t));
    
	b->z = init_mc_poy_t(ma->n_seq, hapN);
	b->z_opt = init_mc_poy_t(ma->n_seq, hapN);

	b->m = mg->m.a;
	b->mask = ((mcg_node_t)1)<<hapN; b->mask--;
	b->hapN = hapN;
    return b;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x40, %rsp
movq %rdi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
movl %edx, -0x14(%rbp)
movl $0x0, -0x20(%rbp)
movq -0x8(%rbp), %rax
movq 0x10(%rax), %rax
movq %rax, -0x28(%rbp)
movl $0x1, %edi
movl $0x70, %esi
callq 0x2140
movq %rax, -0x30(%rbp)
movq -0x10(%rbp), %rcx
movq -0x30(%rbp), %rax
movq %rcx, (%rax)
movl $0x0, -0x18(%rbp)
movl $0x1, -0x1c(%rbp)
movl -0x1c(%rbp), %eax
movq -0x28(%rbp), %rcx
cmpl 0x38(%rcx), %eax
ja 0x228a9c
movl -0x1c(%rbp), %eax
movq -0x28(%rbp), %rcx
cmpl 0x38(%rcx), %eax
je 0x228a65
movq -0x28(%rbp), %rax
movq 0x30(%rax), %rax
movl -0x18(%rbp), %ecx
movq (%rax,%rcx,8), %rax
shrq $0x20, %rax
movq -0x28(%rbp), %rcx
movq 0x30(%rcx), %rcx
movl -0x1c(%rbp), %edx
movq (%rcx,%rdx,8), %rcx
shrq $0x20, %rcx
cmpq %rcx, %rax
je 0x228a8f
movl -0x20(%rbp), %eax
movl -0x1c(%rbp), %ecx
subl -0x18(%rbp), %ecx
cmpl %ecx, %eax
jbe 0x228a7a
movl -0x20(%rbp), %eax
movl %eax, -0x34(%rbp)
jmp 0x228a83
movl -0x1c(%rbp), %eax
subl -0x18(%rbp), %eax
movl %eax, -0x34(%rbp)
movl -0x34(%rbp), %eax
movl %eax, -0x20(%rbp)
movl -0x1c(%rbp), %eax
movl %eax, -0x18(%rbp)
jmp 0x228a91
movl -0x1c(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x1c(%rbp)
jmp 0x228a22
movq -0x30(%rbp), %rax
movq $0x0, 0x18(%rax)
movq -0x30(%rbp), %rax
movq $0x0, 0x10(%rax)
movq -0x30(%rbp), %rax
movq $0x0, 0x20(%rax)
movl -0x20(%rbp), %eax
movl %eax, %edi
shlq $0x2, %rdi
callq 0x2270
movq %rax, %rcx
movq -0x30(%rbp), %rax
movq %rcx, 0x28(%rax)
movq -0x8(%rbp), %rax
movq (%rax), %rax
movq (%rax), %rcx
movq -0x30(%rbp), %rax
movq %rcx, 0x50(%rax)
movq -0x28(%rbp), %rax
movl 0x38(%rax), %eax
movl %eax, %edi
movl $0x20, %esi
callq 0x2140
movq %rax, %rcx
movq -0x30(%rbp), %rax
movq %rcx, 0x58(%rax)
movq -0x28(%rbp), %rax
movl 0x38(%rax), %eax
movl %eax, %edi
shlq $0x2, %rdi
callq 0x2270
movq %rax, %rcx
movq -0x30(%rbp), %rax
movq %rcx, 0x30(%rax)
movq -0x28(%rbp), %rax
movl 0x38(%rax), %eax
movl %eax, %edi
shlq $0x2, %rdi
callq 0x2270
movq %rax, %rcx
movq -0x30(%rbp), %rax
movq %rcx, 0x38(%rax)
movq -0x30(%rbp), %rax
movq 0x38(%rax), %rdi
movq -0x28(%rbp), %rax
movl 0x38(%rax), %eax
movl %eax, %edx
shlq $0x2, %rdx
movl $0xff, %esi
callq 0x2100
movq -0x28(%rbp), %rax
movl 0x38(%rax), %edi
movl -0x14(%rbp), %esi
callq 0x2288f0
movq %rax, %rcx
movq -0x30(%rbp), %rax
movq %rcx, 0x40(%rax)
movq -0x28(%rbp), %rax
movl 0x38(%rax), %edi
movl -0x14(%rbp), %esi
callq 0x2288f0
movq %rax, %rcx
movq -0x30(%rbp), %rax
movq %rcx, 0x48(%rax)
movq -0x8(%rbp), %rax
movq 0x28(%rax), %rcx
movq -0x30(%rbp), %rax
movq %rcx, 0x60(%rax)
movl -0x14(%rbp), %ecx
movl $0x1, %eax
shll %cl, %eax
movl %eax, %ecx
movq -0x30(%rbp), %rax
movl %ecx, 0x68(%rax)
movq -0x30(%rbp), %rax
movl 0x68(%rax), %ecx
addl $-0x1, %ecx
movl %ecx, 0x68(%rax)
movl -0x14(%rbp), %ecx
movq -0x30(%rbp), %rax
movl %ecx, 0x6c(%rax)
movq -0x30(%rbp), %rax
addq $0x40, %rsp
popq %rbp
retq
nopw (%rax,%rax)