// File: /workspace/github_cpp_makefile_star2_O2/tewalds[P]morat/pentago/agentab.cpp
// Function: Morat::Pentago::AgentAB::search(double, unsigned long, int)
void AgentAB::search(double time, uint64_t maxiters, int verbose) {
	reset();
	if(rootboard.outcome() >= 0)
		return;

	if(TT == NULL)
		TT = new Node[maxnodes];

	Alarm timer;
	if (time > 0)
		timer(time/15, std::bind(&AgentAB::timedout, this));

	Time start;

	uint64_t nodes_start, seen, prev_nodes_seen = 0;
	for(unsigned int depth = 2; !timeout && depth < 36 && (maxiters == 0 || depth <= maxiters); depth++){
		maxdepth = depth;
		nodes_start = nodes_seen;
		Time start_depth;
		if (verbose)
			logerr("Depth " + to_str(depth) + "      ");
		negamax(rootboard, SCORE_LOSS, SCORE_WIN, depth);
		seen = nodes_seen - nodes_start;
		if (verbose) {
			logerr("time: " + to_str((Time() - start_depth)*1000, 0) + " msec, ");
			logerr("BF: " + to_str(prev_nodes_seen ? (double)(1.0*seen / prev_nodes_seen) : 0.0, 2) + ", Nodes: " + to_str(seen) + "\n");
		}
		prev_nodes_seen = seen;
	}

	time_used += Time() - start;

	if(verbose){
		logerr("Finished:    " + to_str(nodes_seen) + " nodes in " + to_str(time_used*1000, 0) + " msec: " + to_str((uint64_t)((double)nodes_seen/time_used)) + " Nodes/s\n");

		vecmove pv = get_pv();
		std::string pvstr;
		for(vecmove::iterator m = pv.begin(); m != pv.end(); ++m)
			pvstr += " " + m->to_s();
		logerr("PV:         " + pvstr + "\n");

		if(verbose >= 3)
			logerr("Move stats:\n" + move_stats(vecmove()));
	}
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x238, %rsp            # imm = 0x238
vmovsd %xmm0, 0x20(%rsp)
movb $0x0, 0x8(%rdi)
vxorpd %xmm0, %xmm0, %xmm0
leaq 0x10(%rdi), %r15
movl %edx, %ebp
movq %rsi, %r13
movq %rdi, %rbx
andl $0x0, 0x50(%rdi)
vmovupd %xmm0, 0x58(%rdi)
movq %r15, %rdi
callq 0xa9d0
testb %al, %al
jns 0x9ef6
cmpq $0x0, 0x38(%rbx)
movq %rbx, 0x10(%rsp)
movl %ebp, 0xc(%rsp)
jne 0x990a
movq 0x40(%rbx), %r14
movq %r14, %rax
shrq $0x3c, %rax
movq %r14, %rbx
shlq $0x4, %rbx
negq %rax
sbbq %rdi, %rdi
orq %rbx, %rdi
callq 0x5030
testq %r14, %r14
je 0x9901
movq %rax, %rcx
addq %rbx, %rcx
movabsq $-0x2152fffff1040000, %rdx # imm = 0xDEAD00000EFC0000
movq %rax, %rsi
orq $-0x1, (%rsi)
movq %rdx, 0x8(%rsi)
addq $0x10, %rsi
cmpq %rcx, %rsi
jne 0x98f0
movq 0x10(%rsp), %rbx
movq %rax, 0x38(%rbx)
vmovsd 0x20(%rsp), %xmm1
orl $-0x1, 0x1c(%rsp)
vxorpd %xmm0, %xmm0, %xmm0
vucomisd %xmm0, %xmm1
jbe 0x996e
leaq 0x48(%rsp), %rsi
movq $0x59, (%rsi)
andq $0x0, 0x8(%rsi)
movq %rbx, 0x10(%rsi)
leaq 0x158(%rsp), %rdi
callq 0xaa66
vmovsd 0x20(%rsp), %xmm0
vdivsd 0x167c1(%rip), %xmm0, %xmm0 # 0x20110
leaq 0x1c(%rsp), %rdi
leaq 0x158(%rsp), %rsi
callq 0xa9ec
leaq 0x158(%rsp), %rdi
callq 0x7f04
leaq 0x58(%rbx), %rax
leaq 0xb8(%rsp), %rdi
movq %r15, 0xb0(%rsp)
movq %rax, 0x20(%rsp)
callq 0x5df0
pushq $0x2
popq %r12
xorl %ebp, %ebp
movq %r13, 0xa8(%rsp)
movq 0x10(%rsp), %rdx
testq %r13, %r13
setne %al
cmpq %r13, %r12
seta %cl
cmpb $0x0, 0x8(%rdx)
jne 0x9bff
cmpq $0x23, %r12
ja 0x9bff
andb %cl, %al
jne 0x9bff
movq 0x10(%rsp), %rbx
leaq 0xe0(%rsp), %rdi
movl %r12d, 0x50(%rbx)
movq 0x58(%rbx), %rbx
callq 0x5df0
cmpl $0x0, 0xc(%rsp)
je 0x9a4b
leaq 0x28(%rsp), %r15
movl %r12d, %esi
movq %r15, %rdi
callq 0xaae4
leaq 0x48(%rsp), %r14
leaq 0x16744(%rip), %rsi     # 0x20148
movq %r15, %rdx
movq %r14, %rdi
callq 0xaac0
leaq 0x218(%rsp), %r15
leaq 0x16779(%rip), %rdx     # 0x20197
movq %r14, %rsi
movq %r15, %rdi
callq 0x7b4d
movq %r15, %rdi
callq 0xaaae
movq %r15, %rdi
callq 0x5170
movq %r14, %rdi
callq 0x5170
leaq 0x28(%rsp), %rdi
callq 0x5170
movq 0x10(%rsp), %rdi
movq 0xb0(%rsp), %rsi
movl $0xffff8001, %edx       # imm = 0xFFFF8001
movl $0x7fff, %ecx           # imm = 0x7FFF
movl %r12d, %r8d
callq 0xa0aa
movq 0x20(%rsp), %rax
movq (%rax), %r13
subq %rbx, %r13
cmpl $0x0, 0xc(%rsp)
je 0x9bec
leaq 0x88(%rsp), %rdi
callq 0x5df0
vmovsd 0x88(%rsp), %xmm0
vsubsd 0xe0(%rsp), %xmm0, %xmm0
vmulsd 0x16671(%rip), %xmm0, %xmm0 # 0x20118
leaq 0x28(%rsp), %rbx
xorl %esi, %esi
movq %rbx, %rdi
callq 0x1df78
leaq 0x48(%rsp), %r14
leaq 0x1a3fe(%rip), %rsi     # 0x23ec0
movq %rbx, %rdx
movq %r14, %rdi
callq 0xaac0
leaq 0x1f8(%rsp), %rbx
leaq 0x16673(%rip), %rdx     # 0x2014f
movq %r14, %rsi
movq %rbx, %rdi
callq 0x7b4d
movq %rbx, %rdi
callq 0xaaae
movq %rbx, %rdi
callq 0x5170
movq %r14, %rdi
callq 0x5170
leaq 0x28(%rsp), %rdi
callq 0x5170
vcvtusi2sd %r13, %xmm2, %xmm0
testq %rbp, %rbp
sete %al
kmovd %eax, %k1
vcvtusi2sd %rbp, %xmm2, %xmm1
vdivsd %xmm1, %xmm0, %xmm0
vxorpd %xmm1, %xmm1, %xmm1
vmovsd %xmm1, %xmm0, %xmm0 {%k1}
leaq 0x68(%rsp), %rbx
movq %rbx, %rdi
pushq $0x2
popq %rsi
callq 0x1df78
leaq 0x88(%rsp), %r14
leaq 0x1660b(%rip), %rsi     # 0x20157
movq %rbx, %rdx
movq %r14, %rdi
callq 0xaac0
leaq 0x28(%rsp), %rdi
leaq 0x165f9(%rip), %rdx     # 0x2015c
movq %r14, %rsi
callq 0x7b4d
leaq 0xc0(%rsp), %rbp
movq %r13, %rsi
movq %rbp, %rdi
callq 0xaba2
leaq 0x48(%rsp), %r15
leaq 0x28(%rsp), %rsi
movq %rbp, %rdx
movq %r15, %rdi
callq 0xab3b
leaq 0x1d8(%rsp), %rbp
leaq 0x15c76(%rip), %rdx     # 0x1f818
movq %r15, %rsi
movq %rbp, %rdi
callq 0x7b4d
movq %rbp, %rdi
callq 0xaaae
movq %rbp, %rdi
callq 0x5170
movq %r15, %rdi
callq 0x5170
leaq 0xc0(%rsp), %rdi
callq 0x5170
leaq 0x28(%rsp), %rdi
callq 0x5170
movq %r14, %rdi
callq 0x5170
movq %rbx, %rdi
callq 0x5170
movq %r13, %rbp
movq 0xa8(%rsp), %r13
incq %r12
jmp 0x999a
leaq 0x48(%rsp), %r14
movq %r14, %rdi
callq 0x5df0
movq 0x10(%rsp), %rbx
vmovsd (%r14), %xmm0
cmpl $0x0, 0xc(%rsp)
vsubsd 0xb8(%rsp), %xmm0, %xmm0
vaddsd 0x60(%rbx), %xmm0, %xmm0
vmovsd %xmm0, 0x60(%rbx)
je 0x9eec
movq 0x20(%rsp), %rax
movq (%rax), %rsi
leaq 0xe0(%rsp), %rdi
callq 0xaba2
leaq 0x16516(%rip), %rsi     # 0x20166
leaq 0xc0(%rsp), %rdi
leaq 0xe0(%rsp), %rdx
callq 0xaac0
leaq 0x16508(%rip), %rdx     # 0x20174
leaq 0x68(%rsp), %rdi
leaq 0xc0(%rsp), %rsi
callq 0x7b4d
vmovsd 0x60(%rbx), %xmm0
vmulsd 0x1648d(%rip), %xmm0, %xmm0 # 0x20118
leaq 0x138(%rsp), %rdi
xorl %esi, %esi
callq 0x1df78
leaq 0x88(%rsp), %rdi
leaq 0x68(%rsp), %rsi
leaq 0x138(%rsp), %rdx
callq 0xab3b
leaq 0x164c4(%rip), %rdx     # 0x2017f
leaq 0x28(%rsp), %rdi
leaq 0x88(%rsp), %rsi
callq 0x7b4d
vcvtusi2sdq 0x58(%rbx), %xmm2, %xmm0
vdivsd 0x60(%rbx), %xmm0, %xmm0
vcvttsd2usi %xmm0, %rsi
leaq 0x118(%rsp), %rdi
callq 0xaba2
leaq 0x48(%rsp), %rdi
leaq 0x28(%rsp), %rsi
leaq 0x118(%rsp), %rdx
callq 0xab3b
leaq 0x1647d(%rip), %rdx     # 0x20187
leaq 0x1b8(%rsp), %rdi
leaq 0x48(%rsp), %rsi
callq 0x7b4d
leaq 0x1b8(%rsp), %r14
movq %r14, %rdi
callq 0xaaae
movq %r14, %rdi
callq 0x5170
leaq 0x48(%rsp), %rdi
callq 0x5170
leaq 0x118(%rsp), %rdi
callq 0x5170
leaq 0x28(%rsp), %rdi
callq 0x5170
leaq 0x88(%rsp), %rdi
callq 0x5170
leaq 0x138(%rsp), %rdi
callq 0x5170
leaq 0x68(%rsp), %rdi
callq 0x5170
leaq 0xc0(%rsp), %rdi
callq 0x5170
leaq 0xe0(%rsp), %rdi
callq 0x5170
movq 0x10(%rsp), %rsi
movq (%rsi), %rax
leaq 0x68(%rsp), %rdi
callq *0x40(%rax)
leaq 0x58(%rsp), %rax
movq 0x68(%rsp), %r14
leaq 0x88(%rsp), %r15
leaq 0x1a0ed(%rip), %r12     # 0x23ea9
leaq 0x28(%rsp), %r13
leaq 0x48(%rsp), %rbp
movq %rax, -0x10(%rax)
andq $0x0, -0x8(%rax)
movb $0x0, (%rax)
cmpq 0x70(%rsp), %r14
je 0x9e13
movq %r15, %rdi
movq %r14, %rsi
callq 0xabfe
movq %r13, %rdi
movq %r12, %rsi
movq %r15, %rdx
callq 0xaac0
movq %rbp, %rdi
movq %r13, %rsi
callq 0x5730
movq %r13, %rdi
callq 0x5170
movq %r15, %rdi
callq 0x5170
addq $0x2, %r14
jmp 0x9dd2
leaq 0x16377(%rip), %rsi     # 0x20191
leaq 0x28(%rsp), %rdi
leaq 0x48(%rsp), %rdx
callq 0x7b6c
leaq 0x159e8(%rip), %rdx     # 0x1f818
leaq 0x198(%rsp), %rdi
leaq 0x28(%rsp), %rsi
callq 0x7b4d
leaq 0x198(%rsp), %r14
movq %r14, %rdi
callq 0xaaae
movq %r14, %rdi
callq 0x5170
leaq 0x28(%rsp), %rdi
callq 0x5170
cmpl $0x3, 0xc(%rsp)
jl 0x9ed8
movq 0x10(%rsp), %rsi
leaq 0x100(%rsp), %rdx
vxorpd %xmm0, %xmm0, %xmm0
vmovapd %xmm0, (%rdx)
andq $0x0, 0x10(%rdx)
movq (%rsi), %rax
leaq 0x28(%rsp), %rdi
callq *0x48(%rax)
leaq 0x16307(%rip), %rsi     # 0x2019e
leaq 0x178(%rsp), %rdi
leaq 0x28(%rsp), %rdx
callq 0xaac0
leaq 0x178(%rsp), %rbx
movq %rbx, %rdi
callq 0xaaae
movq %rbx, %rdi
callq 0x5170
leaq 0x28(%rsp), %rdi
callq 0x5170
leaq 0x100(%rsp), %rdi
callq 0x947e
leaq 0x48(%rsp), %rdi
callq 0x5170
leaq 0x68(%rsp), %rdi
callq 0x947e
leaq 0x1c(%rsp), %rdi
callq 0xad40
addq $0x238, %rsp            # imm = 0x238
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
leaq 0x28(%rsp), %rdi
movq %rax, %rbx
callq 0x5170
jmp 0x9f1a
movq %rax, %rbx
leaq 0x100(%rsp), %rdi
callq 0x947e
jmp 0xa00b
leaq 0x158(%rsp), %rdi
movq %rax, %rbx
callq 0x7f04
jmp 0xa098
jmp 0xa095
leaq 0x28(%rsp), %rdi
movq %rax, %rbx
jmp 0xa006
jmp 0x9fe7
jmp 0xa095
leaq 0x48(%rsp), %rdi
movq %rax, %rbx
callq 0x5170
jmp 0x9f6f
movq %rax, %rbx
leaq 0x118(%rsp), %rdi
callq 0x5170
jmp 0x9f81
movq %rax, %rbx
leaq 0x28(%rsp), %rdi
callq 0x5170
jmp 0x9f90
movq %rax, %rbx
leaq 0x88(%rsp), %rdi
callq 0x5170
jmp 0x9fa2
movq %rax, %rbx
leaq 0x138(%rsp), %rdi
callq 0x5170
leaq 0x68(%rsp), %rdi
callq 0x5170
leaq 0xc0(%rsp), %rdi
callq 0x5170
leaq 0xe0(%rsp), %rdi
jmp 0xa08e
movq %rax, %rbx
jmp 0x9faf
movq %rax, %rbx
jmp 0x9fb9
movq %rax, %rbx
jmp 0x9fc6
jmp 0xa095
movq %rax, %rbx
jmp 0xa00b
movq %rax, %rbx
jmp 0x9ffe
leaq 0x28(%rsp), %rdi
movq %rax, %rbx
callq 0x5170
leaq 0x88(%rsp), %rdi
callq 0x5170
leaq 0x48(%rsp), %rdi
callq 0x5170
leaq 0x68(%rsp), %rdi
callq 0x947e
jmp 0xa098
jmp 0xa042
jmp 0xa095
movq %rax, %rbx
jmp 0xa089
leaq 0x48(%rsp), %rdi
movq %rax, %rbx
callq 0x5170
jmp 0xa065
jmp 0xa056
movq %rax, %rbx
jmp 0xa07c
jmp 0xa095
leaq 0x48(%rsp), %rdi
movq %rax, %rbx
callq 0x5170
jmp 0xa059
movq %rax, %rbx
jmp 0xa072
movq %rax, %rbx
leaq 0x28(%rsp), %rdi
jmp 0xa08e
jmp 0xa095
movq %rax, %rbx
leaq 0xc0(%rsp), %rdi
callq 0x5170
leaq 0x28(%rsp), %rdi
callq 0x5170
leaq 0x88(%rsp), %rdi
callq 0x5170
leaq 0x68(%rsp), %rdi
callq 0x5170
jmp 0xa098
movq %rax, %rbx
leaq 0x1c(%rsp), %rdi
callq 0xad40
movq %rbx, %rdi
callq 0x5690