// File: /workspace/github_cpp_makefile_star2_O2/YSRKEN[P]Shioi/I401/main.cpp
// Function: Board::CountRenW2(std::array<std::array<PackedStone, 5ul>, 2ul> const&, unsigned long, Direction)
RenCount CountRenW2(const Pattern &pattern, const size_t position, const Direction dir) {
		/* Count "Straight Shi-Shi"
		* 1. BO|BBB|OB   "Ryoutou-no-ShiShi"
		* 2. BBO|BB|OBB  "Chouda-no-ShiShi"
		* 3. BBBO|B|OBBB "Souryu-no-ShiShi"
		* 一直線上に出来る四々で、両頭の四々・長蛇の四々・双龍の四々
		*/
		namespace p = packed_stone;
		{
			//BO|BBB|OB
			if (MatchPatternW(pattern, position, dir, {{ p::nw, p::wwnw }})) return RenCount(0, 2, 0);
			if (MatchPatternW(pattern, position, dir, {{ p::wnw, p::wnw }})) return RenCount(0, 2, 0);
			if (MatchPatternW(pattern, position, dir, {{ p::wwnw, p::nw }})) return RenCount(0, 2, 0);
			//BBO|BB|OBB
			if (MatchPatternW(pattern, position, dir, {{ p::nww, p::wnww }})) return RenCount(0, 2, 0);
			if (MatchPatternW(pattern, position, dir, {{ p::wnww, p::nww }})) return RenCount(0, 2, 0);
			//BBBO|B|OBBB
			if (MatchPatternW(pattern, position, dir, {{ p::nwww, p::nwww }})) return RenCount(0, 2, 0);
		}
		// Count Shi-ren
		{
			if (MatchPatternW(pattern, position, dir, {{ p::n, p::wwwn }})) return RenCount(1, 0, 0);
			if (MatchPatternW(pattern, position, dir, {{ p::wn, p::wwn }})) return RenCount(1, 0, 0);
			if (MatchPatternW(pattern, position, dir, {{ p::wwwn, p::n }})) return RenCount(1, 0, 0);
			if (MatchPatternW(pattern, position, dir, {{ p::wwn, p::wn }})) return RenCount(1, 0, 0);
		}
		// Count Katsu-Shi
		{
			auto GetPosition = [&position, &dir](int count) -> int {return position + kPositionoffset[dir] * count; };
			//11110
			if (MatchPatternW(pattern, position, dir, {{ p::www, p::n }})) {
				return RenCount(0, 1, GetPosition(1) | limit2(0_sz, kBoardSize * kBoardSize));
			}
			if (MatchPatternW(pattern, position, dir, {{ p::ww, p::wn }})) {
				return RenCount(0, 1, GetPosition(2) | limit2(0_sz, kBoardSize * kBoardSize));
			}
			if (MatchPatternW(pattern, position, dir, {{ p::w, p::wwn }})) {
				return RenCount(0, 1, GetPosition(3) | limit2(0_sz, kBoardSize * kBoardSize));
			}
			if (MatchPatternW(pattern, position, dir, Side::Right, p::wwwn)) {
				return RenCount(0, 1, GetPosition(4) | limit2(0_sz, kBoardSize * kBoardSize));
			}
			//11101
			if (MatchPatternW(pattern, position, dir, Side::Left, p::nwww)) {
				return RenCount(0, 1, GetPosition(-1) | limit2(0_sz, kBoardSize * kBoardSize));
			}
			if (MatchPatternW(pattern, position, dir, {{ p::ww, p::nw }})) {
				return RenCount(0, 1, GetPosition(1) | limit2(0_sz, kBoardSize * kBoardSize));
			}
			if (MatchPatternW(pattern, position, dir, {{ p::w, p::wnw }})) {
				return RenCount(0, 1, GetPosition(2) | limit2(0_sz, kBoardSize * kBoardSize));
			}
			if (MatchPatternW(pattern, position, dir, Side::Right, p::wwnw)) {
				return RenCount(0, 1, GetPosition(3) | limit2(0_sz, kBoardSize * kBoardSize));
			}
			//11011
			if (MatchPatternW(pattern, position, dir, Side::Left, p::wnww)) {
				return RenCount(0, 1, GetPosition(-2) | limit2(0_sz, kBoardSize * kBoardSize));
			}
			if (MatchPatternW(pattern, position, dir, {{ p::nww, p::w }})) {
				return RenCount(0, 1, GetPosition(-1) | limit2(0_sz, kBoardSize * kBoardSize));
			}
			if (MatchPatternW(pattern, position, dir, Side::Right, p::wnww)) {
				return RenCount(0, 1, GetPosition(2) | limit2(0_sz, kBoardSize * kBoardSize));
			}
			if (MatchPatternW(pattern, position, dir, {{ p::w, p::nww }})) {
				return RenCount(0, 1, GetPosition(1) | limit2(0_sz, kBoardSize * kBoardSize));
			}
			//10111
			if (MatchPatternW(pattern, position, dir, Side::Right, p::nwww)) {
				return RenCount(0, 1, GetPosition(1) | limit2(0_sz, kBoardSize * kBoardSize));
			}
			if (MatchPatternW(pattern, position, dir, {{ p::nw, p::ww }})) {
				return RenCount(0, 1, GetPosition(-1) | limit2(0_sz, kBoardSize * kBoardSize));
			}
			if (MatchPatternW(pattern, position, dir, {{ p::wnw, p::w }})) {
				return RenCount(0, 1, GetPosition(-2) | limit2(0_sz, kBoardSize * kBoardSize));
			}
			if (MatchPatternW(pattern, position, dir, Side::Left, p::wwnw)) {
				return RenCount(0, 1, GetPosition(-3) | limit2(0_sz, kBoardSize * kBoardSize));
			}
			//01111
			if (MatchPatternW(pattern, position, dir, {{ p::n, p::www }})) {
				return RenCount(0, 1, GetPosition(-1) | limit2(0_sz, kBoardSize * kBoardSize));
			}
			if (MatchPatternW(pattern, position, dir, {{ p::wn, p::ww }})) {
				return RenCount(0, 1, GetPosition(-2) | limit2(0_sz, kBoardSize * kBoardSize));
			}
			if (MatchPatternW(pattern, position, dir, {{ p::wwn, p::w }})) {
				return RenCount(0, 1, GetPosition(-3) | limit2(0_sz, kBoardSize * kBoardSize));
			}
			if (MatchPatternW(pattern, position, dir, Side::Left, p::wwwn)) {
				return RenCount(0, 1, GetPosition(-4) | limit2(0_sz, kBoardSize * kBoardSize));
			}
		}
		return RenCount(0, 0, 0);
	}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0xa8, %rsp
movl %r8d, %ebp
movq %rcx, %r14
movq %rdx, %r12
movq %rsi, %r13
movq %rdi, %rbx
pushq $0x2
popq %r15
leaq 0x8(%rsp), %r8
movq %r15, (%r8)
movq %r15, 0x8(%r8)
movq $0xa2, 0x10(%r8)
movq $0x4, 0x18(%r8)
movq %rsi, %rdi
movq %rdx, %rsi
movq %rcx, %rdx
movl %ebp, %ecx
callq 0x8900
testb %al, %al
jne 0x82e2
pushq $0x22
popq %rax
leaq 0x8(%rsp), %r8
movq %rax, (%r8)
pushq $0x3
popq %rcx
movq %rcx, 0x8(%r8)
movq %rax, 0x10(%r8)
movq %rcx, 0x18(%r8)
movzbl %bpl, %ebp
movq %r13, %rdi
movq %r12, %rsi
movq %r14, %rdx
movl %ebp, %ecx
callq 0x8900
testb %al, %al
jne 0x82e2
leaq 0x8(%rsp), %r8
movq $0xa2, (%r8)
movq $0x4, 0x8(%r8)
movq %r15, 0x10(%r8)
movq %r15, 0x18(%r8)
movq %r13, %rdi
movq %r12, %rsi
movq %r14, %rdx
movl %ebp, %ecx
callq 0x8900
testb %al, %al
jne 0x82e2
leaq 0x8(%rsp), %r8
movq $0xa, (%r8)
movq $0x3, 0x8(%r8)
movq $0x8a, 0x10(%r8)
movq $0x4, 0x18(%r8)
movq %r13, %rdi
movq %r12, %rsi
movq %r14, %rdx
movl %ebp, %ecx
callq 0x8900
testb %al, %al
jne 0x82e2
leaq 0x8(%rsp), %r8
movq $0x8a, (%r8)
movq $0x4, 0x8(%r8)
movq $0xa, 0x10(%r8)
movq $0x3, 0x18(%r8)
movq %r13, %rdi
movq %r12, %rsi
movq %r14, %rdx
movl %ebp, %ecx
callq 0x8900
testb %al, %al
jne 0x82e2
pushq $0x2a
popq %rax
leaq 0x8(%rsp), %r8
movq %rax, (%r8)
pushq $0x4
popq %rcx
movq %rcx, 0x8(%r8)
movq %rax, 0x10(%r8)
movq %rcx, 0x18(%r8)
movq %r13, %rdi
movq %r12, %rsi
movq %r14, %rdx
movl %ebp, %ecx
callq 0x8900
testb %al, %al
je 0x8308
andq $0x0, (%rbx)
movq $0x2, 0x8(%rbx)
andq $0x0, 0x10(%rbx)
movq %rbx, %rax
addq $0xa8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
leaq 0x8(%rsp), %r8
andq $0x0, (%r8)
movq $0x1, 0x8(%r8)
movq $0xa8, 0x10(%r8)
movq $0x4, 0x18(%r8)
movq %r13, %rdi
movq %r12, %rsi
movq %r14, %rdx
movl %ebp, %ecx
callq 0x8900
testb %al, %al
jne 0x83e6
leaq 0x8(%rsp), %r8
movq $0x8, (%r8)
movq $0x2, 0x8(%r8)
movq $0x28, 0x10(%r8)
movq $0x3, 0x18(%r8)
movq %r13, %rdi
movq %r12, %rsi
movq %r14, %rdx
movl %ebp, %ecx
callq 0x8900
testb %al, %al
jne 0x83e6
leaq 0x8(%rsp), %r8
movq $0xa8, (%r8)
movq $0x4, 0x8(%r8)
andq $0x0, 0x10(%r8)
movq $0x1, 0x18(%r8)
movq %r13, %rdi
movq %r12, %rsi
movq %r14, %rdx
movl %ebp, %ecx
callq 0x8900
testb %al, %al
jne 0x83e6
leaq 0x8(%rsp), %r8
movq $0x28, (%r8)
movq $0x3, 0x8(%r8)
movq $0x8, 0x10(%r8)
movq $0x2, 0x18(%r8)
movq %r13, %rdi
movq %r12, %rsi
movq %r14, %rdx
movl %ebp, %ecx
callq 0x8900
testb %al, %al
je 0x83f9
xorps %xmm0, %xmm0
movups %xmm0, (%rbx)
movq $0x1, 0x10(%rbx)
jmp 0x82f3
leaq 0x8(%rsp), %r8
movq $0x2a, (%r8)
movq $0x3, 0x8(%r8)
andq $0x0, 0x10(%r8)
movq $0x1, 0x18(%r8)
movq %r13, %rdi
movq %r12, %rsi
movq %r14, %rdx
movl %ebp, %ecx
callq 0x8900
testb %al, %al
je 0x845d
leaq 0x2f6b(%rip), %rax      # 0xb3a0
addq (%rax,%rbp,8), %r14
movl %r14d, %eax
movl $0xe1, %ecx
cmpq %rcx, %rax
cmovaeq %rcx, %rax
xorl %edx, %edx
testl %r14d, %r14d
cmovneq %rax, %rdx
cmovsq %rcx, %rdx
movq %rdx, (%rbx)
jmp 0x8545
leaq 0x8(%rsp), %r8
movq $0xa, (%r8)
movq %r15, 0x8(%r8)
movq $0x8, 0x10(%r8)
movq %r15, 0x18(%r8)
movq %r13, %rdi
movq %r12, %rsi
movq %r14, %rdx
movl %ebp, %ecx
callq 0x8900
testb %al, %al
je 0x84a1
leaq 0x2f0c(%rip), %rax      # 0xb3a0
movq (%rax,%rbp,8), %rax
leaq (%r14,%rax,2), %rax
jmp 0x8528
leaq 0x8(%rsp), %r8
movq $0x2, (%r8)
movq $0x1, 0x8(%r8)
movq $0x28, 0x10(%r8)
movq $0x3, 0x18(%r8)
movq %r13, %rdi
movq %r12, %rsi
movq %r14, %rdx
movl %ebp, %ecx
callq 0x8900
testb %al, %al
je 0x84ea
leaq 0x2ec0(%rip), %rax      # 0xb3a0
imulq $0x3, (%rax,%rbp,8), %rax
addq %r14, %rax
jmp 0x8528
leaq 0x98(%rsp), %r9
movq $0xa8, (%r9)
movq $0x4, 0x8(%r9)
pushq $0x1
popq %r8
movq %r13, %rdi
movq %r12, %rsi
movq %r14, %rdx
movl %ebp, %ecx
callq 0x896a
testb %al, %al
je 0x8552
leaq 0x2e80(%rip), %rax      # 0xb3a0
movq (%rax,%rbp,8), %rax
leaq (%r14,%rax,4), %rax
movl %eax, %ecx
movl $0xe1, %edx
cmpq %rdx, %rcx
cmovaeq %rdx, %rcx
xorl %esi, %esi
testl %eax, %eax
cmovneq %rcx, %rsi
cmovsq %rdx, %rsi
movq %rsi, (%rbx)
movq $0x1, 0x8(%rbx)
jmp 0x82ee
leaq 0x88(%rsp), %r9
movq $0x2a, (%r9)
movq $0x4, 0x8(%r9)
movq %r13, %rdi
movq %r12, %rsi
movq %r14, %rdx
movl %ebp, %ecx
xorl %r8d, %r8d
callq 0x896a
testb %al, %al
je 0x85ac
leaq 0x2e19(%rip), %rax      # 0xb3a0
movl $0xffffffff, %ecx       # imm = 0xFFFFFFFF
imulq (%rax,%rbp,8), %rcx
addq %r14, %rcx
movl %ecx, %eax
movl $0xe1, %edx
cmpq %rdx, %rax
cmovaeq %rdx, %rax
xorl %esi, %esi
testl %ecx, %ecx
cmovneq %rax, %rsi
jmp 0x853e
leaq 0x8(%rsp), %r8
movq $0xa, (%r8)
movq %r15, 0x8(%r8)
movq %r15, 0x10(%r8)
movq %r15, 0x18(%r8)
movq %r13, %rdi
movq %r12, %rsi
movq %r14, %rdx
movl %ebp, %ecx
callq 0x8900
testb %al, %al
jne 0x842e
leaq 0x8(%rsp), %r8
movq $0x2, (%r8)
movq $0x1, 0x8(%r8)
movq $0x22, 0x10(%r8)
movq $0x3, 0x18(%r8)
movq %r13, %rdi
movq %r12, %rsi
movq %r14, %rdx
movl %ebp, %ecx
callq 0x8900
testb %al, %al
jne 0x848d
leaq 0x78(%rsp), %r9
movq $0xa2, (%r9)
movq $0x4, 0x8(%r9)
pushq $0x1
popq %r8
movq %r13, %rdi
movq %r12, %rsi
movq %r14, %rdx
movl %ebp, %ecx
callq 0x896a
testb %al, %al
jne 0x84d9
leaq 0x68(%rsp), %r9
movq $0x8a, (%r9)
movq $0x4, 0x8(%r9)
movq %r13, %rdi
movq %r12, %rsi
movq %r14, %rdx
movl %ebp, %ecx
xorl %r8d, %r8d
callq 0x896a
testb %al, %al
je 0x8687
leaq 0x2d26(%rip), %rax      # 0xb3a0
movl $0xffffffff, %ecx       # imm = 0xFFFFFFFF
decq %rcx
jmp 0x858c
leaq 0x8(%rsp), %r8
movq $0xa, (%r8)
movq $0x3, 0x8(%r8)
movq $0x2, 0x10(%r8)
movq $0x1, 0x18(%r8)
movq %r13, %rdi
movq %r12, %rsi
movq %r14, %rdx
movl %ebp, %ecx
callq 0x8900
testb %al, %al
jne 0x8580
leaq 0x58(%rsp), %r9
movq $0x8a, (%r9)
movq $0x4, 0x8(%r9)
pushq $0x1
popq %r8
movq %r13, %rdi
movq %r12, %rsi
movq %r14, %rdx
movl %ebp, %ecx
callq 0x896a
testb %al, %al
jne 0x848d
leaq 0x8(%rsp), %r8
movq $0x2, (%r8)
movq $0x1, 0x8(%r8)
movq $0xa, 0x10(%r8)
movq $0x3, 0x18(%r8)
movq %r13, %rdi
movq %r12, %rsi
movq %r14, %rdx
movl %ebp, %ecx
callq 0x8900
testb %al, %al
jne 0x842e
leaq 0x48(%rsp), %r9
movq $0x2a, (%r9)
movq $0x4, 0x8(%r9)
pushq $0x1
popq %r8
movq %r13, %rdi
movq %r12, %rsi
movq %r14, %rdx
movl %ebp, %ecx
callq 0x896a
testb %al, %al
jne 0x842e
leaq 0x8(%rsp), %r8
movq %r15, (%r8)
movq %r15, 0x8(%r8)
movq $0xa, 0x10(%r8)
movq %r15, 0x18(%r8)
movq %r13, %rdi
movq %r12, %rsi
movq %r14, %rdx
movl %ebp, %ecx
callq 0x8900
testb %al, %al
jne 0x8580
leaq 0x8(%rsp), %r8
movq $0x22, (%r8)
movq $0x3, 0x8(%r8)
movq $0x2, 0x10(%r8)
movq $0x1, 0x18(%r8)
movq %r13, %rdi
movq %r12, %rsi
movq %r14, %rdx
movl %ebp, %ecx
callq 0x8900
testb %al, %al
jne 0x8673
leaq 0x38(%rsp), %r9
movq $0xa2, (%r9)
movq $0x4, 0x8(%r9)
movq %r13, %rdi
movq %r12, %rsi
movq %r14, %rdx
movl %ebp, %ecx
xorl %r8d, %r8d
callq 0x896a
testb %al, %al
je 0x880b
leaq 0x2ba3(%rip), %rax      # 0xb3a0
movl $0xffffffff, %ecx       # imm = 0xFFFFFFFF
addq $-0x2, %rcx
jmp 0x858c
leaq 0x8(%rsp), %r8
andq $0x0, (%r8)
movq $0x1, 0x8(%r8)
movq $0x2a, 0x10(%r8)
movq $0x3, 0x18(%r8)
movq %r13, %rdi
movq %r12, %rsi
movq %r14, %rdx
movl %ebp, %ecx
callq 0x8900
testb %al, %al
jne 0x8580
leaq 0x8(%rsp), %r8
movq $0x8, (%r8)
movq %r15, 0x8(%r8)
movq $0xa, 0x10(%r8)
movq %r15, 0x18(%r8)
movq %r13, %rdi
movq %r12, %rsi
movq %r14, %rdx
movl %ebp, %ecx
callq 0x8900
testb %al, %al
jne 0x8673
leaq 0x8(%rsp), %r8
movq $0x28, (%r8)
movq $0x3, 0x8(%r8)
movq $0x2, 0x10(%r8)
movq $0x1, 0x18(%r8)
movq %r13, %rdi
movq %r12, %rsi
movq %r14, %rdx
movl %ebp, %ecx
callq 0x8900
testb %al, %al
jne 0x87f6
leaq 0x28(%rsp), %r9
movq $0xa8, (%r9)
movq $0x4, 0x8(%r9)
movq %r13, %rdi
movq %r12, %rsi
movq %r14, %rdx
movl %ebp, %ecx
xorl %r8d, %r8d
callq 0x896a
testb %al, %al
je 0x88f4
leaq 0x2aba(%rip), %rax      # 0xb3a0
movl $0xffffffff, %ecx       # imm = 0xFFFFFFFF
addq $-0x3, %rcx
jmp 0x858c
xorps %xmm0, %xmm0
movups %xmm0, (%rbx)
jmp 0x82ee
nop