// File: /workspace/github_cpp_makefile_star2_O3/tewalds[P]morat/hex/gtpagent.cpp
// Function: Morat::Hex::GTP::gtp_solve(std::vector<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>>, std::allocator<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>>>>)
GTPResponse GTP::gtp_solve(vecstr args){
	if(hist->outcome() >= 0)
		return GTPResponse(true, "resign");

	double use_time = (args.size() >= 1 ? from_str<double>(args[0]) : 0);
	if (use_time == 0)
		use_time = time_control.get_time(hist.len(), hist->moves_remain(), agent->gamelen());


	if(verbose)
		logerr("time remain: " + to_str(time_control.remain, 1) + ", time: " + to_str(use_time, 3) + ", sims: " + to_str(time_control.max_sims) + "\n");

	Time start;
	agent->search(use_time, time_control.max_sims, verbose);
	time_control.use(Time() - start);


	//TODO: find the outcome, not the best move...

	Move best = agent->return_move(verbose);

	if(verbose >= 2)
		logerr(hist->to_s(colorboard) + "\n");

	return GTPResponse(true, best.to_s());
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x188, %rsp            # imm = 0x188
movb 0x89(%rsi), %al
movq %rdi, %rbx
testb %al, %al
js 0x20633
leaq 0x118(%rsp), %r15
leaq 0x108(%rsp), %r14
leaq 0x121a3(%rip), %rsi     # 0x3278c
leaq 0x121a2(%rip), %rdx     # 0x32792
movq %r14, %rdi
movq %r15, -0x10(%r15)
callq 0xb1dc
movl $0x1, %esi
movq %rbx, %rdi
movq %r14, %rdx
callq 0xa8ba
movq 0x108(%rsp), %rdi
cmpq %r15, %rdi
je 0x2061e
callq 0x52e0
movq %rbx, %rax
addq $0x188, %rsp            # imm = 0x188
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq (%rdx), %rdi
movq %rsi, %r14
cmpq %rdi, 0x8(%rdx)
je 0x20657
callq 0x28d4a
vxorpd %xmm1, %xmm1, %xmm1
vucomisd %xmm1, %xmm0
jne 0x206a4
jp 0x206a4
movb 0x89(%r14), %al
movq 0x70(%r14), %r12
movq 0xd8(%r14), %rdi
leaq 0x15d48(%rip), %rcx     # 0x363b1
movswl 0x82(%r14), %edx
movswl 0x84(%r14), %esi
xorl %ebp, %ebp
leaq 0x30(%r14), %r15
subq 0x68(%r14), %r12
subl %esi, %edx
shrq %r12
cmpb (%rcx), %al
movq (%rdi), %rax
cmovll %edx, %ebp
callq *0x50(%rax)
vcvttsd2si %xmm0, %ecx
movq %r15, %rdi
movl %r12d, %esi
movl %ebp, %edx
callq 0x28dd4
cmpl $0x0, 0xc8(%r14)
vmovsd %xmm0, 0x20(%rsp)
jne 0x207c0
movq %rsp, %r15
movq %r15, %rdi
xorl %esi, %esi
callq 0x55b0
movq 0xd8(%r14), %rdi
vmovsd 0x20(%rsp), %xmm0
movq 0x58(%r14), %rsi
movl 0xc8(%r14), %edx
movq (%r15), %r12
movq 0x8(%r15), %r13
movq (%rdi), %rax
callq *0x10(%rax)
movq %rsp, %r15
movq %r15, %rdi
xorl %esi, %esi
callq 0x55b0
vpbroadcastq 0x8(%r15), %xmm1
vmovdqa (%r15), %xmm0
vpinsrq $0x1, %r13, %xmm1, %xmm1
vpinsrq $0x1, %r12, %xmm0, %xmm0
vcvtqq2pd %xmm1, %xmm1
vdivpd 0x108ea(%rip){1to2}, %xmm1, %xmm1 # 0x31008
vcvtqq2pd %xmm0, %xmm0
kmovb 0x50(%r14), %k1
vaddpd %xmm0, %xmm1, %xmm0
vmovsd 0x48(%r14), %xmm1
vhsubpd %xmm0, %xmm0, %xmm0
vsubsd %xmm0, %xmm1, %xmm0
vxorpd %xmm1, %xmm1, %xmm1
vminsd %xmm1, %xmm0, %xmm2
vmovsd %xmm0, %xmm2, %xmm2 {%k1}
vaddsd 0x60(%r14), %xmm2, %xmm0
vmaxsd %xmm0, %xmm1, %xmm0
vmovsd %xmm0, 0x60(%r14)
movq 0xd8(%r14), %rdi
movl 0xc8(%r14), %esi
movq (%rdi), %rax
callq *0x18(%rax)
movw %ax, 0x28(%rsp)
cmpl $0x2, 0xc8(%r14)
jge 0x2081a
leaq 0x128(%rsp), %r14
leaq 0x28(%rsp), %rsi
movq %r14, %rdi
callq 0x10e7e
movl $0x1, %esi
movq %rbx, %rdi
movq %r14, %rdx
callq 0xa8ba
leaq 0x138(%rsp), %rax
movq -0x10(%rax), %rdi
cmpq %rax, %rdi
jne 0x20619
jmp 0x2061e
vmovsd 0x60(%r14), %xmm0
leaq 0x148(%rsp), %r15
movl $0x1, %esi
movq %r15, %rdi
callq 0x2f6e8
leaq 0x14320(%rip), %rcx     # 0x34b02
movl $0xd, %r8d
movq %r15, %rdi
xorl %esi, %esi
xorl %edx, %edx
callq 0x5380
leaq 0xd8(%rsp), %r15
movq %rax, %rcx
addq $0x10, %rcx
movq %r15, -0x10(%r15)
movq (%rax), %rdx
cmpq %rcx, %rdx
jne 0x2085b
vmovupd (%rcx), %xmm0
vmovupd %xmm0, (%r15)
jmp 0x2086e
movzbl 0xcd(%r14), %edx
subq $-0x80, %r14
movq %rsp, %r15
movq %r15, %rdi
movq %r14, %rsi
callq 0x1f644
leaq 0x110cb(%rip), %rsi     # 0x31906
movq %r15, %rdi
callq 0x56e0
leaq 0x168(%rsp), %rdi
movq %rsp, %rdx
movq %rax, %rsi
callq 0x5aa1
jmp 0x20781
movq %rdx, 0xc8(%rsp)
movq (%rcx), %rdx
movq %rdx, 0xd8(%rsp)
movq 0x8(%rax), %rdx
leaq 0xc8(%rsp), %rdi
movq %rdx, 0x8(%rdi)
movq %rcx, (%rax)
movq $0x0, 0x8(%rax)
movb $0x0, 0x10(%rax)
leaq 0x1427c(%rip), %rsi     # 0x34b10
callq 0x56e0
vmovsd 0x20(%rsp), %xmm0
leaq 0x78(%rsp), %r12
movq %rax, %rcx
addq $0x10, %rcx
movq %r12, -0x10(%r12)
movq (%rax), %rdx
cmpq %rcx, %rdx
jne 0x208c4
vmovupd (%rcx), %xmm1
vmovupd %xmm1, (%r12)
jmp 0x208d1
movq %rdx, 0x68(%rsp)
movq (%rcx), %rdx
movq %rdx, 0x78(%rsp)
movq 0x8(%rax), %rdx
movq %rdx, 0x70(%rsp)
movq %rcx, (%rax)
movq $0x0, 0x8(%rax)
movb $0x0, 0x10(%rax)
leaq 0xa8(%rsp), %rdi
movl $0x3, %esi
callq 0x2f6e8
movq 0x70(%rsp), %r8
movq 0xb0(%rsp), %rdx
movq 0x68(%rsp), %rcx
movl $0xf, %edi
leaq (%rdx,%r8), %rax
cmpq %r12, %rcx
je 0x20920
movq 0x78(%rsp), %rdi
movq 0xa8(%rsp), %rsi
cmpq %rdi, %rax
jbe 0x2094c
leaq 0xb8(%rsp), %r9
movl $0xf, %edi
cmpq %r9, %rsi
je 0x20947
movq 0xb8(%rsp), %rdi
cmpq %rdi, %rax
jbe 0x20958
leaq 0x68(%rsp), %rdi
callq 0x50c0
jmp 0x20969
leaq 0xa8(%rsp), %rdi
xorl %esi, %esi
xorl %edx, %edx
callq 0x5380
leaq 0x58(%rsp), %rdx
leaq 0x10(%rax), %rcx
movq %rdx, -0x10(%rdx)
movq (%rax), %rsi
cmpq %rcx, %rsi
jne 0x20988
vmovupd (%rcx), %xmm0
vmovupd %xmm0, (%rdx)
jmp 0x20995
movq %rsi, 0x48(%rsp)
movq (%rcx), %rdx
movq %rdx, 0x58(%rsp)
movq 0x8(%rax), %rsi
movq %rax, %rdx
addq $0x8, %rdx
movq %rsi, 0x50(%rsp)
movq %rcx, (%rax)
movq $0x0, (%rdx)
movb $0x0, (%rcx)
leaq 0x14160(%rip), %rsi     # 0x34b19
leaq 0x48(%rsp), %rdi
callq 0x56e0
leaq 0x38(%rsp), %r13
movq %rax, %rcx
addq $0x10, %rcx
movq %r13, -0x10(%r13)
movq (%rax), %rdx
cmpq %rcx, %rdx
jne 0x209e7
vmovupd (%rcx), %xmm0
vmovupd %xmm0, (%r13)
jmp 0x209f4
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)
movq 0x58(%r14), %rsi
leaq 0x88(%rsp), %rdi
callq 0x28e47
movq 0x30(%rsp), %r8
movq 0x90(%rsp), %rdx
movq 0x28(%rsp), %rcx
movl $0xf, %edi
leaq (%rdx,%r8), %rax
cmpq %r13, %rcx
je 0x20a42
movq 0x38(%rsp), %rdi
movq 0x88(%rsp), %rsi
cmpq %rdi, %rax
jbe 0x20a6e
leaq 0x98(%rsp), %r9
movl $0xf, %edi
cmpq %r9, %rsi
je 0x20a69
movq 0x98(%rsp), %rdi
cmpq %rdi, %rax
jbe 0x20a7a
leaq 0x28(%rsp), %rdi
callq 0x50c0
jmp 0x20a8b
leaq 0x88(%rsp), %rdi
xorl %esi, %esi
xorl %edx, %edx
callq 0x5380
leaq 0x10(%rsp), %rdx
leaq 0x10(%rax), %rcx
movq %rdx, -0x10(%rdx)
movq (%rax), %rsi
cmpq %rcx, %rsi
jne 0x20aaa
vmovupd (%rcx), %xmm0
vmovupd %xmm0, (%rdx)
jmp 0x20ab6
movq %rsi, (%rsp)
movq (%rcx), %rdx
movq %rdx, 0x10(%rsp)
movq 0x8(%rax), %rsi
movq %rax, %rdx
addq $0x8, %rdx
movq %rsi, 0x8(%rsp)
movq %rcx, (%rax)
movq $0x0, (%rdx)
movb $0x0, (%rcx)
leaq 0x10e2c(%rip), %rsi     # 0x31906
movq %rsp, %rdi
callq 0x56e0
leaq 0xf8(%rsp), %rbp
movq %rax, %rcx
addq $0x10, %rcx
movq %rbp, -0x10(%rbp)
movq (%rax), %rdx
cmpq %rcx, %rdx
jne 0x20b08
vmovupd (%rcx), %xmm0
vmovupd %xmm0, (%rbp)
jmp 0x20b1b
movq %rdx, 0xe8(%rsp)
movq (%rcx), %rdx
movq %rdx, 0xf8(%rsp)
movq 0x8(%rax), %rdx
movq %rdx, 0xf0(%rsp)
movq %rcx, (%rax)
movq $0x0, 0x8(%rax)
movb $0x0, 0x10(%rax)
movq 0x28493(%rip), %rax     # 0x48fd0
movq 0xe8(%rsp), %rdi
movq (%rax), %rsi
callq 0x5370
movq 0xe8(%rsp), %rdi
cmpq %rbp, %rdi
je 0x20b5f
callq 0x52e0
leaq 0x10(%rsp), %rax
movq -0x10(%rax), %rdi
cmpq %rax, %rdi
je 0x20b72
callq 0x52e0
leaq 0x98(%rsp), %rax
movq -0x10(%rax), %rdi
cmpq %rax, %rdi
je 0x20b88
callq 0x52e0
movq 0x28(%rsp), %rdi
cmpq %r13, %rdi
je 0x20b97
callq 0x52e0
leaq 0x58(%rsp), %rax
movq -0x10(%rax), %rdi
cmpq %rax, %rdi
je 0x20baa
callq 0x52e0
leaq 0xb8(%rsp), %rax
movq -0x10(%rax), %rdi
cmpq %rax, %rdi
je 0x20bc0
callq 0x52e0
movq 0x68(%rsp), %rdi
cmpq %r12, %rdi
je 0x20bcf
callq 0x52e0
movq 0xc8(%rsp), %rdi
cmpq %r15, %rdi
je 0x20be1
callq 0x52e0
leaq 0x158(%rsp), %rax
movq -0x10(%rax), %rdi
cmpq %rax, %rdi
je 0x206b8
callq 0x52e0
jmp 0x206b8
leaq 0x10(%rsp), %rcx
movq %rax, %rbx
movq -0x10(%rcx), %rdi
cmpq %rcx, %rdi
je 0x20c1b
callq 0x52e0
jmp 0x20c1b
movq %rax, %rbx
leaq 0x98(%rsp), %rax
movq -0x10(%rax), %rdi
cmpq %rax, %rdi
je 0x20c36
callq 0x52e0
jmp 0x20c36
movq %rax, %rbx
movq 0x28(%rsp), %rdi
cmpq %r13, %rdi
je 0x20c4a
callq 0x52e0
jmp 0x20c4a
movq %rax, %rbx
leaq 0x58(%rsp), %rax
movq -0x10(%rax), %rdi
cmpq %rax, %rdi
je 0x20c62
callq 0x52e0
jmp 0x20c62
movq %rax, %rbx
leaq 0xb8(%rsp), %rax
movq -0x10(%rax), %rdi
cmpq %rax, %rdi
je 0x20c7d
callq 0x52e0
jmp 0x20c7d
movq %rax, %rbx
movq 0x68(%rsp), %rdi
cmpq %r12, %rdi
je 0x20c91
callq 0x52e0
jmp 0x20c91
movq %rax, %rbx
movq 0xc8(%rsp), %rdi
cmpq %r15, %rdi
je 0x20cb2
callq 0x52e0
jmp 0x20cb2
movq %rax, %rbx
leaq 0x10(%rsp), %rax
jmp 0x20cba
movq %rax, %rbx
leaq 0x158(%rsp), %rax
movq -0x10(%rax), %rdi
cmpq %rax, %rdi
je 0x20cc8
callq 0x52e0
movq %rbx, %rdi
callq 0x5670
movq %rax, %rbx
leaq 0x138(%rsp), %rax
jmp 0x20cba
movq 0x108(%rsp), %rdi
movq %rax, %rbx
cmpq %r15, %rdi
jne 0x20cc3
jmp 0x20cc8
nop