// File: /workspace/github_cpp_makefile_star2_O3/YSRKEN[P]Shioi/I401/main.cpp
// Function: Board::FindGorenMove(Stone)
Result FindGorenMove(const Stone turn) {
		// Row(─)
		for (size_t i : rep(kBoardSize)) {
			for (size_t j : rep(kBoardSize)) {
				size_t p = ToPosition(j, i);
				if (board_[p] != Stone::None) continue;
				size_t rlengh = 0;
				for (int k = j - 1; k >= 0; --k) {
					if (board_[ToPosition(k, i)] != turn) break;
					++rlengh;
				}
				size_t llengh = 0;
				for (size_t k : rep(j + 1, kBoardSize)) {
					if (board_[ToPosition(k, i)] != turn) break;
					++llengh;
				}
				if (turn == Stone::Black) {
					if (rlengh + llengh == 4) return Result(p, true);
				}
				else {
					if (rlengh + llengh >= 4) return Result(p, true);
				}
			}
		}
		// Column(│)
		for (size_t i : rep(kBoardSize)) {
			for (size_t j : rep(kBoardSize)) {
				size_t p = ToPosition(i, j);
				if (board_[p] != Stone::None) continue;
				size_t rlengh = 0;
				for (int k = j - 1; k >= 0; --k) {
					if (board_[ToPosition(i, k)] != turn) break;
					++rlengh;
				}
				size_t llengh = 0;
				for (size_t k : rep(j + 1, kBoardSize)) {
					if (board_[ToPosition(i, k)] != turn) break;
					++llengh;
				}
				if (turn == Stone::Black) {
					if (rlengh + llengh == 4) return Result(p, true);
				}
				else {
					if (rlengh + llengh >= 4) return Result(p, true);
				}
			}
		}
		// Diagonally right(／)
		for (size_t i : rep(4_sz, kBoardSize)) {
			for (size_t j : rep(i)) {
				size_t p = ToPosition(i - j, j);
				if (board_[p] != Stone::None) continue;
				size_t rlengh = 0;
				for (int k = j - 1; k >= 0; --k) {
					if (board_[ToPosition(i - k, k)] != turn) break;
					++rlengh;
				}
				size_t llengh = 0;
				for (size_t k = j + 1; k <= i; ++k) {
					if (board_[ToPosition(i - k, k)] != turn) break;
					++llengh;
				}
				if (turn == Stone::Black) {
					if (rlengh + llengh == 4) return Result(p, true);
				}
				else {
					if (rlengh + llengh >= 4) return Result(p, true);
				}
			}
		}
		for (size_t i : rep(1_sz, kBoardSize - 4_sz)) {
			for (size_t j : rep(kBoardSize - i)) {
				size_t p = ToPosition(kBoardSize - 1 - j, i + j);
				if (board_[p] != Stone::None) continue;
				size_t rlengh = 0;
				for (int k = j - 1; k >= 0; --k) {
					if (board_[ToPosition(kBoardSize - 1 - k, i + k)] != turn) break;
					++rlengh;
				}
				size_t llengh = 0;
				for (size_t k : rep(j + 1, kBoardSize - i)) {
					if (board_[ToPosition(kBoardSize - 1 - k, i + k)] != turn) break;
					++llengh;
				}
				if (turn == Stone::Black) {
					if (rlengh + llengh == 4) return Result(p, true);
				}
				else {
					if (rlengh + llengh >= 4) return Result(p, true);
				}
			}
		}
		// Diagonally left(＼)
		for (size_t i : rep(kBoardSize - 4_sz)) {
			for (size_t j : rep(kBoardSize - i)) {
				size_t p = ToPosition(i + j, j);
				if (board_[p] != Stone::None) continue;
				size_t rlengh = 0;
				for (int k = j - 1; k >= 0; --k) {
					if (board_[ToPosition(i + k, k)] != turn) break;
					++rlengh;
				}
				size_t llengh = 0;
				for (size_t k : rep(j + 1, kBoardSize - i)) {
					if (board_[ToPosition(i + k, k)] != turn) break;
					++llengh;
				}
				if (turn == Stone::Black) {
					if (rlengh + llengh == 4) return Result(p, true);
				}
				else {
					if (rlengh + llengh >= 4) return Result(p, true);
				}
			}
		}
		for (size_t i : rep(1_sz, kBoardSize - 4_sz)) {
			for (size_t j : rep(kBoardSize - i)) {
				size_t p = ToPosition(j, i + j);
				if (board_[p] != Stone::None) continue;
				size_t rlengh = 0;
				for (int k = j - 1; k >= 0; --k) {
					if (board_[ToPosition(k, i + k)] != turn) break;
					++rlengh;
				}
				size_t llengh = 0;
				for (size_t k : rep(j + 1, kBoardSize - i)) {
					if (board_[ToPosition(k, i + k)] != turn) break;
					++llengh;
				}
				if (turn == Stone::Black) {
					if (rlengh + llengh == 4) return Result(p, true);
				}
				else {
					if (rlengh + llengh >= 4) return Result(p, true);
				}
			}
		}
		return Result(0, false);
	}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r12
pushq %rbx
leaq 0x1(%rdi), %rcx
xorl %edx, %edx
leaq (%rdx,%rdx,4), %rax
leaq (%rax,%rax,2), %r8
movl $0xffffffff, %r9d       # imm = 0xFFFFFFFF
xorl %r10d, %r10d
leaq (%r10,%r8), %rax
cmpb $0x0, (%rdi,%rax)
je 0x49c1
incq %r10
movq %r10, %rbx
jmp 0x4a39
movl %r10d, %ebx
decl %ebx
js 0x49ec
movl %r9d, %r14d
incq %r14
xorl %r11d, %r11d
movl %ebx, %r15d
addq %r8, %r15
cmpb %sil, (%rdi,%r15)
jne 0x49ef
incq %r11
decl %ebx
cmpq %r11, %r10
jne 0x49d1
movq %r14, %r11
jmp 0x49ef
xorl %r11d, %r11d
leaq 0x1(%r10), %rbx
cmpq $0xf, %rbx
jne 0x49fe
xorl %r14d, %r14d
jmp 0x4a1b
movl $0xe, %r15d
subq %r10, %r15
addq %rcx, %r10
xorl %r14d, %r14d
cmpb %sil, (%r10,%r14)
jne 0x4a1b
incq %r14
cmpq %r14, %r15
jne 0x4a0d
addq %r11, %r14
cmpb $0x1, %sil
jne 0x4a2f
cmpq $0x4, %r14
jne 0x4a39
jmp 0x4ecb
cmpq $0x3, %r14
ja 0x4ecb
incl %r9d
movq %rbx, %r10
cmpq $0xf, %rbx
jne 0x49af
incq %rdx
addq $0xf, %rcx
cmpq $0xf, %rdx
jne 0x499e
leaq 0xf(%rdi), %rcx
xorl %edx, %edx
movl $0xffffffff, %r8d       # imm = 0xFFFFFFFF
xorl %r10d, %r10d
leaq (%r10,%r10,4), %rax
leaq (%rax,%rax,2), %r9
leaq (%r9,%rdx), %rax
cmpb $0x0, (%rdi,%rax)
je 0x4a86
incq %r10
movq %r10, %rbx
jmp 0x4b09
movl %r10d, %ebx
decl %ebx
js 0x4ab9
movl %r8d, %r14d
incq %r14
xorl %r11d, %r11d
movl %ebx, %r15d
leaq (%r15,%r15,4), %r15
leaq (%r15,%r15,2), %r15
addq %rdx, %r15
cmpb %sil, (%rdi,%r15)
jne 0x4abc
incq %r11
decl %ebx
cmpq %r11, %r10
jne 0x4a96
movq %r14, %r11
jmp 0x4abc
xorl %r11d, %r11d
leaq 0x1(%r10), %rbx
cmpq $0xf, %rbx
jne 0x4acb
xorl %r10d, %r10d
jmp 0x4aeb
movl $0xe, %r14d
subq %r10, %r14
addq %rcx, %r9
xorl %r10d, %r10d
cmpb %sil, (%r9)
jne 0x4aeb
incq %r10
addq $0xf, %r9
cmpq %r10, %r14
jne 0x4ada
addq %r11, %r10
cmpb $0x1, %sil
jne 0x4aff
cmpq $0x4, %r10
jne 0x4b09
jmp 0x4ecb
cmpq $0x3, %r10
ja 0x4ecb
incl %r8d
movq %rbx, %r10
cmpq $0xf, %rbx
jne 0x4a69
incq %rdx
incq %rcx
cmpq $0xf, %rdx
jne 0x4a60
leaq 0x12(%rdi), %rcx
movl $0x4, %edx
movl $0xffffffff, %r8d       # imm = 0xFFFFFFFF
xorl %r9d, %r9d
movq %rdx, %r10
subq %r9, %r10
leaq (%r9,%r9,4), %rax
leaq (%rax,%rax,2), %rax
addq %r10, %rax
cmpb $0x0, (%rdi,%rax)
je 0x4b5d
incq %r9
movq %r9, %r11
jmp 0x4be7
movl %r9d, %r11d
decl %r11d
js 0x4b98
movl %r8d, %ebx
incq %rbx
xorl %r10d, %r10d
movl %r11d, %r14d
movq %rdx, %r15
subq %r14, %r15
leaq (%r14,%r14,4), %r14
leaq (%r14,%r14,2), %r14
addq %r15, %r14
cmpb %sil, (%rdi,%r14)
jne 0x4b9b
incq %r10
decl %r11d
cmpq %r10, %r9
jne 0x4b6e
movq %rbx, %r10
jmp 0x4b9b
xorl %r10d, %r10d
leaq 0x1(%r9), %r11
movq %r9, %r14
shlq $0x4, %r14
subq %r9, %r14
subq %r9, %r14
addq %rcx, %r14
xorl %ebx, %ebx
cmpb %sil, (%r14)
jne 0x4bc9
leaq (%r9,%rbx), %r15
incq %r15
incq %rbx
addq $0xe, %r14
cmpq %rdx, %r15
jb 0x4bb1
addq %r10, %rbx
cmpb $0x1, %sil
jne 0x4bdd
cmpq $0x4, %rbx
jne 0x4be7
jmp 0x4ecb
cmpq $0x3, %rbx
ja 0x4ecb
incl %r8d
movq %r11, %r9
cmpq %rdx, %r11
jne 0x4b3b
incq %rdx
incq %rcx
cmpq $0xf, %rdx
jne 0x4b32
leaq 0x2b(%rdi), %rcx
movl $0x1, %edx
movl $0xd, %r8d
movl $0xf, %r9d
subq %rdx, %r9
movl $0xffffffff, %r10d      # imm = 0xFFFFFFFF
xorl %r11d, %r11d
leaq (%r11,%rdx), %rax
leaq (%rax,%rax,4), %rax
leaq (%rax,%rax,2), %rax
subq %r11, %rax
cmpb $0x0, 0xe(%rdi,%rax)
je 0x4c48
incq %r11
movq %r11, %r14
jmp 0x4cd9
movl %r11d, %ebp
decl %ebp
js 0x4c7f
movl %r10d, %r14d
incq %r14
xorl %ebx, %ebx
movl %ebp, %r15d
leaq (%rdx,%r15), %r12
leaq (%r12,%r12,4), %r12
leaq (%r12,%r12,2), %r12
subq %r15, %r12
cmpb %sil, 0xe(%r12,%rdi)
jne 0x4c81
incq %rbx
decl %ebp
cmpq %rbx, %r11
jne 0x4c57
movq %r14, %rbx
jmp 0x4c81
xorl %ebx, %ebx
leaq 0x1(%r11), %r14
cmpq %r9, %r14
jne 0x4c8f
xorl %r15d, %r15d
jmp 0x4cb7
leaq (%r11,%r11), %r15
movq %r8, %r12
subq %r11, %r12
shlq $0x4, %r11
subq %r15, %r11
addq %rcx, %r11
xorl %r15d, %r15d
cmpb %sil, (%r11)
jne 0x4cb7
incq %r15
addq $0xe, %r11
cmpq %r15, %r12
jne 0x4ca6
addq %rbx, %r15
addq $0xe, %rax
cmpb $0x1, %sil
jne 0x4ccf
cmpq $0x4, %r15
jne 0x4cd9
jmp 0x4ecb
cmpq $0x3, %r15
ja 0x4ecb
incl %r10d
movq %r14, %r11
cmpq %r9, %r14
jne 0x4c27
incq %rdx
addq $0xf, %rcx
decq %r8
cmpq $0xb, %rdx
jne 0x4c15
leaq 0x10(%rdi), %rcx
movl $0x1, %edx
xorl %r8d, %r8d
movl $0xf, %r9d
subq %r8, %r9
movl $0xffffffff, %r10d      # imm = 0xFFFFFFFF
xorl %r11d, %r11d
leaq (%r11,%r8), %rbx
leaq (%r11,%r11,4), %rax
leaq (%rax,%rax,2), %rax
addq %rbx, %rax
cmpb $0x0, (%rdi,%rax)
je 0x4d3a
incq %r11
movq %r11, %r14
jmp 0x4dc1
movl %r11d, %ebp
decl %ebp
js 0x4d70
movl %r10d, %r14d
incq %r14
xorl %ebx, %ebx
movl %ebp, %r15d
leaq (%r8,%r15), %r12
leaq (%r15,%r15,4), %r15
leaq (%r15,%r15,2), %r15
addq %r12, %r15
cmpb %sil, (%rdi,%r15)
jne 0x4d72
incq %rbx
decl %ebp
cmpq %rbx, %r11
jne 0x4d49
movq %r14, %rbx
jmp 0x4d72
xorl %ebx, %ebx
leaq 0x1(%r11), %r14
cmpq %r9, %r14
jne 0x4d80
xorl %r15d, %r15d
jmp 0x4da3
leaq (%rdx,%r11), %r12
shlq $0x4, %r11
addq %rcx, %r11
xorl %r15d, %r15d
cmpb %sil, (%r11)
jne 0x4da3
incq %r15
incq %r12
addq $0x10, %r11
cmpq $0xf, %r12
jne 0x4d8e
addq %rbx, %r15
cmpb $0x1, %sil
jne 0x4db7
cmpq $0x4, %r15
jne 0x4dc1
jmp 0x4ecb
cmpq $0x3, %r15
ja 0x4ecb
incl %r10d
movq %r14, %r11
cmpq %r9, %r14
jne 0x4d1a
incq %r8
incq %rdx
incq %rcx
cmpq $0xb, %r8
jne 0x4d08
leaq 0x1f(%rdi), %rcx
movl $0x1, %r8d
movl $0xd, %r9d
movl $0xf, %edx
subq %r8, %rdx
movl $0xffffffff, %r10d      # imm = 0xFFFFFFFF
xorl %r11d, %r11d
leaq (%r11,%r8), %rax
leaq (%rax,%rax,4), %rax
leaq (%rax,%rax,2), %rax
addq %r11, %rax
cmpb $0x0, (%rdi,%rax)
je 0x4e21
incq %r11
movq %r11, %r14
jmp 0x4e9f
movl %r11d, %ebp
decl %ebp
js 0x4e57
movl %r10d, %r14d
incq %r14
xorl %ebx, %ebx
movl %ebp, %r15d
leaq (%r8,%r15), %r12
leaq (%r12,%r12,4), %r12
leaq (%r12,%r12,2), %r12
addq %r15, %r12
cmpb %sil, (%rdi,%r12)
jne 0x4e59
incq %rbx
decl %ebp
cmpq %rbx, %r11
jne 0x4e30
movq %r14, %rbx
jmp 0x4e59
xorl %ebx, %ebx
leaq 0x1(%r11), %r14
cmpq %rdx, %r14
jne 0x4e67
xorl %r15d, %r15d
jmp 0x4e88
movq %r9, %r12
subq %r11, %r12
shlq $0x4, %r11
addq %rcx, %r11
xorl %r15d, %r15d
cmpb %sil, (%r11)
jne 0x4e88
incq %r15
addq $0x10, %r11
cmpq %r15, %r12
jne 0x4e77
addq %rbx, %r15
cmpb $0x1, %sil
jne 0x4e99
cmpq $0x4, %r15
jne 0x4e9f
jmp 0x4ecb
cmpq $0x3, %r15
ja 0x4ecb
incl %r10d
movq %r14, %r11
cmpq %rdx, %r14
jne 0x4e04
incq %r8
decq %r9
addq $0xf, %rcx
xorl %eax, %eax
movl $0x0, %edx
cmpq $0xb, %r8
jne 0x4df3
jmp 0x4ecd
movb $0x1, %dl
popq %rbx
popq %r12
popq %r14
popq %r15
popq %rbp
retq