// File: /workspace/github_cpp_makefile_star2_O3/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 $0x128, %rsp            # imm = 0x128
movl %esi, %ebp
movq %rdi, %rbx
leaq 0x68(%rsp), %r14
movq %r14, %rdi
movq %rbx, %rsi
callq 0x7690
movq 0x8(%r14), %rax
movq 0x18(%r14), %rcx
cmpl $0x1, %ebp
jne 0x9193
cmpq %rcx, %rax
je 0x9198
movq %rbx, (%rsp)
leaq 0x88(%rsp), %rbx
movq %rcx, 0x40(%rsp)
movq %rax, 0x8(%rsp)
movq 0x68(%rsp), %rcx
movq 0x78(%rsp), %rdi
cmpq %rdi, %rcx
je 0x917b
movq 0x8(%rsp), %rax
leaq (%rax,%rax,4), %rax
leaq (%rax,%rax,2), %rsi
movq %rdi, 0x18(%rsp)
movq %rsi, 0x10(%rsp)
leaq (%rcx,%rsi), %r13
movq (%rsp), %rax
cmpb $0x0, (%rax,%r13)
jne 0x916f
movq %rcx, 0x20(%rsp)
movq $0xe1, 0x28(%rsp)
xorl %r15d, %r15d
xorl %r12d, %r12d
xorl %r14d, %r14d
xorl %ebp, %ebp
movzbl %bpl, %ebp
movq %rbx, %rdi
movq (%rsp), %rsi
movq %r13, %rdx
movl %ebp, %ecx
callq 0x66fe
movq %rbx, %rdi
callq 0x683c
testb %al, %al
jne 0x9158
leaq 0x50(%rsp), %rdi
movq (%rsp), %rsi
movq %rbx, %rdx
movq %r13, %rcx
movl %ebp, %r8d
leaq 0x28(%rsp), %r9
callq 0x773e
addq 0x60(%rsp), %r15
addq 0x58(%rsp), %r12
addq 0x50(%rsp), %r14
incb %bpl
cmpb $0x4, %bpl
jne 0x9038
leaq (%r15,%r12), %rax
cmpq $0x1, %rax
ja 0x9158
cmpq $0x1, %r14
ja 0x9158
testq %r15, %r15
jne 0x937d
movq (%rsp), %rbx
movq %r13, %r14
movb $0x1, (%rbx,%r13)
cmpq $0x1, %r12
jne 0x90fb
movq 0x28(%rsp), %rax
cmpq $0xe0, %rax
ja 0x9378
movb $0x2, (%rbx,%rax)
movq %rbx, %rdi
movl $0x2, %esi
callq 0x4990
testb $0x1, %dl
je 0x912f
movq 0x28(%rsp), %rax
xorl %ecx, %ecx
movb %cl, (%rbx,%rax)
movb %cl, (%rbx,%r14)
jmp 0x9158
movl $0x3, %edx
movq %rbx, %rdi
movl $0x1, %esi
callq 0x4f7e
testb $0x1, %dl
jne 0x9378
movl $0x3, %edx
movq %rbx, %rdi
movl $0x2, %esi
callq 0x4f7e
movb $0x0, (%rbx,%r14)
jmp 0x914f
movl $0x3, %edx
movq %rbx, %rdi
movl $0x2, %esi
callq 0x4f7e
movq 0x28(%rsp), %rax
xorl %ecx, %ecx
movb %cl, (%rbx,%rax)
movb %cl, (%rbx,%r14)
testb $0x1, %dl
je 0x937d
leaq 0x88(%rsp), %rbx
movq 0x20(%rsp), %rcx
movq 0x18(%rsp), %rdi
movq 0x10(%rsp), %rsi
incq %rcx
cmpq %rdi, %rcx
jne 0x900c
movq 0x8(%rsp), %rax
incq %rax
movq 0x40(%rsp), %rcx
cmpq %rcx, %rax
jne 0x8fdd
jmp 0x9198
cmpq %rcx, %rax
jne 0x91a0
xorl %r13d, %r13d
jmp 0x9380
movq %rcx, 0x40(%rsp)
movq %rax, 0x8(%rsp)
movl %ebp, 0x4c(%rsp)
movq %rbx, (%rsp)
movq (%rsp), %r12
movq 0x68(%rsp), %rcx
movq 0x78(%rsp), %rdx
cmpq %rdx, %rcx
je 0x9354
movq 0x8(%rsp), %rax
leaq (%rax,%rax,4), %rax
leaq (%rax,%rax,2), %rax
movq %rdx, 0x38(%rsp)
movq %rax, 0x30(%rsp)
leaq (%rcx,%rax), %rsi
cmpb $0x0, (%rbx,%rsi)
jne 0x9348
movq %rsi, 0x20(%rsp)
movq %rcx, 0x10(%rsp)
movl $0xe1, %eax
movq %rax, 0x18(%rsp)
xorl %r15d, %r15d
xorl %r14d, %r14d
xorl %ebp, %ebp
movzbl %r14b, %r13d
leaq 0x88(%rsp), %rdi
movq %r12, %rsi
movq 0x20(%rsp), %rbx
movq %rbx, %rdx
movl %r13d, %ecx
callq 0x862a
leaq 0x50(%rsp), %rdi
movq %r12, %rsi
leaq 0x88(%rsp), %rdx
movq %rbx, %rcx
movl %r13d, %r8d
callq 0x8752
movq 0x58(%rsp), %rax
testq %rax, %rax
je 0x9258
movq 0x50(%rsp), %rcx
movq %rcx, 0x18(%rsp)
addq 0x60(%rsp), %r15
addq %rax, %rbp
incb %r14b
cmpb $0x4, %r14b
jne 0x920a
movb $0x1, %r13b
testq %r15, %r15
jne 0x9380
cmpq $0x1, %rbp
ja 0x9380
movl 0x4c(%rsp), %ebp
movq (%rsp), %rbx
movq 0x20(%rsp), %r14
movb %bpl, (%rbx,%r14)
jne 0x92e9
movq 0x18(%rsp), %r15
cmpq $0xe1, %r15
jae 0x9371
movq %rbx, %rdi
movq %r15, %rsi
callq 0x4ed6
testb %al, %al
je 0x9371
movb $0x1, (%rbx,%r15)
movq %rbx, %rdi
movl $0x1, %esi
callq 0x4990
testb $0x1, %dl
je 0x9318
xorl %eax, %eax
movb %al, (%rbx,%r15)
movb %al, (%rbx,%r14)
movq 0x10(%rsp), %rcx
movq 0x38(%rsp), %rdx
movq 0x30(%rsp), %rax
jmp 0x9348
movzbl %bpl, %esi
movl $0x3, %edx
movq %rbx, %rdi
callq 0x4f7e
testb $0x1, %dl
jne 0x9371
movl $0x3, %edx
movq %rbx, %rdi
movl $0x1, %esi
callq 0x4f7e
movb $0x0, (%rbx,%r14)
jmp 0x9334
movl $0x3, %edx
movq %rbx, %rdi
movl $0x1, %esi
callq 0x4f7e
xorl %eax, %eax
movb %al, (%rbx,%r15)
movb %al, (%rbx,%r14)
testb $0x1, %dl
movq 0x10(%rsp), %rcx
movq 0x38(%rsp), %rdx
movq 0x30(%rsp), %rax
je 0x9380
incq %rcx
cmpq %rdx, %rcx
jne 0x91e0
movq 0x8(%rsp), %rcx
incq %rcx
xorl %r13d, %r13d
movq %rcx, 0x8(%rsp)
cmpq 0x40(%rsp), %rcx
jne 0x91b6
jmp 0x9380
movb $0x0, (%rbx,%r14)
jmp 0x9380
movb $0x0, (%rbx,%r14)
movb $0x1, %r13b
movl %r13d, %eax
addq $0x128, %rsp            # imm = 0x128
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
nop