// File: /workspace/github_cpp_makefile_star2_O3/chhylp123[P]hifiasm/rcut.cpp
// Function: debug_mb_z(mb_g_t*, unsigned int)
void debug_mb_z(mb_g_t *mbg, uint32_t k)
{
	t_w_t z[4];
	z[0] = z[1] = z[2] = z[3] = 0;
	mb_match_t *ma = mbg->e;
	uint32_t o = ma->idx.a[k] >> 32;
    uint32_t j, n = (uint32_t)ma->idx.a[k];

	for (j = 0; j < n; ++j) {
		const mb_edge_t *e = &ma->ma.a[o + j];
		uint32_t t = ma_y(*e);

		///a[0]->b[0]
		if(mbg->u->u.a[t].s[0] > 0) z[0] += e->w[0];
		else if(mbg->u->u.a[t].s[0] < 0) z[1] += e->w[0];

		///a[0]->b[1]
		if(mbg->u->u.a[t].s[1] > 0) z[0] += e->w[1];
		else if(mbg->u->u.a[t].s[1] < 0) z[1] += e->w[1];

		///a[1]->b[0]
		if(mbg->u->u.a[t].s[0] > 0) z[2] += e->w[2];
		else if(mbg->u->u.a[t].s[0] < 0) z[3] += e->w[2];

		///a[1]->b[1]
		if(mbg->u->u.a[t].s[1] > 0) z[2] += e->w[3];
		else if(mbg->u->u.a[t].s[1] < 0) z[3] += e->w[3];
	}

	if(mbg->u->u.a[k].z[0] != z[0]) fprintf(stderr, "ERROR-0-::%s, z[0]: %f, n-z[0]: %f\n", __func__, z[0], mbg->u->u.a[k].z[0]);
	if(mbg->u->u.a[k].z[1] != z[1]) fprintf(stderr, "ERROR-1-::%s, z[1]: %f, n-z[1]: %f\n", __func__, z[1], mbg->u->u.a[k].z[1]);
	if(mbg->u->u.a[k].z[2] != z[2]) fprintf(stderr, "ERROR-2-::%s, z[2]: %f, n-z[2]: %f\n", __func__, z[2], mbg->u->u.a[k].z[2]);
	if(mbg->u->u.a[k].z[3] != z[3]) fprintf(stderr, "ERROR-3-::%s, z[3]: %f, n-z[3]: %f\n", __func__, z[3], mbg->u->u.a[k].z[3]);
}

// Assembly:
pushq %r14
pushq %rbx
subq $0x18, %rsp
movq %rdi, %rbx
movq (%rdi), %rax
movq 0x8(%rdi), %rdi
movq 0x10(%rdi), %rdx
movl %esi, %ecx
movq (%rdx,%rcx,8), %r8
testl %r8d, %r8d
je 0x16a4ea
movq %r8, %rdx
shrq $0x20, %rdx
movq 0x28(%rdi), %rsi
movq 0x40(%rax), %rax
movl %r8d, %edi
xorpd %xmm2, %xmm2
xorpd %xmm3, %xmm3
xorpd %xmm4, %xmm4
xorpd %xmm0, %xmm0
movl %edx, %r8d
leaq (%r8,%r8,4), %r8
leaq (%rsi,%r8,8), %r8
movl (%r8), %r9d
imulq $0x38, %r9, %r10
movb 0x10(%rax,%r10), %r9b
testb %r9b, %r9b
jle 0x16a494
addsd 0x8(%r8), %xmm0
jmp 0x16a49c
jns 0x16a49c
addsd 0x8(%r8), %xmm4
movb 0x11(%rax,%r10), %r10b
testb %r10b, %r10b
jle 0x16a4ae
addsd 0x10(%r8), %xmm0
jmp 0x16a4b6
jns 0x16a4b6
addsd 0x10(%r8), %xmm4
testb %r9b, %r9b
jle 0x16a4c3
addsd 0x18(%r8), %xmm3
jmp 0x16a4cb
jns 0x16a4cb
addsd 0x18(%r8), %xmm2
testb %r10b, %r10b
jle 0x16a4d8
addsd 0x20(%r8), %xmm3
jmp 0x16a4e0
jns 0x16a4e0
addsd 0x20(%r8), %xmm2
incq %rdx
decq %rdi
jne 0x16a470
jmp 0x16a4fe
movq 0x40(%rax), %rax
xorpd %xmm0, %xmm0
xorpd %xmm4, %xmm4
xorpd %xmm3, %xmm3
xorpd %xmm2, %xmm2
imulq $0x38, %rcx, %r14
movsd 0x18(%rax,%r14), %xmm1
ucomisd %xmm0, %xmm1
jne 0x16a55e
jp 0x16a55e
movsd 0x20(%rax,%r14), %xmm1
ucomisd %xmm4, %xmm1
jne 0x16a5ab
jp 0x16a5ab
movsd 0x28(%rax,%r14), %xmm1
ucomisd %xmm3, %xmm1
jne 0x16a5f0
jp 0x16a5f0
movsd 0x30(%rax,%r14), %xmm1
ucomisd %xmm2, %xmm1
jne 0x16a629
jp 0x16a629
addq $0x18, %rsp
popq %rbx
popq %r14
retq
movq 0x12aa7b(%rip), %rax    # 0x294fe0
movq (%rax), %rdi
leaq 0xd2970(%rip), %rsi     # 0x23cedf
leaq 0xd298d(%rip), %rdx     # 0x23cf03
movb $0x2, %al
movsd %xmm2, (%rsp)
movsd %xmm3, 0x8(%rsp)
movsd %xmm4, 0x10(%rsp)
callq 0x22b0
movsd 0x10(%rsp), %xmm4
movsd 0x8(%rsp), %xmm3
movsd (%rsp), %xmm2
movq (%rbx), %rax
movq 0x40(%rax), %rax
jmp 0x16a511
movq 0x12aa2e(%rip), %rax    # 0x294fe0
movq (%rax), %rdi
leaq 0xd2952(%rip), %rsi     # 0x23cf0e
leaq 0xd2940(%rip), %rdx     # 0x23cf03
movapd %xmm4, %xmm0
movb $0x2, %al
movsd %xmm2, (%rsp)
movsd %xmm3, 0x8(%rsp)
callq 0x22b0
movsd 0x8(%rsp), %xmm3
movsd (%rsp), %xmm2
movq (%rbx), %rax
movq 0x40(%rax), %rax
jmp 0x16a528
movq 0x12a9e9(%rip), %rax    # 0x294fe0
movq (%rax), %rdi
leaq 0xd2931(%rip), %rsi     # 0x23cf32
leaq 0xd28fb(%rip), %rdx     # 0x23cf03
movapd %xmm3, %xmm0
movb $0x2, %al
movsd %xmm2, (%rsp)
callq 0x22b0
movsd (%rsp), %xmm2
movq (%rbx), %rax
movq 0x40(%rax), %rax
jmp 0x16a53f
movq 0x12a9b0(%rip), %rax    # 0x294fe0
movq (%rax), %rdi
leaq 0xd291c(%rip), %rsi     # 0x23cf56
leaq 0xd28c2(%rip), %rdx     # 0x23cf03
movapd %xmm2, %xmm0
movb $0x2, %al
addq $0x18, %rsp
popq %rbx
popq %r14
jmp 0x22b0