// File: /workspace/github_cpp_makefile_star2_O2/tewalds[P]morat/hex/main.cpp
// Function: main
int main(int argc, char **argv){

	srand(Time().in_usec());
	GTP 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"
				);
		}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{
			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 $0x1b8, %rsp            # imm = 0x1B8
leaq 0x90(%rsp), %r14
movl %edi, 0xc(%rsp)
movq %rsi, (%rsp)
movq %r14, %rdi
callq 0x5ca0
vmovsd (%r14), %xmm0
vmulsd 0x1c6a4(%rip), %xmm0, %xmm0 # 0x22008
vcvttsd2usi %xmm0, %rdi
callq 0x5310
movq 0x3664a(%rip), %rax     # 0x3bfc0
movq 0x3662b(%rip), %r15     # 0x3bfa8
leaq 0x90(%rsp), %r14
movq %r14, %rdi
movq (%rax), %rsi
movq (%r15), %rdx
callq 0x5cdc
movq (%r15), %rdi
callq 0x5360
movl %eax, %edi
callq 0x5620
testl %eax, %eax
setne 0xcd(%r14)
pushq $0x1
popq %r14
leaq 0x50(%rsp), %r15
leaq 0x70(%rsp), %r12
leaq 0x170(%rsp), %rbp
cmpl 0xc(%rsp), %r14d
jge 0x5b8b
movq (%rsp), %rax
movslq %r14d, %r13
movq (%rax,%r13,8), %rsi
leaq 0x10(%rsp), %rdx
movq %r15, %rdi
callq 0x5110
leaq 0x1c68c(%rip), %rsi     # 0x22078
movq %r15, %rdi
callq 0x7c91
testb %al, %al
jne 0x5bd4
leaq 0x1c7d7(%rip), %rsi     # 0x221da
movq %r15, %rdi
callq 0x7c91
testb %al, %al
jne 0x5bd4
leaq 0x1c752(%rip), %rsi     # 0x2216c
movq %r15, %rdi
callq 0x7c91
testb %al, %al
jne 0x5a39
leaq 0x1c742(%rip), %rsi     # 0x2216f
movq %r15, %rdi
callq 0x7c91
testb %al, %al
je 0x5a60
movl $0x1, 0x158(%rsp)
movb $0x1, %r13b
movq %r15, %rdi
callq 0x5150
incl %r14d
testb %r13b, %r13b
jne 0x59c2
jmp 0x5bb3
leaq 0x1c712(%rip), %rsi     # 0x22179
movq %r15, %rdi
callq 0x7c91
testb %al, %al
jne 0x5a86
leaq 0x1c702(%rip), %rsi     # 0x2217c
movq %r15, %rdi
callq 0x7c91
testb %al, %al
je 0x5a90
movb $0x0, 0x15d(%rsp)
jmp 0x5a44
leaq 0x1c6ef(%rip), %rsi     # 0x22186
movq %r15, %rdi
callq 0x7c91
testb %al, %al
jne 0x5ab6
leaq 0x1c6df(%rip), %rsi     # 0x22189
movq %r15, %rdi
callq 0x7c91
testb %al, %al
je 0x5b06
movq (%rsp), %rax
movq 0x8(%rax,%r13,8), %rsi
testq %rsi, %rsi
je 0x5bf9
leaq 0x10(%rsp), %rdx
movq %r12, %rdi
movq %r12, %r13
callq 0x5110
leaq 0x90(%rsp), %rsi
movq %rbp, %rbx
movq %rbp, %rdi
movq %r13, %rdx
callq 0x7c9e
movq %rbx, %rdi
incl %r14d
callq 0x7ef6
movq %r13, %rdi
callq 0x5150
jmp 0x5a44
leaq 0x1c694(%rip), %rsi     # 0x221a1
movq %r15, %rdi
callq 0x7c91
testb %al, %al
jne 0x5b30
leaq 0x1c684(%rip), %rsi     # 0x221a4
movq %r15, %rdi
callq 0x7c91
testb %al, %al
je 0x5c29
movq (%rsp), %rax
movq 0x8(%rax,%r13,8), %rdi
testq %rdi, %rdi
je 0x5c11
leaq 0x205da(%rip), %rsi     # 0x26123
callq 0x53f0
movq %rax, 0x90(%rsp)
andq $0x0, 0x98(%rsp)
movq %rax, %rbx
leaq 0x90(%rsp), %rdi
callq 0x7f10
incl %r14d
testb %al, %al
je 0x5b83
movq %rbx, %rdi
callq 0x5330
jmp 0x5a44
xorl %r13d, %r13d
jmp 0x5a47
movq 0x3642e(%rip), %rax     # 0x3bfc0
movq 0x3640f(%rip), %rcx     # 0x3bfa8
leaq 0x90(%rsp), %rdi
movq (%rax), %rax
movq %rax, (%rdi)
movq (%rcx), %rax
movq %rax, 0x8(%rdi)
callq 0x7f10
leaq 0x90(%rsp), %rdi
callq 0x80e6
xorl %eax, %eax
addq $0x1b8, %rsp            # imm = 0x1B8
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
leaq 0x1c4a0(%rip), %rsi     # 0x2207b
leaq 0x10(%rsp), %rdi
leaq 0x30(%rsp), %rdx
callq 0x5110
leaq 0x10(%rsp), %rsi
movl $0xff, %edi
callq 0x591c
leaq 0x1c58f(%rip), %rsi     # 0x2218f
leaq 0x10(%rsp), %rdi
leaq 0x30(%rsp), %rdx
callq 0x5110
jmp 0x5bea
leaq 0x1c593(%rip), %rsi     # 0x221ab
leaq 0x10(%rsp), %rdi
leaq 0x30(%rsp), %rdx
callq 0x5110
jmp 0x5bea
leaq 0x1c591(%rip), %rsi     # 0x221c1
leaq 0x30(%rsp), %rdi
leaq 0x50(%rsp), %rdx
callq 0x8070
leaq 0x1c58e(%rip), %rdx     # 0x221d4
leaq 0x10(%rsp), %rdi
leaq 0x30(%rsp), %rsi
callq 0x8051
jmp 0x5bea
leaq 0x30(%rsp), %rdi
jmp 0x5c6d
jmp 0x5c79
jmp 0x5c79
jmp 0x5c79
jmp 0x5c79
jmp 0x5c88
leaq 0x70(%rsp), %rdi
movq %rax, %rbx
callq 0x5150
jmp 0x5c7c
jmp 0x5c79
movq %rax, %rbx
leaq 0x50(%rsp), %rdi
callq 0x5150
jmp 0x5c8b
movq %rax, %rbx
leaq 0x90(%rsp), %rdi
callq 0x80e6
movq %rbx, %rdi
callq 0x5650