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

	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
leaq 0x1b274(%rip), %rcx     # 0x31ec9
movq %rsi, %rbx
movq %rdi, %r14
movl 0xefc(%rdi), %eax
movl %eax, 0xf00(%rdi)
movb 0x9(%rsi), %r13b
cmpb (%rcx), %r13b
jge 0x16d0b
leaq 0x5d48(%r14), %r15
leaq 0x8(%rsp), %r12
movb 0x8(%rbx), %r13b
leaq 0x6(%rsp), %rdx
movq %r14, %rdi
movq %rbx, %rsi
callq 0x17012
cwtl
movq %rbx, %rdi
movw %ax, 0x6(%rsp)
movslq 0x64a0(%r14), %rdx
movslq 0x649c(%r14), %rcx
addq %rdx, %rcx
leal 0x1(%rdx), %esi
leaq (%rcx,%rcx,2), %rcx
movl %esi, 0x64a0(%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 0x1359e
testb %al, %al
je 0x16d88
movb 0x9(%rbx), %r13b
leaq 0x1b1c9(%rip), %rax     # 0x31ec9
incl %ebp
cmpb (%rax), %r13b
jl 0x16c80
leaq 0x64d8(%r14), %rdi
movl %ebp, %esi
callq 0x17302
leaq 0x1b1a9(%rip), %rax     # 0x31ec9
cmpb (%rax), %r13b
jle 0x16d3c
movsbq %r13b, %rax
movl %ebp, %esi
shlq $0x5, %rax
leaq 0x64d8(%rax,%r14), %rdi
callq 0x17302
movq 0x40(%r14), %rax
movzbl %r13b, %ebp
cmpl $0x0, 0xb8(%rax)
je 0x16d62
leaq 0x4c(%r14), %rdi
leaq 0xf08(%r14), %rdx
movq %rbx, %rsi
movl %ebp, %ecx
callq 0x17368
addq $0xf08, %r14            # imm = 0xF08
movl %ebp, %esi
movq %r14, %rdi
callq 0x17244
movl %r13d, %eax
addq $0xa8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq 0x2e261(%rip), %r14     # 0x44ff0
leaq 0x18b33(%rip), %rsi     # 0x2f8c9
movl $0x34, %edx
movq %r14, %rdi
callq 0x53a0
leaq 0x189ab(%rip), %rsi     # 0x2f755
movl $0x1a, %edx
movq %r14, %rdi
callq 0x53a0
leaq 0x18b40(%rip), %rsi     # 0x2f8fe
movl $0x6, %edx
movq %r14, %rdi
callq 0x53a0
movl $0x168, %esi            # imm = 0x168
movq %r14, %rdi
callq 0x5620
leaq 0x17717(%rip), %rsi     # 0x2e4f6
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 0x1d8ae
leaq 0x16ac7(%rip), %rsi     # 0x2d8d5
leaq 0x68(%rsp), %rdi
movq %r15, %rdx
callq 0x1715f
leaq 0x16ab3(%rip), %rsi     # 0x2d8d5
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 0x16e4f
vmovups (%rcx), %xmm0
vmovups %xmm0, (%r15)
jmp 0x16e5c
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 0x10b92
leaq 0x8(%rsp), %rdi
leaq 0x28(%rsp), %rsi
leaq 0x48(%rsp), %rdx
callq 0x17060
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 0x16f0b
callq 0x52e0
jmp 0x16f0b
movq %rax, %rbx
leaq 0x58(%rsp), %rax
movq -0x10(%rax), %rdi
cmpq %rax, %rdi
je 0x16f23
callq 0x52e0
jmp 0x16f23
movq %rax, %rbx
movq 0x28(%rsp), %rdi
cmpq %r15, %rdi
je 0x16f37
callq 0x52e0
jmp 0x16f37
movq %rax, %rbx
leaq 0x78(%rsp), %rax
movq -0x10(%rax), %rdi
cmpq %rax, %rdi
je 0x16f4f
callq 0x52e0
jmp 0x16f4f
movq %rax, %rbx
leaq 0x98(%rsp), %rax
movq -0x10(%rax), %rdi
cmpq %rax, %rdi
je 0x16f65
callq 0x52e0
movq %rbx, %rdi
callq 0x5670