// File: /workspace/github_cpp_makefile_star2_O3/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 0x40(%rdi), %rax
movq %rdi, %rbx
lock
incq 0x4120(%rax)
movq 0x40(%rdi), %rax
cmpb $0x1, 0x68(%rax)
jne 0x15de2
leaq 0x8(%rsp), %r14
xorl %esi, %esi
movq %r14, %rdi
callq 0x55b0
vcvtsi2sdq (%r14), %xmm0, %xmm0
vcvtsi2sdq 0x8(%r14), %xmm1, %xmm1
vdivsd 0x1b240(%rip), %xmm1, %xmm1 # 0x31008
vaddsd %xmm0, %xmm1, %xmm0
vmovsd %xmm0, 0x121c8(%rbx)
movl $0x0, 0x12120(%rbx)
movq 0x40(%rbx), %rax
leaq 0x10(%rax), %rcx
vxorpd %xmm0, %xmm0, %xmm0
movq $0x0, 0x1210c(%rbx)
movq %rcx, 0x12118(%rbx)
vmovupd %ymm0, 0xcb78(%rbx)
cmpb $0x0, 0x10(%rax)
je 0x15e35
leaq 0xf2a8(%rbx), %rdx
vxorpd %xmm0, %xmm0, %xmm0
xorl %esi, %esi
vmovupd %xmm0, -0x2710(%rdx)
vmovupd %xmm0, (%rdx)
incq %rsi
addq $0x10, %rdx
movsbl (%rcx), %edi
imull %edi, %edi
cmpq %rdi, %rsi
jb 0x15e17
lock
incq 0x40f8(%rax)
leaq 0x18(%rsp), %r14
movq 0x40(%rbx), %r15
movq %r14, %rdi
movzwl 0x18(%r15), %eax
leaq 0x20(%r15), %rsi
movw %ax, -0x8(%r14)
movq 0x10(%r15), %rax
movq %rax, -0x10(%r14)
vzeroupper
callq 0xb44a
vmovups 0x38(%r15), %xmm0
vmovups %xmm0, 0x18(%r14)
vmovups 0x48(%r15), %xmm0
movq 0x50(%r15), %rax
vmovups %xmm0, 0x28(%r14)
testq %rax, %rax
je 0x15e9d
movq 0x33139(%rip), %rcx     # 0x48fc8
cmpb $0x0, (%rcx)
je 0x15e99
incl 0x8(%rax)
jmp 0x15e9d
lock
incl 0x8(%rax)
movl 0x48(%rbx), %eax
movq 0x40(%rbx), %rdx
movl %eax, %ecx
shll $0xd, %ecx
vmovsd 0x88(%rdx), %xmm1
addq $0x40e0, %rdx           # imm = 0x40E0
xorl %eax, %ecx
movl %ecx, %eax
shrl $0x11, %eax
xorl %ecx, %eax
movl %eax, %ecx
shll $0x5, %ecx
xorl %eax, %ecx
movl %ecx, %eax
shll $0xd, %eax
vmovd %ecx, %xmm0
xorl %ecx, %eax
movl %eax, %esi
shrl $0x11, %esi
xorl %eax, %esi
movl %esi, %eax
shll $0x5, %eax
xorl %esi, %eax
vpinsrd $0x1, %eax, %xmm0, %xmm0
vpmulld 0x1d7bf(%rip){1to4}, %xmm0, %xmm0 # 0x336b0
vcvtudq2ps %xmm0, %xmm0
vmulps 0x1d7b3(%rip){1to4}, %xmm0, %xmm0 # 0x336b4
vcmpltps %xmm1, %xmm0, %k0
kshiftrb $0x1, %k0, %k1
kmovd %k0, %esi
kmovd %k1, %ecx
andb $0x1, %sil
andb $0x1, %cl
movb %sil, 0x2f14(%rbx)
movl %eax, 0x48(%rbx)
movb %cl, 0x2f15(%rbx)
leaq 0x8(%rsp), %rsi
movq %rbx, %rdi
xorl %ecx, %ecx
callq 0x1604c
movq 0x40(%rbx), %rax
movb $0x3, %dl
leaq 0xcb78(%rbx), %rcx
subb 0x18(%rax), %dl
movsbq %dl, %rdx
shlq $0x4, %rdx
leaq -0x10(%rdx,%rcx), %rcx
movq (%rcx), %rdx
testq %rdx, %rdx
je 0x15f69
lock
addq %rdx, 0x40f0(%rax)
movq 0x8(%rcx), %rcx
testq %rcx, %rcx
je 0x15f7a
lock
addq %rcx, 0x40f8(%rax)
movq 0x40(%rbx), %rax
cmpb $0x1, 0x68(%rax)
jne 0x1600e
vmovupd 0x121c8(%rbx), %xmm0
vmovupd 0x121d0(%rbx), %xmm1
leaq 0x50(%rsp), %r14
xorl %esi, %esi
movq %r14, %rdi
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)
callq 0x55b0
vcvtsi2sdq (%r14), %xmm2, %xmm0
vcvtsi2sdq 0x8(%r14), %xmm2, %xmm1
vdivsd 0x1b016(%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 0x1601d
callq 0xb272
movq 0x18(%rsp), %rdi
testq %rdi, %rdi
je 0x1602c
callq 0x52e0
addq $0x60, %rsp
popq %rbx
popq %r14
popq %r15
retq
leaq 0x8(%rsp), %rdi
movq %rax, %rbx
callq 0x9d96
movq %rbx, %rdi
callq 0x5670
nop