// File: 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
movq %rsp, %rbp
subq $0x480, %rsp            # imm = 0x480
movb %sil, %al
movq %rdi, -0x10(%rbp)
movb %al, -0x11(%rbp)
movq %rdx, -0x20(%rbp)
movq -0x10(%rbp), %rsi
movq %rsi, -0x448(%rbp)
leaq -0x40(%rbp), %rdi
callq 0x126b0
movzbl -0x11(%rbp), %eax
cmpl $0x1, %eax
jne 0x18689
leaq -0x40(%rbp), %rdi
movl $0x1, %esi
callq 0x12a70
movq %rax, -0x450(%rbp)
leaq -0x40(%rbp), %rdi
movl $0x3, %esi
callq 0x12a70
movq -0x450(%rbp), %rdi
movq %rax, %rsi
callq 0xec40
movq %rax, -0x58(%rbp)
movq %rdx, -0x50(%rbp)
leaq -0x58(%rbp), %rax
movq %rax, -0x48(%rbp)
movq -0x48(%rbp), %rdi
callq 0x54e0
movq %rax, -0x60(%rbp)
movq -0x48(%rbp), %rdi
callq 0x5510
movq %rax, -0x68(%rbp)
leaq -0x60(%rbp), %rdi
leaq -0x68(%rbp), %rsi
callq 0x5550
testb $0x1, %al
jne 0x1817c
jmp 0x18684
leaq -0x60(%rbp), %rdi
callq 0x5580
movq (%rax), %rax
movq %rax, -0x70(%rbp)
leaq -0x40(%rbp), %rdi
xorl %eax, %eax
movl %eax, %esi
callq 0x12a70
movq %rax, -0x458(%rbp)
leaq -0x40(%rbp), %rdi
movl $0x2, %esi
callq 0x12a70
movq -0x458(%rbp), %rdi
movq %rax, %rsi
callq 0xec40
movq %rax, -0x88(%rbp)
movq %rdx, -0x80(%rbp)
leaq -0x88(%rbp), %rax
movq %rax, -0x78(%rbp)
movq -0x78(%rbp), %rdi
callq 0x54e0
movq %rax, -0x90(%rbp)
movq -0x78(%rbp), %rdi
callq 0x5510
movq %rax, -0x98(%rbp)
leaq -0x90(%rbp), %rdi
leaq -0x98(%rbp), %rsi
callq 0x5550
testb $0x1, %al
jne 0x1820f
jmp 0x18674
leaq -0x90(%rbp), %rdi
callq 0x5580
movq (%rax), %rax
movq %rax, -0xa0(%rbp)
movq -0xa0(%rbp), %rdi
movq -0x70(%rbp), %rsi
callq 0x3100
movq -0x448(%rbp), %rdi
movq %rax, -0xa8(%rbp)
movq -0xa8(%rbp), %rsi
callq 0x5590
movzbl (%rax), %eax
cmpl $0x0, %eax
je 0x1825c
jmp 0x18663
movb $0x0, -0xa9(%rbp)
movq $0x0, -0xb8(%rbp)
movq $0x0, -0xc0(%rbp)
movq $0x0, -0xc8(%rbp)
movq $0xe1, -0xd0(%rbp)
movb $0x0, -0xd1(%rbp)
movzbl -0xd1(%rbp), %eax
cmpl $0x4, %eax
jge 0x1839b
movq -0x448(%rbp), %rsi
movq -0xa8(%rbp), %rdx
leaq -0x178(%rbp), %rdi
movzbl -0xd1(%rbp), %ecx
callq 0xed20
leaq -0x178(%rbp), %rdi
callq 0xef70
testb $0x1, %al
jne 0x182d9
jmp 0x182e5
movb $0x1, -0xa9(%rbp)
jmp 0x1839b
movq -0x448(%rbp), %rsi
movq -0xa8(%rbp), %rcx
leaq -0x1a8(%rbp), %rdi
leaq -0x178(%rbp), %rdx
leaq -0xd0(%rbp), %r9
movzbl -0xd1(%rbp), %r8d
callq 0x12aa0
leaq -0x1c0(%rbp), %rdi
leaq -0x180(%rbp), %rsi
leaq -0x188(%rbp), %rdx
leaq -0x190(%rbp), %rcx
callq 0x11390
leaq -0x1c0(%rbp), %rdi
leaq -0x1a8(%rbp), %rsi
callq 0x113d0
movq -0x180(%rbp), %rax
addq -0xb8(%rbp), %rax
movq %rax, -0xb8(%rbp)
movq -0x188(%rbp), %rax
addq -0xc0(%rbp), %rax
movq %rax, -0xc0(%rbp)
movq -0x190(%rbp), %rax
addq -0xc8(%rbp), %rax
movq %rax, -0xc8(%rbp)
movb -0xd1(%rbp), %al
addb $0x1, %al
movb %al, -0xd1(%rbp)
jmp 0x18296
testb $0x1, -0xa9(%rbp)
jne 0x183c2
movq -0xb8(%rbp), %rax
addq -0xc0(%rbp), %rax
cmpq $0x2, %rax
jae 0x183c2
cmpq $0x2, -0xc8(%rbp)
jb 0x183c7
jmp 0x18663
cmpq $0x0, -0xb8(%rbp)
jbe 0x183da
movb $0x1, -0x1(%rbp)
jmp 0x18c22
movq -0x448(%rbp), %rdi
movb -0x11(%rbp), %al
movb %al, -0x459(%rbp)
movq -0xa8(%rbp), %rsi
callq 0x5590
movb -0x459(%rbp), %cl
movb %cl, (%rax)
cmpq $0x1, -0xc0(%rbp)
jne 0x1857c
cmpq $0xe1, -0xd0(%rbp)
jb 0x18438
movq -0x448(%rbp), %rdi
movq -0xa8(%rbp), %rsi
callq 0x5590
movb $0x0, (%rax)
movb $0x1, -0x1(%rbp)
jmp 0x18c22
movzbl -0x11(%rbp), %edi
callq 0x68d0
movq -0x448(%rbp), %rdi
movb %al, -0x1c1(%rbp)
movb -0x1c1(%rbp), %al
movb %al, -0x45a(%rbp)
movq -0xd0(%rbp), %rsi
callq 0x5590
movb -0x45a(%rbp), %cl
movq -0x448(%rbp), %rdi
movb %cl, (%rax)
movzbl -0x1c1(%rbp), %esi
callq 0x9ae0
movb %dl, -0x1e0(%rbp)
movq %rax, -0x1e8(%rbp)
movq -0x1e8(%rbp), %rax
movq %rax, -0x1d8(%rbp)
movb -0x1e0(%rbp), %al
movb %al, -0x1d0(%rbp)
testb $0x1, -0x1d0(%rbp)
je 0x184e2
movq -0x448(%rbp), %rdi
movq -0xd0(%rbp), %rsi
callq 0x5590
movq -0x448(%rbp), %rdi
movb $0x0, (%rax)
movq -0xa8(%rbp), %rsi
callq 0x5590
movb $0x0, (%rax)
jmp 0x18663
movzbl -0x11(%rbp), %edi
callq 0x68d0
movq -0x448(%rbp), %rdi
movzbl %al, %esi
movl $0x3, %edx
callq 0xb0b0
movb %dl, -0x200(%rbp)
movq %rax, -0x208(%rbp)
movq -0x208(%rbp), %rax
movq %rax, -0x1f8(%rbp)
movb -0x200(%rbp), %al
movb %al, -0x1f0(%rbp)
leaq -0x1d8(%rbp), %rdi
leaq -0x1f8(%rbp), %rsi
callq 0xaf40
movq -0x448(%rbp), %rdi
movq -0xd0(%rbp), %rsi
callq 0x5590
movq -0x448(%rbp), %rdi
movb $0x0, (%rax)
movq -0xa8(%rbp), %rsi
callq 0x5590
movb $0x0, (%rax)
testb $0x1, -0x1d0(%rbp)
jne 0x18577
movb $0x1, -0x1(%rbp)
jmp 0x18c22
jmp 0x18661
movq -0x448(%rbp), %rdi
movzbl -0x11(%rbp), %esi
movl $0x3, %edx
callq 0xb0b0
movb %dl, -0x220(%rbp)
movq %rax, -0x228(%rbp)
movq -0x228(%rbp), %rax
movq %rax, -0x218(%rbp)
movb -0x220(%rbp), %al
movb %al, -0x210(%rbp)
testb $0x1, -0x210(%rbp)
je 0x185e0
movq -0x448(%rbp), %rdi
movq -0xa8(%rbp), %rsi
callq 0x5590
movb $0x0, (%rax)
movb $0x1, -0x1(%rbp)
jmp 0x18c22
movzbl -0x11(%rbp), %edi
callq 0x68d0
movq -0x448(%rbp), %rdi
movzbl %al, %esi
movl $0x3, %edx
callq 0xb0b0
movb %dl, -0x240(%rbp)
movq %rax, -0x248(%rbp)
movq -0x248(%rbp), %rax
movq %rax, -0x238(%rbp)
movb -0x240(%rbp), %al
movb %al, -0x230(%rbp)
leaq -0x218(%rbp), %rdi
leaq -0x238(%rbp), %rsi
callq 0xaf40
movq -0x448(%rbp), %rdi
movq -0xa8(%rbp), %rsi
callq 0x5590
movb $0x0, (%rax)
testb $0x1, -0x210(%rbp)
jne 0x1865f
movb $0x1, -0x1(%rbp)
jmp 0x18c22
jmp 0x18661
jmp 0x18663
leaq -0x90(%rbp), %rdi
callq 0x55c0
jmp 0x181f3
jmp 0x18676
leaq -0x60(%rbp), %rdi
callq 0x55c0
jmp 0x18166
jmp 0x18c1e
leaq -0x40(%rbp), %rdi
movl $0x1, %esi
callq 0x12a70
movq %rax, -0x468(%rbp)
leaq -0x40(%rbp), %rdi
movl $0x3, %esi
callq 0x12a70
movq -0x468(%rbp), %rdi
movq %rax, %rsi
callq 0xec40
movq %rax, -0x260(%rbp)
movq %rdx, -0x258(%rbp)
leaq -0x260(%rbp), %rax
movq %rax, -0x250(%rbp)
movq -0x250(%rbp), %rdi
callq 0x54e0
movq %rax, -0x268(%rbp)
movq -0x250(%rbp), %rdi
callq 0x5510
movq %rax, -0x270(%rbp)
leaq -0x268(%rbp), %rdi
leaq -0x270(%rbp), %rsi
callq 0x5550
testb $0x1, %al
jne 0x18719
jmp 0x18c1c
leaq -0x268(%rbp), %rdi
callq 0x5580
movq (%rax), %rax
movq %rax, -0x278(%rbp)
leaq -0x40(%rbp), %rdi
xorl %eax, %eax
movl %eax, %esi
callq 0x12a70
movq %rax, -0x470(%rbp)
leaq -0x40(%rbp), %rdi
movl $0x2, %esi
callq 0x12a70
movq -0x470(%rbp), %rdi
movq %rax, %rsi
callq 0xec40
movq %rax, -0x290(%rbp)
movq %rdx, -0x288(%rbp)
leaq -0x290(%rbp), %rax
movq %rax, -0x280(%rbp)
movq -0x280(%rbp), %rdi
callq 0x54e0
movq %rax, -0x298(%rbp)
movq -0x280(%rbp), %rdi
callq 0x5510
movq %rax, -0x2a0(%rbp)
leaq -0x298(%rbp), %rdi
leaq -0x2a0(%rbp), %rsi
callq 0x5550
testb $0x1, %al
jne 0x187be
jmp 0x18c09
leaq -0x298(%rbp), %rdi
callq 0x5580
movq (%rax), %rax
movq %rax, -0x2a8(%rbp)
movq -0x2a8(%rbp), %rdi
movq -0x278(%rbp), %rsi
callq 0x3100
movq -0x448(%rbp), %rdi
movq %rax, -0x2b0(%rbp)
movq -0x2b0(%rbp), %rsi
callq 0x5590
movzbl (%rax), %eax
cmpl $0x0, %eax
je 0x1880e
jmp 0x18bf8
movq $0xe1, -0x2b8(%rbp)
movq $0x0, -0x2c0(%rbp)
movq $0x0, -0x2c8(%rbp)
movb $0x0, -0x2c9(%rbp)
movzbl -0x2c9(%rbp), %eax
cmpl $0x4, %eax
jge 0x1891b
movq -0x448(%rbp), %rsi
movq -0x2b0(%rbp), %rdx
leaq -0x370(%rbp), %rdi
movzbl -0x2c9(%rbp), %ecx
callq 0x159c0
movq -0x448(%rbp), %rsi
movq -0x2b0(%rbp), %rcx
leaq -0x3a0(%rbp), %rdi
leaq -0x370(%rbp), %rdx
movzbl -0x2c9(%rbp), %r8d
callq 0x15c00
leaq -0x3b8(%rbp), %rdi
leaq -0x378(%rbp), %rsi
leaq -0x380(%rbp), %rdx
leaq -0x388(%rbp), %rcx
callq 0x11390
leaq -0x3b8(%rbp), %rdi
leaq -0x3a0(%rbp), %rsi
callq 0x113d0
movq -0x378(%rbp), %rax
addq -0x2c0(%rbp), %rax
movq %rax, -0x2c0(%rbp)
movq -0x380(%rbp), %rax
addq -0x2c8(%rbp), %rax
movq %rax, -0x2c8(%rbp)
cmpq $0x0, -0x380(%rbp)
je 0x18906
movq -0x388(%rbp), %rax
movq %rax, -0x2b8(%rbp)
jmp 0x18908
movb -0x2c9(%rbp), %al
addb $0x1, %al
movb %al, -0x2c9(%rbp)
jmp 0x18836
cmpq $0x0, -0x2c0(%rbp)
jbe 0x1892e
movb $0x1, -0x1(%rbp)
jmp 0x18c22
cmpq $0x1, -0x2c8(%rbp)
jbe 0x18941
movb $0x1, -0x1(%rbp)
jmp 0x18c22
movq -0x448(%rbp), %rdi
movb -0x11(%rbp), %al
movb %al, -0x471(%rbp)
movq -0x2b0(%rbp), %rsi
callq 0x5590
movb -0x471(%rbp), %cl
movb %cl, (%rax)
cmpq $0x1, -0x2c8(%rbp)
jne 0x18b14
cmpq $0xe1, -0x2b8(%rbp)
jb 0x1899f
movq -0x448(%rbp), %rdi
movq -0x2b0(%rbp), %rsi
callq 0x5590
movb $0x0, (%rax)
movb $0x1, -0x1(%rbp)
jmp 0x18c22
movzbl -0x11(%rbp), %edi
callq 0x68d0
movq -0x448(%rbp), %rdi
movb %al, -0x3b9(%rbp)
movq -0x2b8(%rbp), %rsi
callq 0xaf70
testb $0x1, %al
jne 0x189e4
movq -0x448(%rbp), %rdi
movq -0x2b0(%rbp), %rsi
callq 0x5590
movb $0x0, (%rax)
movb $0x1, -0x1(%rbp)
jmp 0x18c22
movq -0x448(%rbp), %rdi
movb -0x3b9(%rbp), %al
movb %al, -0x472(%rbp)
movq -0x2b8(%rbp), %rsi
callq 0x5590
movb -0x472(%rbp), %cl
movq -0x448(%rbp), %rdi
movb %cl, (%rax)
movzbl -0x3b9(%rbp), %esi
callq 0x9ae0
movb %dl, -0x3d8(%rbp)
movq %rax, -0x3e0(%rbp)
movq -0x3e0(%rbp), %rax
movq %rax, -0x3d0(%rbp)
movb -0x3d8(%rbp), %al
movb %al, -0x3c8(%rbp)
testb $0x1, -0x3c8(%rbp)
je 0x18a7f
movq -0x448(%rbp), %rdi
movq -0x2b8(%rbp), %rsi
callq 0x5590
movq -0x448(%rbp), %rdi
movb $0x0, (%rax)
movq -0x2b0(%rbp), %rsi
callq 0x5590
movb $0x0, (%rax)
jmp 0x18bf8
movq -0x448(%rbp), %rdi
movzbl -0x3b9(%rbp), %esi
movl $0x3, %edx
callq 0xb0b0
movb %dl, -0x3f8(%rbp)
movq %rax, -0x400(%rbp)
movq -0x400(%rbp), %rax
movq %rax, -0x3f0(%rbp)
movb -0x3f8(%rbp), %al
movb %al, -0x3e8(%rbp)
leaq -0x3d0(%rbp), %rdi
leaq -0x3f0(%rbp), %rsi
callq 0xaf40
movq -0x448(%rbp), %rdi
movq -0x2b8(%rbp), %rsi
callq 0x5590
movq -0x448(%rbp), %rdi
movb $0x0, (%rax)
movq -0x2b0(%rbp), %rsi
callq 0x5590
movb $0x0, (%rax)
testb $0x1, -0x3c8(%rbp)
jne 0x18b0f
movb $0x1, -0x1(%rbp)
jmp 0x18c22
jmp 0x18bf6
movq -0x448(%rbp), %rdi
movzbl -0x11(%rbp), %esi
movl $0x3, %edx
callq 0xb0b0
movb %dl, -0x418(%rbp)
movq %rax, -0x420(%rbp)
movq -0x420(%rbp), %rax
movq %rax, -0x410(%rbp)
movb -0x418(%rbp), %al
movb %al, -0x408(%rbp)
testb $0x1, -0x408(%rbp)
je 0x18b78
movq -0x448(%rbp), %rdi
movq -0x2b0(%rbp), %rsi
callq 0x5590
movb $0x0, (%rax)
movb $0x1, -0x1(%rbp)
jmp 0x18c22
movzbl -0x11(%rbp), %edi
callq 0x68d0
movq -0x448(%rbp), %rdi
movzbl %al, %esi
movl $0x3, %edx
callq 0xb0b0
movb %dl, -0x438(%rbp)
movq %rax, -0x440(%rbp)
movq -0x440(%rbp), %rax
movq %rax, -0x430(%rbp)
movb -0x438(%rbp), %al
movb %al, -0x428(%rbp)
leaq -0x410(%rbp), %rdi
leaq -0x430(%rbp), %rsi
callq 0xaf40
movq -0x448(%rbp), %rdi
movq -0x2b0(%rbp), %rsi
callq 0x5590
movb $0x0, (%rax)
testb $0x1, -0x408(%rbp)
jne 0x18bf4
movb $0x1, -0x1(%rbp)
jmp 0x18c22
jmp 0x18bf6
jmp 0x18bf8
leaq -0x298(%rbp), %rdi
callq 0x55c0
jmp 0x187a2
jmp 0x18c0b
leaq -0x268(%rbp), %rdi
callq 0x55c0
jmp 0x186fd
jmp 0x18c1e
movb $0x0, -0x1(%rbp)
movb -0x1(%rbp), %al
andb $0x1, %al
addq $0x480, %rsp            # imm = 0x480
popq %rbp
retq