// File: /workspace/github_cpp_makefile_star2_O1/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
movq %rdi, %rbx
cmpb $0x0, 0x89(%rsi)
js 0x206e6
leaq 0x118(%rsp), %r15
movq %r15, -0x10(%r15)
leaq 0x120f4(%rip), %rsi     # 0x3278c
leaq 0x120f3(%rip), %rdx     # 0x32792
leaq 0x108(%rsp), %r14
movq %r14, %rdi
callq 0xb0e0
movq %rbx, %rdi
movl $0x1, %esi
movq %r14, %rdx
callq 0xa7f0
movq 0x108(%rsp), %rdi
cmpq %r15, %rdi
je 0x206d1
callq 0x52e0
movq %rbx, %rax
addq $0x188, %rsp            # imm = 0x188
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq %rsi, %r14
movq (%rdx), %rdi
vxorpd %xmm1, %xmm1, %xmm1
vxorpd %xmm0, %xmm0, %xmm0
cmpq %rdi, 0x8(%rdx)
je 0x20703
callq 0x28e1e
vxorpd %xmm1, %xmm1, %xmm1
vucomisd %xmm1, %xmm0
jne 0x2075f
jp 0x2075f
leaq 0x30(%r14), %r15
movq 0x70(%r14), %r12
subq 0x68(%r14), %r12
shrq %r12
movb 0x89(%r14), %al
leaq 0x15c89(%rip), %rcx     # 0x363b1
movswl 0x82(%r14), %edx
movswl 0x84(%r14), %esi
subl %esi, %edx
xorl %ebp, %ebp
cmpb (%rcx), %al
cmovll %edx, %ebp
movq 0xd8(%r14), %rdi
movq (%rdi), %rax
callq *0x50(%rax)
vcvttsd2si %xmm0, %ecx
movq %r15, %rdi
movl %r12d, %esi
movl %ebp, %edx
callq 0x28ea8
vmovsd %xmm0, 0x20(%rsp)
cmpl $0x0, 0xc8(%r14)
jne 0x2085b
movq %rsp, %r15
movq %r15, %rdi
xorl %esi, %esi
callq 0x55b0
movq (%r15), %r13
movq 0x8(%r15), %rbp
movq 0xd8(%r14), %rdi
leaq 0x30(%r14), %r15
movq 0x58(%r14), %rsi
movl 0xc8(%r14), %edx
movq (%rdi), %rax
vmovsd 0x20(%rsp), %xmm0
callq *0x10(%rax)
movq %rsp, %r12
movq %r12, %rdi
xorl %esi, %esi
callq 0x55b0
vmovdqa (%r12), %xmm0
vpbroadcastq 0x8(%r12), %xmm1
vpinsrq $0x1, %r13, %xmm0, %xmm0
vcvtqq2pd %xmm0, %xmm0
vpinsrq $0x1, %rbp, %xmm1, %xmm1
vcvtqq2pd %xmm1, %xmm1
vdivpd 0x10823(%rip){1to2}, %xmm1, %xmm1 # 0x31008
vaddpd %xmm0, %xmm1, %xmm0
vhsubpd %xmm0, %xmm0, %xmm0
movq %r15, %rdi
callq 0x28f98
movq 0xd8(%r14), %rdi
movl 0xc8(%r14), %esi
movq (%rdi), %rax
callq *0x18(%rax)
movw %ax, 0x28(%rsp)
cmpl $0x2, 0xc8(%r14)
jge 0x208b5
leaq 0x128(%rsp), %r14
leaq 0x28(%rsp), %rsi
movq %r14, %rdi
callq 0x10cdc
movq %rbx, %rdi
movl $0x1, %esi
movq %r14, %rdx
callq 0xa7f0
leaq 0x138(%rsp), %rax
movq -0x10(%rax), %rdi
cmpq %rax, %rdi
jne 0x206cc
jmp 0x206d1
vmovsd 0x60(%r14), %xmm0
leaq 0x148(%rsp), %r15
movq %r15, %rdi
movl $0x1, %esi
callq 0x2f81c
leaq 0x14285(%rip), %rcx     # 0x34b02
movl $0xd, %r8d
movq %r15, %rdi
xorl %esi, %esi
xorl %edx, %edx
callq 0x5380
leaq 0xd8(%rsp), %r15
movq %r15, -0x10(%r15)
movq (%rax), %rdx
movq %rax, %rcx
addq $0x10, %rcx
cmpq %rcx, %rdx
jne 0x208f6
vmovupd (%rcx), %xmm0
vmovupd %xmm0, (%r15)
jmp 0x20909
movzbl 0xcd(%r14), %edx
subq $-0x80, %r14
movq %rsp, %r15
movq %r15, %rdi
movq %r14, %rsi
callq 0x1f6ee
leaq 0x11030(%rip), %rsi     # 0x31906
movq %r15, %rdi
callq 0x56e0
leaq 0x168(%rsp), %rdi
movq %rsp, %rdx
movq %rax, %rsi
callq 0x5aa4
jmp 0x2081c
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 0x141e1(%rip), %rsi     # 0x34b10
callq 0x56e0
leaq 0x78(%rsp), %r12
movq %r12, -0x10(%r12)
movq (%rax), %rdx
movq %rax, %rcx
addq $0x10, %rcx
cmpq %rcx, %rdx
jne 0x20959
vmovupd (%rcx), %xmm0
vmovupd %xmm0, (%r12)
jmp 0x20966
movq %rdx, 0x68(%rsp)
movq (%rcx), %rdx
movq %rdx, 0x78(%rsp)
vmovsd 0x20(%rsp), %xmm0
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 0x2f81c
movq 0x68(%rsp), %rcx
movq 0x70(%rsp), %r8
movq 0xb0(%rsp), %rdx
leaq (%rdx,%r8), %rax
movl $0xf, %esi
cmpq %r12, %rcx
je 0x209bb
movq 0x78(%rsp), %rsi
cmpq %rsi, %rax
jbe 0x209e0
leaq 0xb8(%rsp), %rdi
movl $0xf, %esi
cmpq %rdi, -0x10(%rdi)
je 0x209db
movq 0xb8(%rsp), %rsi
cmpq %rsi, %rax
jbe 0x209f4
movq 0xa8(%rsp), %rsi
leaq 0x68(%rsp), %rdi
callq 0x50c0
jmp 0x20a05
leaq 0xa8(%rsp), %rdi
xorl %esi, %esi
xorl %edx, %edx
callq 0x5380
leaq 0x58(%rsp), %rdx
movq %rdx, -0x10(%rdx)
movq (%rax), %rsi
leaq 0x10(%rax), %rcx
cmpq %rcx, %rsi
jne 0x20a24
vmovupd (%rcx), %xmm0
vmovupd %xmm0, (%rdx)
jmp 0x20a31
movq %rsi, 0x48(%rsp)
movq (%rcx), %rdx
movq %rdx, 0x58(%rsp)
movq %rax, %rdx
addq $0x8, %rdx
movq 0x8(%rax), %rsi
movq %rsi, 0x50(%rsp)
movq %rcx, (%rax)
movq $0x0, (%rdx)
movb $0x0, (%rcx)
leaq 0x140c4(%rip), %rsi     # 0x34b19
leaq 0x48(%rsp), %rdi
callq 0x56e0
leaq 0x38(%rsp), %r13
movq %r13, -0x10(%r13)
movq (%rax), %rdx
movq %rax, %rcx
addq $0x10, %rcx
cmpq %rcx, %rdx
jne 0x20a83
vmovupd (%rcx), %xmm0
vmovupd %xmm0, (%r13)
jmp 0x20a90
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 0x28f15
movq 0x28(%rsp), %rcx
movq 0x30(%rsp), %r8
movq 0x90(%rsp), %rdx
leaq (%rdx,%r8), %rax
movl $0xf, %esi
cmpq %r13, %rcx
je 0x20ade
movq 0x38(%rsp), %rsi
cmpq %rsi, %rax
jbe 0x20b03
leaq 0x98(%rsp), %rdi
movl $0xf, %esi
cmpq %rdi, -0x10(%rdi)
je 0x20afe
movq 0x98(%rsp), %rsi
cmpq %rsi, %rax
jbe 0x20b17
movq 0x88(%rsp), %rsi
leaq 0x28(%rsp), %rdi
callq 0x50c0
jmp 0x20b28
leaq 0x88(%rsp), %rdi
xorl %esi, %esi
xorl %edx, %edx
callq 0x5380
leaq 0x10(%rsp), %rdx
movq %rdx, -0x10(%rdx)
movq (%rax), %rsi
leaq 0x10(%rax), %rcx
cmpq %rcx, %rsi
jne 0x20b47
vmovupd (%rcx), %xmm0
vmovupd %xmm0, (%rdx)
jmp 0x20b53
movq %rsi, (%rsp)
movq (%rcx), %rdx
movq %rdx, 0x10(%rsp)
movq %rax, %rdx
addq $0x8, %rdx
movq 0x8(%rax), %rsi
movq %rsi, 0x8(%rsp)
movq %rcx, (%rax)
movq $0x0, (%rdx)
movb $0x0, (%rcx)
leaq 0x10d8f(%rip), %rsi     # 0x31906
movq %rsp, %rdi
callq 0x56e0
leaq 0xf8(%rsp), %rbp
movq %rbp, -0x10(%rbp)
movq (%rax), %rdx
movq %rax, %rcx
addq $0x10, %rcx
cmpq %rcx, %rdx
jne 0x20ba5
vmovupd (%rcx), %xmm0
vmovupd %xmm0, (%rbp)
jmp 0x20bb8
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 0x293f6(%rip), %rax     # 0x49fd0
movq (%rax), %rsi
movq 0xe8(%rsp), %rdi
callq 0x5370
movq 0xe8(%rsp), %rdi
cmpq %rbp, %rdi
je 0x20bfc
callq 0x52e0
leaq 0x10(%rsp), %rax
movq -0x10(%rax), %rdi
cmpq %rax, %rdi
je 0x20c0f
callq 0x52e0
leaq 0x98(%rsp), %rax
movq -0x10(%rax), %rdi
cmpq %rax, %rdi
je 0x20c25
callq 0x52e0
movq 0x28(%rsp), %rdi
cmpq %r13, %rdi
je 0x20c34
callq 0x52e0
leaq 0x58(%rsp), %rax
movq -0x10(%rax), %rdi
cmpq %rax, %rdi
je 0x20c47
callq 0x52e0
leaq 0xb8(%rsp), %rax
movq -0x10(%rax), %rdi
cmpq %rax, %rdi
je 0x20c5d
callq 0x52e0
movq 0x68(%rsp), %rdi
cmpq %r12, %rdi
je 0x20c6c
callq 0x52e0
movq 0xc8(%rsp), %rdi
cmpq %r15, %rdi
je 0x20c7e
callq 0x52e0
leaq 0x158(%rsp), %rax
movq -0x10(%rax), %rdi
cmpq %rax, %rdi
je 0x20773
callq 0x52e0
jmp 0x20773
movq %rax, %rbx
leaq 0x10(%rsp), %rax
movq -0x10(%rax), %rdi
cmpq %rax, %rdi
je 0x20cb8
callq 0x52e0
jmp 0x20cb8
movq %rax, %rbx
leaq 0x98(%rsp), %rax
movq -0x10(%rax), %rdi
cmpq %rax, %rdi
je 0x20cd3
callq 0x52e0
jmp 0x20cd3
movq %rax, %rbx
movq 0x28(%rsp), %rdi
cmpq %r13, %rdi
je 0x20ce7
callq 0x52e0
jmp 0x20ce7
movq %rax, %rbx
leaq 0x58(%rsp), %rax
movq -0x10(%rax), %rdi
cmpq %rax, %rdi
je 0x20cff
callq 0x52e0
jmp 0x20cff
movq %rax, %rbx
leaq 0xb8(%rsp), %rax
movq -0x10(%rax), %rdi
cmpq %rax, %rdi
je 0x20d1a
callq 0x52e0
jmp 0x20d1a
movq %rax, %rbx
movq 0x68(%rsp), %rdi
cmpq %r12, %rdi
je 0x20d2e
callq 0x52e0
jmp 0x20d2e
movq %rax, %rbx
movq 0xc8(%rsp), %rdi
cmpq %r15, %rdi
je 0x20d4f
callq 0x52e0
jmp 0x20d4f
movq %rax, %rbx
leaq 0x10(%rsp), %rax
jmp 0x20d57
movq %rax, %rbx
leaq 0x158(%rsp), %rax
movq -0x10(%rax), %rdi
cmpq %rax, %rdi
je 0x20d65
callq 0x52e0
movq %rbx, %rdi
callq 0x5670
movq %rax, %rbx
leaq 0x138(%rsp), %rax
jmp 0x20d57
movq %rax, %rbx
movq 0x108(%rsp), %rdi
cmpq %r15, %rdi
jne 0x20d60
jmp 0x20d65