// File: /workspace/github_cpp_makefile_star2_O1/tewalds[P]morat/hex/agentmcts.cpp
// Function: Morat::Hex::AgentMCTS::move(Morat::Move const&)
void AgentMCTS::move(const Move & m){
	pool.pause();

	uword nodesbefore = nodes;

	if(keeptree && root.children.num() > 0){
		Node child;

		for(Node * i = root.children.begin(); i != root.children.end(); i++){
			if(i->move == m){
				child = *i;          //copy the child experience to temp
				child.swap_tree(*i); //move the child tree to temp
				break;
			}
		}

		nodes -= root.dealloc(ctmem);
		root = child;
		root.swap_tree(child);

		if(nodesbefore > 0)
			logerr("Nodes before: " + to_str(nodesbefore) + ", after: " + to_str(nodes) + ", saved " +  to_str(100.0*nodes/nodesbefore, 1) + "% of the tree\n");
	}else{
		nodes -= root.dealloc(ctmem);
		root = Node();
		root.move = m;
	}
	assert(nodes == root.size());

	rootboard.move(m);

	root.exp.addwins(visitexpand+1); //+1 to compensate for the virtual loss
	if(rootboard.outcome() < Outcome::DRAW)
		root.outcome = Outcome::UNKNOWN;

	if(ponder)
		pool.resume();
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x158, %rsp            # imm = 0x158
movq %rsi, %r15
movq %rdi, %r14
leaq 0x54f0(%rdi), %rbx
movq %rbx, %rdi
callq 0x1141a
cmpb $0x1, 0xa1(%r14)
jne 0xf37e
movq 0x4108(%r14), %rax
cmpq $0x2, %rax
jb 0xf37e
cmpw $0x0, 0x6(%rax)
je 0xf37e
movq 0x4110(%r14), %rcx
movq %rcx, 0xb0(%rsp)
leaq 0x40e0(%r14), %r13
leaq 0x10(%rax), %rcx
xorl %r12d, %r12d
cmpq $0x2, %rax
vxorpd %xmm0, %xmm0, %xmm0
leaq 0x88(%rsp), %rbp
vmovupd %ymm0, -0x28(%rbp)
movw $0x0, -0x8(%rbp)
leaq 0x27093(%rip), %rdx     # 0x363ae
movb (%rdx), %dl
movb %dl, -0x6(%rbp)
movl $0xfc78fd00, -0x5(%rbp) # imm = 0xFC78FD00
movb $0x78, -0x1(%rbp)
movq %r12, (%rbp)
cmovaeq %rcx, %r12
movb (%r15), %dl
movb 0x1(%r15), %dil
addq $0x28, %r12
cmpq $0x2, %rax
jb 0xf355
movzwl 0x6(%rax), %esi
leaq (%rsi,%rsi,2), %r8
shll $0x4, %r8d
addq %rcx, %r8
jmp 0xf358
xorl %r8d, %r8d
leaq -0x28(%r12), %rsi
cmpq %r8, %rsi
je 0xf4f5
cmpb %dl, -0x4(%r12)
jne 0xf378
cmpb %dil, -0x3(%r12)
je 0xf4b0
addq $0x30, %r12
jmp 0xf33e
leaq 0x40e0(%r14), %r12
leaq 0x4130(%r14), %rsi
movq %r12, %rdi
callq 0x12312
movl %eax, %eax
subq %rax, 0x4110(%r14)
vxorpd %xmm0, %xmm0, %xmm0
leaq 0x60(%rsp), %rsi
vmovupd %ymm0, (%rsi)
movw $0x0, 0x20(%rsi)
leaq 0x26ff7(%rip), %rax     # 0x363ae
movb (%rax), %al
movb %al, 0x22(%rsi)
movl $0xfc78fd00, 0x23(%rsi) # imm = 0xFC78FD00
movb $0x78, 0x27(%rsi)
movq $0x0, 0x28(%rsi)
movq %r12, %rdi
vzeroupper
callq 0x1282c
leaq 0x60(%rsp), %rdi
callq 0x122ba
movzwl (%r15), %eax
movw %ax, 0x4104(%r14)
movq 0x4110(%r14), %r12
leaq 0x40e0(%r14), %rdi
callq 0x1289c
movl %eax, %eax
cmpq %rax, %r12
jne 0xf9b2
leaq 0x10(%r14), %rdi
movsbl (%r15), %eax
movsbl 0x10(%r14), %ecx
imull %eax, %ecx
movsbl 0x1(%r15), %eax
addl %ecx, %eax
movzwl (%r15), %ecx
leaq 0x60(%rsp), %rsi
movw %cx, (%rsi)
movw %ax, 0x2(%rsi)
movl $0x1, %edx
movl $0x1, %ecx
callq 0x13778
movl 0xa8(%r14), %eax
incl %eax
vmovq %rax, %xmm0
addq %rax, %rax
vmovq %rax, %xmm1
vpunpcklqdq %xmm0, %xmm1, %xmm0 # xmm0 = xmm1[0],xmm0[0]
vpaddq 0x40f0(%r14), %xmm0, %xmm0
vmovdqu %xmm0, 0x40f0(%r14)
movb 0x19(%r14), %al
leaq 0x26f36(%rip), %rcx     # 0x363b1
cmpb (%rcx), %al
jge 0xf48f
leaq 0x26f28(%rip), %rax     # 0x363ae
movb (%rax), %al
movb %al, 0x4102(%r14)
cmpb $0x1, 0x58(%r14)
jne 0xf49e
movq %rbx, %rdi
callq 0x11586
addq $0x158, %rsp            # imm = 0x158
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
leaq 0x60(%rsp), %rdi
vzeroupper
callq 0x1282c
movq 0x88(%rsp), %rax
movq (%r12), %rcx
movq %rcx, 0x88(%rsp)
movq %rax, (%r12)
movq 0x88(%rsp), %rax
cmpq $0x2, %rax
jb 0xf4e7
movq %rbp, 0x8(%rax)
movq (%r12), %rax
cmpq $0x2, %rax
jb 0xf4f5
movq %r12, 0x8(%rax)
leaq 0x4130(%r14), %rsi
movq %r13, %rdi
vzeroupper
callq 0x12312
movl %eax, %eax
subq %rax, 0x4110(%r14)
leaq 0x60(%rsp), %rsi
movq %r13, %rdi
callq 0x1282c
movq 0x4108(%r14), %rcx
movq 0x88(%rsp), %rax
movq %rax, 0x4108(%r14)
movq %rcx, 0x88(%rsp)
cmpq $0x2, %rax
jb 0xf54c
leaq 0x4108(%r14), %rcx
movq %rcx, 0x8(%rax)
movq 0x88(%rsp), %rax
cmpq $0x2, %rax
jb 0xf55e
movq %rbp, 0x8(%rax)
movq 0xb0(%rsp), %rbp
testq %rbp, %rbp
jne 0xf57a
leaq 0x60(%rsp), %rdi
callq 0x122ba
jmp 0xf3f0
leaq 0x138(%rsp), %rdi
movq %rbp, %rsi
callq 0x1148d
leaq 0x24b61(%rip), %rcx     # 0x340f2
leaq 0x138(%rsp), %rdi
movl $0xe, %r8d
xorl %esi, %esi
xorl %edx, %edx
callq 0x5380
leaq 0x108(%rsp), %r12
movq %r12, -0x10(%r12)
movq (%rax), %rdx
movq %rax, %rcx
addq $0x10, %rcx
cmpq %rcx, %rdx
jne 0xf5d0
vmovupd (%rcx), %xmm0
vmovupd %xmm0, (%r12)
jmp 0xf5e3
movq %rdx, 0xf8(%rsp)
movq (%rcx), %rdx
movq %rdx, 0x108(%rsp)
movq 0x8(%rax), %rdx
leaq 0xf8(%rsp), %rdi
movq %rdx, 0x8(%rdi)
movq %rcx, (%rax)
movq $0x0, 0x8(%rax)
movb $0x0, 0x10(%rax)
leaq 0x22f87(%rip), %rsi     # 0x32590
callq 0x56e0
leaq 0x10(%rsp), %r13
movq %r13, -0x10(%r13)
movq (%rax), %rdx
movq %rax, %rcx
addq $0x10, %rcx
cmpq %rcx, %rdx
jne 0xf632
vmovupd (%rcx), %xmm0
vmovupd %xmm0, (%r13)
jmp 0xf63e
movq %rdx, (%rsp)
movq (%rcx), %rdx
movq %rdx, 0x10(%rsp)
movq 0x8(%rax), %rdx
movq %rdx, 0x8(%rsp)
movq %rcx, (%rax)
movq $0x0, 0x8(%rax)
movb $0x0, 0x10(%rax)
movq 0x4110(%r14), %rsi
leaq 0xd8(%rsp), %rdi
callq 0x1148d
movq (%rsp), %rcx
movq 0x8(%rsp), %r8
movq 0xe0(%rsp), %rdx
leaq (%rdx,%r8), %rax
movl $0xf, %esi
cmpq %r13, %rcx
je 0xf68e
movq 0x10(%rsp), %rsi
cmpq %rsi, %rax
jbe 0xf6b3
leaq 0xe8(%rsp), %rdi
movl $0xf, %esi
cmpq %rdi, -0x10(%rdi)
je 0xf6ae
movq 0xe8(%rsp), %rsi
cmpq %rsi, %rax
jbe 0xf6c5
movq 0xd8(%rsp), %rsi
movq %rsp, %rdi
callq 0x50c0
jmp 0xf6d6
leaq 0xd8(%rsp), %rdi
xorl %esi, %esi
xorl %edx, %edx
callq 0x5380
leaq 0x30(%rsp), %rdx
movq %rdx, -0x10(%rdx)
movq (%rax), %rsi
leaq 0x10(%rax), %rcx
cmpq %rcx, %rsi
jne 0xf6f5
vmovupd (%rcx), %xmm0
vmovupd %xmm0, (%rdx)
jmp 0xf702
movq %rsi, 0x20(%rsp)
movq (%rcx), %rdx
movq %rdx, 0x30(%rsp)
movq %rax, %rdx
addq $0x8, %rdx
movq 0x8(%rax), %rsi
movq %rsi, 0x28(%rsp)
movq %rcx, (%rax)
movq $0x0, (%rdx)
movb $0x0, (%rcx)
leaq 0x22e74(%rip), %rsi     # 0x3259a
leaq 0x20(%rsp), %rdi
callq 0x56e0
leaq 0xa0(%rsp), %r13
movq %r13, -0x10(%r13)
movq (%rax), %rdx
movq %rax, %rcx
addq $0x10, %rcx
cmpq %rcx, %rdx
jne 0xf757
vmovupd (%rcx), %xmm0
vmovupd %xmm0, (%r13)
jmp 0xf76a
movq %rdx, 0x90(%rsp)
movq (%rcx), %rdx
movq %rdx, 0xa0(%rsp)
movq 0x8(%rax), %rdx
movq %rdx, 0x98(%rsp)
movq %rcx, (%rax)
movq $0x0, 0x8(%rax)
movb $0x0, 0x10(%rax)
vcvtusi2sdq 0x4110(%r14), %xmm1, %xmm0
vmulsd 0x22a89(%rip), %xmm0, %xmm0 # 0x32220
vcvtusi2sd %rbp, %xmm1, %xmm1
vdivsd %xmm1, %xmm0, %xmm0
leaq 0xb8(%rsp), %rdi
movl $0x1, %esi
callq 0x2f81c
movq 0x90(%rsp), %rcx
movq 0x98(%rsp), %r8
movq 0xc0(%rsp), %rdx
leaq (%rdx,%r8), %rax
movl $0xf, %esi
cmpq %r13, %rcx
je 0xf7e1
movq 0xa0(%rsp), %rsi
cmpq %rsi, %rax
jbe 0xf806
leaq 0xc8(%rsp), %rdi
movl $0xf, %esi
cmpq %rdi, -0x10(%rdi)
je 0xf801
movq 0xc8(%rsp), %rsi
cmpq %rsi, %rax
jbe 0xf81d
movq 0xb8(%rsp), %rsi
leaq 0x90(%rsp), %rdi
callq 0x50c0
jmp 0xf82e
leaq 0xb8(%rsp), %rdi
xorl %esi, %esi
xorl %edx, %edx
callq 0x5380
leaq 0x50(%rsp), %rdx
movq %rdx, -0x10(%rdx)
movq (%rax), %rsi
leaq 0x10(%rax), %rcx
cmpq %rcx, %rsi
jne 0xf84d
vmovupd (%rcx), %xmm0
vmovupd %xmm0, (%rdx)
jmp 0xf85a
movq %rsi, 0x40(%rsp)
movq (%rcx), %rdx
movq %rdx, 0x50(%rsp)
movq %rax, %rdx
addq $0x8, %rdx
movq 0x8(%rax), %rsi
movq %rsi, 0x48(%rsp)
movq %rcx, (%rax)
movq %r12, %rbp
movq $0x0, (%rdx)
movb $0x0, (%rcx)
leaq 0x22d22(%rip), %rsi     # 0x325a3
leaq 0x40(%rsp), %rdi
callq 0x56e0
leaq 0x128(%rsp), %r12
movq %r12, -0x10(%r12)
movq (%rax), %rdx
movq %rax, %rcx
addq $0x10, %rcx
cmpq %rcx, %rdx
jne 0xf8b3
vmovupd (%rcx), %xmm0
vmovupd %xmm0, (%r12)
jmp 0xf8c6
movq %rdx, 0x118(%rsp)
movq (%rcx), %rdx
movq %rdx, 0x128(%rsp)
movq 0x8(%rax), %rdx
movq %rdx, 0x120(%rsp)
movq %rcx, (%rax)
movq $0x0, 0x8(%rax)
movb $0x0, 0x10(%rax)
movq 0x3a6e8(%rip), %rax     # 0x49fd0
movq (%rax), %rsi
movq 0x118(%rsp), %rdi
callq 0x5370
movq 0x118(%rsp), %rdi
cmpq %r12, %rdi
je 0xf90a
callq 0x52e0
leaq 0x50(%rsp), %rax
movq -0x10(%rax), %rdi
cmpq %rax, %rdi
je 0xf91d
callq 0x52e0
leaq 0xc8(%rsp), %rax
movq -0x10(%rax), %rdi
cmpq %rax, %rdi
je 0xf933
callq 0x52e0
movq 0x90(%rsp), %rdi
cmpq %r13, %rdi
je 0xf945
callq 0x52e0
leaq 0x30(%rsp), %rax
movq -0x10(%rax), %rdi
cmpq %rax, %rdi
leaq 0x10(%rsp), %r12
je 0xf95d
callq 0x52e0
leaq 0xe8(%rsp), %rax
movq -0x10(%rax), %rdi
cmpq %rax, %rdi
je 0xf973
callq 0x52e0
movq (%rsp), %rdi
cmpq %r12, %rdi
je 0xf981
callq 0x52e0
movq 0xf8(%rsp), %rdi
cmpq %rbp, %rdi
je 0xf993
callq 0x52e0
leaq 0x148(%rsp), %rax
movq -0x10(%rax), %rdi
cmpq %rax, %rdi
je 0xf56b
callq 0x52e0
jmp 0xf56b
leaq 0x22bf9(%rip), %rdi     # 0x325b2
leaq 0x22c07(%rip), %rsi     # 0x325c7
leaq 0x22c12(%rip), %rcx     # 0x325d9
movl $0xfd, %edx
callq 0x51d0
jmp 0xfab3
movq %rax, %rbx
leaq 0x50(%rsp), %rax
movq -0x10(%rax), %rdi
cmpq %rax, %rdi
je 0xf9f4
callq 0x52e0
jmp 0xf9f4
movq %r12, %rbp
movq %rax, %rbx
leaq 0xc8(%rsp), %rax
movq -0x10(%rax), %rdi
cmpq %rax, %rdi
je 0xfa12
callq 0x52e0
jmp 0xfa12
movq %r12, %rbp
movq %rax, %rbx
movq 0x90(%rsp), %rdi
cmpq %r13, %rdi
je 0xfa2c
callq 0x52e0
jmp 0xfa2c
movq %r12, %rbp
movq %rax, %rbx
leaq 0x30(%rsp), %rax
movq -0x10(%rax), %rdi
cmpq %rax, %rdi
je 0xfa47
callq 0x52e0
jmp 0xfa47
movq %r12, %rbp
movq %rax, %rbx
leaq 0xe8(%rsp), %rax
movq -0x10(%rax), %rdi
cmpq %rax, %rdi
je 0xfa65
callq 0x52e0
jmp 0xfa65
movq %r12, %rbp
movq %rax, %rbx
movq (%rsp), %rdi
leaq 0x10(%rsp), %rax
cmpq %rax, %rdi
je 0xfa80
callq 0x52e0
jmp 0xfa80
movq %r12, %rbp
movq %rax, %rbx
movq 0xf8(%rsp), %rdi
cmpq %rbp, %rdi
je 0xfa97
callq 0x52e0
jmp 0xfa97
movq %rax, %rbx
leaq 0x148(%rsp), %rax
movq -0x10(%rax), %rdi
cmpq %rax, %rdi
je 0xfab6
callq 0x52e0
jmp 0xfab6
jmp 0xfab3
jmp 0xfab3
movq %rax, %rbx
leaq 0x60(%rsp), %rdi
callq 0x122ba
movq %rbx, %rdi
callq 0x5670