// File: chhylp123[P]hifiasm/rcut.cpp
// Function: get_max_m(unsigned long, mcgg_svaux_t*)
static mcg_node_t get_max_m(uint64_t id, mcgg_svaux_t *b)
{
	uint32_t hn = b->s[id].h[0]-1, k, j, n = (1<<b->z->hapN);
	mcg_node_t m, *p = NULL;
	t_w_t z, max_z = -(1<<30);
	for (k = 0; k < b->m[hn].n; k++)
	{
		m = b->m[hn].a[k]; z = 0;
		for (j = 0; j < n; j++)
		{
			z += ((m&((mcg_node_t)j))?-mcp_de(*(b->z), id, j):mcp_de(*(b->z), id, j));
		}
		if(!p || max_z < z || (max_z == z && m == b->s[id].s)) p = &(b->m[hn].a[k]), max_z = z;
	}

	if(b->s[id].h[1] != (uint16_t)-1)
	{
		hn = b->s[id].h[1]-1;
		for (k = 0; k < b->m[hn].n; k++)
		{
			m = b->m[hn].a[k]; z = 0;
			for (j = 0; j < n; j++)
			{
				z += ((m&((mcg_node_t)j))?-mcp_de(*(b->z), id, j):mcp_de(*(b->z), id, j));
			}
			if(!p || max_z < z || (max_z == z && m == b->s[id].s)) p = &(b->m[hn].a[k]), max_z = z;
		}
	}
	return (*p);
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
movq %rdi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
movq -0x10(%rbp), %rax
movq 0x50(%rax), %rax
movq -0x8(%rbp), %rcx
shlq $0x5, %rcx
addq %rcx, %rax
movzwl 0x4(%rax), %eax
subl $0x1, %eax
movl %eax, -0x14(%rbp)
movq -0x10(%rbp), %rax
movq 0x40(%rax), %rax
movl 0x8(%rax), %ecx
movl $0x1, %eax
shll %cl, %eax
movl %eax, -0x20(%rbp)
movq $0x0, -0x30(%rbp)
movsd 0x160f7a(%rip), %xmm0   # 0x38d8c8
movsd %xmm0, -0x40(%rbp)
movl $0x0, -0x18(%rbp)
movl -0x18(%rbp), %eax
movq -0x10(%rbp), %rcx
movq 0x60(%rcx), %rcx
movl -0x14(%rbp), %edx
imulq $0x18, %rdx, %rdx
addq %rdx, %rcx
cmpq 0x8(%rcx), %rax
jae 0x22cacf
movq -0x10(%rbp), %rax
movq 0x60(%rax), %rax
movl -0x14(%rbp), %ecx
imulq $0x18, %rcx, %rcx
addq %rcx, %rax
movq (%rax), %rax
movl -0x18(%rbp), %ecx
movl (%rax,%rcx,4), %eax
movl %eax, -0x24(%rbp)
xorps %xmm0, %xmm0
movsd %xmm0, -0x38(%rbp)
movl $0x0, -0x1c(%rbp)
movl -0x1c(%rbp), %eax
cmpl -0x20(%rbp), %eax
jae 0x22ca53
movl -0x24(%rbp), %eax
andl -0x1c(%rbp), %eax
cmpl $0x0, %eax
je 0x22ca06
movq -0x10(%rbp), %rax
movq 0x40(%rax), %rax
movq (%rax), %rax
movq -0x8(%rbp), %rdx
movq -0x10(%rbp), %rcx
movq 0x40(%rcx), %rcx
movl 0x8(%rcx), %ecx
shlq %cl, %rdx
movq %rdx, %rcx
movl -0x1c(%rbp), %edx
addq %rdx, %rcx
movsd (%rax,%rcx,8), %xmm0
movq %xmm0, %rax
movabsq $-0x8000000000000000, %rcx # imm = 0x8000000000000000
xorq %rcx, %rax
movq %rax, %xmm0
movsd %xmm0, -0x48(%rbp)
jmp 0x22ca36
movq -0x10(%rbp), %rax
movq 0x40(%rax), %rax
movq (%rax), %rax
movq -0x8(%rbp), %rdx
movq -0x10(%rbp), %rcx
movq 0x40(%rcx), %rcx
movl 0x8(%rcx), %ecx
shlq %cl, %rdx
movq %rdx, %rcx
movl -0x1c(%rbp), %edx
addq %rdx, %rcx
movsd (%rax,%rcx,8), %xmm0
movsd %xmm0, -0x48(%rbp)
movsd -0x48(%rbp), %xmm0
addsd -0x38(%rbp), %xmm0
movsd %xmm0, -0x38(%rbp)
movl -0x1c(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x1c(%rbp)
jmp 0x22c9a6
cmpq $0x0, -0x30(%rbp)
je 0x22ca92
movsd -0x40(%rbp), %xmm1
movsd -0x38(%rbp), %xmm0
ucomisd %xmm1, %xmm0
ja 0x22ca92
movsd -0x40(%rbp), %xmm0
ucomisd -0x38(%rbp), %xmm0
jne 0x22cabf
jp 0x22cabf
movl -0x24(%rbp), %eax
movq -0x10(%rbp), %rcx
movq 0x50(%rcx), %rcx
movq -0x8(%rbp), %rdx
shlq $0x5, %rdx
addq %rdx, %rcx
cmpl (%rcx), %eax
jne 0x22cabf
movq -0x10(%rbp), %rax
movq 0x60(%rax), %rax
movl -0x14(%rbp), %ecx
imulq $0x18, %rcx, %rcx
addq %rcx, %rax
movq (%rax), %rax
movl -0x18(%rbp), %ecx
shlq $0x2, %rcx
addq %rcx, %rax
movq %rax, -0x30(%rbp)
movsd -0x38(%rbp), %xmm0
movsd %xmm0, -0x40(%rbp)
jmp 0x22cac1
movl -0x18(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x18(%rbp)
jmp 0x22c95a
movq -0x10(%rbp), %rax
movq 0x50(%rax), %rax
movq -0x8(%rbp), %rcx
shlq $0x5, %rcx
addq %rcx, %rax
movzwl 0x6(%rax), %eax
cmpl $0xffff, %eax           # imm = 0xFFFF
je 0x22cc8c
movq -0x10(%rbp), %rax
movq 0x50(%rax), %rax
movq -0x8(%rbp), %rcx
shlq $0x5, %rcx
addq %rcx, %rax
movzwl 0x6(%rax), %eax
subl $0x1, %eax
movl %eax, -0x14(%rbp)
movl $0x0, -0x18(%rbp)
movl -0x18(%rbp), %eax
movq -0x10(%rbp), %rcx
movq 0x60(%rcx), %rcx
movl -0x14(%rbp), %edx
imulq $0x18, %rdx, %rdx
addq %rdx, %rcx
cmpq 0x8(%rcx), %rax
jae 0x22cc8a
movq -0x10(%rbp), %rax
movq 0x60(%rax), %rax
movl -0x14(%rbp), %ecx
imulq $0x18, %rcx, %rcx
addq %rcx, %rax
movq (%rax), %rax
movl -0x18(%rbp), %ecx
movl (%rax,%rcx,4), %eax
movl %eax, -0x24(%rbp)
xorps %xmm0, %xmm0
movsd %xmm0, -0x38(%rbp)
movl $0x0, -0x1c(%rbp)
movl -0x1c(%rbp), %eax
cmpl -0x20(%rbp), %eax
jae 0x22cc0e
movl -0x24(%rbp), %eax
andl -0x1c(%rbp), %eax
cmpl $0x0, %eax
je 0x22cbc1
movq -0x10(%rbp), %rax
movq 0x40(%rax), %rax
movq (%rax), %rax
movq -0x8(%rbp), %rdx
movq -0x10(%rbp), %rcx
movq 0x40(%rcx), %rcx
movl 0x8(%rcx), %ecx
shlq %cl, %rdx
movq %rdx, %rcx
movl -0x1c(%rbp), %edx
addq %rdx, %rcx
movsd (%rax,%rcx,8), %xmm0
movq %xmm0, %rax
movabsq $-0x8000000000000000, %rcx # imm = 0x8000000000000000
xorq %rcx, %rax
movq %rax, %xmm0
movsd %xmm0, -0x50(%rbp)
jmp 0x22cbf1
movq -0x10(%rbp), %rax
movq 0x40(%rax), %rax
movq (%rax), %rax
movq -0x8(%rbp), %rdx
movq -0x10(%rbp), %rcx
movq 0x40(%rcx), %rcx
movl 0x8(%rcx), %ecx
shlq %cl, %rdx
movq %rdx, %rcx
movl -0x1c(%rbp), %edx
addq %rdx, %rcx
movsd (%rax,%rcx,8), %xmm0
movsd %xmm0, -0x50(%rbp)
movsd -0x50(%rbp), %xmm0
addsd -0x38(%rbp), %xmm0
movsd %xmm0, -0x38(%rbp)
movl -0x1c(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x1c(%rbp)
jmp 0x22cb61
cmpq $0x0, -0x30(%rbp)
je 0x22cc4d
movsd -0x40(%rbp), %xmm1
movsd -0x38(%rbp), %xmm0
ucomisd %xmm1, %xmm0
ja 0x22cc4d
movsd -0x40(%rbp), %xmm0
ucomisd -0x38(%rbp), %xmm0
jne 0x22cc7a
jp 0x22cc7a
movl -0x24(%rbp), %eax
movq -0x10(%rbp), %rcx
movq 0x50(%rcx), %rcx
movq -0x8(%rbp), %rdx
shlq $0x5, %rdx
addq %rdx, %rcx
cmpl (%rcx), %eax
jne 0x22cc7a
movq -0x10(%rbp), %rax
movq 0x60(%rax), %rax
movl -0x14(%rbp), %ecx
imulq $0x18, %rcx, %rcx
addq %rcx, %rax
movq (%rax), %rax
movl -0x18(%rbp), %ecx
shlq $0x2, %rcx
addq %rcx, %rax
movq %rax, -0x30(%rbp)
movsd -0x38(%rbp), %xmm0
movsd %xmm0, -0x40(%rbp)
jmp 0x22cc7c
movl -0x18(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x18(%rbp)
jmp 0x22cb15
jmp 0x22cc8c
movq -0x30(%rbp), %rax
movl (%rax), %eax
popq %rbp
retq
nopw %cs:(%rax,%rax)