// File: /workspace/github_cpp_makefile_star2_O1/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 $0x28, %rsp
movl %r8d, %ebp
movq %rcx, %r14
movq %rdx, %r12
movq %rsi, %r13
movq %rdi, %rbx
movl $0x2, %eax
leaq 0x8(%rsp), %r8
movq %rax, (%r8)
movq %rax, 0x8(%r8)
movq $0xa2, 0x10(%r8)
movq $0x4, 0x18(%r8)
movq %rsi, %rdi
movq %rdx, %rsi
movq %rcx, %rdx
movl %ebp, %ecx
callq 0x993a
testb %al, %al
jne 0x92dc
movl $0x22, %eax
leaq 0x8(%rsp), %r8
movq %rax, (%r8)
movl $0x3, %ecx
movq %rcx, 0x8(%r8)
movq %rax, 0x10(%r8)
movq %rcx, 0x18(%r8)
movzbl %bpl, %r15d
movq %r13, %rdi
movq %r12, %rsi
movq %r14, %rdx
movl %r15d, %ecx
callq 0x993a
testb %al, %al
jne 0x92dc
leaq 0x8(%rsp), %r8
movq $0xa2, (%r8)
movq $0x4, 0x8(%r8)
movl $0x2, %eax
movq %rax, 0x10(%r8)
movq %rax, 0x18(%r8)
movq %r13, %rdi
movq %r12, %rsi
movq %r14, %rdx
movl %r15d, %ecx
callq 0x993a
testb %al, %al
jne 0x92dc
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 %r15d, %ecx
callq 0x993a
testb %al, %al
jne 0x92dc
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 %r15d, %ecx
callq 0x993a
testb %al, %al
jne 0x92dc
movl $0x2a, %eax
leaq 0x8(%rsp), %r8
movq %rax, (%r8)
movl $0x4, %ecx
movq %rcx, 0x8(%r8)
movq %rax, 0x10(%r8)
movq %rcx, 0x18(%r8)
movq %r13, %rdi
movq %r12, %rsi
movq %r14, %rdx
movl %r15d, %ecx
callq 0x993a
testb %al, %al
je 0x92ff
xorl %eax, %eax
movq %rax, (%rbx)
movq $0x2, 0x8(%rbx)
movq %rax, 0x10(%rbx)
movq %rbx, %rax
addq $0x28, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
leaq 0x8(%rsp), %r8
movq $0x0, (%r8)
movq $0x1, 0x8(%r8)
movq $0xa8, 0x10(%r8)
movq $0x4, 0x18(%r8)
movq %r13, %rdi
movq %r12, %rsi
movq %r14, %rdx
movl %r15d, %ecx
callq 0x993a
testb %al, %al
jne 0x93e7
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 %r15d, %ecx
callq 0x993a
testb %al, %al
jne 0x93e7
leaq 0x8(%rsp), %r8
movq $0xa8, (%r8)
movq $0x4, 0x8(%r8)
movq $0x0, 0x10(%r8)
movq $0x1, 0x18(%r8)
movq %r13, %rdi
movq %r12, %rsi
movq %r14, %rdx
movl %r15d, %ecx
callq 0x993a
testb %al, %al
jne 0x93e7
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 %r15d, %ecx
callq 0x993a
testb %al, %al
je 0x93fa
xorps %xmm0, %xmm0
movups %xmm0, (%rbx)
movq $0x1, 0x10(%rbx)
jmp 0x92ed
leaq 0x8(%rsp), %r8
movq $0x2a, (%r8)
movq $0x3, 0x8(%r8)
movq $0x0, 0x10(%r8)
movq $0x1, 0x18(%r8)
movq %r13, %rdi
movq %r12, %rsi
movq %r14, %rdx
movl %r15d, %ecx
callq 0x993a
testb %al, %al
je 0x9457
leaq 0x2f96(%rip), %rax      # 0xc3d0
addq (%rax,%r15,8), %r14
testl %r14d, %r14d
js 0x9506
movl %r14d, %eax
andl $0x7fffffff, %eax       # imm = 0x7FFFFFFF
testl %r14d, %r14d
jmp 0x94f6
leaq 0x8(%rsp), %r8
movq $0xa, (%r8)
movl $0x2, %eax
movq %rax, 0x8(%r8)
movq $0x8, 0x10(%r8)
movq %rax, 0x18(%r8)
movq %r13, %rdi
movq %r12, %rsi
movq %r14, %rdx
movl %r15d, %ecx
callq 0x993a
testb %al, %al
je 0x949e
leaq 0x2f3c(%rip), %rax      # 0xc3d0
movq (%rax,%r15,8), %rax
leaq (%r14,%rax,2), %rcx
jmp 0x94e9
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 %r15d, %ecx
callq 0x993a
testb %al, %al
je 0x9523
leaq 0x2ef2(%rip), %rax      # 0xc3d0
movq (%rax,%r15,8), %rax
leaq (%rax,%rax,2), %rcx
addq %r14, %rcx
testl %ecx, %ecx
js 0x9506
movl %ecx, %eax
andl $0x7fffffff, %eax       # imm = 0x7FFFFFFF
testl %ecx, %ecx
sete %cl
cmpq $0xe1, %rax
setb %dl
orb %cl, %dl
jne 0x950b
movl $0xe1, %eax
movq %rax, (%rbx)
movq $0x1, 0x8(%rbx)
movq $0x0, 0x10(%rbx)
jmp 0x92ed
movq %r14, %rax
shlq $0x6, %rax
addq %r13, %rax
movl %r15d, %ecx
shll $0x4, %ecx
cmpq $0x4, 0xf0(%rcx,%rax)
jae 0x97cb
leaq (%rcx,%rax), %rbp
addq $0xe8, %rbp
cmpq $0x4, (%rbp)
jae 0x9800
leaq 0x8(%rsp), %r8
movq $0xa, (%r8)
movl $0x2, %eax
movq %rax, 0x8(%r8)
movq %rax, 0x10(%r8)
movq %rax, 0x18(%r8)
movq %r13, %rdi
movq %r12, %rsi
movq %r14, %rdx
movl %r15d, %ecx
callq 0x993a
testb %al, %al
jne 0x9433
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 %r15d, %ecx
callq 0x993a
testb %al, %al
jne 0x948d
cmpq $0x4, 0x8(%rbp)
jae 0x9832
cmpq $0x4, (%rbp)
jae 0x9858
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 %r15d, %ecx
callq 0x993a
testb %al, %al
jne 0x9818
cmpq $0x4, 0x8(%rbp)
jae 0x98b6
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 %r15d, %ecx
callq 0x993a
testb %al, %al
jne 0x9433
cmpq $0x4, 0x8(%rbp)
jae 0x98dc
movl $0x2, %eax
leaq 0x8(%rsp), %r8
movq %rax, (%r8)
movq %rax, 0x8(%r8)
movq $0xa, 0x10(%r8)
movq %rax, 0x18(%r8)
movq %r13, %rdi
movq %r12, %rsi
movq %r14, %rdx
movl %r15d, %ecx
callq 0x993a
testb %al, %al
jne 0x9818
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 %r15d, %ecx
callq 0x993a
testb %al, %al
jne 0x9873
cmpq $0x4, (%rbp)
jb 0x9702
cmpq $0x4, 0x38(%r12)
jne 0x9702
cmpq $0xa2, 0x30(%r12)
je 0x97b6
leaq 0x8(%rsp), %r8
movq $0x0, (%r8)
movq $0x1, 0x8(%r8)
movq $0x2a, 0x10(%r8)
movq $0x3, 0x18(%r8)
movq %r13, %rdi
movq %r12, %rsi
movq %r14, %rdx
movl %r15d, %ecx
callq 0x993a
testb %al, %al
jne 0x9818
leaq 0x8(%rsp), %r8
movq $0x8, (%r8)
movl $0x2, %eax
movq %rax, 0x8(%r8)
movq $0xa, 0x10(%r8)
movq %rax, 0x18(%r8)
movq %r13, %rdi
movq %r12, %rsi
movq %r14, %rdx
movl %r15d, %ecx
callq 0x993a
testb %al, %al
jne 0x9873
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 %r15d, %ecx
callq 0x993a
testb %al, %al
je 0x98ff
leaq 0x2c13(%rip), %rcx      # 0xc3d0
movl $0xffffffff, %eax       # imm = 0xFFFFFFFF
addq $-0x2, %rax
jmp 0x9882
cmpq $0x4, 0x88(%r12)
jne 0x9542
cmpq $0xa8, 0x80(%r12)
jne 0x9542
leaq 0x2bdd(%rip), %rax      # 0xc3d0
movq (%rax,%r15,8), %rax
leaq (%r14,%rax,4), %rcx
jmp 0x94e9
cmpq $0x4, 0x38(%r12)
jne 0x9558
cmpq $0x2a, 0x30(%r12)
jne 0x9558
leaq 0x2bb1(%rip), %rax      # 0xc3d0
movq (%rax,%r15,8), %rax
movq %rax, %rcx
shlq $0x20, %rcx
subq %rax, %rcx
jmp 0x94e6
cmpq $0x4, 0x88(%r12)
jne 0x95d6
cmpq $0xa2, 0x80(%r12)
je 0x94d7
jmp 0x95d6
cmpq $0x4, 0x38(%r12)
jne 0x95e1
cmpq $0x8a, 0x30(%r12)
jne 0x95e1
leaq 0x2b56(%rip), %rcx      # 0xc3d0
movl $0xffffffff, %eax       # imm = 0xFFFFFFFF
decq %rax
imulq (%rcx,%r15,8), %rax
addq %r14, %rax
testl %eax, %eax
js 0x98a9
movl %eax, %ecx
andl $0x7fffffff, %ecx       # imm = 0x7FFFFFFF
testl %eax, %eax
sete %al
cmpq $0xe1, %rcx
setb %dl
orb %al, %dl
jne 0x98ae
movl $0xe1, %ecx
movq %rcx, (%rbx)
jmp 0x950e
cmpq $0x4, 0x88(%r12)
jne 0x9629
cmpq $0x8a, 0x80(%r12)
je 0x948d
jmp 0x9629
cmpq $0x4, 0x88(%r12)
jne 0x9671
cmpq $0x2a, 0x80(%r12)
je 0x9433
jmp 0x9671
cmpq $0x4, (%rbp)
jb 0x992e
cmpq $0x4, 0x38(%r12)
jne 0x992e
cmpq $0xa8, 0x30(%r12)
jne 0x992e
leaq 0x2ab0(%rip), %rcx      # 0xc3d0
movl $0xffffffff, %eax       # imm = 0xFFFFFFFF
addq $-0x3, %rax
jmp 0x9882
xorps %xmm0, %xmm0
movups %xmm0, (%rbx)
jmp 0x9516
nop