// File: /workspace/github_cpp_makefile_star2_O1/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 %r13
pushq %r12
pushq %rbx
leaq 0x1(%rdi), %rax
xorl %edx, %edx
xorl %r8d, %r8d
leaq (%r8,%r8,4), %r9
leaq (%r9,%r9,2), %r9
movl $0xffffffff, %r10d      # imm = 0xFFFFFFFF
movq %rax, %r11
xorl %ebx, %ebx
leaq (%rbx,%r9), %r14
movl $0x5, %ebp
cmpb $0x0, (%rdi,%r14)
jne 0x4ab4
movl %ebx, %ebp
decl %ebp
js 0x4a5c
movl %r10d, %r12d
incq %r12
xorl %r15d, %r15d
movl %ebp, %r13d
addq %r9, %r13
cmpb %sil, (%rdi,%r13)
jne 0x4a5f
incq %r15
decl %ebp
cmpq %r15, %rbx
jne 0x4a41
movq %r12, %r15
jmp 0x4a5f
xorl %r15d, %r15d
movq $-0x1, %r12
leaq (%rbx,%r12), %r13
cmpq $0xd, %r13
je 0x4a8c
leaq 0x1(%r12), %r13
cmpb %sil, 0x1(%r11,%r12)
movq %r13, %r12
je 0x4a66
sete %bpl
movzbl %bpl, %r12d
addq %r13, %r12
jmp 0x4a8f
incq %r12
addq %r15, %r12
xorl %ebp, %ebp
cmpb $0x1, %sil
jne 0x4aa8
cmpq $0x4, %r12
sete %bpl
cmoveq %r14, %rcx
jmp 0x4ab4
cmpq $0x4, %r12
setae %bpl
cmovaeq %r14, %rcx
cmpl $0x5, %ebp
je 0x4abd
testl %ebp, %ebp
jne 0x4ad5
incq %rbx
incl %r10d
incq %r11
cmpq $0xf, %rbx
jne 0x4a1e
movl $0x4, %ebp
testb $0x3, %bpl
jne 0x4aef
incq %r8
addq $0xf, %rax
cmpq $0xf, %r8
sete %dl
jne 0x4a0b
testb $0x1, %dl
je 0x508d
leaq 0xf(%rdi), %rax
xorl %edx, %edx
xorl %r8d, %r8d
movl $0xffffffff, %r9d       # imm = 0xFFFFFFFF
movq %rax, %r10
xorl %r11d, %r11d
leaq (%r11,%r11,4), %rbx
leaq (%rbx,%rbx,2), %rbx
addq %r8, %rbx
movl $0xe, %ebp
cmpb $0x0, (%rdi,%rbx)
jne 0x4bb2
movl %r11d, %ebp
decl %ebp
js 0x4b5a
movl %r9d, %r15d
incq %r15
xorl %r14d, %r14d
movl %ebp, %r12d
leaq (%r12,%r12,4), %r12
leaq (%r12,%r12,2), %r12
addq %r8, %r12
cmpb %sil, (%rdi,%r12)
jne 0x4b5d
incq %r14
decl %ebp
cmpq %r14, %r11
jne 0x4b37
movq %r15, %r14
jmp 0x4b5d
xorl %r14d, %r14d
movq $-0x1, %r15
movq %r10, %r12
leaq (%r11,%r15), %r13
incq %r15
cmpq $0xd, %r13
je 0x4b8d
leaq 0xf(%r12), %r13
cmpb %sil, (%r12)
movq %r13, %r12
je 0x4b67
sete %bpl
movzbl %bpl, %r12d
addq %r12, %r15
addq %r14, %r15
xorl %ebp, %ebp
cmpb $0x1, %sil
jne 0x4ba6
cmpq $0x4, %r15
sete %bpl
cmoveq %rbx, %rcx
jmp 0x4bb2
cmpq $0x4, %r15
setae %bpl
cmovaeq %rbx, %rcx
cmpl $0xe, %ebp
je 0x4bbb
testl %ebp, %ebp
jne 0x4bd4
incq %r11
incl %r9d
addq $0xf, %r10
cmpq $0xf, %r11
jne 0x4b0d
movl $0xd, %ebp
cmpl $0xd, %ebp
je 0x4bdd
testl %ebp, %ebp
jne 0x4bf0
incq %r8
incq %rax
cmpq $0xf, %r8
sete %dl
jne 0x4b01
testb $0x1, %dl
je 0x508d
leaq 0x12(%rdi), %rax
movl $0x4, %edx
xorl %r8d, %r8d
movl $0xffffffff, %r9d       # imm = 0xFFFFFFFF
movq %rax, %r10
xorl %r11d, %r11d
movq %rdx, %r14
subq %r11, %r14
leaq (%r11,%r11,4), %rbx
leaq (%rbx,%rbx,2), %rbx
addq %r14, %rbx
movl $0x17, %ebp
cmpb $0x0, (%rdi,%rbx)
jne 0x4cb1
movl %r11d, %ebp
decl %ebp
js 0x4c6a
movl %r9d, %r15d
incq %r15
xorl %r14d, %r14d
movl %ebp, %r12d
movq %rdx, %r13
subq %r12, %r13
leaq (%r12,%r12,4), %r12
leaq (%r12,%r12,2), %r12
addq %r13, %r12
cmpb %sil, (%rdi,%r12)
jne 0x4c6d
incq %r14
decl %ebp
cmpq %r14, %r11
jne 0x4c41
movq %r15, %r14
jmp 0x4c6d
xorl %r14d, %r14d
movq %r10, %r12
xorl %r15d, %r15d
cmpb %sil, (%r12)
jne 0x4c8c
addq $0xe, %r12
leaq (%r11,%r15), %r13
incq %r13
incq %r15
cmpq %rdx, %r13
jb 0x4c73
addq %r14, %r15
xorl %ebp, %ebp
cmpb $0x1, %sil
jne 0x4ca5
cmpq $0x4, %r15
sete %bpl
cmoveq %rbx, %rcx
jmp 0x4cb1
cmpq $0x4, %r15
setae %bpl
cmovaeq %rbx, %rcx
cmpl $0x17, %ebp
je 0x4cba
testl %ebp, %ebp
jne 0x4cd2
incq %r11
incl %r9d
addq $0xe, %r10
cmpq %rdx, %r11
jne 0x4c11
movl $0x16, %ebp
cmpl $0x16, %ebp
je 0x4cdb
testl %ebp, %ebp
jne 0x4cef
incq %rdx
incq %rax
cmpq $0xf, %rdx
sete %r8b
jne 0x4c05
testb $0x1, %r8b
je 0x508d
leaq 0x2b(%rdi), %r14
movl $0x1, %edx
movl $0xd, %ebx
movq $0x0, -0x18(%rsp)
movl $0xf, %r10d
subq %rdx, %r10
movl $0xffffffff, %r11d      # imm = 0xFFFFFFFF
movq %rbx, -0x10(%rsp)
movq %r14, -0x8(%rsp)
xorl %r15d, %r15d
leaq (%r15,%rdx), %r9
leaq (%r9,%r9,4), %r9
leaq (%r9,%r9,2), %r12
subq %r15, %r12
movl $0x21, %ebp
cmpb $0x0, 0xe(%rdi,%r12)
jne 0x4dd9
movl %r15d, %r9d
decl %r9d
js 0x4d86
movl %r11d, %ebp
incq %rbp
xorl %r13d, %r13d
movl %r9d, %eax
leaq (%rdx,%rax), %r8
leaq (%r8,%r8,4), %r8
leaq (%r8,%r8,2), %r8
subq %rax, %r8
cmpb %sil, 0xe(%r8,%rdi)
jne 0x4d89
incq %r13
decl %r9d
cmpq %r13, %r15
jne 0x4d5d
movq %rbp, %r13
jmp 0x4d89
xorl %r13d, %r13d
addq $0xe, %r12
xorl %r9d, %r9d
movq %r14, %rbp
cmpq %r9, %rbx
je 0x4db4
leaq 0xe(%rbp), %rax
incq %r9
cmpb %sil, (%rbp)
movq %rax, %rbp
je 0x4d93
sete %al
movzbl %al, %eax
addq %rax, %r9
decq %r9
addq %r13, %r9
xorl %ebp, %ebp
cmpb $0x1, %sil
jne 0x4dcd
cmpq $0x4, %r9
sete %bpl
cmoveq %r12, %rcx
jmp 0x4dd9
cmpq $0x4, %r9
setae %bpl
cmovaeq %r12, %rcx
cmpl $0x21, %ebp
je 0x4de2
testl %ebp, %ebp
jne 0x4dfd
incq %r15
incl %r11d
addq $0xe, %r14
decq %rbx
cmpq %r10, %r15
jne 0x4d2c
movl $0x20, %ebp
testb $0x1f, %bpl
movq -0x8(%rsp), %r14
movq -0x10(%rsp), %rbx
jne 0x4e29
incq %rdx
addq $0xf, %r14
decq %rbx
cmpq $0xb, %rdx
sete %al
movq %rax, -0x18(%rsp)
jne 0x4d10
testb $0x1, -0x18(%rsp)
je 0x508d
leaq 0x10(%rdi), %rbx
movl $0xe, %r14d
movq $0x0, -0x18(%rsp)
xorl %r9d, %r9d
movl $0xf, %r10d
subq %r9, %r10
movl $0xffffffff, %r11d      # imm = 0xFFFFFFFF
movq %rbx, -0x8(%rsp)
movq %r14, -0x10(%rsp)
xorl %r15d, %r15d
leaq (%r15,%r9), %r8
leaq (%r15,%r15,4), %r12
leaq (%r12,%r12,2), %r12
addq %r8, %r12
movl $0x2a, %ebp
cmpb $0x0, (%rdi,%r12)
jne 0x4f0d
movl %r15d, %r8d
decl %r8d
js 0x4ebe
movl %r11d, %ebp
incq %rbp
xorl %r13d, %r13d
movl %r8d, %eax
leaq (%r9,%rax), %rdx
leaq (%rax,%rax,4), %rax
leaq (%rax,%rax,2), %rax
addq %rdx, %rax
cmpb %sil, (%rdi,%rax)
jne 0x4ec1
incq %r13
decl %r8d
cmpq %r13, %r15
jne 0x4e96
movq %rbp, %r13
jmp 0x4ec1
xorl %r13d, %r13d
movq %rbx, %rbp
xorl %r8d, %r8d
cmpq %r8, %r14
je 0x4ee8
incq %r8
leaq 0x10(%rbp), %rax
cmpb %sil, (%rbp)
movq %rax, %rbp
je 0x4ec7
sete %al
movzbl %al, %eax
addq %rax, %r8
decq %r8
addq %r13, %r8
xorl %ebp, %ebp
cmpb $0x1, %sil
jne 0x4f01
cmpq $0x4, %r8
sete %bpl
cmoveq %r12, %rcx
jmp 0x4f0d
cmpq $0x4, %r8
setae %bpl
cmovaeq %r12, %rcx
cmpl $0x2a, %ebp
je 0x4f16
testl %ebp, %ebp
jne 0x4f31
incq %r15
incl %r11d
decq %r14
addq $0x10, %rbx
cmpq %r10, %r15
jne 0x4e66
movl $0x29, %ebp
cmpl $0x29, %ebp
movq -0x8(%rsp), %rbx
movq -0x10(%rsp), %r14
je 0x4f44
testl %ebp, %ebp
jne 0x4f5f
incq %r9
decq %r14
incq %rbx
cmpq $0xb, %r9
sete %al
movq %rax, -0x18(%rsp)
jne 0x4e4a
testb $0x1, -0x18(%rsp)
je 0x508d
leaq 0x1f(%rdi), %r11
movl $0x1, %r9d
movl $0xd, %ebx
movl $0xf, %eax
subq %r9, %rax
movl $0xffffffff, %edx       # imm = 0xFFFFFFFF
movq %r11, -0x8(%rsp)
movq %rbx, -0x10(%rsp)
xorl %r14d, %r14d
leaq (%r14,%r9), %r15
leaq (%r15,%r15,4), %r15
leaq (%r15,%r15,2), %r15
addq %r14, %r15
movl $0x33, %ebp
cmpb $0x0, (%rdi,%r15)
jne 0x503a
movl %r14d, %ebp
decl %ebp
js 0x4fe9
movl %edx, %r13d
incq %r13
xorl %r12d, %r12d
movl %ebp, %r8d
leaq (%r9,%r8), %r10
leaq (%r10,%r10,4), %r10
leaq (%r10,%r10,2), %r10
addq %r8, %r10
cmpb %sil, (%rdi,%r10)
jne 0x4fec
incq %r12
decl %ebp
cmpq %r12, %r14
jne 0x4fc2
movq %r13, %r12
jmp 0x4fec
xorl %r12d, %r12d
movq %r11, %rbp
xorl %r13d, %r13d
cmpq %r13, %rbx
je 0x5015
incq %r13
leaq 0x10(%rbp), %r8
cmpb %sil, (%rbp)
movq %r8, %rbp
je 0x4ff2
sete %r8b
movzbl %r8b, %r8d
addq %r8, %r13
decq %r13
addq %r12, %r13
xorl %ebp, %ebp
cmpb $0x1, %sil
jne 0x502e
cmpq $0x4, %r13
sete %bpl
cmoveq %r15, %rcx
jmp 0x503a
cmpq $0x4, %r13
setae %bpl
cmovaeq %r15, %rcx
cmpl $0x33, %ebp
je 0x5043
testl %ebp, %ebp
jne 0x505d
incq %r14
incl %edx
decq %rbx
addq $0x10, %r11
cmpq %rax, %r14
jne 0x4f93
movl $0x32, %ebp
cmpl $0x32, %ebp
je 0x5066
testl %ebp, %ebp
jne 0x508d
incq %r9
movq -0x10(%rsp), %rbx
decq %rbx
movq -0x8(%rsp), %r11
addq $0xf, %r11
xorl %eax, %eax
movl $0x0, %edx
cmpq $0xb, %r9
jne 0x4f79
jmp 0x5092
movq %rcx, %rax
movb $0x1, %dl
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
nop