// File: tewalds[P]morat/hex/gtpagent.cpp
// Function: Morat::Hex::GTP::gtp_genmove(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_genmove(vecstr args){
	if(hist->outcome() >= 0)
		return GTPResponse(true, "resign");

	double use_time = (args.size() >= 2 ? from_str<double>(args[1]) : 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) + ", use: " + 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);


	Move best = agent->return_move(verbose);

	move(best);

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

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

// Assembly:
subq $0x258, %rsp            # imm = 0x258
movq %rdx, 0x40(%rsp)
movq %rdi, 0x48(%rsp)
movq %rdi, %rax
movq %rax, 0x50(%rsp)
movq %rdi, 0x250(%rsp)
movq %rsi, 0x248(%rsp)
movq %rdx, 0x240(%rsp)
movq 0x248(%rsp), %rdi
movq %rdi, 0x58(%rsp)
addq $0x68, %rdi
callq 0x3ea90
movq %rax, %rdi
callq 0x1a900
movb %al, 0x23f(%rsp)
movb $0x0, 0x23d(%rsp)
leaq 0x23e(%rsp), %rdi
leaq 0x23d(%rsp), %rsi
callq 0x1a870
leaq 0x23f(%rsp), %rdi
leaq 0x23e(%rsp), %rsi
callq 0x1a8c0
testb $0x1, %al
jne 0x38561
jmp 0x3860f
leaq 0x217(%rsp), %rdi
movq %rdi, 0x38(%rsp)
callq 0x5770
movq 0x38(%rsp), %rdx
leaq 0x1502d(%rip), %rsi     # 0x4d5ac
leaq 0x218(%rsp), %rdi
callq 0x5590
jmp 0x3858e
movq 0x48(%rsp), %rdi
movl $0x1, %esi
leaq 0x218(%rsp), %rdx
callq 0xd9a0
jmp 0x385a7
leaq 0x218(%rsp), %rdi
callq 0x5260
leaq 0x217(%rsp), %rdi
callq 0x5450
jmp 0x38b8f
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x208(%rsp)
movl %eax, 0x204(%rsp)
jmp 0x385fd
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x208(%rsp)
movl %eax, 0x204(%rsp)
leaq 0x218(%rsp), %rdi
callq 0x5260
leaq 0x217(%rsp), %rdi
callq 0x5450
jmp 0x38b9c
movq 0x40(%rsp), %rdi
callq 0x13c80
cmpq $0x2, %rax
jb 0x3863e
movq 0x40(%rsp), %rdi
movl $0x1, %esi
callq 0x13ca0
movq %rax, %rdi
callq 0x3eaa0
vmovsd %xmm0, 0x30(%rsp)
jmp 0x3864a
vpxor %xmm0, %xmm0, %xmm0
vmovsd %xmm0, 0x30(%rsp)
jmp 0x3864a
vmovsd 0x30(%rsp), %xmm0
vmovsd %xmm0, 0x1f8(%rsp)
vmovsd 0x1f8(%rsp), %xmm0
vpxor %xmm1, %xmm1, %xmm1
vucomisd %xmm1, %xmm0
jne 0x386d9
jp 0x386d9
movq 0x58(%rsp), %rdi
movq %rdi, %rax
addq $0x30, %rax
movq %rax, 0x20(%rsp)
addq $0x68, %rdi
callq 0x3ec40
movq 0x58(%rsp), %rdi
movl %eax, 0x28(%rsp)
addq $0x68, %rdi
callq 0x3ea90
movq %rax, %rdi
callq 0x28e80
movl %eax, %ecx
movq 0x58(%rsp), %rax
movl %ecx, 0x2c(%rsp)
movq 0xd8(%rax), %rdi
movq (%rdi), %rax
callq *0x50(%rax)
movq 0x20(%rsp), %rdi
movl 0x28(%rsp), %esi
movl 0x2c(%rsp), %edx
vcvttsd2si %xmm0, %ecx
callq 0x3eb30
vmovsd %xmm0, 0x1f8(%rsp)
movq 0x58(%rsp), %rax
cmpl $0x0, 0xc8(%rax)
je 0x389ca
movq 0x58(%rsp), %rax
vmovsd 0x60(%rax), %xmm0
leaq 0x118(%rsp), %rdi
movq %rdi, 0x18(%rsp)
movl $0x1, %esi
callq 0x48780
movq 0x18(%rsp), %rdx
leaq 0x16fea(%rip), %rsi     # 0x4f702
leaq 0x138(%rsp), %rdi
callq 0x19f30
jmp 0x38727
leaq 0x16fea(%rip), %rdx     # 0x4f718
leaq 0x158(%rsp), %rdi
leaq 0x138(%rsp), %rsi
callq 0xb910
jmp 0x38745
vmovsd 0x1f8(%rsp), %xmm0
leaq 0xf8(%rsp), %rdi
movl $0x3, %esi
callq 0x48780
jmp 0x38762
leaq 0x178(%rsp), %rdi
leaq 0x158(%rsp), %rsi
leaq 0xf8(%rsp), %rdx
callq 0x19e40
jmp 0x38781
leaq 0x16f71(%rip), %rdx     # 0x4f6f9
leaq 0x198(%rsp), %rdi
leaq 0x178(%rsp), %rsi
callq 0xb910
jmp 0x3879f
movq 0x58(%rsp), %rax
movq 0x58(%rax), %rsi
leaq 0xd8(%rsp), %rdi
callq 0x3ec50
jmp 0x387b7
leaq 0x1b8(%rsp), %rdi
leaq 0x198(%rsp), %rsi
leaq 0xd8(%rsp), %rdx
callq 0x19e40
jmp 0x387d6
leaq 0x1410b(%rip), %rdx     # 0x4c8e8
leaq 0x1d8(%rsp), %rdi
leaq 0x1b8(%rsp), %rsi
callq 0xb910
jmp 0x387f4
leaq 0x1d8(%rsp), %rdi
callq 0x1a9b0
jmp 0x38803
leaq 0x1d8(%rsp), %rdi
callq 0x5260
leaq 0x1b8(%rsp), %rdi
callq 0x5260
leaq 0xd8(%rsp), %rdi
callq 0x5260
leaq 0x198(%rsp), %rdi
callq 0x5260
leaq 0x178(%rsp), %rdi
callq 0x5260
leaq 0xf8(%rsp), %rdi
callq 0x5260
leaq 0x158(%rsp), %rdi
callq 0x5260
leaq 0x138(%rsp), %rdi
callq 0x5260
leaq 0x118(%rsp), %rdi
callq 0x5260
jmp 0x389ca
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x208(%rsp)
movl %eax, 0x204(%rsp)
jmp 0x389b8
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x208(%rsp)
movl %eax, 0x204(%rsp)
jmp 0x389ab
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x208(%rsp)
movl %eax, 0x204(%rsp)
jmp 0x3899e
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x208(%rsp)
movl %eax, 0x204(%rsp)
jmp 0x38991
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x208(%rsp)
movl %eax, 0x204(%rsp)
jmp 0x38984
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x208(%rsp)
movl %eax, 0x204(%rsp)
jmp 0x38977
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x208(%rsp)
movl %eax, 0x204(%rsp)
jmp 0x3896a
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x208(%rsp)
movl %eax, 0x204(%rsp)
jmp 0x3895d
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x208(%rsp)
movl %eax, 0x204(%rsp)
leaq 0x1d8(%rsp), %rdi
callq 0x5260
leaq 0x1b8(%rsp), %rdi
callq 0x5260
leaq 0xd8(%rsp), %rdi
callq 0x5260
leaq 0x198(%rsp), %rdi
callq 0x5260
leaq 0x178(%rsp), %rdi
callq 0x5260
leaq 0xf8(%rsp), %rdi
callq 0x5260
leaq 0x158(%rsp), %rdi
callq 0x5260
leaq 0x138(%rsp), %rdi
callq 0x5260
leaq 0x118(%rsp), %rdi
callq 0x5260
jmp 0x38b9c
leaq 0xd0(%rsp), %rdi
callq 0x6780
movq 0x58(%rsp), %rax
movq 0xd8(%rax), %rdi
vmovsd 0x1f8(%rsp), %xmm0
movq 0x58(%rax), %rsi
movl 0xc8(%rax), %edx
movq (%rdi), %rax
callq *0x10(%rax)
movq 0x58(%rsp), %rax
addq $0x30, %rax
movq %rax, 0x10(%rsp)
leaq 0xc8(%rsp), %rdi
callq 0x6780
leaq 0xc8(%rsp), %rdi
leaq 0xd0(%rsp), %rsi
callq 0x1ad50
movq 0x10(%rsp), %rdi
callq 0x3ece0
movq 0x58(%rsp), %rax
movq 0xd8(%rax), %rdi
movl 0xc8(%rax), %esi
movq (%rdi), %rax
callq *0x18(%rax)
movq 0x58(%rsp), %rdi
movw %ax, 0xc6(%rsp)
leaq 0xc6(%rsp), %rsi
callq 0x3ed80
movq 0x58(%rsp), %rax
cmpl $0x2, 0xc8(%rax)
jl 0x38b38
movq 0x58(%rsp), %rdi
addq $0x68, %rdi
callq 0x3ea90
movq %rax, %rsi
movq 0x58(%rsp), %rax
movzbl 0xcd(%rax), %edx
andl $0x1, %edx
leaq 0x80(%rsp), %rdi
movq %rdi, 0x8(%rsp)
callq 0x35f30
movq 0x8(%rsp), %rsi
leaq 0x13e30(%rip), %rdx     # 0x4c8e8
leaq 0xa0(%rsp), %rdi
callq 0xb910
jmp 0x38ac7
leaq 0xa0(%rsp), %rdi
callq 0x1a9b0
jmp 0x38ad6
leaq 0xa0(%rsp), %rdi
callq 0x5260
leaq 0x80(%rsp), %rdi
callq 0x5260
jmp 0x38b38
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x208(%rsp)
movl %eax, 0x204(%rsp)
jmp 0x38b29
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x208(%rsp)
movl %eax, 0x204(%rsp)
leaq 0xa0(%rsp), %rdi
callq 0x5260
leaq 0x80(%rsp), %rdi
callq 0x5260
jmp 0x38b9c
leaq 0x60(%rsp), %rdi
movq %rdi, (%rsp)
leaq 0xc6(%rsp), %rsi
callq 0x19f80
movq 0x48(%rsp), %rdi
movq (%rsp), %rdx
movl $0x1, %esi
callq 0xd9a0
jmp 0x38b63
leaq 0x60(%rsp), %rdi
callq 0x5260
jmp 0x38b8f
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x208(%rsp)
movl %eax, 0x204(%rsp)
leaq 0x60(%rsp), %rdi
callq 0x5260
jmp 0x38b9c
movq 0x50(%rsp), %rax
addq $0x258, %rsp            # imm = 0x258
retq
movq 0x208(%rsp), %rdi
callq 0x5760
nopl (%rax)