// File: /workspace/github_cpp_makefile_star2_O2/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 0x188fb
leaq 0xad1f(%rip), %rsi      # 0x235e8
leaq 0xe8(%rsp), %rdi
leaq 0x8(%rsp), %rdx
callq 0x5110
pushq $0x1
popq %rsi
leaq 0xe8(%rsp), %rdx
movq %rbx, %rdi
callq 0x8d00
leaq 0xe8(%rsp), %rdi
jmp 0x18bb0
movq (%rdx), %rdi
movq %rsi, %r14
cmpq %rdi, 0x8(%rdx)
je 0x1891f
callq 0x1c89a
vxorpd %xmm1, %xmm1, %xmm1
vucomisd %xmm1, %xmm0
jne 0x1896c
jp 0x1896c
movb 0x89(%r14), %al
movq 0x70(%r14), %r12
movq 0xd8(%r14), %rdi
leaq 0xe580(%rip), %rcx      # 0x26eb1
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 0x1c8fa
cmpl $0x0, 0xc8(%r14)
vmovsd %xmm0, (%rsp)
je 0x18abf
vmovsd 0x60(%r14), %xmm0
leaq 0x128(%rsp), %r15
pushq $0x1
popq %rsi
movq %r15, %rdi
callq 0x20e6c
leaq 0xccb4(%rip), %rsi      # 0x25653
leaq 0xa8(%rsp), %rdi
movq %r15, %rdx
callq 0xcf8b
leaq 0xccab(%rip), %rdx      # 0x25661
leaq 0xc8(%rsp), %rdi
leaq 0xa8(%rsp), %rsi
callq 0x8051
leaq 0x88(%rsp), %rdi
pushq $0x3
popq %rsi
vmovsd (%rsp), %xmm0
callq 0x20e6c
leaq 0x28(%rsp), %rdi
leaq 0xc8(%rsp), %rsi
leaq 0x88(%rsp), %rdx
callq 0xcf24
leaq 0xcc69(%rip), %rdx      # 0x2566a
leaq 0x48(%rsp), %rdi
leaq 0x28(%rsp), %rsi
callq 0x8051
movq 0x58(%r14), %rsi
leaq 0x68(%rsp), %rdi
callq 0x1c96d
leaq 0x8(%rsp), %rdi
leaq 0x48(%rsp), %rsi
leaq 0x68(%rsp), %rdx
callq 0xcf24
leaq 0x9ea3(%rip), %rdx      # 0x228dc
leaq 0x168(%rsp), %rdi
leaq 0x8(%rsp), %rsi
callq 0x8051
leaq 0x168(%rsp), %r15
movq %r15, %rdi
callq 0xd451
movq %r15, %rdi
callq 0x5150
leaq 0x8(%rsp), %rdi
callq 0x5150
leaq 0x68(%rsp), %rdi
callq 0x5150
leaq 0x48(%rsp), %rdi
callq 0x5150
leaq 0x28(%rsp), %rdi
callq 0x5150
leaq 0x88(%rsp), %rdi
callq 0x5150
leaq 0xc8(%rsp), %rdi
callq 0x5150
leaq 0xa8(%rsp), %rdi
callq 0x5150
leaq 0x128(%rsp), %rdi
callq 0x5150
leaq 0x48(%rsp), %r15
movq %r15, %rdi
callq 0x5ca0
movq 0xd8(%r14), %rdi
vmovsd (%rsp), %xmm0
movq 0x58(%r14), %rsi
movl 0xc8(%r14), %edx
leaq 0x30(%r14), %r12
movq (%rdi), %rax
callq *0x10(%rax)
leaq 0x8(%rsp), %r13
movq %r13, %rdi
callq 0x5ca0
vmovsd (%r13), %xmm0
movq %r12, %rdi
vsubsd (%r15), %xmm0, %xmm0
callq 0x1c9c8
movq 0xd8(%r14), %rdi
movl 0xc8(%r14), %esi
movq (%rdi), %rax
callq *0x18(%rax)
movw %ax, 0x28(%rsp)
cmpl $0x2, 0xc8(%r14)
jl 0x18b85
movzbl 0xcd(%r14), %edx
subq $-0x80, %r14
leaq 0x8(%rsp), %r15
movq %r15, %rdi
movq %r14, %rsi
callq 0x17dc6
leaq 0x9d89(%rip), %rdx      # 0x228dc
leaq 0x148(%rsp), %rdi
movq %r15, %rsi
callq 0x8051
leaq 0x148(%rsp), %r14
movq %r14, %rdi
callq 0xd451
movq %r14, %rdi
callq 0x5150
leaq 0x8(%rsp), %rdi
callq 0x5150
leaq 0x108(%rsp), %r14
leaq 0x28(%rsp), %rsi
movq %r14, %rdi
callq 0xcfb0
pushq $0x1
popq %rsi
movq %rbx, %rdi
movq %r14, %rdx
callq 0x8d00
leaq 0x108(%rsp), %rdi
callq 0x5150
movq %rbx, %rax
addq $0x188, %rsp            # imm = 0x188
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
leaq 0x8(%rsp), %rdi
jmp 0x18c65
leaq 0x8(%rsp), %rdi
movq %rax, %rbx
callq 0x5150
jmp 0x18be6
movq %rax, %rbx
leaq 0x68(%rsp), %rdi
callq 0x5150
jmp 0x18bf5
movq %rax, %rbx
leaq 0x48(%rsp), %rdi
callq 0x5150
jmp 0x18c04
movq %rax, %rbx
leaq 0x28(%rsp), %rdi
callq 0x5150
jmp 0x18c13
movq %rax, %rbx
leaq 0x88(%rsp), %rdi
callq 0x5150
leaq 0xc8(%rsp), %rdi
callq 0x5150
leaq 0xa8(%rsp), %rdi
callq 0x5150
leaq 0x128(%rsp), %rdi
jmp 0x18c68
movq %rax, %rbx
jmp 0x18c20
movq %rax, %rbx
jmp 0x18c2d
movq %rax, %rbx
jmp 0x18c3a
leaq 0x108(%rsp), %rdi
jmp 0x18c65
leaq 0xe8(%rsp), %rdi
movq %rax, %rbx
callq 0x5150
movq %rbx, %rdi
callq 0x5650
movq %rax, %rbx
jmp 0x18c6d