// File: /workspace/github_cpp_makefile_star2_O2/tewalds[P]morat/hex/agentpns.cpp
// Function: Morat::Hex::AgentPNS::search(double, unsigned long, int)
void AgentPNS::search(double time, uint64_t maxiters, int verbose){
	max_nodes_seen = maxiters;

	if(rootboard.outcome() >= 0)
		return;

	Time starttime;

	pool.reset();
	pool.resume();

	pool.wait_pause(time);


	double time_used = Time() - starttime;


	if(verbose){
		DepthStats treelen;
		for(auto & t : pool)
			treelen += t->treelen;

		logerr("Finished:    " + to_str(nodes_seen) + " nodes created in " + to_str(time_used*1000, 0) + " msec: " + to_str(nodes_seen/time_used, 0) + " Nodes/s\n");
		if(nodes_seen > 0){
			logerr("Tree depth:  " + treelen.to_s() + "\n");
		}

		Side to_play = rootboard.to_play();

		logerr("Root:        " + root.to_s() + "\n");
		Outcome outcome = root.to_outcome(~to_play);
		if(outcome != Outcome::UNKNOWN)
			logerr("Solved as a " + outcome.to_s_rel(to_play) + "\n");

		std::string pvstr;
		for(auto m : Agent::get_pv())
			pvstr += " " + m.to_s();
		logerr("PV:         " + pvstr + "\n");

		if(verbose >= 3 && !root.children.empty())
			logerr("Move stats:\n" + move_stats(vecmove()));
	}
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x208, %rsp            # imm = 0x208
movq %rsi, 0x1520(%rdi)
cmpb $0x0, 0x19(%rdi)
jns 0x14706
movq %rdi, %r13
leaq 0xa0(%rsp), %rdi
movl %edx, %ebp
vmovsd %xmm0, 0x8(%rsp)
callq 0x5ca0
leaq 0x1430(%r13), %r14
movq %r14, %rdi
callq 0x157f0
movq %r14, %rdi
callq 0x15866
vmovsd 0x8(%rsp), %xmm0
movq %r14, %rdi
callq 0x158a4
leaq 0x128(%rsp), %rdi
callq 0x5ca0
testl %ebp, %ebp
je 0x14706
leaq 0x128(%rsp), %r14
movl $0x9ca8, %r12d          # imm = 0x9CA8
vmovsd (%r14), %xmm0
andl $0x0, 0x8(%r14)
movq $0x3b9aca00, (%r14)     # imm = 0x3B9ACA00
vsubsd 0xa0(%rsp), %xmm0, %xmm0
vmovsd %xmm0, 0x8(%rsp)
vxorpd %xmm0, %xmm0, %xmm0
vmovupd %xmm0, 0x10(%r14)
movq 0x1438(%r13), %rbx
movq 0x1440(%r13), %r15
cmpq %r15, %rbx
je 0x142a7
movq (%rbx), %rsi
movq %r14, %rdi
addq %r12, %rsi
callq 0xd63e
addq $0x8, %rbx
jmp 0x1428e
movq 0x1518(%r13), %rsi
leaq 0xc8(%rsp), %r14
movq %r14, %rdi
callq 0xd463
leaq 0xf090(%rip), %rsi      # 0x23355
leaq 0xa8(%rsp), %rdi
movq %r14, %rdx
callq 0xcf8b
leaq 0x104f6(%rip), %rdx     # 0x247d2
leaq 0x78(%rsp), %rdi
leaq 0xa8(%rsp), %rsi
callq 0x8051
vmovsd 0x8(%rsp), %xmm0
vmulsd 0xeed4(%rip), %xmm0, %xmm0 # 0x231d0
leaq 0x108(%rsp), %rdi
xorl %esi, %esi
callq 0x20e6c
leaq 0x50(%rsp), %rdi
leaq 0x78(%rsp), %rsi
leaq 0x108(%rsp), %rdx
callq 0xcf24
leaq 0xf044(%rip), %rdx      # 0x2336d
leaq 0x10(%rsp), %rdi
leaq 0x50(%rsp), %rsi
callq 0x8051
vcvtusi2sdq 0x1518(%r13), %xmm1, %xmm0
vdivsd 0x8(%rsp), %xmm0, %xmm0
leaq 0xe8(%rsp), %rdi
xorl %esi, %esi
callq 0x20e6c
leaq 0x30(%rsp), %rdi
leaq 0x10(%rsp), %rsi
leaq 0xe8(%rsp), %rdx
callq 0xcf24
leaq 0x10470(%rip), %rdx     # 0x247e5
leaq 0x1e8(%rsp), %rdi
leaq 0x30(%rsp), %rsi
callq 0x8051
leaq 0x1e8(%rsp), %r14
movq %r14, %rdi
callq 0xd451
movq %r14, %rdi
callq 0x5150
leaq 0x30(%rsp), %rdi
callq 0x5150
leaq 0xe8(%rsp), %rdi
callq 0x5150
leaq 0x10(%rsp), %rdi
callq 0x5150
leaq 0x50(%rsp), %rdi
callq 0x5150
leaq 0x108(%rsp), %rdi
callq 0x5150
leaq 0x78(%rsp), %rdi
callq 0x5150
leaq 0xa8(%rsp), %rdi
callq 0x5150
leaq 0xc8(%rsp), %rdi
callq 0x5150
cmpq $0x0, 0x1518(%r13)
je 0x14473
leaq 0x10(%rsp), %r14
leaq 0x128(%rsp), %rsi
movq %r14, %rdi
callq 0xd66a
leaq 0xef6c(%rip), %rsi      # 0x2338d
leaq 0x30(%rsp), %rdi
movq %r14, %rdx
callq 0xcf8b
leaq 0xe4a7(%rip), %rdx      # 0x228dc
leaq 0x1c8(%rsp), %rdi
leaq 0x30(%rsp), %rsi
callq 0x8051
leaq 0x1c8(%rsp), %r14
movq %r14, %rdi
callq 0xd451
movq %r14, %rdi
callq 0x5150
leaq 0x30(%rsp), %rdi
callq 0x5150
leaq 0x10(%rsp), %rdi
callq 0x5150
movl %ebp, 0x8(%rsp)
movb 0x18(%r13), %bpl
leaq 0x1540(%r13), %r14
leaq 0x10(%rsp), %r15
movq %r15, %rdi
movq %r14, %rsi
callq 0x13bdc
leaq 0x10356(%rip), %rsi     # 0x247ef
leaq 0x30(%rsp), %rdi
movq %r15, %rdx
callq 0xcf8b
leaq 0xe42f(%rip), %rdx      # 0x228dc
leaq 0x1a8(%rsp), %rdi
leaq 0x30(%rsp), %rsi
callq 0x8051
leaq 0x1a8(%rsp), %r15
movq %r15, %rdi
callq 0xd451
movq %r15, %rdi
callq 0x5150
leaq 0x30(%rsp), %rdi
callq 0x5150
leaq 0x10(%rsp), %rdi
callq 0x5150
movb $0x3, %al
movq %r14, %rdi
subb %bpl, %al
movzbl %al, %esi
callq 0x15970
leaq 0x129ac(%rip), %rcx     # 0x26eae
movb %al, 0xc8(%rsp)
cmpb (%rcx), %al
je 0x1457f
leaq 0x10(%rsp), %r14
movzbl %bpl, %edx
leaq 0xc8(%rsp), %rsi
movq %r14, %rdi
callq 0x20dc4
leaq 0xee98(%rip), %rsi      # 0x233c5
leaq 0x30(%rsp), %rdi
movq %r14, %rdx
callq 0xcf8b
leaq 0xe39b(%rip), %rdx      # 0x228dc
leaq 0x188(%rsp), %rdi
leaq 0x30(%rsp), %rsi
callq 0x8051
leaq 0x188(%rsp), %r14
movq %r14, %rdi
callq 0xd451
movq %r14, %rdi
callq 0x5150
leaq 0x30(%rsp), %rdi
callq 0x5150
leaq 0x10(%rsp), %rdi
callq 0x5150
leaq 0x40(%rsp), %rax
movq %rax, -0x10(%rax)
andq $0x0, -0x8(%rax)
movb $0x0, (%rax)
leaq 0x78(%rsp), %rdi
movq %r13, %rsi
movq %r13, 0x98(%rsp)
callq 0xd936
movq 0x78(%rsp), %rbx
movq 0x80(%rsp), %r15
leaq 0x50(%rsp), %r14
leaq 0x12385(%rip), %r12     # 0x26943
leaq 0x10(%rsp), %r13
leaq 0x30(%rsp), %rbp
cmpq %r15, %rbx
je 0x14617
movzwl (%rbx), %eax
movw %ax, 0xa8(%rsp)
leaq 0xa8(%rsp), %rsi
movq %r14, %rdi
callq 0xcfb0
movq %r13, %rdi
movq %r12, %rsi
movq %r14, %rdx
callq 0xcf8b
movq %rbp, %rdi
movq %r13, %rsi
callq 0x5700
movq %r13, %rdi
callq 0x5150
movq %r14, %rdi
callq 0x5150
addq $0x2, %rbx
jmp 0x145c8
leaq 0x78(%rsp), %rdi
callq 0x9a04
leaq 0xedaa(%rip), %rsi      # 0x233d2
leaq 0x10(%rsp), %rdi
leaq 0x30(%rsp), %rdx
callq 0x8070
leaq 0xe29e(%rip), %rdx      # 0x228dc
leaq 0x168(%rsp), %rdi
leaq 0x10(%rsp), %rsi
callq 0x8051
movq 0x98(%rsp), %rbx
movl 0x8(%rsp), %ebp
leaq 0x168(%rsp), %r14
movq %r14, %rdi
callq 0xd451
movq %r14, %rdi
callq 0x5150
leaq 0x10(%rsp), %rdi
callq 0x5150
cmpl $0x3, %ebp
jl 0x146fc
movq 0x1558(%rbx), %rax
cmpq $0x2, %rax
jb 0x146fc
cmpw $0x0, 0x6(%rax)
je 0x146fc
leaq 0x50(%rsp), %rdx
vxorpd %xmm0, %xmm0, %xmm0
vmovapd %xmm0, (%rdx)
andq $0x0, 0x10(%rdx)
movq (%rbx), %rax
leaq 0x10(%rsp), %rdi
movq %rbx, %rsi
callq *0x48(%rax)
leaq 0xed21(%rip), %rsi      # 0x233df
leaq 0x148(%rsp), %rdi
leaq 0x10(%rsp), %rdx
callq 0xcf8b
leaq 0x148(%rsp), %rbx
movq %rbx, %rdi
callq 0xd451
movq %rbx, %rdi
callq 0x5150
leaq 0x10(%rsp), %rdi
callq 0x5150
leaq 0x50(%rsp), %rdi
callq 0x9a04
leaq 0x30(%rsp), %rdi
callq 0x5150
addq $0x208, %rsp            # imm = 0x208
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
leaq 0x10(%rsp), %rdi
movq %rax, %rbx
callq 0x5150
jmp 0x1472a
movq %rax, %rbx
leaq 0x50(%rsp), %rdi
jmp 0x14819
jmp 0x14758
jmp 0x14767
jmp 0x14758
jmp 0x14767
leaq 0x10(%rsp), %rdi
movq %rax, %rbx
callq 0x5150
jmp 0x1481e
jmp 0x14750
movq %rax, %rbx
jmp 0x1481e
leaq 0x30(%rsp), %rdi
movq %rax, %rbx
callq 0x5150
jmp 0x1476a
movq %rax, %rbx
leaq 0x10(%rsp), %rdi
jmp 0x14823
leaq 0x30(%rsp), %rdi
movq %rax, %rbx
callq 0x5150
jmp 0x14786
movq %rax, %rbx
leaq 0xe8(%rsp), %rdi
callq 0x5150
jmp 0x14798
movq %rax, %rbx
leaq 0x10(%rsp), %rdi
callq 0x5150
jmp 0x147a7
movq %rax, %rbx
leaq 0x50(%rsp), %rdi
callq 0x5150
jmp 0x147b6
movq %rax, %rbx
leaq 0x108(%rsp), %rdi
callq 0x5150
leaq 0x78(%rsp), %rdi
callq 0x5150
leaq 0xa8(%rsp), %rdi
callq 0x5150
leaq 0xc8(%rsp), %rdi
jmp 0x14823
movq %rax, %rbx
jmp 0x147c3
movq %rax, %rbx
jmp 0x147cd
movq %rax, %rbx
jmp 0x147da
movq %rax, %rbx
jmp 0x14814
movq %rax, %rbx
jmp 0x1480a
leaq 0x10(%rsp), %rdi
movq %rax, %rbx
callq 0x5150
leaq 0x50(%rsp), %rdi
callq 0x5150
leaq 0x78(%rsp), %rdi
callq 0x9a04
leaq 0x30(%rsp), %rdi
callq 0x5150
movq %rbx, %rdi
callq 0x5650