// File: /workspace/github_cpp_makefile_star2_O3/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 %rbp
pushq $0x50
popq %rsi
movq %rbp, %rdi
callq 0x2120
movq %rax, %rbx
movq %r12, 0x38(%rax)
movq %r13, 0x40(%rax)
movq %r14, (%rax)
movq %r15, 0x20(%rax)
movq 0x10(%r14), %rax
movq 0x18(%rax), %rax
movl 0x14(%rax), %r12d
andl $0x7fffffff, %r12d      # imm = 0x7FFFFFFF
movq %r12, %rdi
movq %rbp, %rsi
callq 0x2120
movq %rax, 0x30(%rbx)
pushq $0x20
popq %rsi
movq %r15, %rdi
callq 0x2120
movq %rax, 0x28(%rbx)
pushq $0x18
popq %rsi
movq %r15, %rdi
callq 0x2120
movq %rbx, 0x10(%rsp)
movq %rax, 0x48(%rbx)
testq %r15, %r15
je 0x1d494
movq %rax, %r13
pushq $0x1
popq %rbx
xorl %eax, %eax
movq %r15, %rbp
imulq $0x18, %rax, %r15
movq %r12, (%r13,%r15)
movq %r12, 0x8(%r13,%r15)
movq %r12, %rdi
pushq $0x1
popq %rsi
callq 0x2120
movq %rax, 0x10(%r13,%r15)
movq %rbp, %r15
movl %ebx, %eax
incl %ebx
cmpq %rbp, %rax
jb 0x1d467
movq 0xc8(%r14), %rbx
leaq 0x8(,%rbx,8), %rdi
callq 0x2280
movq %rax, %rdx
movq 0x10(%rsp), %rax
movq %rdx, 0x8(%rax)
xorl %r15d, %r15d
testq %rbx, %rbx
jne 0x1d4cb
xorl %r13d, %r13d
xorl %eax, %eax
movq 0x10(%rsp), %rbx
jmp 0x1d570
leaq 0x1c(%rsp), %rbp
xorl %r13d, %r13d
xorl %eax, %eax
movq %rdx, 0x20(%rsp)
movq %r13, (%rdx,%rax,8)
movq 0xd8(%r14), %rcx
shlq $0x5, %rax
cmpb $0x0, 0x18(%rcx,%rax)
jne 0x1d554
addq %rax, %rcx
movq 0xc0(%r14), %rax
movq 0x10(%rax), %r12
imulq $0x28, 0x10(%rcx), %rax
cmpl $0x0, 0x10(%r12,%rax)
je 0x1d554
addq %rax, %r12
xorl %ebx, %ebx
movq 0x18(%r12), %rax
movq (%rax,%rbx,8), %rsi
shrq $0x21, %rsi
andq $0x0, (%rsp)
movq %r14, %rdi
xorl %edx, %edx
xorl %ecx, %ecx
xorl %r8d, %r8d
movq %rbp, %r9
callq 0x13df01
movl 0x1c(%rsp), %eax
addq %rax, %r13
incq %rbx
movl 0x10(%r12), %eax
cmpq %rax, %rbx
jb 0x1d510
movq 0xc8(%r14), %rbx
movq 0x20(%rsp), %rdx
incq %r15
movl %r15d, %eax
cmpq %rax, %rbx
ja 0x1d4da
movq 0x10(%rsp), %rbx
movq %r13, 0x18(%rbx)
movq %r15, 0x10(%rbx)
movq %r13, (%rdx,%rax,8)
movq 0x277a65(%rip), %rax    # 0x294fe0
movq (%rax), %rdi
leaq 0x21f933(%rip), %rsi    # 0x23ceb8
movq %r13, %rdx
movq %r15, %rcx
xorl %eax, %eax
callq 0x22b0
movq %rbx, %rax
addq $0x28, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq