// File: /workspace/github_cpp_makefile_star2_O1/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 0x17630
callq 0x196a4
leaq 0x88(%rsp), %r14
movq %r14, %rdi
xorl %esi, %esi
callq 0x4500
vcvtsi2sdq (%r14), %xmm0, %xmm0
vcvtsi2sdq 0x8(%r14), %xmm1, %xmm1
vdivsd 0x24215(%rip), %xmm1, %xmm1 # 0x29008
vaddsd %xmm0, %xmm1, %xmm0
vmulsd 0x24211(%rip), %xmm0, %xmm0 # 0x29010
vcvttsd2si %xmm0, %rdi
callq 0x42c0
movq 0x321c0(%rip), %rax     # 0x36fd0
movq (%rax), %rsi
movq 0x32196(%rip), %r15     # 0x36fb0
movq (%r15), %rdx
leaq 0x88(%rsp), %r14
movq %r14, %rdi
xorl %ecx, %ecx
callq 0x530c
movq (%r15), %rdi
callq 0x4310
movl %eax, %edi
callq 0x4580
testl %eax, %eax
setne 0x54(%r14)
cmpl $0x2, %ebp
jl 0x50f5
movl $0x1, %r15d
leaq 0x38(%rsp), %r13
leaq 0x28(%rsp), %r14
movslq %r15d, %r12
movq (%rbx,%r12,8), %rsi
movq %r14, %rdi
leaq 0x8(%rsp), %rdx
callq 0x4100
movq %r14, %rdi
leaq 0x242e4(%rip), %rsi     # 0x29160
callq 0x40a0
testl %eax, %eax
je 0x5150
movq %r14, %rdi
leaq 0x244b3(%rip), %rsi     # 0x29346
callq 0x40a0
testl %eax, %eax
je 0x5150
movq %r14, %rdi
leaq 0x243ee(%rip), %rsi     # 0x29298
callq 0x40a0
testl %eax, %eax
je 0x4fcd
movq %r14, %rdi
leaq 0x243da(%rip), %rsi     # 0x2929b
callq 0x40a0
testl %eax, %eax
je 0x4fcd
movq %r14, %rdi
leaq 0x243cd(%rip), %rsi     # 0x292a5
callq 0x40a0
testl %eax, %eax
je 0x4fdd
movq %r14, %rdi
leaq 0x243b9(%rip), %rsi     # 0x292a8
callq 0x40a0
testl %eax, %eax
je 0x4fdd
movq %r14, %rdi
leaq 0x243ac(%rip), %rsi     # 0x292b2
callq 0x40a0
testl %eax, %eax
je 0x4fea
movq %r14, %rdi
leaq 0x24398(%rip), %rsi     # 0x292b5
callq 0x40a0
testl %eax, %eax
je 0x4fea
movq %r14, %rdi
leaq 0x24399(%rip), %rsi     # 0x292cd
callq 0x40a0
testl %eax, %eax
je 0x5096
movq %r14, %rdi
leaq 0x24385(%rip), %rsi     # 0x292d0
callq 0x40a0
testl %eax, %eax
je 0x5096
movq %r14, %rdi
leaq 0x2438b(%rip), %rsi     # 0x292ed
callq 0x40a0
testl %eax, %eax
je 0x4f82
movq %r14, %rdi
leaq 0x2437b(%rip), %rsi     # 0x292f0
callq 0x40a0
testl %eax, %eax
jne 0x5221
movq 0x8(%rbx,%r12,8), %r13
testq %r13, %r13
je 0x51fb
movq %r13, %rdi
leaq 0x25ce8(%rip), %rsi     # 0x2ac82
callq 0x4380
testq %rax, %rax
je 0x51cb
movq %rax, %r12
movq 0x98(%rsp), %rdi
testq %rdi, %rdi
je 0x4fbd
callq 0x42d0
incl %r15d
movq %r12, 0x98(%rsp)
jmp 0x50e3
movl $0x1, 0xd8(%rsp)
jmp 0x506d
movb $0x0, 0xdc(%rsp)
jmp 0x506d
movq 0x8(%rbx,%r12,8), %rsi
testq %rsi, %rsi
je 0x5185
leaq 0x68(%rsp), %r12
movq %r12, %rdi
leaq 0x8(%rsp), %rdx
callq 0x4100
leaq 0x120(%rsp), %rdi
leaq 0x88(%rsp), %rsi
movq %r12, %rdx
callq 0x768e
movq 0x148(%rsp), %rdi
leaq 0x158(%rsp), %rax
cmpq %rax, %rdi
je 0x503c
callq 0x42b0
movq 0x128(%rsp), %rdi
leaq 0x138(%rsp), %rax
cmpq %rax, %rdi
je 0x5056
callq 0x42b0
movq 0x68(%rsp), %rdi
leaq 0x78(%rsp), %rax
cmpq %rax, %rdi
je 0x506a
callq 0x42b0
incl %r15d
movb $0x1, %r12b
movq 0x28(%rsp), %rdi
cmpq %r13, %rdi
je 0x507f
callq 0x42b0
testb %r12b, %r12b
je 0x511d
incl %r15d
cmpl %ebp, %r15d
jl 0x4e5e
jmp 0x50f5
movq 0x8(%rbx,%r12,8), %rdi
testq %rdi, %rdi
je 0x51a8
leaq 0x2557a(%rip), %rsi     # 0x2a625
callq 0x4380
movq %rax, %r13
movq %rax, 0x88(%rsp)
movq $0x0, 0x90(%rsp)
leaq 0x88(%rsp), %rdi
callq 0x79ec
incl %r15d
testb %al, %al
je 0x50e8
movq %r13, %rdi
callq 0x42d0
movb $0x1, %r12b
jmp 0x50eb
xorl %r12d, %r12d
leaq 0x38(%rsp), %r13
jmp 0x5070
movq 0x31ed4(%rip), %rax     # 0x36fd0
movq (%rax), %rax
leaq 0x88(%rsp), %rdi
movq %rax, (%rdi)
movq 0x31e9f(%rip), %rax     # 0x36fb0
movq (%rax), %rax
movq %rax, 0x8(%rdi)
callq 0x79ec
movq 0xc0(%rsp), %rdi
testq %rdi, %rdi
je 0x512f
callq 0x42b0
leaq 0x88(%rsp), %rdi
callq 0x8608
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 0x24003(%rip), %rsi     # 0x29163
leaq 0x24130(%rip), %rdx     # 0x29297
leaq 0x8(%rsp), %rdi
callq 0xa874
movq 0x8(%rsp), %rdi
callq 0x4490
movl $0xff, %edi
callq 0x43b0
leaq 0x18(%rsp), %rax
movq %rax, -0x10(%rax)
leaq 0x24126(%rip), %rsi     # 0x292bb
leaq 0x24130(%rip), %rdx     # 0x292cc
leaq 0x8(%rsp), %rdi
callq 0xa874
jmp 0x5171
leaq 0x18(%rsp), %rax
movq %rax, -0x10(%rax)
leaq 0x2411f(%rip), %rsi     # 0x292d7
leaq 0x2412d(%rip), %rdx     # 0x292ec
leaq 0x8(%rsp), %rdi
callq 0xa874
jmp 0x5171
leaq 0x58(%rsp), %r14
movq %r14, -0x10(%r14)
leaq 0x2413c(%rip), %rsi     # 0x29317
leaq 0x2414a(%rip), %rdx     # 0x2932c
leaq 0x48(%rsp), %rdi
callq 0xa874
leaq 0x48(%rsp), %rdi
movq %r13, %rsi
callq 0x4610
jmp 0x5248
leaq 0x18(%rsp), %rax
movq %rax, -0x10(%rax)
leaq 0x240ef(%rip), %rsi     # 0x292fa
leaq 0x24104(%rip), %rdx     # 0x29316
leaq 0x8(%rsp), %rdi
callq 0xa874
jmp 0x5171
leaq 0x24105(%rip), %rsi     # 0x2932d
leaq 0x48(%rsp), %rdi
leaq 0x28(%rsp), %rdx
callq 0x7b95
leaq 0x24102(%rip), %rsi     # 0x29340
leaq 0x48(%rsp), %rdi
callq 0x4610
leaq 0x18(%rsp), %rdx
movq %rdx, -0x10(%rdx)
movq (%rax), %rsi
movq %rax, %rcx
addq $0x10, %rcx
cmpq %rcx, %rsi
jne 0x526a
vmovupd (%rcx), %xmm0
vmovupd %xmm0, (%rdx)
jmp 0x5277
movq %rsi, 0x8(%rsp)
movq (%rcx), %rdx
movq %rdx, 0x18(%rsp)
movq 0x8(%rax), %rdx
movq %rdx, 0x10(%rsp)
movq %rcx, (%rax)
movq $0x0, 0x8(%rax)
movb $0x0, 0x10(%rax)
jmp 0x5171
movq %rax, %rbx
leaq 0x58(%rsp), %rax
movq -0x10(%rax), %rdi
jmp 0x52cc
movq %rax, %rbx
movq 0x48(%rsp), %rdi
cmpq %r14, %rdi
jne 0x52d1
jmp 0x52e2
jmp 0x52df
jmp 0x52df
jmp 0x52df
jmp 0x52df
jmp 0x52df
jmp 0x52df
jmp 0x52da
movq %rax, %rbx
movq 0x68(%rsp), %rdi
leaq 0x78(%rsp), %rax
cmpq %rax, %rdi
je 0x52e2
callq 0x42b0
jmp 0x52e2
jmp 0x52df
movq %rax, %rbx
jmp 0x52f6
movq %rax, %rbx
movq 0x28(%rsp), %rdi
leaq 0x38(%rsp), %rax
cmpq %rax, %rdi
je 0x52f6
callq 0x42b0
leaq 0x88(%rsp), %rdi
callq 0x7c16
movq %rbx, %rdi
callq 0x45b0
nop