// File: 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:
subq $0x2e8, %rsp            # imm = 0x2E8
movl $0x0, 0x2e4(%rsp)
movl %edi, 0x2e0(%rsp)
movq %rsi, 0x2d8(%rsp)
leaq 0x2d0(%rsp), %rdi
callq 0x6780
leaq 0x2d0(%rsp), %rdi
callq 0x67d0
movl %eax, %edi
callq 0x53c0
movq 0x6702f(%rip), %rax     # 0x6cfb8
movq (%rax), %rsi
movq 0x67005(%rip), %rax     # 0x6cf98
movq (%rax), %rdx
leaq 0x1f0(%rsp), %rdi
callq 0x6800
movq 0x66fee(%rip), %rax     # 0x6cf98
movq (%rax), %rdi
callq 0x5430
movl %eax, %edi
callq 0x5740
cmpl $0x0, %eax
setne %al
andb $0x1, %al
movb %al, 0x2bd(%rsp)
movl $0x1, 0x1ec(%rsp)
movl 0x1ec(%rsp), %eax
cmpl 0x2e0(%rsp), %eax
jge 0x66d3
movq 0x2d8(%rsp), %rax
movslq 0x1ec(%rsp), %rcx
movq (%rax,%rcx,8), %rax
movq %rax, 0x58(%rsp)
leaq 0x1c7(%rsp), %rdi
movq %rdi, 0x60(%rsp)
callq 0x5770
movq 0x58(%rsp), %rsi
movq 0x60(%rsp), %rdx
leaq 0x1c8(%rsp), %rdi
callq 0x5590
jmp 0x602b
leaq 0x1c7(%rsp), %rdi
callq 0x5450
leaq 0x46045(%rip), %rsi     # 0x4c084
leaq 0x1c8(%rsp), %rdi
callq 0xb0f0
movb %al, 0x57(%rsp)
jmp 0x6052
movb 0x57(%rsp), %al
testb $0x1, %al
jne 0x6083
jmp 0x605c
leaq 0x46183(%rip), %rsi     # 0x4c1e6
leaq 0x1c8(%rsp), %rdi
callq 0xb0f0
movb %al, 0x56(%rsp)
jmp 0x6076
movb 0x56(%rsp), %al
testb $0x1, %al
jne 0x6083
jmp 0x616b
leaq 0x18f(%rsp), %rdi
movq %rdi, 0x48(%rsp)
callq 0x5770
movq 0x48(%rsp), %rdx
leaq 0x45fe6(%rip), %rsi     # 0x4c087
leaq 0x190(%rsp), %rdi
callq 0x5590
jmp 0x60b0
movl $0xff, %edi
leaq 0x190(%rsp), %rsi
callq 0x5f00
jmp 0x60c4
leaq 0x190(%rsp), %rdi
callq 0x5260
leaq 0x18f(%rsp), %rdi
callq 0x5450
jmp 0x6680
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x1b8(%rsp)
movl %eax, 0x1b4(%rsp)
leaq 0x1c7(%rsp), %rdi
callq 0x5450
jmp 0x675e
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x1b8(%rsp)
movl %eax, 0x1b4(%rsp)
jmp 0x66c1
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x1b8(%rsp)
movl %eax, 0x1b4(%rsp)
jmp 0x6159
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x1b8(%rsp)
movl %eax, 0x1b4(%rsp)
leaq 0x190(%rsp), %rdi
callq 0x5260
leaq 0x18f(%rsp), %rdi
callq 0x5450
jmp 0x66c1
leaq 0x46006(%rip), %rsi     # 0x4c178
leaq 0x1c8(%rsp), %rdi
callq 0xb0f0
movb %al, 0x47(%rsp)
jmp 0x6185
movb 0x47(%rsp), %al
testb $0x1, %al
jne 0x61b3
jmp 0x618f
leaq 0x45fe5(%rip), %rsi     # 0x4c17b
leaq 0x1c8(%rsp), %rdi
callq 0xb0f0
movb %al, 0x46(%rsp)
jmp 0x61a9
movb 0x46(%rsp), %al
testb $0x1, %al
jne 0x61b3
jmp 0x61c3
movl $0x1, 0x2b8(%rsp)
jmp 0x667e
leaq 0x45fbb(%rip), %rsi     # 0x4c185
leaq 0x1c8(%rsp), %rdi
callq 0xb0f0
movb %al, 0x45(%rsp)
jmp 0x61dd
movb 0x45(%rsp), %al
testb $0x1, %al
jne 0x620b
jmp 0x61e7
leaq 0x45f9a(%rip), %rsi     # 0x4c188
leaq 0x1c8(%rsp), %rdi
callq 0xb0f0
movb %al, 0x44(%rsp)
jmp 0x6201
movb 0x44(%rsp), %al
testb $0x1, %al
jne 0x620b
jmp 0x6218
movb $0x0, 0x2bd(%rsp)
jmp 0x667c
leaq 0x45f73(%rip), %rsi     # 0x4c192
leaq 0x1c8(%rsp), %rdi
callq 0xb0f0
movb %al, 0x43(%rsp)
jmp 0x6232
movb 0x43(%rsp), %al
testb $0x1, %al
jne 0x6263
jmp 0x623c
leaq 0x45f52(%rip), %rsi     # 0x4c195
leaq 0x1c8(%rsp), %rdi
callq 0xb0f0
movb %al, 0x42(%rsp)
jmp 0x6256
movb 0x42(%rsp), %al
testb $0x1, %al
jne 0x6263
jmp 0x640c
movq 0x2d8(%rsp), %rax
movl 0x1ec(%rsp), %ecx
addl $0x1, %ecx
movl %ecx, 0x1ec(%rsp)
movslq %ecx, %rcx
movq (%rax,%rcx,8), %rax
movq %rax, 0x180(%rsp)
cmpq $0x0, 0x180(%rsp)
jne 0x6340
leaq 0x15f(%rsp), %rdi
movq %rdi, 0x38(%rsp)
callq 0x5770
movq 0x38(%rsp), %rdx
leaq 0x45ee3(%rip), %rsi     # 0x4c19b
leaq 0x160(%rsp), %rdi
callq 0x5590
jmp 0x62c7
movl $0xff, %edi
leaq 0x160(%rsp), %rsi
callq 0x5f00
jmp 0x62db
leaq 0x160(%rsp), %rdi
callq 0x5260
leaq 0x15f(%rsp), %rdi
callq 0x5450
jmp 0x6340
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x1b8(%rsp)
movl %eax, 0x1b4(%rsp)
jmp 0x632e
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x1b8(%rsp)
movl %eax, 0x1b4(%rsp)
leaq 0x160(%rsp), %rdi
callq 0x5260
leaq 0x15f(%rsp), %rdi
callq 0x5450
jmp 0x66c1
movq 0x180(%rsp), %rax
movq %rax, 0x28(%rsp)
leaq 0xef(%rsp), %rdi
movq %rdi, 0x30(%rsp)
callq 0x5770
movq 0x28(%rsp), %rsi
movq 0x30(%rsp), %rdx
leaq 0xf0(%rsp), %rdi
callq 0x5590
jmp 0x6378
leaq 0x110(%rsp), %rdi
leaq 0x1f0(%rsp), %rsi
leaq 0xf0(%rsp), %rdx
callq 0xb120
jmp 0x6397
leaq 0x110(%rsp), %rdi
callq 0xb5f0
leaq 0xf0(%rsp), %rdi
callq 0x5260
leaq 0xef(%rsp), %rdi
callq 0x5450
jmp 0x667a
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x1b8(%rsp)
movl %eax, 0x1b4(%rsp)
jmp 0x63fa
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x1b8(%rsp)
movl %eax, 0x1b4(%rsp)
leaq 0xf0(%rsp), %rdi
callq 0x5260
leaq 0xef(%rsp), %rdi
callq 0x5450
jmp 0x66c1
leaq 0x45d9a(%rip), %rsi     # 0x4c1ad
leaq 0x1c8(%rsp), %rdi
callq 0xb0f0
movb %al, 0x27(%rsp)
jmp 0x6426
movb 0x27(%rsp), %al
testb $0x1, %al
jne 0x6457
jmp 0x6430
leaq 0x45d79(%rip), %rsi     # 0x4c1b0
leaq 0x1c8(%rsp), %rdi
callq 0xb0f0
movb %al, 0x26(%rsp)
jmp 0x644a
movb 0x26(%rsp), %al
testb $0x1, %al
jne 0x6457
jmp 0x65d2
movq 0x2d8(%rsp), %rax
movl 0x1ec(%rsp), %ecx
addl $0x1, %ecx
movl %ecx, 0x1ec(%rsp)
movslq %ecx, %rcx
movq (%rax,%rcx,8), %rax
movq %rax, 0xe0(%rsp)
cmpq $0x0, 0xe0(%rsp)
jne 0x6534
leaq 0xbf(%rsp), %rdi
movq %rdi, 0x18(%rsp)
callq 0x5770
movq 0x18(%rsp), %rdx
leaq 0x45d0b(%rip), %rsi     # 0x4c1b7
leaq 0xc0(%rsp), %rdi
callq 0x5590
jmp 0x64bb
movl $0xff, %edi
leaq 0xc0(%rsp), %rsi
callq 0x5f00
jmp 0x64cf
leaq 0xc0(%rsp), %rdi
callq 0x5260
leaq 0xbf(%rsp), %rdi
callq 0x5450
jmp 0x6534
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x1b8(%rsp)
movl %eax, 0x1b4(%rsp)
jmp 0x6522
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x1b8(%rsp)
movl %eax, 0x1b4(%rsp)
leaq 0xc0(%rsp), %rdi
callq 0x5260
leaq 0xbf(%rsp), %rdi
callq 0x5450
jmp 0x66c1
movq 0xe0(%rsp), %rdi
leaq 0x49c6f(%rip), %rsi     # 0x501b2
callq 0x54b0
movq %rax, 0x10(%rsp)
jmp 0x654f
movq 0x10(%rsp), %rax
movq %rax, 0xb0(%rsp)
movq 0xb0(%rsp), %rsi
leaq 0x1f0(%rsp), %rdi
callq 0xb620
jmp 0x6573
xorl %eax, %eax
movl %eax, %esi
leaq 0x1f0(%rsp), %rdi
callq 0xb640
jmp 0x6586
leaq 0x1f0(%rsp), %rdi
callq 0xb660
movb %al, 0xf(%rsp)
jmp 0x6599
movb 0xf(%rsp), %al
testb $0x1, %al
jne 0x65be
jmp 0x65a3
movl $0x0, 0x2e4(%rsp)
movl $0x1, 0xac(%rsp)
jmp 0x668b
movq 0xb0(%rsp), %rdi
callq 0x53f0
jmp 0x65cd
jmp 0x6678
leaq 0x45bf4(%rip), %rsi     # 0x4c1cd
leaq 0x68(%rsp), %rdi
leaq 0x1c8(%rsp), %rdx
callq 0xb960
jmp 0x65ed
leaq 0x45bec(%rip), %rdx     # 0x4c1e0
leaq 0x88(%rsp), %rdi
leaq 0x68(%rsp), %rsi
callq 0xb910
jmp 0x6608
movl $0xff, %edi
leaq 0x88(%rsp), %rsi
callq 0x5f00
jmp 0x661c
leaq 0x88(%rsp), %rdi
callq 0x5260
leaq 0x68(%rsp), %rdi
callq 0x5260
jmp 0x6678
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x1b8(%rsp)
movl %eax, 0x1b4(%rsp)
jmp 0x666c
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x1b8(%rsp)
movl %eax, 0x1b4(%rsp)
leaq 0x88(%rsp), %rdi
callq 0x5260
leaq 0x68(%rsp), %rdi
callq 0x5260
jmp 0x66c1
jmp 0x667a
jmp 0x667c
jmp 0x667e
jmp 0x6680
movl $0x0, 0xac(%rsp)
leaq 0x1c8(%rsp), %rdi
callq 0x5260
movl 0xac(%rsp), %eax
testl %eax, %eax
jne 0x6742
jmp 0x66a9
jmp 0x66ab
movl 0x1ec(%rsp), %eax
addl $0x1, %eax
movl %eax, 0x1ec(%rsp)
jmp 0x5fd3
leaq 0x1c8(%rsp), %rdi
callq 0x5260
jmp 0x675e
movq 0x668de(%rip), %rax     # 0x6cfb8
movq (%rax), %rsi
leaq 0x1f0(%rsp), %rdi
callq 0xb620
jmp 0x66ec
movq 0x668a5(%rip), %rax     # 0x6cf98
movq (%rax), %rsi
leaq 0x1f0(%rsp), %rdi
callq 0xb640
jmp 0x6705
leaq 0x1f0(%rsp), %rdi
callq 0xb660
jmp 0x6714
movl $0x0, 0x2e4(%rsp)
movl $0x1, 0xac(%rsp)
jmp 0x6742
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x1b8(%rsp)
movl %eax, 0x1b4(%rsp)
jmp 0x675e
leaq 0x1f0(%rsp), %rdi
callq 0xba90
movl 0x2e4(%rsp), %eax
addq $0x2e8, %rsp            # imm = 0x2E8
retq
leaq 0x1f0(%rsp), %rdi
callq 0xba90
movq 0x1b8(%rsp), %rdi
callq 0x5760
nopl (%rax,%rax)