// File: /workspace/github_cpp_makefile_star2_O1/tewalds[P]morat/hex/agentmctsthread.cpp
// Function: Morat::Hex::AgentMCTS::AgentThread::iterate()
void AgentMCTS::AgentThread::iterate(){
	INCR(agent->runs);
	if(agent->profile){
		timestamps[0] = Time();
		stage = 0;
	}

	movelist.reset(&(agent->rootboard));
	agent->root.exp.addvloss();
	Board copy = agent->rootboard;
	use_rave    = (unitrand() < agent->userave);
	use_explore = (unitrand() < agent->useexplore);
	walk_tree(copy, & agent->root, 0);
	agent->root.exp.addv(movelist.getexp(~agent->rootboard.to_play()));

	if(agent->profile){
		times[0] += timestamps[1] - timestamps[0];
		times[1] += timestamps[2] - timestamps[1];
		times[2] += timestamps[3] - timestamps[2];
		times[3] += Time() - timestamps[3];
	}
}

// Assembly:
pushq %r15
pushq %r14
pushq %rbx
subq $0x60, %rsp
movq %rdi, %rbx
movq 0x40(%rdi), %rax
lock
incq 0x4120(%rax)
movq 0x40(%rdi), %rax
cmpb $0x1, 0x68(%rax)
jne 0x15cde
leaq 0x8(%rsp), %r14
movq %r14, %rdi
xorl %esi, %esi
callq 0x55b0
vcvtsi2sdq (%r14), %xmm0, %xmm0
vcvtsi2sdq 0x8(%r14), %xmm1, %xmm1
vdivsd 0x1b340(%rip), %xmm1, %xmm1 # 0x31008
vaddsd %xmm0, %xmm1, %xmm0
vmovsd %xmm0, 0x121c8(%rbx)
movl $0x0, 0x12120(%rbx)
movq 0x40(%rbx), %rax
leaq 0x10(%rax), %rcx
movq $0x0, 0x1210c(%rbx)
movq %rcx, 0x12118(%rbx)
vxorpd %xmm0, %xmm0, %xmm0
vmovupd %ymm0, 0xcb78(%rbx)
cmpb $0x0, 0x10(%rax)
je 0x15d35
leaq 0xf2a8(%rbx), %rdx
xorl %esi, %esi
vxorpd %xmm0, %xmm0, %xmm0
vmovupd %xmm0, -0x2710(%rdx)
vmovupd %xmm0, (%rdx)
incq %rsi
movsbl (%rcx), %edi
imull %edi, %edi
addq $0x10, %rdx
cmpq %rdi, %rsi
jb 0x15d17
lock
incq 0x40f8(%rax)
movq 0x40(%rbx), %r15
movzwl 0x18(%r15), %eax
leaq 0x18(%rsp), %r14
movw %ax, -0x8(%r14)
movq 0x10(%r15), %rax
movq %rax, -0x10(%r14)
leaq 0x20(%r15), %rsi
movq %r14, %rdi
vzeroupper
callq 0xb34a
vmovups 0x38(%r15), %xmm0
vmovups %xmm0, 0x18(%r14)
movq 0x50(%r15), %rax
vmovups 0x48(%r15), %xmm0
vmovups %xmm0, 0x28(%r14)
testq %rax, %rax
je 0x15d9d
movq 0x34239(%rip), %rcx     # 0x49fc8
cmpb $0x0, (%rcx)
je 0x15d99
incl 0x8(%rax)
jmp 0x15d9d
lock
incl 0x8(%rax)
movl 0x48(%rbx), %eax
movl %eax, %ecx
shll $0xd, %ecx
xorl %eax, %ecx
movl %ecx, %eax
shrl $0x11, %eax
xorl %ecx, %eax
movl %eax, %ecx
shll $0x5, %ecx
movq 0x40(%rbx), %rdx
xorl %eax, %ecx
movl %ecx, 0x48(%rbx)
movl %ecx, %eax
shll $0xd, %eax
xorl %ecx, %eax
movl %eax, %esi
shrl $0x11, %esi
xorl %eax, %esi
movl %esi, %eax
shll $0x5, %eax
xorl %esi, %eax
vmovd %ecx, %xmm0
vpinsrd $0x1, %eax, %xmm0, %xmm0
vpmulld 0x1d8cb(%rip){1to4}, %xmm0, %xmm0 # 0x336b0
vcvtudq2ps %xmm0, %xmm0
vmulps 0x1d8bf(%rip){1to4}, %xmm0, %xmm0 # 0x336b4
vmovsd 0x88(%rdx), %xmm1
vcmpltps %xmm1, %xmm0, %k0
kshiftrb $0x1, %k0, %k1
kmovd %k1, %ecx
kmovd %k0, %esi
andb $0x1, %sil
movb %sil, 0x2f14(%rbx)
movl %eax, 0x48(%rbx)
andb $0x1, %cl
movb %cl, 0x2f15(%rbx)
addq $0x40e0, %rdx           # imm = 0x40E0
leaq 0x8(%rsp), %rsi
movq %rbx, %rdi
xorl %ecx, %ecx
callq 0x15f4e
leaq 0xcb78(%rbx), %rcx
movq 0x40(%rbx), %rax
movb $0x3, %dl
subb 0x18(%rax), %dl
movsbq %dl, %rdx
shlq $0x4, %rdx
leaq -0x10(%rdx,%rcx), %rcx
movq (%rcx), %rdx
testq %rdx, %rdx
je 0x15e6c
lock
addq %rdx, 0x40f0(%rax)
movq 0x8(%rcx), %rcx
testq %rcx, %rcx
je 0x15e7d
lock
addq %rcx, 0x40f8(%rax)
movq 0x40(%rbx), %rax
cmpb $0x1, 0x68(%rax)
jne 0x15f11
vmovupd 0x121c8(%rbx), %xmm0
vmovupd 0x121d0(%rbx), %xmm1
vunpcklpd %xmm1, %xmm0, %xmm0 # xmm0 = xmm0[0],xmm1[0]
vsubpd %xmm0, %xmm1, %xmm0
vaddpd 0x121a8(%rbx), %xmm0, %xmm0
vmovupd %xmm0, 0x121a8(%rbx)
vmovsd 0x121e0(%rbx), %xmm0
vsubsd 0x121d8(%rbx), %xmm0, %xmm0
vaddsd 0x121b8(%rbx), %xmm0, %xmm0
vmovsd %xmm0, 0x121b8(%rbx)
leaq 0x50(%rsp), %r14
movq %r14, %rdi
xorl %esi, %esi
callq 0x55b0
vcvtsi2sdq (%r14), %xmm2, %xmm0
vcvtsi2sdq 0x8(%r14), %xmm2, %xmm1
vdivsd 0x1b113(%rip), %xmm1, %xmm1 # 0x31008
vaddsd %xmm0, %xmm1, %xmm0
vsubsd 0x121e0(%rbx), %xmm0, %xmm0
vaddsd 0x121c0(%rbx), %xmm0, %xmm0
vmovsd %xmm0, 0x121c0(%rbx)
movq 0x48(%rsp), %rdi
testq %rdi, %rdi
je 0x15f20
callq 0xb170
movq 0x18(%rsp), %rdi
testq %rdi, %rdi
je 0x15f2f
callq 0x52e0
addq $0x60, %rsp
popq %rbx
popq %r14
popq %r15
retq
movq %rax, %rbx
leaq 0x8(%rsp), %rdi
callq 0x9ce0
movq %rbx, %rdi
callq 0x5670