// File: /workspace/github_cpp_makefile_star2_O1/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
movl %ecx, %ebp
movq %rsi, %rbx
movq %rdi, %r14
movw %dx, 0x6(%rsp)
movl 0xefc(%rdi), %eax
movl %eax, 0xf00(%rdi)
movb 0x9(%rsi), %r15b
leaq 0x1c172(%rip), %rax     # 0x32ec9
cmpb (%rax), %r15b
jge 0x16dff
leaq 0x5d48(%r14), %r12
leaq 0x8(%rsp), %r13
movb 0x8(%rbx), %r15b
movq %r14, %rdi
movq %rbx, %rsi
leaq 0x6(%rsp), %rdx
callq 0x17106
movw %ax, 0x6(%rsp)
movslq 0x649c(%r14), %rcx
movslq 0x64a0(%r14), %rdx
leal 0x1(%rdx), %esi
movl %esi, 0x64a0(%r14)
addq %rdx, %rcx
leaq (%rcx,%rcx,2), %rcx
movw %ax, (%r12,%rcx)
movb %r15b, 0x2(%r12,%rcx)
movsbl 0x6(%rsp), %eax
movsbl (%rbx), %ecx
imull %eax, %ecx
movsbl 0x7(%rsp), %eax
addl %ecx, %eax
movzwl 0x6(%rsp), %ecx
movw %cx, 0x8(%rsp)
movw %ax, 0xa(%rsp)
movq %rbx, %rdi
movq %r13, %rsi
movl $0x1, %edx
xorl %ecx, %ecx
callq 0x135c0
testb %al, %al
je 0x16e7c
incl %ebp
movb 0x9(%rbx), %r15b
leaq 0x1c0d3(%rip), %rax     # 0x32ec9
cmpb (%rax), %r15b
jl 0x16d6c
leaq 0x64d8(%r14), %rdi
movl %ebp, %esi
callq 0x173f0
leaq 0x1c0b5(%rip), %rax     # 0x32ec9
cmpb (%rax), %r15b
jle 0x16e30
movsbq %r15b, %rax
shlq $0x5, %rax
leaq 0x64d8(%rax,%r14), %rdi
movl %ebp, %esi
callq 0x173f0
movq 0x40(%r14), %rax
cmpl $0x0, 0xb8(%rax)
movzbl %r15b, %ebp
je 0x16e56
leaq 0x4c(%r14), %rdi
leaq 0xf08(%r14), %rdx
movq %rbx, %rsi
movl %ebp, %ecx
callq 0x17456
addq $0xf08, %r14            # imm = 0xF08
movq %r14, %rdi
movl %ebp, %esi
callq 0x17332
movl %r15d, %eax
addq $0xa8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq 0x2f16d(%rip), %r14     # 0x45ff0
leaq 0x19a3f(%rip), %rsi     # 0x308c9
movl $0x34, %edx
movq %r14, %rdi
callq 0x53a0
leaq 0x198b7(%rip), %rsi     # 0x30755
movl $0x1a, %edx
movq %r14, %rdi
callq 0x53a0
leaq 0x19a4c(%rip), %rsi     # 0x308fe
movl $0x6, %edx
movq %r14, %rdi
callq 0x53a0
movq %r14, %rdi
movl $0x168, %esi            # imm = 0x168
callq 0x5620
movq %rax, %r14
leaq 0x18620(%rip), %rsi     # 0x2f4f6
movl $0x2, %edx
movq %rax, %rdi
callq 0x53a0
leaq 0x88(%rsp), %r15
movq %r15, %rdi
movq %rbx, %rsi
movl $0x1, %edx
callq 0x1da8c
leaq 0x179d3(%rip), %rsi     # 0x2e8d5
leaq 0x68(%rsp), %rdi
movq %r15, %rdx
callq 0x17253
leaq 0x179bf(%rip), %rsi     # 0x2e8d5
leaq 0x68(%rsp), %rdi
callq 0x56e0
leaq 0x38(%rsp), %r15
movq %r15, -0x10(%r15)
movq (%rax), %rdx
movq %rax, %rcx
addq $0x10, %rcx
cmpq %rcx, %rdx
jne 0x16f43
vmovups (%rcx), %xmm0
vmovups %xmm0, (%r15)
jmp 0x16f50
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 0x10b26
leaq 0x8(%rsp), %rdi
leaq 0x28(%rsp), %rsi
leaq 0x48(%rsp), %rdx
callq 0x17154
movq 0x8(%rsp), %rsi
movq 0x10(%rsp), %rdx
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
movq %rax, %rbx
leaq 0x18(%rsp), %rax
movq -0x10(%rax), %rdi
cmpq %rax, %rdi
je 0x16fff
callq 0x52e0
jmp 0x16fff
movq %rax, %rbx
leaq 0x58(%rsp), %rax
movq -0x10(%rax), %rdi
cmpq %rax, %rdi
je 0x17017
callq 0x52e0
jmp 0x17017
movq %rax, %rbx
movq 0x28(%rsp), %rdi
cmpq %r15, %rdi
je 0x1702b
callq 0x52e0
jmp 0x1702b
movq %rax, %rbx
leaq 0x78(%rsp), %rax
movq -0x10(%rax), %rdi
cmpq %rax, %rdi
je 0x17043
callq 0x52e0
jmp 0x17043
movq %rax, %rbx
leaq 0x98(%rsp), %rax
movq -0x10(%rax), %rdi
cmpq %rax, %rdi
je 0x17059
callq 0x52e0
movq %rbx, %rdi
callq 0x5670