// File: /workspace/github_cpp_makefile_star2_O2/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 $0x178, %rsp            # imm = 0x178
movq %rsi, 0x8(%rsp)
movl %edi, 0x14(%rsp)
callq 0x10792
callq 0x1204c
leaq 0x78(%rsp), %r14
movq %r14, %rdi
callq 0x4c50
vmovsd (%r14), %xmm0
vmulsd 0x1779c(%rip), %xmm0, %xmm0 # 0x1c008
vcvttsd2si %xmm0, %rdi
callq 0x42d0
movq 0x2675b(%rip), %rax     # 0x2afd8
movq 0x2673c(%rip), %r15     # 0x2afc0
leaq 0x78(%rsp), %r14
xorl %ecx, %ecx
movq %r14, %rdi
movq (%rax), %rsi
movq (%r15), %rdx
callq 0x4c8c
movq (%r15), %rdi
callq 0x4310
movl %eax, %edi
callq 0x4560
testl %eax, %eax
setne 0x54(%r14)
pushq $0x1
popq %r14
leaq 0x58(%rsp), %r15
leaq 0x110(%rsp), %r12
leaq 0x130(%rsp), %rbp
cmpl 0x14(%rsp), %r14d
jge 0x4af1
movq 0x8(%rsp), %rax
movslq %r14d, %r13
movq (%rax,%r13,8), %rsi
leaq 0x18(%rsp), %rdx
movq %r15, %rdi
callq 0x40f0
leaq 0x1786d(%rip), %rsi     # 0x1c160
movq %r15, %rdi
callq 0x6462
testb %al, %al
jne 0x4b34
leaq 0x17a3c(%rip), %rsi     # 0x1c346
movq %r15, %rdi
callq 0x6462
testb %al, %al
jne 0x4b34
leaq 0x17977(%rip), %rsi     # 0x1c298
movq %r15, %rdi
callq 0x6462
testb %al, %al
jne 0x4940
leaq 0x17967(%rip), %rsi     # 0x1c29b
movq %r15, %rdi
callq 0x6462
testb %al, %al
je 0x4967
movl $0x1, 0xc8(%rsp)
movb $0x1, %r13b
movq %r15, %rdi
callq 0x4130
incl %r14d
testb %r13b, %r13b
jne 0x48c8
jmp 0x4b16
leaq 0x17937(%rip), %rsi     # 0x1c2a5
movq %r15, %rdi
callq 0x6462
testb %al, %al
jne 0x498d
leaq 0x17927(%rip), %rsi     # 0x1c2a8
movq %r15, %rdi
callq 0x6462
testb %al, %al
je 0x4997
movb $0x0, 0xcc(%rsp)
jmp 0x494b
leaq 0x17914(%rip), %rsi     # 0x1c2b2
movq %r15, %rdi
callq 0x6462
testb %al, %al
jne 0x49bd
leaq 0x17904(%rip), %rsi     # 0x1c2b5
movq %r15, %rdi
callq 0x6462
testb %al, %al
je 0x4a0b
movq 0x8(%rsp), %rax
movq 0x8(%rax,%r13,8), %rsi
testq %rsi, %rsi
je 0x4b59
leaq 0x18(%rsp), %rdx
movq %r12, %rdi
movq %r12, %r13
callq 0x40f0
leaq 0x78(%rsp), %rsi
movq %rbp, %rbx
movq %rbp, %rdi
movq %r13, %rdx
callq 0x6470
movq %rbx, %rdi
incl %r14d
callq 0x66c6
movq %r13, %rdi
callq 0x4130
jmp 0x494b
leaq 0x178bb(%rip), %rsi     # 0x1c2cd
movq %r15, %rdi
callq 0x6462
testb %al, %al
jne 0x4a31
leaq 0x178ab(%rip), %rsi     # 0x1c2d0
movq %r15, %rdi
callq 0x6462
testb %al, %al
je 0x4a87
movq 0x8(%rsp), %rax
movq 0x8(%rax,%r13,8), %rdi
testq %rdi, %rdi
je 0x4b71
leaq 0x18b9a(%rip), %rsi     # 0x1d5e5
callq 0x4380
movq %rax, 0x78(%rsp)
andq $0x0, 0x80(%rsp)
movq %rax, %rbx
leaq 0x78(%rsp), %rdi
callq 0x66e0
incl %r14d
testb %al, %al
je 0x4a7f
movq %rbx, %rdi
callq 0x42e0
jmp 0x494b
xorl %r13d, %r13d
jmp 0x494e
leaq 0x1785f(%rip), %rsi     # 0x1c2ed
movq %r15, %rdi
callq 0x6462
testb %al, %al
jne 0x4ab1
leaq 0x1784f(%rip), %rsi     # 0x1c2f0
movq %r15, %rdi
callq 0x6462
testb %al, %al
je 0x4bce
movq 0x8(%rsp), %rax
movq 0x8(%rax,%r13,8), %rbx
testq %rbx, %rbx
je 0x4bb3
leaq 0x19177(%rip), %rsi     # 0x1dc42
movq %rbx, %rdi
callq 0x4380
testq %rax, %rax
je 0x4b89
leaq 0x78(%rsp), %rdi
movq %rax, %rsi
callq 0x6840
incl %r14d
jmp 0x494b
movq 0x264e0(%rip), %rax     # 0x2afd8
movq 0x264c1(%rip), %rcx     # 0x2afc0
leaq 0x78(%rsp), %rdi
movq (%rax), %rax
movq %rax, (%rdi)
movq (%rcx), %rax
movq %rax, 0x8(%rdi)
callq 0x66e0
leaq 0x78(%rsp), %rdi
callq 0x68da
xorl %eax, %eax
addq $0x178, %rsp            # imm = 0x178
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
leaq 0x17628(%rip), %rsi     # 0x1c163
leaq 0x18(%rsp), %rdi
leaq 0x38(%rsp), %rdx
callq 0x40f0
leaq 0x18(%rsp), %rsi
movl $0xff, %edi
callq 0x481c
leaq 0x1775b(%rip), %rsi     # 0x1c2bb
leaq 0x18(%rsp), %rdi
leaq 0x38(%rsp), %rdx
callq 0x40f0
jmp 0x4b4a
leaq 0x1775f(%rip), %rsi     # 0x1c2d7
leaq 0x18(%rsp), %rdi
leaq 0x38(%rsp), %rdx
callq 0x40f0
jmp 0x4b4a
leaq 0x17787(%rip), %rsi     # 0x1c317
leaq 0x38(%rsp), %rdi
leaq 0x7(%rsp), %rdx
callq 0x40f0
leaq 0x18(%rsp), %rdi
leaq 0x38(%rsp), %rsi
movq %rbx, %rdx
callq 0x6821
jmp 0x4b4a
leaq 0x17740(%rip), %rsi     # 0x1c2fa
leaq 0x18(%rsp), %rdi
leaq 0x38(%rsp), %rdx
callq 0x40f0
jmp 0x4b4a
leaq 0x17758(%rip), %rsi     # 0x1c32d
leaq 0x38(%rsp), %rdi
leaq 0x58(%rsp), %rdx
callq 0x6864
leaq 0x17755(%rip), %rdx     # 0x1c340
leaq 0x18(%rsp), %rdi
leaq 0x38(%rsp), %rsi
callq 0x6821
jmp 0x4b4a
jmp 0x4c01
leaq 0x38(%rsp), %rdi
jmp 0x4c20
jmp 0x4c2c
jmp 0x4c2c
jmp 0x4c2c
jmp 0x4c2c
jmp 0x4c2c
jmp 0x4c2c
jmp 0x4c2c
jmp 0x4c3b
leaq 0x110(%rsp), %rdi
movq %rax, %rbx
callq 0x4130
jmp 0x4c2f
jmp 0x4c2c
movq %rax, %rbx
leaq 0x58(%rsp), %rdi
callq 0x4130
jmp 0x4c3e
movq %rax, %rbx
leaq 0x78(%rsp), %rdi
callq 0x68da
movq %rbx, %rdi
callq 0x4590