// File: /workspace/github_cpp_makefile_star2_O2/YSRKEN[P]Shioi/I401/main.cpp
// Function: Board::IsBlockMove(Stone, unsigned long)
bool IsBlockMove(const Stone turn, const size_t depth) {
		auto range = GetRange();
		if (turn == Stone::Black) {
			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;
					bool cho_ren_flg = false;
					size_t sum_4_strong = 0, sum_4_normal = 0, sum_3 = 0;
					size_t block_position = 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;
						}
						size_t s4s, s4n, s3;
						std::tie(s4s, s4n, s3) = CountRenB2(move_pattern, p, static_cast<Direction>(dir), block_position);
						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;
					// Shi-ren
					if (sum_4_strong > 0) return true;
					// Katsu-Shi or Other move
					board_[p] = turn;
					if (sum_4_normal == 1) {
						if (block_position >= kBoardSize * kBoardSize) {
							board_[p] = Stone::None;
							return true;
						}
						auto enemy_stone = EnemyTurn(turn);
						board_[block_position] = enemy_stone;
						auto result = FindGorenMove(enemy_stone);
						if (result.second) {
							board_[block_position] = Stone::None;
							board_[p] = Stone::None;
							continue;
						}
						result = FindShioiMove(EnemyTurn(turn), kShioiDepth2);
						//auto flg = IsOiteMove(enemy_stone, depth - 1);
						board_[block_position] = Stone::None;
						board_[p] = Stone::None;
						if (/*!flg &&*/ !result.second) return true;
					}else{
						auto result = FindShioiMove(turn, kShioiDepth2);
						if (result.second) {
							board_[p] = Stone::None;
							return true;
						}
						result = FindShioiMove(EnemyTurn(turn), kShioiDepth2);
						//auto flg = IsOiteMove(EnemyTurn(turn), depth - 1);
						board_[p] = Stone::None;
						if (/*!flg &&*/ !result.second) return true;
					}
				}
			}
		}else{
			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;
					size_t block_position = 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_position = blk;
					}
					// Shi-ren or Shi-Shi
					if (sum_4_strong > 0) {
						return true;
					}
					if (sum_4_normal > 1) {
						return true;
					}
					// Katsu-Shi or Other move
					board_[p] = turn;
					if (sum_4_normal == 1) {
						if (block_position >= kBoardSize * kBoardSize) {
							board_[p] = Stone::None;
							return true;
						}
						auto enemy_stone = EnemyTurn(turn);
						if (!IsValidMove(block_position)) {
							board_[p] = Stone::None;
							return true;
						}
						board_[block_position] = enemy_stone;
						auto result = FindGorenMove(enemy_stone);
						if (result.second) {
							board_[block_position] = Stone::None;
							board_[p] = Stone::None;
							continue;
						}
						result = FindShioiMove(enemy_stone, kShioiDepth2);
						//auto flg = IsOiteMove(enemy_stone, depth - 1);
						board_[block_position] = Stone::None;
						board_[p] = Stone::None;
						if (/*!flg &&*/ !result.second){
							return true;
						}
					}
					else {
						auto result = FindShioiMove(turn, kShioiDepth2);
						if (result.second) {
							board_[p] = Stone::None;
							return true;
						}
						result = FindShioiMove(EnemyTurn(turn), kShioiDepth2);
						//auto flg = IsOiteMove(EnemyTurn(turn), depth - 1);
						board_[p] = Stone::None;
						if (/*!flg &&*/ !result.second) {
							return true;
						}
					}
				}
			}
		}
		return false;
	}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x168, %rsp            # imm = 0x168
movl %esi, %ebp
movq %rdi, %rbx
leaq 0x90(%rsp), %r14
movq %r14, %rdi
movq %rbx, %rsi
callq 0x7058
movq 0x8(%r14), %r12
movq 0x18(%r14), %rax
movq %rax, 0x68(%rsp)
cmpl $0x1, %ebp
movq %rbx, 0x38(%rsp)
jne 0x8c0d
cmpq 0x68(%rsp), %r12
je 0x8e75
movq 0x90(%rsp), %rax
movq 0xa0(%rsp), %rcx
imulq $0xf, %r12, %rdx
movq %r12, 0x30(%rsp)
movq %rcx, 0x28(%rsp)
movq %rdx, 0x20(%rsp)
cmpq %rcx, %rax
je 0x8c05
leaq (%rax,%rdx), %rsi
movq %rsi, (%rsp)
cmpb $0x0, (%rbx,%rsi)
jne 0x8bfd
movq %rax, 0x8(%rsp)
movq $0xe1, 0x18(%rsp)
xorl %eax, %eax
xorl %r14d, %r14d
movq $0x0, 0x10(%rsp)
xorl %r13d, %r13d
leaq 0xc8(%rsp), %rbp
cmpb $0x4, %al
je 0x8b1f
movq %rax, %r12
movzbl %al, %r15d
movq %rbp, %rdi
movq 0x38(%rsp), %rbx
movq %rbx, %rsi
movq (%rsp), %rdx
movl %r15d, %ecx
callq 0x6124
movq %rbp, %rdi
callq 0x6266
testb %al, %al
jne 0x8be9
movq %r13, 0x48(%rsp)
leaq 0xb0(%rsp), %r13
movq %r13, %rdi
movq %rbx, %rsi
movq %rbp, %rdx
movq (%rsp), %rcx
movl %r15d, %r8d
leaq 0x18(%rsp), %r9
callq 0x7102
leaq 0x88(%rsp), %rax
movq %rax, 0x70(%rsp)
leaq 0x50(%rsp), %rax
movq %rax, 0x78(%rsp)
leaq 0x58(%rsp), %rax
movq %rax, 0x80(%rsp)
leaq 0x70(%rsp), %rdi
movq %r13, %rsi
movq 0x48(%rsp), %r13
callq 0x6e2c
addq 0x58(%rsp), %r13
movq 0x10(%rsp), %rax
addq 0x50(%rsp), %rax
movq %rax, 0x10(%rsp)
addq 0x88(%rsp), %r14
movq %r12, %rax
incb %al
jmp 0x8a66
movq 0x10(%rsp), %rax
addq %r13, %rax
cmpq $0x1, %rax
movq 0x38(%rsp), %rbx
ja 0x8be9
cmpq $0x1, %r14
ja 0x8be9
testq %r13, %r13
jne 0x8e5d
movq (%rsp), %rax
movb $0x1, (%rbx,%rax)
cmpq $0x1, 0x10(%rsp)
jne 0x8b93
movq 0x18(%rsp), %rax
cmpq $0xe0, %rax
pushq $0x2
popq %rbp
ja 0x8e4e
movb $0x2, (%rbx,%rax)
movq %rbx, %rdi
movl %ebp, %esi
callq 0x439c
testb $0x1, %dl
je 0x8bc2
movq 0x18(%rsp), %rax
xorl %ecx, %ecx
movb %cl, (%rbx,%rax)
movq (%rsp), %rax
movb %cl, (%rbx,%rax)
jmp 0x8be9
movq %rbx, %rdi
pushq $0x1
popq %rsi
pushq $0x3
popq %rdx
callq 0x4974
testb $0x1, %dl
pushq $0x2
popq %rsi
jne 0x8e4e
movq %rbx, %rdi
pushq $0x3
popq %rdx
callq 0x4974
movq (%rsp), %rax
movb $0x0, (%rbx,%rax)
jmp 0x8be0
movq %rbx, %rdi
movl %ebp, %esi
pushq $0x3
popq %rdx
callq 0x4974
movq 0x18(%rsp), %rax
xorl %ecx, %ecx
movb %cl, (%rbx,%rax)
movq (%rsp), %rax
movb %cl, (%rbx,%rax)
testb $0x1, %dl
je 0x8e5d
movq 0x30(%rsp), %r12
movq 0x8(%rsp), %rax
movq 0x28(%rsp), %rcx
movq 0x20(%rsp), %rdx
incq %rax
jmp 0x8a24
incq %r12
jmp 0x89f6
movzbl %bpl, %eax
movl %eax, 0x60(%rsp)
movl %ebp, 0x64(%rsp)
cmpq 0x68(%rsp), %r12
je 0x8e75
movq 0x90(%rsp), %rax
movq 0xa0(%rsp), %rcx
imulq $0xf, %r12, %rdx
movq %r12, 0x30(%rsp)
movq %rcx, 0x20(%rsp)
movq %rdx, 0x40(%rsp)
cmpq %rcx, %rax
je 0x8e46
leaq (%rax,%rdx), %rsi
cmpb $0x0, (%rbx,%rsi)
jne 0x8e3e
movq %rsi, 0x8(%rsp)
movq %rax, 0x28(%rsp)
movl $0xe1, %r15d
xorl %eax, %eax
xorl %ecx, %ecx
xorl %edx, %edx
cmpb $0x4, %cl
je 0x8d31
movq %rdx, 0x10(%rsp)
movq %rax, (%rsp)
movq %rcx, 0x48(%rsp)
movzbl %cl, %r14d
movq %r15, %r13
leaq 0xc8(%rsp), %r15
movq %r15, %rdi
movq 0x38(%rsp), %r12
movq %r12, %rsi
movq 0x8(%rsp), %rbx
movq %rbx, %rdx
movl %r14d, %ecx
callq 0x805a
leaq 0xb0(%rsp), %rbp
movq %rbp, %rdi
movq %r12, %rsi
movq %r15, %rdx
movq %r13, %r15
movq %rbx, %rcx
movl %r14d, %r8d
callq 0x8182
leaq 0x50(%rsp), %rax
movq %rax, 0x70(%rsp)
leaq 0x58(%rsp), %rax
movq %rax, 0x78(%rsp)
leaq 0x18(%rsp), %rax
movq %rax, 0x80(%rsp)
leaq 0x70(%rsp), %rdi
movq %rbp, %rsi
callq 0x6e2c
movq 0x58(%rsp), %rax
testq %rax, %rax
je 0x8d11
movq 0x50(%rsp), %r15
movq 0x10(%rsp), %rdx
addq 0x18(%rsp), %rdx
movq (%rsp), %rcx
addq %rax, %rcx
movq %rcx, %rax
movq 0x48(%rsp), %rcx
incb %cl
jmp 0x8c74
movb $0x1, %r13b
testq %rdx, %rdx
jne 0x8e60
cmpq $0x1, %rax
ja 0x8e60
movq %r15, %rax
movq 0x38(%rsp), %rbx
movl 0x64(%rsp), %ebp
movq 0x8(%rsp), %r15
movb %bpl, (%rbx,%r15)
jne 0x8dc1
cmpq $0xe1, %rax
movq 0x30(%rsp), %r12
pushq $0x1
popq %r14
pushq $0x3
popq %r13
jae 0x8e54
movq %rax, %r15
movq %rbx, %rdi
movq %rax, %rsi
callq 0x4884
testb %al, %al
je 0x8e54
movb $0x1, (%rbx,%r15)
movq %rbx, %rdi
movl %r14d, %esi
callq 0x439c
testb $0x1, %dl
je 0x8e0b
xorl %eax, %eax
movb %al, (%rbx,%r15)
movq 0x8(%rsp), %rcx
movb %al, (%rbx,%rcx)
movq 0x28(%rsp), %rax
movq 0x20(%rsp), %rcx
movq 0x40(%rsp), %rdx
jmp 0x8e3e
movq %rbx, %rdi
movl 0x60(%rsp), %esi
pushq $0x3
popq %r14
movq %r14, %rdx
callq 0x4974
testb $0x1, %dl
movq 0x30(%rsp), %r12
pushq $0x1
popq %rsi
jne 0x8e7a
movq %rbx, %rdi
movq %r14, %rdx
callq 0x4974
movb $0x0, (%rbx,%r15)
testb $0x1, %dl
movq 0x28(%rsp), %rax
movq 0x20(%rsp), %rcx
movq 0x40(%rsp), %rdx
jne 0x8e3e
jmp 0x8e60
movq %rbx, %rdi
movl %r14d, %esi
movq %r13, %rdx
callq 0x4974
xorl %eax, %eax
movb %al, (%rbx,%r15)
movq 0x8(%rsp), %rcx
movb %al, (%rbx,%rcx)
testb $0x1, %dl
movq 0x28(%rsp), %rax
movq 0x20(%rsp), %rcx
movq 0x40(%rsp), %rdx
movb $0x1, %r13b
je 0x8e60
incq %rax
jmp 0x8c47
incq %r12
jmp 0x8c19
movq (%rsp), %rax
jmp 0x8e59
movq 0x8(%rsp), %rax
movb $0x0, (%rbx,%rax)
movb $0x1, %r13b
movl %r13d, %eax
addq $0x168, %rsp            # imm = 0x168
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
xorl %r13d, %r13d
jmp 0x8e60
movb $0x0, (%rbx,%r15)
jmp 0x8e60
nop