// File: /workspace/github_cpp_makefile_star2_O3/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, (%rsp)
movq %rdi, %rbp
xorl %r14d, %r14d
cmpq $0x0, 0x18(%rdi)
je 0x167e20
movl $0xffffffff, %r15d      # imm = 0xFFFFFFFF
leaq 0xd4f23(%rip), %r12     # 0x23cce0
leaq 0xd4f3e(%rip), %r13     # 0x23cd02
movq 0x28(%rbp), %rax
movl (%rax,%r14,4), %ecx
movq %r12, %rdi
cmpq %r15, %rcx
je 0x167e0d
movl %ecx, %eax
shrl %eax
imulq $0x38, %rax, %rdx
addq 0x40(%rbp), %rdx
andl $0x1, %ecx
movl 0x8(%rdx,%rcx,4), %eax
movq %r13, %rdi
testq %rax, %rax
je 0x167e0d
movl (%rdx,%rcx,4), %ecx
shlq $0x2, %rcx
addq 0x10(%rbp), %rcx
xorl %edx, %edx
cmpl %r14d, (%rcx,%rdx,4)
je 0x167e12
incq %rdx
cmpq %rdx, %rax
jne 0x167dfc
movq %r13, %rdi
callq 0x1f1ff
incl %r14d
movq 0x18(%rbp), %rdi
cmpq %r14, %rdi
ja 0x167dc4
jmp 0x167e22
xorl %edi, %edi
movl $0x1, %esi
callq 0x2120
movq %rax, %r12
cmpq $0x0, 0x30(%rbp)
je 0x1680ac
xorl %r9d, %r9d
movq %rbp, 0x38(%rsp)
movq 0x40(%rbp), %rax
imulq $0x38, %r9, %rcx
movl 0x8(%rax,%rcx), %r10d
movl 0xc(%rax,%rcx), %edx
movl %r10d, %esi
xorl $0x1, %esi
orl %edx, %esi
je 0x16809f
movq 0x10(%rbp), %rsi
movl (%rax,%rcx), %edi
leaq (%rsi,%rdi,4), %r11
testq %r10, %r10
je 0x167e84
xorl %edi, %edi
movl (%r11,%rdi,4), %r8d
movb $0x1, (%r12,%r8)
incq %rdi
cmpq %rdi, %r10
jne 0x167e73
movq %r9, 0x40(%rsp)
movl 0x4(%rax,%rcx), %eax
leaq (%rsi,%rax,4), %rsi
movl %edx, %edx
testq %rdx, %rdx
je 0x167eaa
xorl %eax, %eax
movl (%rsi,%rax,4), %ecx
movb $-0x1, (%r12,%rcx)
incq %rax
cmpq %rax, %rdx
jne 0x167e9a
movq %rdx, 0x18(%rsp)
movq %rsi, 0x20(%rsp)
movq %r11, 0x28(%rsp)
movq %r10, 0x30(%rsp)
testq %r10, %r10
je 0x167f87
xorl %ecx, %ecx
movq 0x28(%rsp), %rax
movq %rcx, 0x8(%rsp)
movl (%rax,%rcx,4), %eax
movq (%rsp), %rcx
movq 0x28(%rcx), %rcx
movq (%rcx,%rax,8), %rax
testl %eax, %eax
je 0x167f80
movq (%rsp), %rcx
movq 0x10(%rcx), %rcx
movq %rax, %rdx
shrq $0x20, %rdx
movl %eax, %r13d
negq %r13
leaq (%rdx,%rdx,2), %rax
shlq $0x4, %rax
addq %rcx, %rax
addq $0x14, %rax
movq %rax, 0x10(%rsp)
movb $0x1, %r14b
xorl %r15d, %r15d
leaq (%r15,%r15,2), %rbp
incq %r15
shlq $0x4, %rbp
addq 0x10(%rsp), %rbp
movl (%rbp), %eax
movq 0x10(%rbx), %rcx
cmpl $0x0, (%rcx,%rax,8)
je 0x167f42
cmpb $-0x1, (%r12,%rax)
je 0x167f58
callq 0x1f21a
addq $0x30, %rbp
leaq (%r15,%r13), %rax
incq %rax
incq %r15
cmpq $0x1, %rax
jne 0x167f29
jmp 0x167f65
xorl %r14d, %r14d
movq %r13, %rax
addq %r15, %rax
jne 0x167f19
jmp 0x167f6b
testb $0x1, %r14b
jne 0x167f80
movq 0x8(%rsp), %rcx
incq %rcx
cmpq 0x30(%rsp), %rcx
jne 0x167ec9
jmp 0x167f87
callq 0x1f239
jmp 0x167f6b
movq 0x18(%rsp), %r8
testq %r8, %r8
je 0x168058
xorl %ecx, %ecx
movq 0x20(%rsp), %rax
movq %rcx, 0x8(%rsp)
movl (%rax,%rcx,4), %eax
movq (%rsp), %rcx
movq 0x28(%rcx), %rcx
movq (%rcx,%rax,8), %rax
testl %eax, %eax
je 0x168051
movq (%rsp), %rcx
movq 0x10(%rcx), %rcx
movq %rax, %rdx
shrq $0x20, %rdx
movl %eax, %r13d
negq %r13
leaq (%rdx,%rdx,2), %rax
shlq $0x4, %rax
addq %rcx, %rax
addq $0x14, %rax
movq %rax, 0x10(%rsp)
movb $0x1, %r14b
xorl %r15d, %r15d
leaq (%r15,%r15,2), %rbp
incq %r15
shlq $0x4, %rbp
addq 0x10(%rsp), %rbp
movl (%rbp), %eax
movq 0x10(%rbx), %rcx
cmpl $0x0, (%rcx,%rax,8)
je 0x168010
cmpb $0x1, (%r12,%rax)
je 0x168026
callq 0x1f258
addq $0x30, %rbp
leaq (%r15,%r13), %rax
incq %rax
incq %r15
cmpq $0x1, %rax
jne 0x167ff7
jmp 0x168033
xorl %r14d, %r14d
movq %r13, %rax
addq %r15, %rax
jne 0x167fe7
jmp 0x168039
testb $0x1, %r14b
jne 0x168051
movq 0x8(%rsp), %rcx
incq %rcx
movq 0x18(%rsp), %r8
cmpq %r8, %rcx
jne 0x167f97
jmp 0x168058
callq 0x1f277
jmp 0x168039
movq 0x30(%rsp), %rdx
testq %rdx, %rdx
movq 0x28(%rsp), %rsi
movq 0x20(%rsp), %rdi
je 0x16807e
xorl %eax, %eax
movl (%rsi,%rax,4), %ecx
movb $0x0, (%r12,%rcx)
incq %rax
cmpq %rax, %rdx
jne 0x16806e
testq %r8, %r8
movq 0x38(%rsp), %rbp
movq 0x40(%rsp), %r9
je 0x16809f
xorl %eax, %eax
movl (%rdi,%rax,4), %ecx
movb $0x0, (%r12,%rcx)
incq %rax
cmpq %rax, %r8
jne 0x16808f
incl %r9d
cmpq %r9, 0x30(%rbp)
ja 0x167e42
movq %r12, %rdi
addq $0x48, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
jmp 0x2220