// File: /workspace/github_cpp_makefile_star2_O2/tewalds[P]morat/lib/gtpcommon.cpp
// Function: Morat::GTPCommon::gtp_time(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 GTPCommon::gtp_time(vecstr args){
	if(args.size() == 0)
		return GTPResponse(true, string("\n") +
			"Update the time settings, eg: time -s 2.5 -m 10 -g 600 -f 1\n" +
			"Method for distributing remaining time, current: " + time_control.method_name() + " " + to_str(time_control.param) + "\n" +
			"  -p --percent  Percentage of the remaining time every move            [10.0]\n" +
			"  -e --even     Multiple of even split of the maximum  remaining moves [2.0]\n" +
			"  -s --stats    Multiple of even split of the expected remaining moves [2.0]\n" +
			"Time allocation\n" +
			"  -m --move     Time per move                                          [" + to_str(time_control.move) + "]\n" +
			"  -g --game     Time per game                                          [" + to_str(time_control.game) + "]\n" +
			"  -f --flexible Add remaining time per move to remaining time          [" + to_str(time_control.flexible) + "]\n" +
			"  -i --maxsims  Maximum number of simulations per move                 [" + to_str(time_control.max_sims) + "]\n" +
			"Current game\n" +
			"  -r --remain   Remaining time for this game                           [" + to_str(time_control.remain) + "]\n");

	for(unsigned int i = 0; i < args.size(); i++) {
		string arg = args[i];

		if(arg == "-p" || arg == "--percent"){
			time_control.method = TimeControl::PERCENT;
			time_control.param = 10;
			if(i+1 < args.size() && from_str<double>(args[i+1]) > 0) time_control.param = from_str<double>(args[++i]);
		}else if(arg == "-e" || arg == "--even"){
			time_control.method = TimeControl::EVEN;
			time_control.param = 2;
			if(i+1 < args.size() && from_str<double>(args[i+1]) > 0) time_control.param = from_str<double>(args[++i]);
		}else if(arg == "-s" || arg == "--stats"){
			time_control.method = TimeControl::STATS;
			time_control.param = 2;
			if(i+1 < args.size() && from_str<double>(args[i+1]) > 0) time_control.param = from_str<double>(args[++i]);
		}else if((arg == "-m" || arg == "--move") && i+1 < args.size()){
			time_control.move = from_str<double>(args[++i]);
		}else if((arg == "-g" || arg == "--game") && i+1 < args.size()){
			time_control.game = from_str<float>(args[++i]);
			// TODO: should this only happen if the game hasn't started yet?
			time_control.remain = time_control.game;
		}else if((arg == "-f" || arg == "--flexible") && i+1 < args.size()){
			time_control.flexible = from_str<bool>(args[++i]);
		}else if((arg == "-i" || arg == "--maxsims") && i+1 < args.size()){
			time_control.max_sims = from_str<int>(args[++i]);
		}else if((arg == "-r" || arg == "--remain") && i+1 < args.size()){
			time_control.remain = from_str<double>(args[++i]);
		}else{
			return GTPResponse(false, "Missing or unknown parameter");
		}
	}

	return GTPResponse(true);
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x498, %rsp            # imm = 0x498
movq 0x8(%rdx), %rax
movq %rsi, (%rsp)
movq %rdi, 0x10(%rsp)
cmpq (%rdx), %rax
je 0x20240
leaq 0x18(%rsp), %r12
leaq 0x6387(%rip), %rbx      # 0x261d4
movq %rdx, %r15
xorl %r13d, %r13d
movq (%r15), %rsi
movq 0x8(%r15), %rcx
movl %r13d, %eax
subq %rsi, %rcx
sarq $0x5, %rcx
cmpq %rax, %rcx
jbe 0x20781
shlq $0x5, %rax
movq %r12, %rdi
addq %rax, %rsi
callq 0x5490
movq %r12, %rdi
movq %rbx, %rsi
callq 0x7c91
testb %al, %al
jne 0x1fe9e
leaq 0x6f7c(%rip), %rsi      # 0x26e0e
movq %r12, %rdi
callq 0x7c91
testb %al, %al
je 0x1ff08
movq (%rsp), %rax
movabsq $0x4024000000000000, %rcx # imm = 0x4024000000000000
leal 0x1(%r13), %ebp
movb $0x1, %r14b
andl $0x0, 0x30(%rax)
movq %rcx, 0x38(%rax)
movq (%r15), %rdi
movq 0x8(%r15), %rax
subq %rdi, %rax
sarq $0x5, %rax
cmpq %rbp, %rax
jbe 0x20222
movq %rbp, %rbx
shlq $0x5, %rbx
addq %rbx, %rdi
callq 0x1c89a
vucomisd 0x3317(%rip), %xmm0     # 0x23200
jbe 0x20018
addq (%r15), %rbx
movq %rbx, %rdi
callq 0x1c89a
movq (%rsp), %rax
vmovsd %xmm0, 0x38(%rax)
jmp 0x2001b
leaq 0x6186(%rip), %rsi      # 0x26095
movq %r12, %rdi
callq 0x7c91
testb %al, %al
jne 0x1ff2e
leaq 0x6ef6(%rip), %rsi      # 0x26e18
movq %r12, %rdi
callq 0x7c91
testb %al, %al
je 0x1ff92
movq (%rsp), %rax
movabsq $0x4000000000000000, %rcx # imm = 0x4000000000000000
leal 0x1(%r13), %ebp
movb $0x1, %r14b
movl $0x1, 0x30(%rax)
movq %rcx, 0x38(%rax)
movq (%r15), %rdi
movq 0x8(%r15), %rax
subq %rdi, %rax
sarq $0x5, %rax
cmpq %rbp, %rax
jbe 0x20222
movq %rbp, %rbx
shlq $0x5, %rbx
addq %rbx, %rdi
callq 0x1c89a
vucomisd 0x3284(%rip), %xmm0     # 0x23200
jbe 0x20018
addq (%r15), %rbx
movq %rbx, %rdi
callq 0x1c89a
jmp 0x1fefa
leaq 0x6143(%rip), %rsi      # 0x260dc
movq %r12, %rdi
callq 0x7c91
testb %al, %al
jne 0x1ffb8
leaq 0x6e73(%rip), %rsi      # 0x26e1f
movq %r12, %rdi
callq 0x7c91
testb %al, %al
je 0x20027
movq (%rsp), %rax
movabsq $0x4000000000000000, %rcx # imm = 0x4000000000000000
leal 0x1(%r13), %ebp
movb $0x1, %r14b
movl $0x2, 0x30(%rax)
movq %rcx, 0x38(%rax)
movq (%r15), %rdi
movq 0x8(%r15), %rax
subq %rdi, %rax
sarq $0x5, %rax
cmpq %rbp, %rax
jbe 0x20222
movq %rbp, %rbx
shlq $0x5, %rbx
addq %rbx, %rdi
callq 0x1c89a
vucomisd 0x31fa(%rip), %xmm0     # 0x23200
jbe 0x20018
addq (%r15), %rbx
movq %rbx, %rdi
callq 0x1c89a
jmp 0x1fefa
movl %r13d, %ebp
leaq 0x61b2(%rip), %rbx      # 0x261d4
jmp 0x20225
leaq 0x60cb(%rip), %rsi      # 0x260f9
movq %r12, %rdi
callq 0x7c91
testb %al, %al
jne 0x2004d
leaq 0x6de6(%rip), %rsi      # 0x26e27
movq %r12, %rdi
callq 0x7c91
testb %al, %al
je 0x20081
movq (%r15), %rdi
movq 0x8(%r15), %rax
leal 0x1(%r13), %ebp
subq %rdi, %rax
sarq $0x5, %rax
cmpq %rbp, %rax
jbe 0x20081
movq %rbp, %rax
shlq $0x5, %rax
addq %rax, %rdi
callq 0x1c89a
movq (%rsp), %rax
vmovsd %xmm0, 0x48(%rax)
jmp 0x2018f
leaq 0x6159(%rip), %rsi      # 0x261e1
movq %r12, %rdi
callq 0x7c91
testb %al, %al
jne 0x200a7
leaq 0x6d93(%rip), %rsi      # 0x26e2e
movq %r12, %rdi
callq 0x7c91
testb %al, %al
je 0x200e4
movq (%r15), %rdi
movq 0x8(%r15), %rax
leal 0x1(%r13), %ebp
subq %rdi, %rax
sarq $0x5, %rax
cmpq %rbp, %rax
jbe 0x200e4
movq %rbp, %rax
shlq $0x5, %rax
addq %rax, %rdi
callq 0xeac0
movq (%rsp), %rax
vcvtss2sd %xmm0, %xmm0, %xmm0
vmovsd %xmm0, 0x40(%rax)
vmovsd %xmm0, 0x60(%rax)
jmp 0x2018f
leaq 0x20b6(%rip), %rsi      # 0x221a1
movq %r12, %rdi
callq 0x7c91
testb %al, %al
jne 0x2010a
leaq 0x6d37(%rip), %rsi      # 0x26e35
movq %r12, %rdi
callq 0x7c91
testb %al, %al
je 0x20139
movq (%r15), %rdi
movq 0x8(%r15), %rax
leal 0x1(%r13), %ebp
subq %rdi, %rax
sarq $0x5, %rax
cmpq %rbp, %rax
jbe 0x20139
movq %rbp, %rax
shlq $0x5, %rax
addq %rax, %rdi
callq 0x1cae1
movq (%rsp), %rcx
movb %al, 0x50(%rcx)
jmp 0x2018f
leaq 0x6d00(%rip), %rsi      # 0x26e40
movq %r12, %rdi
callq 0x7c91
testb %al, %al
jne 0x2015f
leaq 0x6cf0(%rip), %rsi      # 0x26e43
movq %r12, %rdi
callq 0x7c91
testb %al, %al
je 0x20197
movq (%r15), %rdi
movq 0x8(%r15), %rax
leal 0x1(%r13), %ebp
subq %rdi, %rax
sarq $0x5, %rax
cmpq %rbp, %rax
jbe 0x20197
movq %rbp, %rax
shlq $0x5, %rax
addq %rax, %rdi
callq 0x94a7
movq (%rsp), %rcx
cltq
movq %rax, 0x58(%rcx)
movb $0x1, %r14b
jmp 0x2001b
leaq 0x5f84(%rip), %rsi      # 0x26122
movq %r12, %rdi
callq 0x7c91
testb %al, %al
jne 0x201bd
leaq 0x6c9c(%rip), %rsi      # 0x26e4d
movq %r12, %rdi
callq 0x7c91
testb %al, %al
je 0x201ec
movq (%r15), %rdi
movq 0x8(%r15), %rax
leal 0x1(%r13), %ebp
subq %rdi, %rax
sarq $0x5, %rax
cmpq %rbp, %rax
jbe 0x201ec
movq %rbp, %rax
shlq $0x5, %rax
addq %rax, %rdi
callq 0x1c89a
movq (%rsp), %rax
jmp 0x200da
leaq 0x478(%rsp), %r14
leaq 0x6005(%rip), %rsi      # 0x26200
leaq 0x38(%rsp), %rdx
movq %r14, %rdi
callq 0x5110
movq 0x10(%rsp), %rdi
xorl %esi, %esi
movq %r14, %rdx
callq 0x8d00
movq %r14, %rdi
callq 0x5150
xorl %r14d, %r14d
movl %r13d, %ebp
movq %r12, %rdi
callq 0x5150
incl %ebp
movl %ebp, %r13d
testb %r14b, %r14b
jne 0x1fe53
jmp 0x207b3
movq %rdi, %rbx
leaq 0x2692(%rip), %rsi      # 0x228dc
leaq 0x158(%rsp), %rdi
leaq 0xf(%rsp), %rdx
callq 0x5110
leaq 0x68c5(%rip), %rdx      # 0x26b28
leaq 0x178(%rsp), %rdi
leaq 0x158(%rsp), %rsi
callq 0x8051
leaq 0x68e6(%rip), %rdx      # 0x26b65
leaq 0x198(%rsp), %rdi
leaq 0x178(%rsp), %rsi
callq 0x8051
movq (%rsp), %rax
leaq 0x30(%rax), %rsi
leaq 0x138(%rsp), %rdi
callq 0x20ac0
leaq 0x1b8(%rsp), %rdi
leaq 0x198(%rsp), %rsi
leaq 0x138(%rsp), %rdx
callq 0xcf24
leaq 0x6676(%rip), %rdx      # 0x26943
leaq 0x1d8(%rsp), %rdi
leaq 0x1b8(%rsp), %rsi
callq 0x8051
movq (%rsp), %rax
vmovsd 0x38(%rax), %xmm0
leaq 0x118(%rsp), %rdi
callq 0x20b1f
leaq 0x1f8(%rsp), %rdi
leaq 0x1d8(%rsp), %rsi
leaq 0x118(%rsp), %rdx
callq 0xcf24
leaq 0x25c0(%rip), %rdx      # 0x228dc
leaq 0x218(%rsp), %rdi
leaq 0x1f8(%rsp), %rsi
callq 0x8051
leaq 0x685f(%rip), %rdx      # 0x26b97
leaq 0x238(%rsp), %rdi
leaq 0x218(%rsp), %rsi
callq 0x8051
leaq 0x6892(%rip), %rdx      # 0x26be6
leaq 0x258(%rsp), %rdi
leaq 0x238(%rsp), %rsi
callq 0x8051
leaq 0x68c4(%rip), %rdx      # 0x26c34
leaq 0x278(%rsp), %rdi
leaq 0x258(%rsp), %rsi
callq 0x8051
leaq 0x68f6(%rip), %rdx      # 0x26c82
leaq 0x298(%rsp), %rdi
leaq 0x278(%rsp), %rsi
callq 0x8051
leaq 0x68eb(%rip), %rdx      # 0x26c93
leaq 0x2b8(%rsp), %rdi
leaq 0x298(%rsp), %rsi
callq 0x8051
movq (%rsp), %rax
vmovsd 0x48(%rax), %xmm0
leaq 0xf8(%rsp), %rdi
callq 0x20b1f
leaq 0x2d8(%rsp), %rdi
leaq 0x2b8(%rsp), %rsi
leaq 0xf8(%rsp), %rdx
callq 0xcf24
leaq 0x67ec(%rip), %rdx      # 0x26be3
leaq 0x2f8(%rsp), %rdi
leaq 0x2d8(%rsp), %rsi
callq 0x8051
leaq 0x68c9(%rip), %rdx      # 0x26cdc
leaq 0x318(%rsp), %rdi
leaq 0x2f8(%rsp), %rsi
callq 0x8051
movq (%rsp), %rax
vmovsd 0x40(%rax), %xmm0
leaq 0xd8(%rsp), %rdi
callq 0x20b1f
leaq 0x338(%rsp), %rdi
leaq 0x318(%rsp), %rsi
leaq 0xd8(%rsp), %rdx
callq 0xcf24
leaq 0x6781(%rip), %rdx      # 0x26be3
leaq 0x358(%rsp), %rdi
leaq 0x338(%rsp), %rsi
callq 0x8051
leaq 0x68a7(%rip), %rdx      # 0x26d25
leaq 0x378(%rsp), %rdi
leaq 0x358(%rsp), %rsi
callq 0x8051
movq (%rsp), %rax
movzbl 0x50(%rax), %esi
leaq 0xb8(%rsp), %rdi
callq 0x1ca27
leaq 0x398(%rsp), %rdi
leaq 0x378(%rsp), %rsi
leaq 0xb8(%rsp), %rdx
callq 0xcf24
leaq 0x6717(%rip), %rdx      # 0x26be3
leaq 0x3b8(%rsp), %rdi
leaq 0x398(%rsp), %rsi
callq 0x8051
leaq 0x6886(%rip), %rdx      # 0x26d6e
leaq 0x3d8(%rsp), %rdi
leaq 0x3b8(%rsp), %rsi
callq 0x8051
movq (%rsp), %rax
movq 0x58(%rax), %rsi
leaq 0x98(%rsp), %rdi
callq 0x1c96d
leaq 0x3f8(%rsp), %rdi
leaq 0x3d8(%rsp), %rsi
leaq 0x98(%rsp), %rdx
callq 0xcf24
leaq 0x66ad(%rip), %rdx      # 0x26be3
leaq 0x418(%rsp), %rdi
leaq 0x3f8(%rsp), %rsi
callq 0x8051
leaq 0x6865(%rip), %rdx      # 0x26db7
leaq 0x438(%rsp), %rdi
leaq 0x418(%rsp), %rsi
callq 0x8051
leaq 0x6857(%rip), %rdx      # 0x26dc5
leaq 0x38(%rsp), %rdi
leaq 0x438(%rsp), %rsi
callq 0x8051
movq (%rsp), %rax
vmovsd 0x60(%rax), %xmm0
leaq 0x78(%rsp), %rdi
callq 0x20b1f
leaq 0x18(%rsp), %rdi
leaq 0x38(%rsp), %rsi
leaq 0x78(%rsp), %rdx
callq 0xcf24
leaq 0x6635(%rip), %rdx      # 0x26be3
leaq 0x458(%rsp), %rdi
leaq 0x18(%rsp), %rsi
callq 0x8051
pushq $0x1
popq %rsi
leaq 0x458(%rsp), %rdx
movq %rbx, %rdi
callq 0x8d00
leaq 0x458(%rsp), %rdi
callq 0x5150
leaq 0x18(%rsp), %rdi
callq 0x5150
leaq 0x78(%rsp), %rdi
callq 0x5150
leaq 0x38(%rsp), %rdi
callq 0x5150
leaq 0x438(%rsp), %rdi
callq 0x5150
leaq 0x418(%rsp), %rdi
callq 0x5150
leaq 0x3f8(%rsp), %rdi
callq 0x5150
leaq 0x98(%rsp), %rdi
callq 0x5150
leaq 0x3d8(%rsp), %rdi
callq 0x5150
leaq 0x3b8(%rsp), %rdi
callq 0x5150
leaq 0x398(%rsp), %rdi
callq 0x5150
leaq 0xb8(%rsp), %rdi
callq 0x5150
leaq 0x378(%rsp), %rdi
callq 0x5150
leaq 0x358(%rsp), %rdi
callq 0x5150
leaq 0x338(%rsp), %rdi
callq 0x5150
leaq 0xd8(%rsp), %rdi
callq 0x5150
leaq 0x318(%rsp), %rdi
callq 0x5150
leaq 0x2f8(%rsp), %rdi
callq 0x5150
leaq 0x2d8(%rsp), %rdi
callq 0x5150
leaq 0xf8(%rsp), %rdi
callq 0x5150
leaq 0x2b8(%rsp), %rdi
callq 0x5150
leaq 0x298(%rsp), %rdi
callq 0x5150
leaq 0x278(%rsp), %rdi
callq 0x5150
leaq 0x258(%rsp), %rdi
callq 0x5150
leaq 0x238(%rsp), %rdi
callq 0x5150
leaq 0x218(%rsp), %rdi
callq 0x5150
leaq 0x1f8(%rsp), %rdi
callq 0x5150
leaq 0x118(%rsp), %rdi
callq 0x5150
leaq 0x1d8(%rsp), %rdi
callq 0x5150
leaq 0x1b8(%rsp), %rdi
callq 0x5150
leaq 0x138(%rsp), %rdi
callq 0x5150
leaq 0x198(%rsp), %rdi
callq 0x5150
leaq 0x178(%rsp), %rdi
callq 0x5150
leaq 0x158(%rsp), %rdi
jmp 0x207ae
leaq 0x2155(%rip), %rsi      # 0x228dd
leaq 0x58(%rsp), %rdi
leaq 0x18(%rsp), %rdx
callq 0x5110
pushq $0x1
popq %rsi
movq 0x10(%rsp), %rdi
leaq 0x58(%rsp), %rdx
callq 0x8d00
leaq 0x58(%rsp), %rdi
callq 0x5150
movq 0x10(%rsp), %rax
addq $0x498, %rsp            # imm = 0x498
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
leaq 0x478(%rsp), %rdi
movq %rax, %rbx
callq 0x5150
jmp 0x20aae
jmp 0x20aab
leaq 0x58(%rsp), %rdi
movq %rax, %rbx
jmp 0x20ab3
jmp 0x20aa6
leaq 0x458(%rsp), %rdi
movq %rax, %rbx
callq 0x5150
jmp 0x2080b
movq %rax, %rbx
leaq 0x18(%rsp), %rdi
callq 0x5150
jmp 0x2081a
movq %rax, %rbx
leaq 0x78(%rsp), %rdi
callq 0x5150
jmp 0x20829
movq %rax, %rbx
leaq 0x38(%rsp), %rdi
callq 0x5150
jmp 0x20838
movq %rax, %rbx
leaq 0x438(%rsp), %rdi
callq 0x5150
leaq 0x418(%rsp), %rdi
callq 0x5150
leaq 0x3f8(%rsp), %rdi
callq 0x5150
leaq 0x98(%rsp), %rdi
callq 0x5150
leaq 0x3d8(%rsp), %rdi
callq 0x5150
leaq 0x3b8(%rsp), %rdi
callq 0x5150
leaq 0x398(%rsp), %rdi
callq 0x5150
leaq 0xb8(%rsp), %rdi
callq 0x5150
leaq 0x378(%rsp), %rdi
callq 0x5150
leaq 0x358(%rsp), %rdi
callq 0x5150
leaq 0x338(%rsp), %rdi
callq 0x5150
leaq 0xd8(%rsp), %rdi
callq 0x5150
leaq 0x318(%rsp), %rdi
callq 0x5150
leaq 0x2f8(%rsp), %rdi
callq 0x5150
leaq 0x2d8(%rsp), %rdi
callq 0x5150
leaq 0xf8(%rsp), %rdi
callq 0x5150
leaq 0x2b8(%rsp), %rdi
callq 0x5150
leaq 0x298(%rsp), %rdi
callq 0x5150
leaq 0x278(%rsp), %rdi
callq 0x5150
leaq 0x258(%rsp), %rdi
callq 0x5150
leaq 0x238(%rsp), %rdi
callq 0x5150
leaq 0x218(%rsp), %rdi
callq 0x5150
leaq 0x1f8(%rsp), %rdi
callq 0x5150
leaq 0x118(%rsp), %rdi
callq 0x5150
leaq 0x1d8(%rsp), %rdi
callq 0x5150
leaq 0x1b8(%rsp), %rdi
callq 0x5150
leaq 0x138(%rsp), %rdi
callq 0x5150
leaq 0x198(%rsp), %rdi
callq 0x5150
leaq 0x178(%rsp), %rdi
callq 0x5150
leaq 0x158(%rsp), %rdi
jmp 0x20ab3
movq %rax, %rbx
jmp 0x20845
movq %rax, %rbx
jmp 0x20852
movq %rax, %rbx
jmp 0x2085f
movq %rax, %rbx
jmp 0x2086c
movq %rax, %rbx
jmp 0x20879
movq %rax, %rbx
jmp 0x20886
movq %rax, %rbx
jmp 0x20893
movq %rax, %rbx
jmp 0x208a0
movq %rax, %rbx
jmp 0x208ad
movq %rax, %rbx
jmp 0x208ba
movq %rax, %rbx
jmp 0x208c7
movq %rax, %rbx
jmp 0x208d4
movq %rax, %rbx
jmp 0x208e1
movq %rax, %rbx
jmp 0x208ee
movq %rax, %rbx
jmp 0x208fb
movq %rax, %rbx
jmp 0x20908
movq %rax, %rbx
jmp 0x20915
movq %rax, %rbx
jmp 0x20922
movq %rax, %rbx
jmp 0x2092f
movq %rax, %rbx
jmp 0x2093c
movq %rax, %rbx
jmp 0x20949
movq %rax, %rbx
jmp 0x20956
movq %rax, %rbx
jmp 0x20963
movq %rax, %rbx
jmp 0x20970
movq %rax, %rbx
jmp 0x2097d
movq %rax, %rbx
jmp 0x2098a
movq %rax, %rbx
jmp 0x20997
movq %rax, %rbx
jmp 0x209a4
movq %rax, %rbx
jmp 0x209b1
movq %rax, %rbx
jmp 0x20ab8
movq %rax, %rbx
leaq 0x18(%rsp), %rdi
callq 0x5150
movq %rbx, %rdi
callq 0x5650