// File: /workspace/github_cpp_makefile_star2_O3/tewalds[P]pentagod/pentagod.cpp
// Function: main
int main(int argc, char **argv){
	Board::test();
	Move::test();

	srand(Time().in_msec());
	PentagoGTP gtp;

	gtp.colorboard = isatty(fileno(stdout));

	for(int i = 1; i < argc; i++) {
		string arg = argv[i];
		if(arg == "-h" || arg == "--help"){
			die(255, "Usage:\n"
				"\t-h --help     Show this help\n"
				"\t-v --verbose  Give more output over gtp\n"
				"\t-n --nocolor  Don't output the board in color\n"
				"\t-c --cmd      Pass a gtp command from the command line\n"
				"\t-f --file     Run this gtp file before reading from stdin\n"
				"\t-l --logfile  Log the gtp commands in standard format to this file\n"
				);
		}else if(arg == "-v" || arg == "--verbose"){
			gtp.verbose = true;
		}else if(arg == "-n" || arg == "--nocolor"){
			gtp.colorboard = false;
		}else if(arg == "-c" || arg == "--cmd"){
			char * ptr = argv[++i];
			if(ptr == NULL) die(255, "Missing a command");
			gtp.cmd(ptr);
		}else if(arg == "-f" || arg == "--file"){
			char * ptr = argv[++i];
			if(ptr == NULL) die(255, "Missing a file to run");
			FILE * fd = fopen(ptr, "r");
			gtp.setinfile(fd);
			gtp.setoutfile(NULL);
			if(!gtp.run())
				return 0;
			fclose(fd);
		}else if(arg == "-l" || arg == "--logfile"){
			char * ptr = argv[++i];
			if(ptr == NULL) die(255, "Missing a filename to log to");
			FILE * fd = fopen(ptr, "w");
			if(!fd) die(255, string("Failed to open file: ") + ptr);
			gtp.setlogfile(fd);
		}else{
			die(255, "Unknown argument: " + arg + ", try --help");
		}
	}

	gtp.setinfile(stdin);
	gtp.setoutfile(stdout);
	gtp.run();
	return 0;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x168, %rsp            # imm = 0x168
movq %rsi, %rbx
movl %edi, %ebp
callq 0x1743e
callq 0x191d8
leaq 0x88(%rsp), %r14
xorl %esi, %esi
movq %r14, %rdi
callq 0x4500
vcvtsi2sdq (%r14), %xmm0, %xmm0
vcvtsi2sdq 0x8(%r14), %xmm1, %xmm1
vdivsd 0x231a5(%rip), %xmm1, %xmm1 # 0x28008
vaddsd %xmm0, %xmm1, %xmm0
vmulsd 0x231a1(%rip), %xmm0, %xmm0 # 0x28010
vcvttsd2si %xmm0, %rdi
callq 0x42c0
movq 0x31150(%rip), %rax     # 0x35fd0
movq 0x31129(%rip), %r15     # 0x35fb0
leaq 0x88(%rsp), %r14
xorl %ecx, %ecx
movq %r14, %rdi
movq (%rax), %rsi
movq (%r15), %rdx
callq 0x537e
movq (%r15), %rdi
callq 0x4310
movl %eax, %edi
callq 0x4580
testl %eax, %eax
setne 0x54(%r14)
cmpl $0x2, %ebp
jl 0x5165
movl $0x1, %r15d
leaq 0x38(%rsp), %r13
leaq 0x28(%rsp), %r14
movslq %r15d, %r12
movq (%rbx,%r12,8), %rsi
leaq 0x8(%rsp), %rdx
movq %r14, %rdi
callq 0x4100
leaq 0x23277(%rip), %rsi     # 0x28160
movq %r14, %rdi
callq 0x40a0
testl %eax, %eax
je 0x51c0
leaq 0x23446(%rip), %rsi     # 0x28346
movq %r14, %rdi
callq 0x40a0
testl %eax, %eax
je 0x51c0
leaq 0x23381(%rip), %rsi     # 0x28298
movq %r14, %rdi
callq 0x40a0
testl %eax, %eax
je 0x503d
leaq 0x2336d(%rip), %rsi     # 0x2829b
movq %r14, %rdi
callq 0x40a0
testl %eax, %eax
je 0x503d
leaq 0x23360(%rip), %rsi     # 0x282a5
movq %r14, %rdi
callq 0x40a0
testl %eax, %eax
je 0x504d
leaq 0x2334c(%rip), %rsi     # 0x282a8
movq %r14, %rdi
callq 0x40a0
testl %eax, %eax
je 0x504d
leaq 0x2333f(%rip), %rsi     # 0x282b2
movq %r14, %rdi
callq 0x40a0
testl %eax, %eax
je 0x505a
leaq 0x2332b(%rip), %rsi     # 0x282b5
movq %r14, %rdi
callq 0x40a0
testl %eax, %eax
je 0x505a
leaq 0x2332c(%rip), %rsi     # 0x282cd
movq %r14, %rdi
callq 0x40a0
testl %eax, %eax
je 0x5106
leaq 0x23318(%rip), %rsi     # 0x282d0
movq %r14, %rdi
callq 0x40a0
testl %eax, %eax
je 0x5106
leaq 0x2331e(%rip), %rsi     # 0x282ed
movq %r14, %rdi
callq 0x40a0
testl %eax, %eax
je 0x4ff2
leaq 0x2330e(%rip), %rsi     # 0x282f0
movq %r14, %rdi
callq 0x40a0
testl %eax, %eax
jne 0x5291
movq 0x8(%rbx,%r12,8), %r13
testq %r13, %r13
je 0x526b
leaq 0x24c6b(%rip), %rsi     # 0x29c72
movq %r13, %rdi
callq 0x4380
testq %rax, %rax
je 0x523b
movq 0x98(%rsp), %rdi
movq %rax, %r12
testq %rdi, %rdi
je 0x502d
callq 0x42d0
incl %r15d
movq %r12, 0x98(%rsp)
jmp 0x5153
movl $0x1, 0xd8(%rsp)
jmp 0x50dd
movb $0x0, 0xdc(%rsp)
jmp 0x50dd
movq 0x8(%rbx,%r12,8), %rsi
testq %rsi, %rsi
je 0x51f5
leaq 0x68(%rsp), %r12
leaq 0x8(%rsp), %rdx
movq %r12, %rdi
callq 0x4100
leaq 0x120(%rsp), %rdi
leaq 0x88(%rsp), %rsi
movq %r12, %rdx
callq 0x76a8
movq 0x148(%rsp), %rdi
leaq 0x158(%rsp), %rax
cmpq %rax, %rdi
je 0x50ac
callq 0x42b0
movq 0x128(%rsp), %rdi
leaq 0x138(%rsp), %rax
cmpq %rax, %rdi
je 0x50c6
callq 0x42b0
movq 0x68(%rsp), %rdi
leaq 0x78(%rsp), %rax
cmpq %rax, %rdi
je 0x50da
callq 0x42b0
incl %r15d
movb $0x1, %r12b
movq 0x28(%rsp), %rdi
cmpq %r13, %rdi
je 0x50ef
callq 0x42b0
testb %r12b, %r12b
je 0x518d
incl %r15d
cmpl %ebp, %r15d
jl 0x4ece
jmp 0x5165
movq 0x8(%rbx,%r12,8), %rdi
testq %rdi, %rdi
je 0x5218
leaq 0x244fa(%rip), %rsi     # 0x29615
callq 0x4380
movq %rax, %r13
movq %rax, 0x88(%rsp)
movq $0x0, 0x90(%rsp)
leaq 0x88(%rsp), %rdi
callq 0x7a06
incl %r15d
testb %al, %al
je 0x5158
movq %r13, %rdi
callq 0x42d0
movb $0x1, %r12b
jmp 0x515b
xorl %r12d, %r12d
leaq 0x38(%rsp), %r13
jmp 0x50e0
movq 0x30e64(%rip), %rax     # 0x35fd0
movq 0x30e3d(%rip), %rcx     # 0x35fb0
leaq 0x88(%rsp), %rdi
movq (%rax), %rax
movq %rax, (%rdi)
movq (%rcx), %rax
movq %rax, 0x8(%rdi)
callq 0x7a06
movq 0xc0(%rsp), %rdi
testq %rdi, %rdi
je 0x519f
callq 0x42b0
leaq 0x88(%rsp), %rdi
callq 0x864a
xorl %eax, %eax
addq $0x168, %rsp            # imm = 0x168
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
leaq 0x18(%rsp), %rax
movq %rax, -0x10(%rax)
leaq 0x22f93(%rip), %rsi     # 0x28163
leaq 0x230c0(%rip), %rdx     # 0x28297
leaq 0x8(%rsp), %rdi
callq 0xa810
movq 0x8(%rsp), %rdi
callq 0x4490
movl $0xff, %edi
callq 0x43b0
leaq 0x18(%rsp), %rax
movq %rax, -0x10(%rax)
leaq 0x230b6(%rip), %rsi     # 0x282bb
leaq 0x230c0(%rip), %rdx     # 0x282cc
leaq 0x8(%rsp), %rdi
callq 0xa810
jmp 0x51e1
leaq 0x18(%rsp), %rax
movq %rax, -0x10(%rax)
leaq 0x230af(%rip), %rsi     # 0x282d7
leaq 0x230bd(%rip), %rdx     # 0x282ec
leaq 0x8(%rsp), %rdi
callq 0xa810
jmp 0x51e1
leaq 0x58(%rsp), %r14
movq %r14, -0x10(%r14)
leaq 0x230cc(%rip), %rsi     # 0x28317
leaq 0x230da(%rip), %rdx     # 0x2832c
leaq 0x48(%rsp), %rdi
callq 0xa810
leaq 0x48(%rsp), %rdi
movq %r13, %rsi
callq 0x4610
jmp 0x52b8
leaq 0x18(%rsp), %rax
movq %rax, -0x10(%rax)
leaq 0x2307f(%rip), %rsi     # 0x282fa
leaq 0x23094(%rip), %rdx     # 0x28316
leaq 0x8(%rsp), %rdi
callq 0xa810
jmp 0x51e1
leaq 0x23095(%rip), %rsi     # 0x2832d
leaq 0x48(%rsp), %rdi
leaq 0x28(%rsp), %rdx
callq 0x7bb7
leaq 0x23092(%rip), %rsi     # 0x28340
leaq 0x48(%rsp), %rdi
callq 0x4610
leaq 0x18(%rsp), %rdi
movq %rax, %rcx
addq $0x10, %rcx
movq %rdi, -0x10(%rdi)
movq (%rax), %rdx
cmpq %rcx, %rdx
jne 0x52da
vmovupd (%rcx), %xmm0
vmovupd %xmm0, (%rdi)
jmp 0x52ea
movq %rdx, 0x8(%rsp)
movq %rdx, %rdi
movq (%rcx), %rsi
movq %rsi, 0x18(%rsp)
movq 0x8(%rax), %rdx
movq %rdx, 0x10(%rsp)
movq %rcx, (%rax)
movq $0x0, 0x8(%rax)
movb $0x0, 0x10(%rax)
jmp 0x51e6
movq %rax, %rbx
leaq 0x58(%rsp), %rax
movq -0x10(%rax), %rdi
jmp 0x533f
movq 0x48(%rsp), %rdi
movq %rax, %rbx
cmpq %r14, %rdi
jne 0x5344
jmp 0x5355
jmp 0x5352
jmp 0x5352
jmp 0x5352
jmp 0x5352
jmp 0x5352
jmp 0x5352
jmp 0x534d
movq 0x68(%rsp), %rdi
movq %rax, %rbx
leaq 0x78(%rsp), %rax
cmpq %rax, %rdi
je 0x5355
callq 0x42b0
jmp 0x5355
jmp 0x5352
movq %rax, %rbx
jmp 0x5369
movq %rax, %rbx
movq 0x28(%rsp), %rdi
leaq 0x38(%rsp), %rax
cmpq %rax, %rdi
je 0x5369
callq 0x42b0
leaq 0x88(%rsp), %rdi
callq 0x7c38
movq %rbx, %rdi
callq 0x45b0