// File: /workspace/github_cpp_makefile_star2_O1/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
movl %ecx, %ebp
movq %rsi, %rbx
movq %rdi, %r14
movw %dx, 0x6(%rsp)
movq 0x40(%rdi), %rax
movl 0xd8(%rax), %eax
testl %eax, %eax
je 0x17025
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
movl %eax, 0xf00(%r14)
movb 0x9(%rbx), %r15b
leaq 0x1f373(%rip), %rax     # 0x363b1
cmpb (%rax), %r15b
jge 0x170e6
leaq 0x119b8(%r14), %r12
leaq 0x8(%rsp), %r13
movb 0x8(%rbx), %r15b
movq %r14, %rdi
movq %rbx, %rsi
leaq 0x6(%rsp), %rdx
callq 0x176ae
movw %ax, 0x6(%rsp)
movslq 0x1210c(%r14), %rcx
movslq 0x12110(%r14), %rdx
leal 0x1(%rdx), %esi
movl %esi, 0x12110(%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 0x13778
testb %al, %al
je 0x17163
incl %ebp
movb 0x9(%rbx), %r15b
leaq 0x1f2d4(%rip), %rax     # 0x363b1
cmpb (%rax), %r15b
jl 0x17053
leaq 0x12148(%r14), %rdi
movl %ebp, %esi
callq 0x179de
leaq 0x1f2b6(%rip), %rax     # 0x363b1
cmpb (%rax), %r15b
jle 0x17117
movsbq %r15b, %rax
shlq $0x5, %rax
leaq 0x12148(%rax,%r14), %rdi
movl %ebp, %esi
callq 0x179de
movq 0x40(%r14), %rax
cmpl $0x0, 0xd4(%rax)
movzbl %r15b, %ebp
je 0x1713d
leaq 0x4c(%r14), %rdi
leaq 0xcb78(%r14), %rdx
movq %rbx, %rsi
movl %ebp, %ecx
callq 0x17d72
addq $0xcb78, %r14           # imm = 0xCB78
movq %r14, %rdi
movl %ebp, %esi
callq 0x17920
movl %r15d, %eax
addq $0xa8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq 0x32e86(%rip), %r14     # 0x49ff0
leaq 0x1c7c0(%rip), %rsi     # 0x33931
movl $0x34, %edx
movq %r14, %rdi
callq 0x53a0
leaq 0x1c644(%rip), %rsi     # 0x337c9
movl $0x17, %edx
movq %r14, %rdi
callq 0x53a0
leaq 0x1c7cd(%rip), %rsi     # 0x33966
movl $0x6, %edx
movq %r14, %rdi
callq 0x53a0
movq %r14, %rdi
movl $0x1ad, %esi            # imm = 0x1AD
callq 0x5620
movq %rax, %r14
leaq 0x1b359(%rip), %rsi     # 0x32516
movl $0x2, %edx
movq %rax, %rdi
callq 0x53a0
leaq 0x88(%rsp), %r15
movq %r15, %rdi
movq %rbx, %rsi
movl $0x1, %edx
callq 0x1f6ee
leaq 0x1a71d(%rip), %rsi     # 0x31906
leaq 0x68(%rsp), %rdi
movq %r15, %rdx
callq 0x17841
leaq 0x1a709(%rip), %rsi     # 0x31906
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 0x1722a
vmovups (%rcx), %xmm0
vmovups %xmm0, (%r15)
jmp 0x17237
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 0x10cdc
leaq 0x8(%rsp), %rdi
leaq 0x28(%rsp), %rsi
leaq 0x48(%rsp), %rdx
callq 0x17742
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 0x172e6
callq 0x52e0
jmp 0x172e6
movq %rax, %rbx
leaq 0x58(%rsp), %rax
movq -0x10(%rax), %rdi
cmpq %rax, %rdi
je 0x172fe
callq 0x52e0
jmp 0x172fe
movq %rax, %rbx
movq 0x28(%rsp), %rdi
cmpq %r15, %rdi
je 0x17312
callq 0x52e0
jmp 0x17312
movq %rax, %rbx
leaq 0x78(%rsp), %rax
movq -0x10(%rax), %rdi
cmpq %rax, %rdi
je 0x1732a
callq 0x52e0
jmp 0x1732a
movq %rax, %rbx
leaq 0x98(%rsp), %rax
movq -0x10(%rax), %rdi
cmpq %rax, %rdi
je 0x17340
callq 0x52e0
movq %rbx, %rdi
callq 0x5670