// File: YSRKEN[P]Shioi/I401/main.cpp
// Function: Board::Board(char const*, char const*)
Board(const char board_text[], const char turn_text[]) 
		: turn_(turn_text[0] | toStone("Can't read turn data."))
	{
		// Read board-text
		if (strlen(board_text) < kBoardSize * kBoardSize) {
			throw std::invalid_argument("Too short board-text size!");
		}
		for (size_t p : rep(kBoardSize * kBoardSize)) {
			board_[p] = board_text[p] | toStone("Can't read board data.");
		}
		// Initialize IterateTable
		constexpr size_t kTengen = kBoardSize / 2;
		for (size_t y : rep(kBoardSize)) {
			for (size_t x : rep(kBoardSize)) {
				const auto p = ToPosition(x, y);
				kTenGenDist[p] = kTengen - std::max(safe_dist(x, kTengen), safe_dist(y, kTengen));
				// Row(─)
				kIterateTable[p][Direction::Row][Side::Right] = std::min(kBoardSize - x - 1, kSearchWidth);
				kIterateTable[p][Direction::Row][Side::Left ] = std::min(x, kSearchWidth);
				// Column(│)
				kIterateTable[p][Direction::Column][Side::Right] = std::min(kBoardSize - y - 1, kSearchWidth);
				kIterateTable[p][Direction::Column][Side::Left ] = std::min(y, kSearchWidth);
				// Diagonally right(／)
				kIterateTable[p][Direction::DiagR][Side::Right] = min(x, kBoardSize - y - 1, kSearchWidth);
				kIterateTable[p][Direction::DiagR][Side::Left] = min(kBoardSize - x - 1, y, kSearchWidth);
				// Diagonally left(＼)
				kIterateTable[p][Direction::DiagL][Side::Right] = min(kBoardSize - x - 1, kBoardSize - y - 1, kSearchWidth);
				kIterateTable[p][Direction::DiagL][Side::Left] = min(x, y, kSearchWidth);
			}
		}
	}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x180, %rsp            # imm = 0x180
movq %rdi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
movq %rdx, -0x18(%rbp)
movq -0x8(%rbp), %rax
movq %rax, -0x120(%rbp)
movq -0x18(%rbp), %rax
movb (%rax), %al
movb %al, -0x121(%rbp)
leaq 0x1adf5(%rip), %rdi     # 0x1e20a
callq 0x5480
movq %rax, %rcx
movb -0x121(%rbp), %al
movq %rcx, -0x20(%rbp)
movq -0x20(%rbp), %rsi
movsbl %al, %edi
callq 0x2ba0
movb %al, %cl
movq -0x120(%rbp), %rax
movb %cl, 0xe1(%rax)
movq -0x10(%rbp), %rdi
callq 0x20f0
cmpq $0xe1, %rax
jae 0x34af
movl $0x10, %edi
callq 0x2110
movq %rax, %rdi
movq %rdi, %rax
movq %rax, -0x130(%rbp)
leaq 0x1adaf(%rip), %rsi     # 0x1e220
callq 0x23b0
jmp 0x3478
movq -0x130(%rbp), %rdi
movq 0x23b4a(%rip), %rsi     # 0x26fd0
movq 0x23b2b(%rip), %rdx     # 0x26fb8
callq 0x2350
movq -0x130(%rbp), %rdi
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x28(%rbp)
movl %eax, -0x2c(%rbp)
callq 0x21a0
jmp 0x3a96
movl $0xe1, %edi
callq 0x54a0
movq %rax, -0x48(%rbp)
movq %rdx, -0x40(%rbp)
leaq -0x48(%rbp), %rax
movq %rax, -0x38(%rbp)
movq -0x38(%rbp), %rdi
callq 0x54e0
movq %rax, -0x50(%rbp)
movq -0x38(%rbp), %rdi
callq 0x5510
movq %rax, -0x58(%rbp)
leaq -0x50(%rbp), %rdi
leaq -0x58(%rbp), %rsi
callq 0x5550
testb $0x1, %al
jne 0x34f6
jmp 0x3568
leaq -0x50(%rbp), %rdi
callq 0x5580
movq (%rax), %rax
movq %rax, -0x60(%rbp)
movq -0x10(%rbp), %rax
movq -0x60(%rbp), %rcx
movb (%rax,%rcx), %al
movb %al, -0x132(%rbp)
leaq 0x1ad1d(%rip), %rdi     # 0x1e23b
callq 0x5480
movq %rax, %rcx
movb -0x132(%rbp), %al
movq %rcx, -0x68(%rbp)
movq -0x68(%rbp), %rsi
movsbl %al, %edi
callq 0x2ba0
movq -0x120(%rbp), %rdi
movb %al, -0x131(%rbp)
movq -0x60(%rbp), %rsi
callq 0x5590
movb -0x131(%rbp), %cl
movb %cl, (%rax)
leaq -0x50(%rbp), %rdi
callq 0x55c0
jmp 0x34e3
movq $0x7, -0x70(%rbp)
movl $0xf, %edi
callq 0x54a0
movq %rax, -0x88(%rbp)
movq %rdx, -0x80(%rbp)
leaq -0x88(%rbp), %rax
movq %rax, -0x78(%rbp)
movq -0x78(%rbp), %rdi
callq 0x54e0
movq %rax, -0x90(%rbp)
movq -0x78(%rbp), %rdi
callq 0x5510
movq %rax, -0x98(%rbp)
leaq -0x90(%rbp), %rdi
leaq -0x98(%rbp), %rsi
callq 0x5550
testb $0x1, %al
jne 0x35cc
jmp 0x3a8d
leaq -0x90(%rbp), %rdi
callq 0x5580
movq (%rax), %rax
movq %rax, -0xa0(%rbp)
movl $0xf, %edi
callq 0x54a0
movq %rax, -0xb8(%rbp)
movq %rdx, -0xb0(%rbp)
leaq -0xb8(%rbp), %rax
movq %rax, -0xa8(%rbp)
movq -0xa8(%rbp), %rdi
callq 0x54e0
movq %rax, -0xc0(%rbp)
movq -0xa8(%rbp), %rdi
callq 0x5510
movq %rax, -0xc8(%rbp)
leaq -0xc0(%rbp), %rdi
leaq -0xc8(%rbp), %rsi
callq 0x5550
testb $0x1, %al
jne 0x364a
jmp 0x3a7a
leaq -0xc0(%rbp), %rdi
callq 0x5580
movq (%rax), %rax
movq %rax, -0xd0(%rbp)
movq -0xd0(%rbp), %rdi
movq -0xa0(%rbp), %rsi
callq 0x3100
movq %rax, -0xd8(%rbp)
leaq -0xd0(%rbp), %rdi
leaq -0x70(%rbp), %rsi
callq 0x5620
movq %rax, -0xe0(%rbp)
leaq -0xa0(%rbp), %rdi
leaq -0x70(%rbp), %rsi
callq 0x5620
movq %rax, -0xe8(%rbp)
leaq -0xe0(%rbp), %rdi
leaq -0xe8(%rbp), %rsi
callq 0x55e0
movq -0x120(%rbp), %rdi
movq %rax, %rcx
movl $0x7, %eax
subq (%rcx), %rax
movq %rax, -0x180(%rbp)
addq $0x3928, %rdi           # imm = 0x3928
movq -0xd8(%rbp), %rsi
callq 0x5670
movq -0x180(%rbp), %rcx
movq %rcx, (%rax)
movl $0xf, %eax
subq -0xd0(%rbp), %rax
subq $0x1, %rax
movq %rax, -0xf0(%rbp)
leaq -0xf0(%rbp), %rdi
leaq 0x1ac9a(%rip), %rsi     # 0x1e3b0
callq 0x56a0
movq -0x120(%rbp), %rdi
movq (%rax), %rax
movq %rax, -0x178(%rbp)
addq $0xe8, %rdi
movq -0xd8(%rbp), %rsi
callq 0x56e0
movq %rax, %rdi
xorl %eax, %eax
movl %eax, %esi
callq 0x5710
movq %rax, %rdi
movl $0x1, %esi
callq 0x5740
movq -0x178(%rbp), %rcx
movq %rcx, (%rax)
leaq -0xd0(%rbp), %rdi
leaq 0x1ac40(%rip), %rsi     # 0x1e3b0
callq 0x56a0
movq -0x120(%rbp), %rdi
movq (%rax), %rax
movq %rax, -0x170(%rbp)
addq $0xe8, %rdi
movq -0xd8(%rbp), %rsi
callq 0x56e0
movq %rax, %rdi
xorl %eax, %eax
movl %eax, %esi
callq 0x5710
movq %rax, %rdi
xorl %eax, %eax
movl %eax, %esi
callq 0x5740
movq -0x170(%rbp), %rcx
movq %rcx, (%rax)
movl $0xf, %eax
subq -0xa0(%rbp), %rax
subq $0x1, %rax
movq %rax, -0xf8(%rbp)
leaq -0xf8(%rbp), %rdi
leaq 0x1abd0(%rip), %rsi     # 0x1e3b0
callq 0x56a0
movq -0x120(%rbp), %rdi
movq (%rax), %rax
movq %rax, -0x168(%rbp)
addq $0xe8, %rdi
movq -0xd8(%rbp), %rsi
callq 0x56e0
movq %rax, %rdi
movl $0x1, %esi
callq 0x5710
movq %rax, %rdi
movl $0x1, %esi
callq 0x5740
movq -0x168(%rbp), %rcx
movq %rcx, (%rax)
leaq -0xa0(%rbp), %rdi
leaq 0x1ab75(%rip), %rsi     # 0x1e3b0
callq 0x56a0
movq -0x120(%rbp), %rdi
movq (%rax), %rax
movq %rax, -0x160(%rbp)
addq $0xe8, %rdi
movq -0xd8(%rbp), %rsi
callq 0x56e0
movq %rax, %rdi
movl $0x1, %esi
callq 0x5710
movq %rax, %rdi
xorl %eax, %eax
movl %eax, %esi
callq 0x5740
movq -0x160(%rbp), %rcx
movq %rcx, (%rax)
movl $0xf, %eax
subq -0xa0(%rbp), %rax
subq $0x1, %rax
movq %rax, -0x100(%rbp)
leaq -0xd0(%rbp), %rdi
leaq -0x100(%rbp), %rsi
leaq 0x1aafd(%rip), %rdx     # 0x1e3b0
callq 0x5770
movq -0x120(%rbp), %rdi
movq (%rax), %rax
movq %rax, -0x158(%rbp)
addq $0xe8, %rdi
movq -0xd8(%rbp), %rsi
callq 0x56e0
movq %rax, %rdi
movl $0x2, %esi
callq 0x5710
movq %rax, %rdi
movl $0x1, %esi
callq 0x5740
movq -0x158(%rbp), %rcx
movq %rcx, (%rax)
movl $0xf, %eax
subq -0xd0(%rbp), %rax
subq $0x1, %rax
movq %rax, -0x108(%rbp)
leaq -0x108(%rbp), %rdi
leaq -0xa0(%rbp), %rsi
leaq 0x1aa84(%rip), %rdx     # 0x1e3b0
callq 0x5770
movq -0x120(%rbp), %rdi
movq (%rax), %rax
movq %rax, -0x150(%rbp)
addq $0xe8, %rdi
movq -0xd8(%rbp), %rsi
callq 0x56e0
movq %rax, %rdi
movl $0x2, %esi
callq 0x5710
movq %rax, %rdi
xorl %eax, %eax
movl %eax, %esi
callq 0x5740
movq -0x150(%rbp), %rcx
movq %rcx, (%rax)
movl $0xf, %eax
subq -0xd0(%rbp), %rax
subq $0x1, %rax
movq %rax, -0x110(%rbp)
movl $0xf, %eax
subq -0xa0(%rbp), %rax
subq $0x1, %rax
movq %rax, -0x118(%rbp)
leaq -0x110(%rbp), %rdi
leaq -0x118(%rbp), %rsi
leaq 0x1a9f5(%rip), %rdx     # 0x1e3b0
callq 0x5770
movq -0x120(%rbp), %rdi
movq (%rax), %rax
movq %rax, -0x148(%rbp)
addq $0xe8, %rdi
movq -0xd8(%rbp), %rsi
callq 0x56e0
movq %rax, %rdi
movl $0x3, %esi
callq 0x5710
movq %rax, %rdi
movl $0x1, %esi
callq 0x5740
movq -0x148(%rbp), %rcx
movq %rcx, (%rax)
leaq -0xd0(%rbp), %rdi
leaq -0xa0(%rbp), %rsi
leaq 0x1a993(%rip), %rdx     # 0x1e3b0
callq 0x5770
movq -0x120(%rbp), %rdi
movq (%rax), %rax
movq %rax, -0x140(%rbp)
addq $0xe8, %rdi
movq -0xd8(%rbp), %rsi
callq 0x56e0
movq %rax, %rdi
movl $0x3, %esi
callq 0x5710
movq %rax, %rdi
xorl %eax, %eax
movl %eax, %esi
callq 0x5740
movq -0x140(%rbp), %rcx
movq %rcx, (%rax)
leaq -0xc0(%rbp), %rdi
callq 0x55c0
jmp 0x362e
jmp 0x3a7c
leaq -0x90(%rbp), %rdi
callq 0x55c0
jmp 0x35b0
addq $0x180, %rsp            # imm = 0x180
popq %rbp
retq
movq -0x28(%rbp), %rdi
callq 0x2370
nop