// File: 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:
subq $0xc8, %rsp
movq %rdi, 0xc0(%rsp)
movq 0xc0(%rsp), %rax
movq %rax, 0x50(%rsp)
movq 0x40(%rax), %rdi
addq $0x4120, %rdi           # imm = 0x4120
callq 0x28cb0
movq 0x50(%rsp), %rax
movq 0x40(%rax), %rax
testb $0x1, 0x68(%rax)
je 0x263b6
leaq 0xb8(%rsp), %rdi
callq 0x6780
movq 0x50(%rsp), %rax
movq 0xb8(%rsp), %rcx
movq %rcx, 0x121c8(%rax)
movl $0x0, 0x12120(%rax)
movq 0x50(%rsp), %rax
movq %rax, %rdi
addq $0xcb78, %rdi           # imm = 0xCB78
movq 0x40(%rax), %rsi
addq $0x10, %rsi
callq 0x28cd0
movq 0x50(%rsp), %rax
movq 0x40(%rax), %rdi
addq $0x40f0, %rdi           # imm = 0x40F0
callq 0x28d90
movq 0x50(%rsp), %rax
movq 0x40(%rax), %rsi
addq $0x10, %rsi
leaq 0x70(%rsp), %rdi
callq 0x118b0
movq 0x50(%rsp), %rdi
addq $0x48, %rdi
callq 0x28db0
vmovss %xmm0, 0x4c(%rsp)
jmp 0x26414
movq 0x50(%rsp), %rdi
vmovss 0x4c(%rsp), %xmm1
movq 0x40(%rdi), %rax
vmovss 0x88(%rax), %xmm0
vucomiss %xmm1, %xmm0
seta 0x2f14(%rdi)
addq $0x48, %rdi
callq 0x28db0
vmovss %xmm0, 0x48(%rsp)
jmp 0x26447
movq 0x50(%rsp), %rdi
vmovss 0x48(%rsp), %xmm1
movq 0x40(%rdi), %rax
vmovss 0x8c(%rax), %xmm0
vucomiss %xmm1, %xmm0
seta 0x2f15(%rdi)
movq 0x40(%rdi), %rdx
addq $0x40e0, %rdx           # imm = 0x40E0
leaq 0x70(%rsp), %rsi
xorl %ecx, %ecx
callq 0x26650
jmp 0x26482
movq 0x50(%rsp), %rax
movq 0x40(%rax), %rdi
movq %rdi, %rcx
addq $0x40f0, %rcx           # imm = 0x40F0
movq %rcx, 0x30(%rsp)
addq $0xcb78, %rax           # imm = 0xCB78
movq %rax, 0x38(%rsp)
addq $0x10, %rdi
callq 0x1a8a0
movb %al, 0x47(%rsp)
jmp 0x264b4
movb 0x47(%rsp), %al
movb %al, 0x62(%rsp)
movzbl 0x62(%rsp), %edi
callq 0x1c680
movb %al, 0x2f(%rsp)
jmp 0x264cc
movq 0x38(%rsp), %rdi
movb 0x2f(%rsp), %al
movb %al, 0x63(%rsp)
movzbl 0x63(%rsp), %esi
callq 0x28e40
movq %rax, 0x20(%rsp)
jmp 0x264ea
movq 0x20(%rsp), %rsi
movq 0x30(%rsp), %rdi
callq 0x28de0
jmp 0x264fb
movq 0x50(%rsp), %rax
movq 0x40(%rax), %rax
testb $0x1, 0x68(%rax)
je 0x26629
movq 0x50(%rsp), %rdi
movq %rdi, %rsi
addq $0x121c8, %rsi          # imm = 0x121C8
addq $0x121d0, %rdi          # imm = 0x121D0
callq 0x1ad50
vmovsd %xmm0, 0x18(%rsp)
jmp 0x26531
movq 0x50(%rsp), %rsi
vmovsd 0x18(%rsp), %xmm1
vmovsd 0x121a8(%rsi), %xmm0
vaddsd %xmm1, %xmm0, %xmm0
vmovsd %xmm0, 0x121a8(%rsi)
movq %rsi, %rdi
addq $0x121d8, %rdi          # imm = 0x121D8
addq $0x121d0, %rsi          # imm = 0x121D0
callq 0x1ad50
vmovsd %xmm0, 0x10(%rsp)
jmp 0x2656e
movq 0x50(%rsp), %rsi
vmovsd 0x10(%rsp), %xmm1
vmovsd 0x121b0(%rsi), %xmm0
vaddsd %xmm1, %xmm0, %xmm0
vmovsd %xmm0, 0x121b0(%rsi)
movq %rsi, %rdi
addq $0x121e0, %rdi          # imm = 0x121E0
addq $0x121d8, %rsi          # imm = 0x121D8
callq 0x1ad50
vmovsd %xmm0, 0x8(%rsp)
jmp 0x265ab
movq 0x50(%rsp), %rax
vmovsd 0x8(%rsp), %xmm1
vmovsd 0x121b8(%rax), %xmm0
vaddsd %xmm1, %xmm0, %xmm0
vmovsd %xmm0, 0x121b8(%rax)
leaq 0x58(%rsp), %rdi
callq 0x6780
jmp 0x265d6
movq 0x50(%rsp), %rsi
addq $0x121e0, %rsi          # imm = 0x121E0
leaq 0x58(%rsp), %rdi
callq 0x1ad50
vmovsd %xmm0, (%rsp)
jmp 0x265f3
movq 0x50(%rsp), %rax
vmovsd (%rsp), %xmm0
vaddsd 0x121c0(%rax), %xmm0, %xmm0
vmovsd %xmm0, 0x121c0(%rax)
jmp 0x26629
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x68(%rsp)
movl %eax, 0x64(%rsp)
leaq 0x70(%rsp), %rdi
callq 0xc040
jmp 0x2663b
leaq 0x70(%rsp), %rdi
callq 0xc040
addq $0xc8, %rsp
retq
movq 0x68(%rsp), %rdi
callq 0x5760
nopw %cs:(%rax,%rax)