// File: /workspace/github_cpp_makefile_star2_O1/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 $0x148, %rsp            # imm = 0x148
movl %esi, %ebp
movq %rdi, %r12
leaq 0x88(%rsp), %rbx
movq %rbx, %rdi
movq %r12, %rsi
callq 0x7f28
movq 0x8(%rbx), %rax
movq 0x18(%rbx), %rcx
movl %ebp, 0x3c(%rsp)
cmpl $0x1, %ebp
movq %r12, 0x30(%rsp)
movq %rcx, 0x58(%rsp)
jne 0x9c9e
cmpq %rcx, %rax
je 0x9eff
leaq 0xa8(%rsp), %r13
movq 0x88(%rsp), %r14
movq 0x98(%rsp), %r15
cmpq %r15, %r14
movq %rax, 0x48(%rsp)
jne 0x9a3f
movl $0x4, %ebx
cmpl $0x4, %ebx
movl $0x0, %eax
cmovel %eax, %ebx
testl %ebx, %ebx
jne 0x9eea
movq 0x48(%rsp), %rax
incq %rax
cmpq 0x58(%rsp), %rax
jne 0x99f9
jmp 0x9ee5
leaq (%rax,%rax,4), %rax
leaq (%rax,%rax,2), %rbp
movq %r15, 0x68(%rsp)
movq %rbp, 0x60(%rsp)
leaq (%r14,%rbp), %rcx
movl $0x5, %ebx
cmpb $0x0, (%r12,%rcx)
jne 0x9bc6
movq %r14, 0x50(%rsp)
movq $0xe1, 0x40(%rsp)
movq $0x0, 0x18(%rsp)
movq $0x0, 0x28(%rsp)
movq $0x0, 0x20(%rsp)
movq $0x0, 0x10(%rsp)
xorl %ebp, %ebp
movq %rcx, 0x8(%rsp)
movzbl %bpl, %r12d
movq %r13, %rdi
movq %r13, %r15
movq 0x30(%rsp), %r13
movq %r13, %rsi
movq %rcx, %r14
movq %rcx, %rdx
movl %r12d, %ecx
callq 0x6f68
movq %r15, %rdi
callq 0x70a3
movl %eax, %ebx
testb %al, %al
je 0x9ad5
movb $0x1, %al
movq %rax, 0x18(%rsp)
jmp 0x9b20
leaq 0x70(%rsp), %rdi
movq %r13, %rsi
movq %r15, %rdx
movq %r14, %rcx
movl %r12d, %r8d
leaq 0x40(%rsp), %r9
callq 0x7fea
movq 0x28(%rsp), %rax
addq 0x80(%rsp), %rax
movq %rax, 0x28(%rsp)
movq 0x20(%rsp), %rax
addq 0x78(%rsp), %rax
movq %rax, 0x20(%rsp)
movq 0x10(%rsp), %rax
addq 0x70(%rsp), %rax
movq %rax, 0x10(%rsp)
movq %r15, %r13
cmpb $0x3, %bpl
leal 0x1(%rbp), %eax
setb %cl
xorb $0x1, %bl
movl %eax, %ebp
testb %bl, %cl
movq 0x8(%rsp), %rcx
jne 0x9a9e
movl $0x5, %ebx
testb $0x1, 0x18(%rsp)
je 0x9b61
movq 0x30(%rsp), %r12
movq 0x50(%rsp), %r14
movq 0x68(%rsp), %r15
movq 0x60(%rsp), %rbp
jmp 0x9bc6
movq 0x20(%rsp), %rax
movq 0x28(%rsp), %rdx
addq %rdx, %rax
cmpq $0x1, %rax
movq 0x30(%rsp), %r12
movq 0x68(%rsp), %r15
movq 0x60(%rsp), %rbp
ja 0x9bc1
cmpq $0x1, 0x10(%rsp)
movq 0x50(%rsp), %r14
ja 0x9bc6
movl $0x1, %ebx
cmpq $0x0, 0x28(%rsp)
jne 0x9bc6
movl 0x3c(%rsp), %eax
movb %al, (%r12,%rcx)
cmpq $0x1, 0x20(%rsp)
jne 0x9be4
movq 0x40(%rsp), %rax
cmpq $0xe1, %rax
jb 0x9c05
movb $0x0, (%r12,%rcx)
jmp 0x9bc6
movq 0x50(%rsp), %r14
cmpl $0x5, %ebx
je 0x9bd3
testl %ebx, %ebx
jne 0x9a18
incq %r14
cmpq %r15, %r14
jne 0x9a51
jmp 0x9a13
movzbl %al, %esi
movl $0x3, %edx
movq %r12, %rdi
callq 0x519a
testb $0x1, %dl
je 0x9c37
movq 0x8(%rsp), %rax
movb $0x0, (%r12,%rax)
jmp 0x9bc6
movb $0x2, (%r12,%rax)
movq %r12, %rdi
movl $0x2, %esi
callq 0x49f8
testb $0x1, %dl
je 0x9c5e
movq 0x40(%rsp), %rax
xorl %edx, %edx
movb %dl, (%r12,%rax)
movq 0x8(%rsp), %rax
movb %dl, (%r12,%rax)
movl $0x5, %ebx
jmp 0x9c8e
movl $0x3, %edx
movq %r12, %rdi
movl $0x2, %esi
callq 0x519a
movq 0x8(%rsp), %rax
movb $0x0, (%r12,%rax)
testb $0x1, %dl
je 0x9bc6
jmp 0x9c97
movl $0x3, %edx
movq %r12, %rdi
movl $0x2, %esi
callq 0x519a
movq 0x40(%rsp), %rax
xorl %ecx, %ecx
movb %cl, (%r12,%rax)
movq 0x8(%rsp), %rax
movb %cl, (%r12,%rax)
movl %edx, %eax
notb %al
movzbl %al, %ebx
andl $0x1, %ebx
testb $0x1, %dl
je 0x9bc6
xorl %ebx, %ebx
jmp 0x9bc6
cmpq %rcx, %rax
je 0x9eff
movq 0x30(%rsp), %rbp
movq 0x88(%rsp), %rcx
movq 0x98(%rsp), %rdx
cmpq %rdx, %rcx
movq %rax, 0x48(%rsp)
jne 0x9cf2
movl $0xb, %ebx
cmpl $0xb, %ebx
movl $0x0, %eax
cmovel %eax, %ebx
testl %ebx, %ebx
jne 0x9ef8
movq 0x48(%rsp), %rax
incq %rax
cmpq 0x58(%rsp), %rax
jne 0x9cac
jmp 0x9ef3
leaq (%rax,%rax,4), %rax
leaq (%rax,%rax,2), %rax
movq %rdx, 0x8(%rsp)
movq %rax, 0x18(%rsp)
leaq (%rcx,%rax), %rsi
movl $0xc, %ebx
cmpb $0x0, (%r12,%rsi)
jne 0x9e47
movq %rsi, 0x28(%rsp)
movq %rcx, 0x10(%rsp)
movl $0xe1, %eax
movq %rax, 0x20(%rsp)
xorl %r12d, %r12d
xorl %r15d, %r15d
xorl %r14d, %r14d
movzbl %r15b, %ebx
leaq 0xa8(%rsp), %rdi
movq %rbp, %rsi
movq 0x28(%rsp), %r13
movq %r13, %rdx
movl %ebx, %ecx
callq 0x902a
leaq 0x70(%rsp), %rdi
movq %rbp, %rsi
leaq 0xa8(%rsp), %rdx
movq %r13, %rcx
movl %ebx, %r8d
callq 0x916c
movq 0x78(%rsp), %rax
testq %rax, %rax
je 0x9d82
movq 0x70(%rsp), %rcx
movq %rcx, 0x20(%rsp)
addq 0x80(%rsp), %r12
addq %rax, %r14
incb %r15b
cmpb $0x4, %r15b
jne 0x9d35
testq %r12, %r12
setne %al
cmpq $0x2, %r14
setae %cl
orb %al, %cl
movl $0x1, %ebx
je 0x9db6
movq 0x30(%rsp), %r12
jmp 0x9e38
movl 0x3c(%rsp), %eax
movq 0x30(%rsp), %r12
movq 0x28(%rsp), %r15
movb %al, (%r12,%r15)
cmpq $0x1, %r14
jne 0x9e1e
movq 0x20(%rsp), %r14
cmpq $0xe1, %r14
jae 0x9e33
movq %r12, %rdi
movq %r14, %rsi
callq 0x509e
testb %al, %al
je 0x9e97
movb $0x1, (%r12,%r14)
movq %r12, %rdi
movl $0x1, %esi
callq 0x49f8
testb $0x1, %dl
je 0x9ea3
xorl %eax, %eax
movb %al, (%r12,%r14)
movb %al, (%r12,%r15)
movl $0xc, %ebx
jmp 0x9ec7
movzbl %al, %esi
movl $0x3, %edx
movq %r12, %rdi
callq 0x519a
testb $0x1, %dl
je 0x9e65
movb $0x0, (%r12,%r15)
movq 0x10(%rsp), %rcx
movq 0x8(%rsp), %rdx
movq 0x18(%rsp), %rax
cmpl $0xc, %ebx
je 0x9e54
testl %ebx, %ebx
jne 0x9ccb
incq %rcx
cmpq %rdx, %rcx
jne 0x9d04
jmp 0x9cc6
movl $0x1, %ebx
movl $0x3, %edx
movq %r12, %rdi
movl $0x1, %esi
callq 0x519a
movb $0x0, (%r12,%r15)
testb $0x1, %dl
movq 0x10(%rsp), %rcx
movq 0x8(%rsp), %rdx
movq 0x18(%rsp), %rax
je 0x9e47
jmp 0x9ede
movb $0x0, (%r12,%r15)
movl $0x1, %ebx
jmp 0x9ec7
movl $0x3, %edx
movq %r12, %rdi
movl $0x1, %esi
callq 0x519a
notb %dl
xorl %eax, %eax
movb %al, (%r12,%r14)
movb %al, (%r12,%r15)
andb $0x1, %dl
movzbl %dl, %ebx
movq 0x10(%rsp), %rcx
movq 0x8(%rsp), %rdx
testl %ebx, %ebx
movq 0x18(%rsp), %rax
jne 0x9e47
xorl %ebx, %ebx
jmp 0x9e47
movl $0x2, %ebx
movb $0x1, %al
cmpl $0x2, %ebx
je 0x9eff
jmp 0x9f01
movl $0x9, %ebx
movb $0x1, %al
cmpl $0x9, %ebx
jne 0x9f01
xorl %eax, %eax
addq $0x148, %rsp            # imm = 0x148
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
nop