// File: /workspace/github_cpp_makefile_star2_O2/tewalds[P]pentagod/agentab.cpp
// Function: AgentAB::search(double, unsigned long, int)
void AgentAB::search(double time, uint64_t maxiters, int verbose) {
	reset();
	if(rootboard.won() >= 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");

		vector<Move> pv = get_pv();
		string pvstr;
		for(vector<Move>::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(vector<Move>()));
	}
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x238, %rsp            # imm = 0x238
vmovsd %xmm0, 0x8(%rsp)
movb $0x0, 0x8(%rdi)
vxorpd %xmm0, %xmm0, %xmm0
leaq 0x10(%rdi), %r15
movl %edx, %ebx
movq %rsi, %r12
movq %rdi, %r14
andl $0x0, 0x50(%rdi)
vmovupd %xmm0, 0x58(%rdi)
movq %r15, %rdi
callq 0xae70
testb %al, %al
jns 0x1aad1
cmpq $0x0, 0x38(%r14)
movq %r12, %r13
movq %r14, %r12
movq %r15, 0xa0(%rsp)
jne 0x1a4c2
movq 0x40(%r12), %r15
pushq $0x18
popq %rcx
movq %r15, %rax
mulq %rcx
pushq $-0x1
popq %rdi
cmovnoq %rax, %rdi
callq 0x4030
testq %r15, %r15
je 0x1a4bd
imulq $0x18, %r15, %rdx
movq %rax, %rcx
movq %rax, %rsi
addq %rdx, %rcx
movabsq $-0x2152ffffffff7104, %rdx # imm = 0xDEAD000000008EFC
orq $-0x1, (%rsi)
andw $0x0, 0x8(%rsi)
movq %rdx, 0xc(%rsi)
addq $0x18, %rsi
cmpq %rcx, %rsi
jne 0x1a4a7
movq %rax, 0x38(%r12)
vmovsd 0x8(%rsp), %xmm1
orl $-0x1, 0x14(%rsp)
vxorpd %xmm0, %xmm0, %xmm0
vucomisd %xmm0, %xmm1
jbe 0x1a526
leaq 0x38(%rsp), %rsi
movq $0x59, (%rsi)
andq $0x0, 0x8(%rsi)
movq %r12, 0x10(%rsi)
leaq 0x158(%rsp), %rdi
callq 0x1b3a8
vmovsd 0x8(%rsp), %xmm0
vdivsd 0x6441(%rip), %xmm0, %xmm0 # 0x20948
leaq 0x14(%rsp), %rdi
leaq 0x158(%rsp), %rsi
callq 0x15364
leaq 0x158(%rsp), %rdi
callq 0x70f8
leaq 0x58(%r12), %rax
leaq 0xb8(%rsp), %rdi
movl %ebx, 0x10(%rsp)
movq %r12, 0x8(%rsp)
movq %rax, 0x58(%rsp)
callq 0x4c50
pushq $0x2
popq %r12
leaq 0x18(%rsp), %r14
xorl %esi, %esi
movq %r13, %r15
movq 0x8(%rsp), %rdx
testq %r15, %r15
setne %al
cmpq %r15, %r12
seta %cl
cmpb $0x0, 0x8(%rdx)
jne 0x1a7ce
cmpq $0x23, %r12
ja 0x1a7ce
andb %cl, %al
jne 0x1a7ce
movq 0x8(%rsp), %rax
leaq 0xe0(%rsp), %rdi
movq %rsi, 0xa8(%rsp)
movl %r12d, 0x50(%rax)
movq %rax, %rbx
movq 0x58(%rax), %rax
movq %rax, 0xb0(%rsp)
callq 0x4c50
cmpl $0x0, 0x10(%rsp)
je 0x1a614
movq %r14, %rbp
movq %r14, %rdi
movl %r12d, %esi
callq 0x83cc
leaq 0x38(%rsp), %r13
leaq 0x6391(%rip), %rsi      # 0x20960
movq %rbp, %rdx
movq %r13, %rdi
callq 0x8423
leaq 0x218(%rsp), %rbp
leaq 0x51cf(%rip), %rdx      # 0x1f7b8
movq %r13, %rsi
movq %rbp, %rdi
callq 0x6821
movq %rbp, %rdi
callq 0xac65
movq %rbp, %rdi
callq 0x4130
movq %r13, %rdi
callq 0x4130
movq %r14, %rdi
callq 0x4130
movq 0xa0(%rsp), %rsi
movl $0xffff8001, %edx       # imm = 0xFFFF8001
movl $0x7fff, %ecx           # imm = 0x7FFF
movq %r15, %rbp
movq %rbx, %rdi
movl %r12d, %r8d
callq 0x1ac86
movq 0x58(%rsp), %rax
leaq 0x80(%rsp), %r15
movq (%rax), %r13
subq 0xb0(%rsp), %r13
cmpl $0x0, 0x10(%rsp)
je 0x1a7c0
movq %r15, %rdi
callq 0x4c50
vmovsd 0x80(%rsp), %xmm0
vsubsd 0xe0(%rsp), %xmm0, %xmm0
vmulsd 0x198f(%rip), %xmm0, %xmm0 # 0x1c008
movq %r14, %rdi
xorl %esi, %esi
callq 0xf350
leaq 0x38(%rsp), %rbx
leaq 0x2f8e(%rip), %rsi      # 0x1d61d
movq %r14, %rdx
movq %rbx, %rdi
callq 0x8423
leaq 0x1f8(%rsp), %r15
leaq 0x62be(%rip), %rdx      # 0x20967
movq %rbx, %rsi
movq %r15, %rdi
callq 0x6821
movq %r15, %rdi
callq 0xac65
movq %r15, %rdi
callq 0x4130
movq %rbx, %rdi
callq 0x4130
movq %r14, %rdi
callq 0x4130
movq 0xa8(%rsp), %rcx
vcvtusi2sd %r13, %xmm2, %xmm0
vcvtusi2sd %rcx, %xmm2, %xmm1
testq %rcx, %rcx
sete %al
kmovd %eax, %k1
vdivsd %xmm1, %xmm0, %xmm0
vxorpd %xmm1, %xmm1, %xmm1
vmovsd %xmm1, %xmm0, %xmm0 {%k1}
leaq 0x60(%rsp), %rbx
movq %rbx, %rdi
pushq $0x2
popq %rsi
callq 0xf350
leaq 0x80(%rsp), %r15
leaq 0x6250(%rip), %rsi      # 0x2096f
movq %rbx, %rdx
movq %r15, %rdi
callq 0x8423
leaq 0x6243(%rip), %rdx      # 0x20974
movq %r14, %rdi
movq %r15, %rsi
callq 0x6821
leaq 0xc0(%rsp), %r15
movq %r13, %rsi
movq %r15, %rdi
callq 0xaf8f
leaq 0x38(%rsp), %rbx
movq %r14, %rsi
movq %r15, %rdx
movq %rbx, %rdi
callq 0x8365
leaq 0x1d8(%rsp), %r15
leaq 0x2347(%rip), %rdx      # 0x1cab8
movq %rbx, %rsi
movq %r15, %rdi
callq 0x6821
movq %r15, %rdi
callq 0xac65
movq %r15, %rdi
callq 0x4130
movq %rbx, %rdi
callq 0x4130
leaq 0xc0(%rsp), %rdi
callq 0x4130
movq %r14, %rdi
callq 0x4130
leaq 0x80(%rsp), %rdi
callq 0x4130
leaq 0x60(%rsp), %rdi
callq 0x4130
incq %r12
movq %r13, %rsi
movq %rbp, %r15
jmp 0x1a554
leaq 0x38(%rsp), %r14
movq %r14, %rdi
callq 0x4c50
movq 0x8(%rsp), %rax
vmovsd (%r14), %xmm0
cmpl $0x0, 0x10(%rsp)
vsubsd 0xb8(%rsp), %xmm0, %xmm0
vaddsd 0x60(%rax), %xmm0, %xmm0
vmovsd %xmm0, 0x60(%rax)
je 0x1aac7
movq 0x58(%rsp), %rax
movq (%rax), %rsi
leaq 0xe0(%rsp), %rdi
callq 0xaf8f
leaq 0x4ef7(%rip), %rsi      # 0x1f716
leaq 0xc0(%rsp), %rdi
leaq 0xe0(%rsp), %rdx
callq 0x8423
leaq 0x6143(%rip), %rdx      # 0x2097e
leaq 0x60(%rsp), %rdi
leaq 0xc0(%rsp), %rsi
callq 0x6821
movq 0x8(%rsp), %rax
vmovsd 0x60(%rax), %xmm0
vmulsd 0x17a9(%rip), %xmm0, %xmm0 # 0x1c008
leaq 0x138(%rsp), %rdi
xorl %esi, %esi
callq 0xf350
leaq 0x80(%rsp), %rdi
leaq 0x60(%rsp), %rsi
leaq 0x138(%rsp), %rdx
callq 0x8365
leaq 0x4e9f(%rip), %rdx      # 0x1f72e
leaq 0x18(%rsp), %rdi
leaq 0x80(%rsp), %rsi
callq 0x6821
movq 0x8(%rsp), %rax
vcvtusi2sdq 0x58(%rax), %xmm2, %xmm0
vdivsd 0x60(%rax), %xmm0, %xmm0
vcvttsd2usi %xmm0, %rsi
leaq 0x118(%rsp), %rdi
callq 0xaf8f
leaq 0x38(%rsp), %rdi
leaq 0x18(%rsp), %rsi
leaq 0x118(%rsp), %rdx
callq 0x8365
leaq 0x60a6(%rip), %rdx      # 0x20989
leaq 0x1b8(%rsp), %rdi
leaq 0x38(%rsp), %rsi
callq 0x6821
leaq 0x1b8(%rsp), %r14
movq %r14, %rdi
callq 0xac65
movq %r14, %rdi
callq 0x4130
leaq 0x38(%rsp), %rdi
callq 0x4130
leaq 0x118(%rsp), %rdi
callq 0x4130
leaq 0x18(%rsp), %rdi
callq 0x4130
leaq 0x80(%rsp), %rdi
callq 0x4130
leaq 0x138(%rsp), %rdi
callq 0x4130
leaq 0x60(%rsp), %rdi
callq 0x4130
leaq 0xc0(%rsp), %rdi
callq 0x4130
leaq 0xe0(%rsp), %rdi
callq 0x4130
movq 0x8(%rsp), %rsi
movq (%rsi), %rax
leaq 0x60(%rsp), %rdi
callq *0x40(%rax)
leaq 0x48(%rsp), %rax
movq 0x60(%rsp), %r14
leaq 0x80(%rsp), %r15
leaq 0x4e28(%rip), %r12      # 0x1f7bd
leaq 0x18(%rsp), %r13
leaq 0x38(%rsp), %rbp
movq %rax, -0x10(%rax)
andq $0x0, -0x8(%rax)
movb $0x0, (%rax)
cmpq 0x68(%rsp), %r14
je 0x1a9ee
movq %r15, %rdi
movq %r14, %rsi
xorl %edx, %edx
callq 0x8178
movq %r13, %rdi
movq %r12, %rsi
movq %r15, %rdx
callq 0x8423
movq %rbp, %rdi
movq %r13, %rsi
callq 0x4610
movq %r13, %rdi
callq 0x4130
movq %r15, %rdi
callq 0x4130
addq $0x4, %r14
jmp 0x1a9ab
leaq 0x4dbd(%rip), %rsi      # 0x1f7b2
leaq 0x18(%rsp), %rdi
leaq 0x38(%rsp), %rdx
callq 0x6864
leaq 0x20ad(%rip), %rdx      # 0x1cab8
leaq 0x198(%rsp), %rdi
leaq 0x18(%rsp), %rsi
callq 0x6821
leaq 0x198(%rsp), %r14
movq %r14, %rdi
callq 0xac65
movq %r14, %rdi
callq 0x4130
leaq 0x18(%rsp), %rdi
callq 0x4130
cmpl $0x3, 0x10(%rsp)
jl 0x1aab3
movq 0x8(%rsp), %rsi
leaq 0x100(%rsp), %rdx
vxorpd %xmm0, %xmm0, %xmm0
vmovapd %xmm0, (%rdx)
andq $0x0, 0x10(%rdx)
movq (%rsi), %rax
leaq 0x18(%rsp), %rdi
callq *0x48(%rax)
leaq 0x4d4d(%rip), %rsi      # 0x1f7bf
leaq 0x178(%rsp), %rdi
leaq 0x18(%rsp), %rdx
callq 0x8423
leaq 0x178(%rsp), %rbx
movq %rbx, %rdi
callq 0xac65
movq %rbx, %rdi
callq 0x4130
leaq 0x18(%rsp), %rdi
callq 0x4130
leaq 0x100(%rsp), %rdi
callq 0x8958
leaq 0x38(%rsp), %rdi
callq 0x4130
leaq 0x60(%rsp), %rdi
callq 0x8958
leaq 0x14(%rsp), %rdi
callq 0x1571e
addq $0x238, %rsp            # imm = 0x238
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
leaq 0x18(%rsp), %rdi
movq %rax, %rbx
callq 0x4130
jmp 0x1aaf5
movq %rax, %rbx
leaq 0x100(%rsp), %rdi
callq 0x8958
jmp 0x1abe6
leaq 0x158(%rsp), %rdi
movq %rax, %rbx
callq 0x70f8
jmp 0x1ac73
jmp 0x1ac70
leaq 0x18(%rsp), %rdi
movq %rax, %rbx
jmp 0x1abe1
jmp 0x1abc2
jmp 0x1ac70
leaq 0x38(%rsp), %rdi
movq %rax, %rbx
callq 0x4130
jmp 0x1ab4a
movq %rax, %rbx
leaq 0x118(%rsp), %rdi
callq 0x4130
jmp 0x1ab5c
movq %rax, %rbx
leaq 0x18(%rsp), %rdi
callq 0x4130
jmp 0x1ab6b
movq %rax, %rbx
leaq 0x80(%rsp), %rdi
callq 0x4130
jmp 0x1ab7d
movq %rax, %rbx
leaq 0x138(%rsp), %rdi
callq 0x4130
leaq 0x60(%rsp), %rdi
callq 0x4130
leaq 0xc0(%rsp), %rdi
callq 0x4130
leaq 0xe0(%rsp), %rdi
jmp 0x1ac69
movq %rax, %rbx
jmp 0x1ab8a
movq %rax, %rbx
jmp 0x1ab94
movq %rax, %rbx
jmp 0x1aba1
jmp 0x1ac70
movq %rax, %rbx
jmp 0x1abe6
movq %rax, %rbx
jmp 0x1abd9
leaq 0x18(%rsp), %rdi
movq %rax, %rbx
callq 0x4130
leaq 0x80(%rsp), %rdi
callq 0x4130
leaq 0x38(%rsp), %rdi
callq 0x4130
leaq 0x60(%rsp), %rdi
callq 0x8958
jmp 0x1ac73
jmp 0x1ac1d
jmp 0x1ac70
movq %rax, %rbx
jmp 0x1ac64
leaq 0x38(%rsp), %rdi
movq %rax, %rbx
callq 0x4130
jmp 0x1ac40
jmp 0x1ac31
movq %rax, %rbx
jmp 0x1ac57
jmp 0x1ac70
leaq 0x38(%rsp), %rdi
movq %rax, %rbx
callq 0x4130
jmp 0x1ac34
movq %rax, %rbx
jmp 0x1ac4d
movq %rax, %rbx
leaq 0x18(%rsp), %rdi
jmp 0x1ac69
jmp 0x1ac70
movq %rax, %rbx
leaq 0xc0(%rsp), %rdi
callq 0x4130
leaq 0x18(%rsp), %rdi
callq 0x4130
leaq 0x80(%rsp), %rdi
callq 0x4130
leaq 0x60(%rsp), %rdi
callq 0x4130
jmp 0x1ac73
movq %rax, %rbx
leaq 0x14(%rsp), %rdi
callq 0x1571e
movq %rbx, %rdi
callq 0x4590
nop