// File: /workspace/github_cpp_makefile_star2_O3/tewalds[P]morat/hex/agentmctsthread.cpp
// Function: Morat::Hex::AgentMCTS::AgentThread::rollout(Morat::Hex::Board&, Morat::Move, int)
Outcome AgentMCTS::AgentThread::rollout(Board & board, Move move, int depth){
	Outcome won;

	if(agent->instantwin)
		instant_wins.rollout_start(board, agent->instantwin);

	random_policy.rollout_start(board);

	while((won = board.outcome()) < Outcome::DRAW){
		Side turn = board.to_play();

		move = rollout_choose_move(board, move);

		movelist.addrollout(move, turn);

		assert2(board.move(move, true, false), "\n" + board.to_s(true) + "\n" + move.to_s());
		depth++;
	}

	gamelen.add(depth);

	if(won > Outcome::DRAW)
		win_types[won.to_i() - 1][(int)board.win_type()].add(depth);

	//update the last good reply table
	if(agent->lastgoodreply)
		last_good_reply.rollout_end(board, movelist, won);

	movelist.finishrollout(won);
	return won;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0xa8, %rsp
movw %dx, 0x6(%rsp)
movl %ecx, %ebp
movq %rsi, %rbx
movq %rdi, %r14
movq 0x40(%rdi), %rax
movl 0xd8(%rax), %eax
testl %eax, %eax
je 0x170c9
movsbl (%rbx), %ecx
imull %eax, %ecx
negl %ecx
testl %eax, %eax
cmovnsl %eax, %ecx
movl %ecx, 0x2f08(%r14)
movl $0x0, 0x2f0c(%r14)
movw $0x78fc, 0x2f10(%r14)   # imm = 0x78FC
movl 0xefc(%r14), %eax
leaq 0x1f2da(%rip), %rcx     # 0x363b1
movl %eax, 0xf00(%r14)
movb 0x9(%rbx), %r13b
cmpb (%rcx), %r13b
jge 0x17182
leaq 0x119b8(%r14), %r15
leaq 0x8(%rsp), %r12
movb 0x8(%rbx), %r13b
leaq 0x6(%rsp), %rdx
movq %r14, %rdi
movq %rbx, %rsi
callq 0x17710
cwtl
movq %rbx, %rdi
movw %ax, 0x6(%rsp)
movslq 0x12110(%r14), %rdx
movslq 0x1210c(%r14), %rcx
addq %rdx, %rcx
leal 0x1(%rdx), %esi
leaq (%rcx,%rcx,2), %rcx
movl %esi, 0x12110(%r14)
movq %r12, %rsi
movw %ax, (%r15,%rcx)
movb %r13b, 0x2(%r15,%rcx)
movsbl %al, %ecx
movsbl (%rbx), %edx
movw %ax, 0x8(%rsp)
sarl $0x8, %eax
imull %ecx, %edx
xorl %ecx, %ecx
addl %edx, %eax
movl $0x1, %edx
movw %ax, 0xa(%rsp)
callq 0x1388c
testb %al, %al
je 0x171ff
movb 0x9(%rbx), %r13b
leaq 0x1f23a(%rip), %rax     # 0x363b1
incl %ebp
cmpb (%rax), %r13b
jl 0x170f7
leaq 0x12148(%r14), %rdi
movl %ebp, %esi
callq 0x17a46
leaq 0x1f21a(%rip), %rax     # 0x363b1
cmpb (%rax), %r13b
jle 0x171b3
movsbq %r13b, %rax
movl %ebp, %esi
shlq $0x5, %rax
leaq 0x12148(%rax,%r14), %rdi
callq 0x17a46
movq 0x40(%r14), %rax
movzbl %r13b, %ebp
cmpl $0x0, 0xd4(%rax)
je 0x171d9
leaq 0x4c(%r14), %rdi
leaq 0xcb78(%r14), %rdx
movq %rbx, %rsi
movl %ebp, %ecx
callq 0x17e10
addq $0xcb78, %r14           # imm = 0xCB78
movl %ebp, %esi
movq %r14, %rdi
callq 0x17988
movl %r13d, %eax
addq $0xa8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq 0x31dea(%rip), %r14     # 0x48ff0
leaq 0x1c724(%rip), %rsi     # 0x33931
movl $0x34, %edx
movq %r14, %rdi
callq 0x53a0
leaq 0x1c5a8(%rip), %rsi     # 0x337c9
movl $0x17, %edx
movq %r14, %rdi
callq 0x53a0
leaq 0x1c731(%rip), %rsi     # 0x33966
movl $0x6, %edx
movq %r14, %rdi
callq 0x53a0
movl $0x1ad, %esi            # imm = 0x1AD
movq %r14, %rdi
callq 0x5620
leaq 0x1b2c0(%rip), %rsi     # 0x32516
movl $0x2, %edx
movq %rax, %rdi
movq %rax, %r14
callq 0x53a0
leaq 0x88(%rsp), %r15
movl $0x1, %edx
movq %rbx, %rsi
movq %r15, %rdi
callq 0x1f644
leaq 0x1a681(%rip), %rsi     # 0x31906
leaq 0x68(%rsp), %rdi
movq %r15, %rdx
callq 0x178a3
leaq 0x1a66d(%rip), %rsi     # 0x31906
leaq 0x68(%rsp), %rdi
callq 0x56e0
leaq 0x38(%rsp), %r15
movq %rax, %rcx
addq $0x10, %rcx
movq %r15, -0x10(%r15)
movq (%rax), %rdx
cmpq %rcx, %rdx
jne 0x172c6
vmovups (%rcx), %xmm0
vmovups %xmm0, (%r15)
jmp 0x172d3
movq %rdx, 0x28(%rsp)
movq (%rcx), %rdx
movq %rdx, 0x38(%rsp)
movq 0x8(%rax), %rdx
movq %rdx, 0x30(%rsp)
movq %rcx, (%rax)
movq $0x0, 0x8(%rax)
movb $0x0, 0x10(%rax)
leaq 0x48(%rsp), %rdi
leaq 0x6(%rsp), %rsi
callq 0x10e7e
leaq 0x8(%rsp), %rdi
leaq 0x28(%rsp), %rsi
leaq 0x48(%rsp), %rdx
callq 0x177a4
movq 0x10(%rsp), %rdx
movq 0x8(%rsp), %rsi
movq %r14, %rdi
callq 0x53a0
movq %rax, %rdi
callq 0x5160
leaq 0x8(%rsp), %rdi
callq 0x5150
leaq 0x48(%rsp), %rdi
callq 0x5150
leaq 0x28(%rsp), %rdi
callq 0x5150
leaq 0x68(%rsp), %rdi
callq 0x5150
leaq 0x88(%rsp), %rdi
callq 0x5150
movl $0x1, %edi
callq 0x5420
leaq 0x18(%rsp), %rcx
movq %rax, %rbx
movq -0x10(%rcx), %rdi
cmpq %rcx, %rdi
je 0x17382
callq 0x52e0
jmp 0x17382
movq %rax, %rbx
leaq 0x58(%rsp), %rax
movq -0x10(%rax), %rdi
cmpq %rax, %rdi
je 0x1739a
callq 0x52e0
jmp 0x1739a
movq %rax, %rbx
movq 0x28(%rsp), %rdi
cmpq %r15, %rdi
je 0x173ae
callq 0x52e0
jmp 0x173ae
movq %rax, %rbx
leaq 0x78(%rsp), %rax
movq -0x10(%rax), %rdi
cmpq %rax, %rdi
je 0x173c6
callq 0x52e0
jmp 0x173c6
movq %rax, %rbx
leaq 0x98(%rsp), %rax
movq -0x10(%rax), %rdi
cmpq %rax, %rdi
je 0x173dc
callq 0x52e0
movq %rbx, %rdi
callq 0x5670