// File: /workspace/github_cpp_makefile_star2_O2/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), %rcx
xorl %edx, %edx
movabsq $0xe, %r8
movl $0xffffffff, %r9d       # imm = 0xFFFFFFFF
cmpq $0xf, %rdx
je 0x4453
imulq $0xf, %rdx, %r10
movq %rcx, %r11
movl %r9d, %ebx
movq %r8, %r14
xorl %r15d, %r15d
cmpq $0xf, %r15
je 0x4447
leaq (%r15,%r10), %rax
cmpb $0x0, (%rdi,%rax)
jne 0x443a
movl %ebx, %ebp
xorl %r12d, %r12d
cmpq %r12, %r15
je 0x4403
movl %ebp, %r13d
addq %r10, %r13
cmpb %sil, (%rdi,%r13)
jne 0x4406
incq %r12
decl %ebp
jmp 0x43eb
movq %r15, %r12
xorl %r13d, %r13d
cmpq %r13, %r14
je 0x4419
cmpb %sil, (%r11,%r13)
jne 0x441c
incq %r13
jmp 0x4409
movq %r14, %r13
addq %r12, %r13
cmpb $0x1, %sil
jne 0x4430
cmpq $0x4, %r13
jne 0x443a
jmp 0x4870
cmpq $0x3, %r13
ja 0x4870
incq %r15
decq %r14
incl %ebx
incq %r11
jmp 0x43d6
incq %rdx
addq $0xf, %rcx
jmp 0x43bc
leaq 0xf(%rdi), %rcx
xorl %edx, %edx
movabsq $0xe, %r8
movl $0xffffffff, %r9d       # imm = 0xFFFFFFFF
cmpq $0xf, %rdx
je 0x450f
movq %rcx, %r10
movl %r9d, %r11d
movq %r8, %rbx
xorl %r14d, %r14d
cmpq $0xf, %r14
je 0x4504
imulq $0xf, %r14, %rax
addq %rdx, %rax
cmpb $0x0, (%rdi,%rax)
jne 0x44f2
movl %r11d, %ebp
xorl %r15d, %r15d
cmpq %r15, %r14
je 0x44b4
movl %ebp, %r12d
imulq $0xf, %r12, %r12
addq %rdx, %r12
cmpb %sil, (%rdi,%r12)
jne 0x44b7
incq %r15
decl %ebp
jmp 0x4498
movq %r14, %r15
movq %r10, %r13
xorl %r12d, %r12d
cmpq %r12, %rbx
je 0x44d1
cmpb %sil, (%r13)
jne 0x44d4
incq %r12
addq $0xf, %r13
jmp 0x44bd
movq %rbx, %r12
addq %r15, %r12
cmpb $0x1, %sil
jne 0x44e8
cmpq $0x4, %r12
jne 0x44f2
jmp 0x4870
cmpq $0x3, %r12
ja 0x4870
incq %r14
decq %rbx
incl %r11d
addq $0xf, %r10
jmp 0x447f
incq %rdx
incq %rcx
jmp 0x4469
leaq 0x12(%rdi), %rcx
movabsq $0x4, %rdx
movl $0xffffffff, %r8d       # imm = 0xFFFFFFFF
cmpq $0xf, %rdx
je 0x45c6
movq %rcx, %r9
movl %r8d, %r10d
xorl %r11d, %r11d
movq %rdx, %rbx
subq %r11, %rbx
je 0x45bb
imulq $0xf, %r11, %rax
addq %rbx, %rax
cmpb $0x0, (%rdi,%rax)
jne 0x45ac
movl %r10d, %ebp
xorl %ebx, %ebx
cmpq %rbx, %r11
je 0x4572
movl %ebp, %r14d
movq %rdx, %r15
subq %r14, %r15
imulq $0xf, %r14, %r14
addq %r15, %r14
cmpb %sil, (%rdi,%r14)
jne 0x4575
incq %rbx
decl %ebp
jmp 0x4550
movq %r11, %rbx
movq %r9, %r14
movq %r11, %r15
cmpq %rdx, %r15
jae 0x4591
cmpb %sil, (%r14)
jne 0x4591
addq $0xe, %r14
incq %rbx
incq %r15
jmp 0x457b
cmpb $0x1, %sil
jne 0x45a2
cmpq $0x4, %rbx
jne 0x45ac
jmp 0x4870
cmpq $0x3, %rbx
ja 0x4870
incq %r11
incl %r10d
addq $0xe, %r9
jmp 0x4536
incq %rdx
incq %rcx
jmp 0x4523
leaq 0x2b(%rdi), %rdx
movabsq $0x1, %r8
movabsq $-0xd, %r9
cmpq $0xb, %r8
je 0x46a7
movabsq $0xf, %r11
subq %r8, %r11
movq %r9, %rbx
movq %rdx, %r14
movl $0xffffffff, %ebp       # imm = 0xFFFFFFFF
xorl %r15d, %r15d
cmpq %r11, %r15
je 0x4698
leaq (%r15,%r8), %rax
imulq $0xf, %rax, %rax
subq %r15, %rax
cmpb $0x0, 0xe(%rdi,%rax)
jne 0x4687
addq $0xe, %rax
movl %ebp, %r13d
xorl %r12d, %r12d
cmpq %r12, %r15
je 0x464a
movl %r13d, %ecx
leaq (%r8,%rcx), %r10
imulq $0xf, %r10, %r10
subq %rcx, %r10
cmpb %sil, 0xe(%r10,%rdi)
jne 0x464d
incq %r12
decl %r13d
jmp 0x4628
movq %r15, %r12
xorl %r13d, %r13d
movq %r14, %rcx
cmpq %r13, %rbx
je 0x4666
cmpb %sil, (%rcx)
jne 0x4666
addq $0xe, %rcx
decq %r13
jmp 0x4653
cmpb $0x1, %sil
jne 0x467a
addq $-0x4, %r12
cmpq %r13, %r12
jne 0x4687
jmp 0x4870
subq %r13, %r12
cmpq $0x3, %r12
ja 0x4870
incq %r15
incl %ebp
addq $0xe, %r14
incq %rbx
jmp 0x4603
incq %r8
addq $0xf, %rdx
incq %r9
jmp 0x45de
leaq 0x10(%rdi), %rdx
movabsq $-0xe, %r8
xorl %r9d, %r9d
cmpq $0xb, %r9
je 0x478a
movabsq $0xf, %r11
subq %r9, %r11
movq %rdx, -0x8(%rsp)
movq %r8, %r14
movl $0xffffffff, %ebp       # imm = 0xFFFFFFFF
xorl %r15d, %r15d
xorl %r12d, %r12d
cmpq %r11, %r12
je 0x4777
leaq (%r12,%r9), %r10
imulq $0xf, %r12, %rax
addq %r10, %rax
cmpb $0x0, (%rdi,%rax)
jne 0x4763
movl %ebp, %r10d
xorl %r13d, %r13d
movq %r15, %rbx
addq %r13, %rbx
je 0x4726
movl %r10d, %ebx
leaq (%r9,%rbx), %rcx
imulq $0xf, %rbx, %rbx
addq %rcx, %rbx
cmpb %sil, (%rdi,%rbx)
jne 0x4729
incq %r13
decl %r10d
jmp 0x4702
movq %r12, %r13
movq %rdx, %rbx
xorl %r10d, %r10d
cmpq %r10, %r14
je 0x4742
cmpb %sil, (%rbx)
jne 0x4742
decq %r10
addq $0x10, %rbx
jmp 0x472f
cmpb $0x1, %sil
jne 0x4756
addq $-0x4, %r13
cmpq %r10, %r13
jne 0x4763
jmp 0x4870
subq %r10, %r13
cmpq $0x3, %r13
ja 0x4870
incq %r12
decq %r15
incl %ebp
incq %r14
addq $0x10, %rdx
jmp 0x46e2
incq %r9
incq %r8
movq -0x8(%rsp), %rdx
incq %rdx
jmp 0x46b8
leaq 0x1f(%rdi), %rax
movq %rax, -0x8(%rsp)
movabsq $0x1, %r8
movabsq $-0xd, %r9
cmpq $0xb, %r8
je 0x487d
movabsq $0xf, %r11
subq %r8, %r11
movq -0x8(%rsp), %rbx
movq %r9, %r14
movl $0xffffffff, %ebp       # imm = 0xFFFFFFFF
xorl %r15d, %r15d
xorl %r12d, %r12d
cmpq %r11, %r12
je 0x485f
leaq (%r12,%r8), %rax
imulq $0xf, %rax, %rax
addq %r12, %rax
cmpb $0x0, (%rdi,%rax)
jne 0x484b
movl %ebp, %r10d
xorl %r13d, %r13d
movq %r15, %rcx
addq %r13, %rcx
je 0x4815
movl %r10d, %ecx
leaq (%r8,%rcx), %rdx
imulq $0xf, %rdx, %rdx
addq %rcx, %rdx
cmpb %sil, (%rdi,%rdx)
jne 0x4818
incq %r13
decl %r10d
jmp 0x47f1
movq %r12, %r13
movq %rbx, %rcx
xorl %r10d, %r10d
cmpq %r10, %r14
je 0x4831
cmpb %sil, (%rcx)
jne 0x4831
decq %r10
addq $0x10, %rcx
jmp 0x481e
cmpb $0x1, %sil
jne 0x4842
addq $-0x4, %r13
cmpq %r10, %r13
jne 0x484b
jmp 0x4870
subq %r10, %r13
cmpq $0x3, %r13
ja 0x4870
incq %r12
decq %r15
incl %ebp
incq %r14
addq $0x10, %rbx
jmp 0x47d1
incq %r8
incq %r9
addq $0xf, -0x8(%rsp)
jmp 0x47a7
movb $0x1, %dl
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
xorl %eax, %eax
xorl %edx, %edx
jmp 0x4872
nop