// File: /workspace/github_cpp_makefile_star2_O3/YSRKEN[P]Shioi/I401/main.cpp
// Function: Board::IsShioiMove(Stone, unsigned long, unsigned long)
bool IsShioiMove(const Stone turn, const size_t block_position, const size_t depth) {
		// Block Katsu-Shi
		if (block_position >= kBoardSize * kBoardSize) {
			return true;
		}
		auto enemy_stone = EnemyTurn(turn);
		if (enemy_stone == Stone::Black && !IsValidMove(block_position)) {
			//PutBoard();
			return true;
		}
		board_[block_position] = enemy_stone;
		// If you must block enemy's Shi-ren or Katsu-shi, this Shioi's challenge is failed.
		auto result = FindGorenMove(enemy_stone);
		if (result.second) {
			board_[block_position] = Stone::None;
			return false;
		}
		//depth limit
		if (depth == 0) {
			board_[block_position] = Stone::None;
			return false;
		}
		// Find Next Shi-ren or Katsu-shi
		auto range = GetRange();
		for (size_t y : rep(range[1], range[3])) {
			for (size_t x : rep(range[0], range[2])) {
				size_t p = ToPosition(x, y);
			if (board_[p] != Stone::None) continue;
			if (turn == Stone::Black) {
				bool cho_ren_flg = false;
				size_t sum_4_strong = 0, sum_4_normal = 0, sum_3 = 0;
				size_t block_position2 = kBoardSize * kBoardSize;
				for (uint8_t dir = 0; dir < Direction::Directions; ++dir) {
					auto move_pattern = GetPatternB(p, static_cast<Direction>(dir));
					if (Board_helper::IsChorenB(move_pattern)) {
						cho_ren_flg = true;
						break;
					}
					//auto ren_count = CountRenB(move_pattern, p, static_cast<Direction>(dir));
					size_t s4s, s4n, s3;
					std::tie(s4s, s4n, s3) = CountRenB2(move_pattern, p, static_cast<Direction>(dir), block_position2);
					sum_4_strong += s4s;
					sum_4_normal += s4n;
					sum_3 += s3;
				}
				if (cho_ren_flg || sum_4_strong + sum_4_normal >= 2 || sum_3 >= 2) continue;
				if (sum_4_strong > 0) {
					board_[block_position] = Stone::None;
					return true;
				}
				if (sum_4_normal == 1) {
					board_[p] = Stone::Black;
					auto score = IsShioiMove(Stone::Black, block_position2, depth - 1);
					board_[p] = Stone::None;
					if (score) {
						board_[block_position] = Stone::None;
						return true;
					}
					continue;
				}
			}
			else {
				size_t block_position2 = kBoardSize * kBoardSize;
				size_t sum_4_strong = 0, sum_4_normal = 0;
				for (uint8_t dir = 0; dir < Direction::Directions; ++dir) {
					auto move_pattern = GetPatternW(p, static_cast<Direction>(dir));
					if (Board_helper::IsChorenW(move_pattern)) return true;
					size_t s4s, s4n, blk;
					std::tie(s4s, s4n, blk) = CountRenW2(move_pattern, p, static_cast<Direction>(dir));
					sum_4_strong += s4s;
					sum_4_normal += s4n;
					if (s4n) block_position2 = blk;
				}
				if (sum_4_strong > 0 || sum_4_normal > 1) {
					board_[block_position] = Stone::None;
					return true;
				}
				if (sum_4_normal == 1) {
					board_[p] = Stone::White;
					auto score = IsShioiMove(Stone::White, block_position2, depth - 1);
					board_[p] = Stone::None;
					if (score) {
						board_[block_position] = Stone::None;
						return true;
					}
					continue;
				}
			}
		}
		}

		board_[block_position] = Stone::None;
		return false;
	}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x148, %rsp            # imm = 0x148
movq %rcx, 0x20(%rsp)
movb $0x1, %bl
movq %rdx, 0x18(%rsp)
cmpq $0xe0, %rdx
ja 0x8389
movl %esi, %r15d
movq %rdi, %r14
cmpb $0x1, %r15b
sete %bpl
je 0x8327
movq %r14, %rdi
movq 0x18(%rsp), %rsi
callq 0x4ed6
testb %al, %al
je 0x8389
incb %bpl
movq 0x18(%rsp), %rbx
movb %bpl, (%r14,%rbx)
movzbl %bpl, %esi
movq %r14, %rdi
callq 0x4990
testb $0x1, %dl
jne 0x8382
cmpq $0x0, 0x20(%rsp)
je 0x8382
leaq 0x88(%rsp), %rbx
movq %rbx, %rdi
movq %r14, %rsi
callq 0x7690
movq 0x8(%rbx), %rcx
movq 0x18(%rbx), %rdx
movq %rcx, 0x30(%rsp)
movq %rdx, 0x78(%rsp)
cmpq %rdx, %rcx
jne 0x839d
movq 0x18(%rsp), %rax
movb $0x0, (%r14,%rax)
jmp 0x8387
movb $0x0, (%r14,%rbx)
xorl %ebx, %ebx
movl %ebx, %eax
addq $0x148, %rsp            # imm = 0x148
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
decq 0x20(%rsp)
movl %r15d, 0x14(%rsp)
movq %r14, 0x8(%rsp)
movq 0x88(%rsp), %r12
movq 0x98(%rsp), %rbp
cmpq %rbp, %r12
je 0x85eb
movq 0x30(%rsp), %rax
leaq (%rax,%rax,4), %rax
leaq (%rax,%rax,2), %r13
movq %rbp, 0x38(%rsp)
movq %r13, 0x40(%rsp)
leaq (%r12,%r13), %rax
cmpb $0x0, (%r14,%rax)
jne 0x85df
movq %rax, 0x28(%rsp)
movq %r12, 0x48(%rsp)
cmpb $0x1, %r15b
jne 0x84e3
movq $0xe1, 0x58(%rsp)
xorl %ebp, %ebp
xorl %r12d, %r12d
xorl %r15d, %r15d
xorl %r13d, %r13d
leaq 0xa8(%rsp), %r14
movq 0x28(%rsp), %rbx
movzbl %bpl, %ebp
movq %r14, %rdi
movq 0x8(%rsp), %rsi
movq %rbx, %rdx
movl %ebp, %ecx
callq 0x66fe
movq %r14, %rdi
callq 0x683c
testb %al, %al
jne 0x85c6
leaq 0x60(%rsp), %rdi
movq 0x8(%rsp), %rsi
movq %r14, %rdx
movq %rbx, %rcx
movl %ebp, %r8d
leaq 0x58(%rsp), %r9
callq 0x773e
addq 0x70(%rsp), %r13
addq 0x68(%rsp), %r15
addq 0x60(%rsp), %r12
incb %bpl
cmpb $0x4, %bpl
jne 0x8420
leaq (%r15,%r13), %rax
cmpq $0x1, %rax
movq 0x8(%rsp), %r14
movq 0x38(%rsp), %rbp
ja 0x85d0
cmpq $0x1, %r12
ja 0x85d0
testq %r13, %r13
jne 0x8618
cmpq $0x1, %r15
jne 0x85d0
movq 0x28(%rsp), %rbx
movb $0x1, (%r14,%rbx)
movq 0x58(%rsp), %rdx
movq %r14, %rdi
movl $0x1, %esi
movq 0x20(%rsp), %rcx
callq 0x82dc
movb $0x0, (%r14,%rbx)
testb %al, %al
je 0x85d0
jmp 0x8618
movl $0xe1, %eax
movq %rax, 0x50(%rsp)
xorl %r13d, %r13d
xorl %eax, %eax
xorl %ebp, %ebp
movq %rax, 0x80(%rsp)
movzbl %r13b, %r15d
leaq 0xa8(%rsp), %r14
movq %r14, %rdi
movq 0x8(%rsp), %rbx
movq %rbx, %rsi
movq 0x28(%rsp), %r12
movq %r12, %rdx
movl %r15d, %ecx
callq 0x862a
leaq 0x60(%rsp), %rdi
movq %rbx, %rsi
movq %r14, %rdx
movq %r12, %rcx
movl %r15d, %r8d
callq 0x8752
movq 0x68(%rsp), %rax
testq %rax, %rax
je 0x854d
movq 0x60(%rsp), %rcx
movq %rcx, 0x50(%rsp)
addq 0x70(%rsp), %rbp
movq 0x80(%rsp), %rcx
addq %rax, %rcx
movq %rcx, %rax
incb %r13b
cmpb $0x4, %r13b
jne 0x84f4
testq %rbp, %rbp
movq 0x40(%rsp), %r13
jne 0x8608
cmpq $0x1, %rax
ja 0x8608
movl 0x14(%rsp), %r15d
movq 0x8(%rsp), %r14
movq 0x48(%rsp), %r12
movq 0x38(%rsp), %rbp
movq 0x28(%rsp), %rax
jne 0x85df
movb $0x2, (%r14,%rax)
movq %r14, %rdi
movq %rax, %rbx
movl $0x2, %esi
movq 0x50(%rsp), %rdx
movq 0x20(%rsp), %rcx
callq 0x82dc
movb $0x0, (%r14,%rbx)
testb %al, %al
je 0x85df
jmp 0x8618
movq 0x8(%rsp), %r14
movq 0x38(%rsp), %rbp
movl 0x14(%rsp), %r15d
movq 0x48(%rsp), %r12
movq 0x40(%rsp), %r13
incq %r12
cmpq %rbp, %r12
jne 0x83dc
movq 0x30(%rsp), %rcx
incq %rcx
movq %rcx, 0x30(%rsp)
cmpq 0x78(%rsp), %rcx
jne 0x83ac
jmp 0x8376
movq 0x18(%rsp), %rax
movq 0x8(%rsp), %rcx
movb $0x0, (%rcx,%rax)
jmp 0x8622
movq 0x18(%rsp), %rax
movb $0x0, (%r14,%rax)
movb $0x1, %bl
jmp 0x8389
nop