// File: /workspace/github_cpp_makefile_star2_O1/chhylp123[P]hifiasm/rcut.cpp
// Function: debug_mb_nodes(mb_nodes_t*, kv_u_trans_t*, mc_match_t*)
void debug_mb_nodes(mb_nodes_t *x, kv_u_trans_t *ref, mc_match_t* ma)
{
	uint32_t i, k, bid, ori, *a = NULL, a_n, v;
	for (i = 0; i < x->idx.n; i++)
	{
		if(x->idx.a[i] == (uint32_t)-1)
		{
			fprintf(stderr, "ERROR-0-::%s\n", __func__);
			continue;
		}
		bid = x->idx.a[i]>>1; ori = x->idx.a[i] & 1;
		a = x->bid.a + x->u.a[bid].a[ori];
		a_n = x->u.a[bid].occ[ori];
		for (k = 0; k < a_n; k++)
		{
			if(a[k] == i) break;
		}
		if(k >= a_n) fprintf(stderr, "ERROR-1-::%s\n", __func__);
	}
	
	uint32_t *tt[2], t_n[2], o_n, m, t, found;
	int8_t *vis = NULL; CALLOC(vis, x->idx.n);
	u_trans_t *o = NULL;
	for (i = 0; i < x->u.n; i++)///each block
	{
		tt[0] = x->bid.a + x->u.a[i].a[0];
		t_n[0] = x->u.a[i].occ[0];
		tt[1] = x->bid.a + x->u.a[i].a[1];
		t_n[1] = x->u.a[i].occ[1];

		if(t_n[0] == 1 && t_n[1] == 0) continue;

		for (k = 0; k < t_n[0]; k++)
		{
			vis[tt[0][k]] = 1;
		}
		for (k = 0; k < t_n[1]; k++)
		{
			vis[tt[1][k]] = -1;
		}





		for (k = 0; k < t_n[0]; k++)
		{
			v = tt[0][k];
			o = u_trans_a(*ref, v); 
        	o_n = u_trans_n(*ref, v);
			found = 0;
			for (m = 0; m < o_n; m++)
			{
				t = o[m].tn;
				if (pt_n(*ma, t) == 0) continue;
				if (vis[t] != -1) fprintf(stderr, "ERROR-2-::%s\n", __func__);
				else found = 1;
			}
			if(found == 0) fprintf(stderr, "ERROR-2-*::%s\n", __func__);
		}

		for (k = 0; k < t_n[1]; k++)
		{
			v = tt[1][k];
			o = u_trans_a(*ref, v); 
        	o_n = u_trans_n(*ref, v);
			found = 0;
			for (m = 0; m < o_n; m++)
			{
				t = o[m].tn;
				if (pt_n(*ma, t) == 0) continue;
				if (vis[t] != 1) fprintf(stderr, "ERROR-3-::%s\n", __func__);
				else found = 1;
			}
			if(found == 0) fprintf(stderr, "ERROR-3-*::%s\n", __func__);
		}


		for (k = 0; k < t_n[0]; k++)
		{
			vis[tt[0][k]] = 0;
		}
		for (k = 0; k < t_n[1]; k++)
		{
			vis[tt[1][k]] = 0;
		}
	}

	free(vis);
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x48, %rsp
movq %rdx, %rbx
movq %rsi, %rbp
movq %rdi, %r15
movq 0x18(%rdi), %rdi
testq %rdi, %rdi
movq %r15, 0x8(%rsp)
je 0x16156a
xorl %r14d, %r14d
movl $0xffffffff, %r8d       # imm = 0xFFFFFFFF
leaq 0xcf5b9(%rip), %r12     # 0x230a90
leaq 0xcf5d4(%rip), %r13     # 0x230ab2
movq 0x28(%r15), %rax
movl (%rax,%r14,4), %ecx
movq %r12, %rdi
cmpq %r8, %rcx
je 0x16155d
movl %ecx, %eax
shrl %eax
andl $0x1, %ecx
imulq $0x38, %rax, %rsi
addq 0x40(%r15), %rsi
movl 0x8(%rsi,%rcx,4), %eax
movq %r13, %rdi
testl %eax, %eax
setne %dl
je 0x16155d
movq 0x10(%r15), %rdi
movl (%rsi,%rcx,4), %ecx
cmpl %r14d, (%rdi,%rcx,4)
je 0x16153b
leaq (%rdi,%rcx,4), %rcx
addq $0x4, %rcx
leal -0x1(%rax), %edx
xorl %esi, %esi
cmpl %esi, %edx
je 0x161555
leaq 0x1(%rsi), %rdi
cmpl %r14d, (%rcx,%rsi,4)
movq %rdi, %rsi
jne 0x161525
cmpl %eax, %edi
setb %dl
movq %r13, %rdi
testb %dl, %dl
movq 0x8(%rsp), %r15
je 0x16155d
incl %r14d
movq 0x18(%r15), %rdi
cmpq %r14, %rdi
ja 0x1614de
jmp 0x16156a
movq %r13, %rdi
movq 0x8(%rsp), %r15
callq 0x1fe7f
movl $0xffffffff, %r8d       # imm = 0xFFFFFFFF
jmp 0x161547
movl $0x1, %esi
callq 0x2120
movq %rax, %r12
movq 0x8(%rsp), %rax
cmpq $0x0, 0x30(%rax)
je 0x1617c1
xorl %ecx, %ecx
movq %rbp, 0x20(%rsp)
movq 0x40(%rax), %rax
movq %rcx, 0x40(%rsp)
imulq $0x38, %rcx, %rcx
movl 0x8(%rax,%rcx), %r14d
movl 0xc(%rax,%rcx), %edx
movl %r14d, %esi
xorl $0x1, %esi
orl %edx, %esi
je 0x1617ab
movq 0x8(%rsp), %rsi
movq 0x10(%rsi), %rsi
movl (%rax,%rcx), %edi
leaq (%rsi,%rdi,4), %r15
testq %r14, %r14
je 0x1615da
xorl %edi, %edi
movl (%r15,%rdi,4), %r8d
movb $0x1, (%r12,%r8)
incq %rdi
cmpq %rdi, %r14
jne 0x1615c9
movl 0x4(%rax,%rcx), %eax
leaq (%rsi,%rax,4), %r13
movl %edx, %edx
testq %rdx, %rdx
je 0x1615fd
xorl %eax, %eax
movl (%r13,%rax,4), %ecx
movb $-0x1, (%r12,%rcx)
incq %rax
cmpq %rax, %rdx
jne 0x1615eb
movq %rdx, 0x10(%rsp)
testq %r14, %r14
movq %r14, 0x38(%rsp)
movq %r15, 0x30(%rsp)
movq %r13, 0x28(%rsp)
je 0x1616c0
xorl %eax, %eax
movq %rax, 0x18(%rsp)
movl (%r15,%rax,4), %eax
movq 0x28(%rbp), %rcx
movq (%rcx,%rax,8), %rax
testl %eax, %eax
je 0x1616b9
movq 0x10(%rbp), %rcx
movq %rax, %rdx
shrq $0x20, %rdx
movl %eax, %eax
leaq (%rdx,%rdx,2), %rdx
shlq $0x4, %rdx
leaq (%rcx,%rdx), %r13
addq $0x14, %r13
shlq $0x4, %rax
leaq (%rax,%rax,2), %rbp
xorl %r14d, %r14d
xorl %eax, %eax
movl %eax, %r15d
movl (%r13,%r14), %ecx
movq 0x10(%rbx), %rax
cmpl $0x0, (%rax,%rcx,8)
je 0x161682
movl $0x1, %eax
cmpb $-0x1, (%r12,%rcx)
je 0x161685
callq 0x1fe9a
movl %r15d, %eax
addq $0x30, %r14
cmpq %r14, %rbp
jne 0x16165f
testl %eax, %eax
movq 0x20(%rsp), %rbp
movq 0x38(%rsp), %r14
movq 0x30(%rsp), %r15
movq 0x28(%rsp), %r13
je 0x1616b9
movq 0x18(%rsp), %rax
incq %rax
cmpq %r14, %rax
jne 0x16161c
jmp 0x1616c0
callq 0x1feb9
jmp 0x1616a6
cmpq $0x0, 0x10(%rsp)
je 0x161775
xorl %eax, %eax
movq %rax, 0x18(%rsp)
movl (%r13,%rax,4), %eax
movq 0x28(%rbp), %rcx
movq (%rcx,%rax,8), %rax
testl %eax, %eax
je 0x16176e
movq 0x10(%rbp), %rcx
movq %rax, %rdx
shrq $0x20, %rdx
movl %eax, %eax
leaq (%rdx,%rdx,2), %rdx
shlq $0x4, %rdx
leaq (%rcx,%rdx), %r13
addq $0x14, %r13
shlq $0x4, %rax
leaq (%rax,%rax,2), %rbp
xorl %r14d, %r14d
xorl %eax, %eax
movl %eax, %r15d
movl (%r13,%r14), %ecx
movq 0x10(%rbx), %rax
cmpl $0x0, (%rax,%rcx,8)
je 0x161735
movl $0x1, %eax
cmpb $0x1, (%r12,%rcx)
je 0x161738
callq 0x1fed8
movl %r15d, %eax
addq $0x30, %r14
cmpq %r14, %rbp
jne 0x161712
testl %eax, %eax
movq 0x20(%rsp), %rbp
movq 0x38(%rsp), %r14
movq 0x30(%rsp), %r15
movq 0x28(%rsp), %r13
je 0x16176e
movq 0x18(%rsp), %rax
incq %rax
cmpq 0x10(%rsp), %rax
jne 0x1616ce
jmp 0x161775
callq 0x1fef7
jmp 0x161759
testq %r14, %r14
je 0x16178d
xorl %eax, %eax
movl (%r15,%rax,4), %ecx
movb $0x0, (%r12,%rcx)
incq %rax
cmpq %rax, %r14
jne 0x16177c
movq 0x10(%rsp), %rdx
testq %rdx, %rdx
je 0x1617ab
xorl %eax, %eax
movl (%r13,%rax,4), %ecx
movb $0x0, (%r12,%rcx)
incq %rax
cmpq %rax, %rdx
jne 0x161799
movq 0x40(%rsp), %rcx
incl %ecx
movq 0x8(%rsp), %rax
cmpq %rcx, 0x30(%rax)
ja 0x16158e
movq %r12, %rdi
addq $0x48, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
jmp 0x2220