// File: /workspace/github_cpp_makefile_star2_O1/chhylp123[P]hifiasm/rcut.cpp
// Function: mc_bp_t_init(mc_match_t*, mc_svaux_t*, bubble_type*, unsigned long)
mc_bp_t *mc_bp_t_init(mc_match_t *ma, mc_svaux_t *b_aux, bubble_type* bub, uint64_t n_thread)
{
	uint32_t i, k, n;
	mc_bp_t *bp = NULL; 
	ma_utg_t *u = NULL;
	CALLOC(bp, 1);
	bp->b_aux = b_aux;
	bp->ma = ma;
	bp->b_b = bub;
	bp->n_thread = n_thread;
	CALLOC(bp->lock, bub->ug->g->n_seq);
	CALLOC(bp->res, n_thread);
	CALLOC(bp->vis, n_thread);
	for (i = 0; i < n_thread; i++)
	{
		bp->vis[i].m = bp->vis[i].n = bub->ug->g->n_seq;
		CALLOC(bp->vis[i].a, bp->vis[i].n);
	}
	

	MALLOC(bp->idx, bub->chain_weight.n+1);
	bp->idx_n = bp->occ = 0;
	for (i = 0; i < bub->chain_weight.n; i++)
	{
		bp->idx[i] = bp->occ;
		bp->idx_n++;
		if(bub->chain_weight.a[i].del) continue;
		u = &(bub->b_ug->u.a[bub->chain_weight.a[i].id]);///list of bubbles
		for (k = 0; k < u->n; k++)
		{
			get_bubbles(bub, u->a[k]>>33, NULL, NULL, NULL, &n, NULL);
			bp->occ += n;
		}
	}
	bp->idx[i] = bp->occ;
	fprintf(stderr, "# nodes in chains: %lu, # chains: %lu\n", bp->occ, bp->idx_n);
	return bp;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x28, %rsp
movq %rcx, %r15
movq %rdx, %r14
movq %rsi, %r12
movq %rdi, %r13
pushq $0x1
popq %rdi
pushq $0x50
popq %rsi
callq 0x2120
movq %rax, %rbp
movq %r12, 0x38(%rax)
movq %r13, 0x40(%rax)
movq %r14, (%rax)
movq %r15, 0x20(%rax)
movq 0x10(%r14), %rax
movq 0x18(%rax), %rbx
movl 0x14(%rbx), %edi
andl $0x7fffffff, %edi       # imm = 0x7FFFFFFF
pushq $0x1
popq %rsi
callq 0x2120
movq %rax, 0x30(%rbp)
pushq $0x20
popq %rsi
movq %r15, %rdi
callq 0x2120
movq %rax, 0x28(%rbp)
pushq $0x18
popq %rsi
movq %r15, %rdi
callq 0x2120
movq %rbp, 0x10(%rsp)
movq %rax, 0x48(%rbp)
testq %r15, %r15
je 0x1e21d
movq %rax, %r12
pushq $0x1
popq %rbp
xorl %eax, %eax
movl 0x14(%rbx), %edi
andl $0x7fffffff, %edi       # imm = 0x7FFFFFFF
imulq $0x18, %rax, %r13
movq %rdi, (%r12,%r13)
movq %rdi, 0x8(%r12,%r13)
pushq $0x1
popq %rsi
callq 0x2120
movq %rax, 0x10(%r12,%r13)
movl %ebp, %eax
incl %ebp
cmpq %r15, %rax
jb 0x1e1f1
movq 0xc8(%r14), %rax
leaq 0x8(,%rax,8), %rdi
callq 0x2280
movq 0x10(%rsp), %r15
movq %rax, 0x18(%rsp)
movq %rax, 0x8(%r15)
xorps %xmm0, %xmm0
movups %xmm0, 0x10(%r15)
xorl %ecx, %ecx
cmpq $0x0, 0xc8(%r14)
jne 0x1e25a
xorl %eax, %eax
jmp 0x1e306
movq 0x10(%r15), %r13
movq 0x18(%r15), %rbp
leaq 0xc(%rsp), %rbx
xorl %eax, %eax
movq %rcx, 0x20(%rsp)
movq 0x18(%rsp), %rcx
movq %rbp, (%rcx,%rax,8)
movq 0xd8(%r14), %rcx
shlq $0x5, %rax
cmpb $0x0, 0x18(%rcx,%rax)
jne 0x1e2e0
addq %rax, %rcx
movq 0xc0(%r14), %rax
movq 0x10(%rax), %r15
imulq $0x28, 0x10(%rcx), %rax
cmpl $0x0, 0x10(%r15,%rax)
je 0x1e2e0
addq %rax, %r15
xorl %r12d, %r12d
movq 0x18(%r15), %rax
movq (%rax,%r12,8), %rsi
shrq $0x21, %rsi
andq $0x0, (%rsp)
movq %r14, %rdi
xorl %edx, %edx
xorl %ecx, %ecx
xorl %r8d, %r8d
movq %rbx, %r9
callq 0x13812e
movl 0xc(%rsp), %eax
addq %rax, %rbp
incq %r12
movl 0x10(%r15), %eax
cmpq %rax, %r12
jb 0x1e2aa
incq %r13
movq 0x20(%rsp), %rax
incl %eax
movl %eax, %ecx
cmpq %rax, 0xc8(%r14)
ja 0x1e269
movq 0x10(%rsp), %r15
movq %rbp, 0x18(%r15)
movq %r13, 0x10(%r15)
movq 0x18(%r15), %rdx
movq 0x18(%rsp), %rcx
movq %rdx, (%rcx,%rax,8)
movq 0x26bcc6(%rip), %rax    # 0x289fe0
movq (%rax), %rdi
movq 0x10(%r15), %rcx
leaq 0x212940(%rip), %rsi    # 0x230c68
xorl %eax, %eax
callq 0x22b0
movq %r15, %rax
addq $0x28, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq