// File: /workspace/github_cpp_makefile_star2_O2/YSRKEN[P]Shioi/I401/main.cpp
// Function: Board::NegaMax(Stone, unsigned long, int, int)
int NegaMax(const Stone turn, const size_t depth, int /*alpha*/, int beta) {
		if (FindGorenMove(turn).second) return beta;
		int max_score = -kScoreInf2;
		if (depth == 0) {
			// Find enemy's Shioi(Pre-search)
			if (turn == Stone::Black) {
				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;
						// Judge valid move
						bool cho_ren_flg = false;
						size_t sum_4_strong = 0, sum_4_normal = 0, sum_3 = 0;
						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) = CountRenB(move_pattern, p, static_cast<Direction>(dir));
							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 == 1) return beta;
						int score;
						/* // Find enemy's Shioi
						board_[p] = turn;
						auto result = FindShioiMove(EnemyTurn(turn), kShioiDepth3);
						board_[p] = Stone::None;
						if (result.second) {
							// Don't block Shioi
							score = -kScoreInf;
						}
						else {*/
							// Normal Score
							score = CalcScore(p, turn);
						//}
						if (max_score < score) {
							max_score = score;
							if (max_score >= beta) {
								return beta;
							}
						}
					}
				}
			}
			else {
				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;
						size_t sum_4_strong = 0, sum_4_normal = 0, sum_3 = 0;
						for (uint8_t dir = 0; dir < Direction::Directions; ++dir) {
							auto move_pattern = GetPatternB(p, static_cast<Direction>(dir));
							if (Board_helper::IsChorenB(move_pattern)) return beta;
							size_t s4s, s4n, s3;
							std::tie(s4s, s4n, s3) = CountRenB(move_pattern, p, static_cast<Direction>(dir));
							sum_4_strong += s4s;
							sum_4_normal += s4n;
							sum_3 += s3;
						}
						if (sum_4_strong >= 1 || sum_4_normal >= 2) return beta;
						int score;
						/*// Find enemy's Shioi
						board_[p] = turn;
						auto result = FindShioiMove(EnemyTurn(turn), kShioiDepth3);
						board_[p] = Stone::None;
						if (result.second) {
							// Don't block Shioi
							score = -kScoreInf;
						}
						else {*/
							// Normal Score
							score = CalcScore(p, turn);
						//}
						if (max_score < score) {
							max_score = score;
							if (max_score >= beta) {
								return beta;
							}
						}
					}
				}
			}
			return max_score;
		}
		else {
			vector<Score> next_move2;
			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;
						// Judge valid move
						bool cho_ren_flg = false;
						size_t sum_4_strong = 0, sum_4_normal = 0, sum_3 = 0;
						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) = CountRenB(move_pattern, p, static_cast<Direction>(dir));
							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 == 1) return kScoreInf;
						/*// Find enemy's Shioi
						board_[p] = Stone::Black;
						auto result = FindShioiMove(Stone::White, kShioiDepth3);
						board_[p] = Stone::None;
						if (result.second) {
							// Don't block Shioi
							next_move2.emplace_back(p, -kScoreInf);
						}
						else {*/
							// Normal Score
							next_move2.emplace_back(p, kTenGenDist[p]);
						//}
					}
				}
			}
			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 sum_4_strong = 0, sum_4_normal = 0, sum_3 = 0;
						for (uint8_t dir = 0; dir < Direction::Directions; ++dir) {
							auto move_pattern = GetPatternB(p, static_cast<Direction>(dir));
							if (Board_helper::IsChorenB(move_pattern)) return kScoreInf;
							size_t s4s, s4n, s3;
							std::tie(s4s, s4n, s3) = CountRenB(move_pattern, p, static_cast<Direction>(dir));
							sum_4_strong += s4s;
							sum_4_normal += s4n;
							sum_3 += s3;
						}
						if (sum_4_strong >= 1 || sum_4_normal >= 2) return kScoreInf;
						/*// Find enemy's Shioi
						board_[p] = Stone::White;
						auto result = FindShioiMove(Stone::Black, kShioiDepth3);
						board_[p] = Stone::None;
						if (result.second) {
							// Don't block Shioi
							next_move2.emplace_back(p, -kScoreInf);
						}
						else {*/
							// Normal Score
							next_move2.emplace_back(p, kTenGenDist[p]);
						//}
					}
				}
			}
			std::sort(next_move2.begin(), next_move2.end(), [](const Score &a, const Score &b) {return a.second > b.second; });
			for (auto &it : next_move2) {
				board_[it.first] = turn;
				auto score = -NegaMax(EnemyTurn(turn), depth - 1, -kScoreInf2, kScoreInf2) + CalcScore(it.first, turn);
				board_[it.first] = Stone::None;
				if (max_score < score) {
					max_score = score;
					if (max_score >= beta) {
						return beta;
					}
				}
			}
			return max_score;
		}
	}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x188, %rsp            # imm = 0x188
movl %r8d, 0x14(%rsp)
movq %rdx, %rbx
movl %esi, %ebp
movq %rdi, 0x8(%rsp)
callq 0x439c
testb $0x1, %dl
je 0x917b
movl 0x14(%rsp), %eax
jmp 0x96e1
testq %rbx, %rbx
je 0x938a
movq %rbx, 0x38(%rsp)
xorps %xmm0, %xmm0
movaps %xmm0, 0x70(%rsp)
andq $0x0, 0x80(%rsp)
leaq 0xc8(%rsp), %rbx
movq %rbx, %rdi
movq 0x8(%rsp), %r14
movq %r14, %rsi
callq 0x7058
movq %r14, %rsi
leaq 0x3928(%r14), %rax
movq %rax, 0x40(%rsp)
movq 0x8(%rbx), %rax
movq 0x18(%rbx), %rcx
movq %rcx, 0x58(%rsp)
cmpb $0x1, %bpl
movl %ebp, 0x60(%rsp)
leaq 0xe8(%rsp), %rbp
jne 0x957d
leaq 0xa8(%rsp), %rbx
cmpq 0x58(%rsp), %rax
je 0x9889
movq 0xc8(%rsp), %r15
movq 0xd8(%rsp), %r12
movq %rax, 0x20(%rsp)
imulq $0xf, %rax, %r13
movq %r12, 0x48(%rsp)
movq %r13, 0x28(%rsp)
cmpq %r12, %r15
je 0x937d
leaq (%r15,%r13), %rax
movq %rax, 0x18(%rsp)
cmpb $0x0, (%rsi,%rax)
jne 0x9375
movq %r15, 0x50(%rsp)
xorl %r14d, %r14d
xorl %r15d, %r15d
xorl %eax, %eax
xorl %ecx, %ecx
cmpb $0x4, %cl
je 0x9305
movq %rax, 0x30(%rsp)
movq 0x18(%rsp), %rdx
movq %rcx, %r13
movzbl %cl, %r12d
movq %rbp, %rdi
movl %r12d, %ecx
callq 0x6124
movq %rbp, %rdi
callq 0x6266
testb %al, %al
jne 0x9359
movq 0x18(%rsp), %rcx
movq %rbx, %rdi
movq 0x8(%rsp), %rsi
leaq 0xe8(%rsp), %rdx
movl %r12d, %r8d
callq 0x6406
leaq 0xc0(%rsp), %rax
movq %rax, 0x88(%rsp)
leaq 0xa0(%rsp), %rax
movq %rax, 0x90(%rsp)
leaq 0x68(%rsp), %rax
movq %rax, 0x98(%rsp)
leaq 0x88(%rsp), %rdi
movq %rbx, %rsi
callq 0x6e2c
addq 0x68(%rsp), %r14
addq 0xa0(%rsp), %r15
movq 0x30(%rsp), %rax
addq 0xc0(%rsp), %rax
movq %r13, %rcx
incb %cl
movq 0x8(%rsp), %rsi
leaq 0xe8(%rsp), %rbp
jmp 0x9245
addq %r14, %r15
cmpq $0x1, %r15
movq 0x50(%rsp), %r15
movq 0x48(%rsp), %r12
movq 0x28(%rsp), %r13
ja 0x9375
cmpq $0x1, %rax
ja 0x9375
cmpq $0x1, %r14
je 0x96ce
movq 0x18(%rsp), %rax
movq 0x40(%rsp), %rcx
leaq (%rcx,%rax,8), %rdx
leaq 0x70(%rsp), %rdi
leaq 0x18(%rsp), %rsi
callq 0x9120
leaq 0xe8(%rsp), %rbp
movq 0x8(%rsp), %rsi
jmp 0x9375
movq 0x8(%rsp), %rsi
leaq 0xe8(%rsp), %rbp
movq 0x50(%rsp), %r15
movq 0x48(%rsp), %r12
movq 0x28(%rsp), %r13
incq %r15
jmp 0x921a
movq 0x20(%rsp), %rax
incq %rax
jmp 0x91ec
cmpb $0x1, %bpl
movq 0x8(%rsp), %rsi
leaq 0xc8(%rsp), %rbx
movq %rbx, %rdi
jne 0x96f3
movq 0x8(%rsp), %rsi
callq 0x7058
movq 0x8(%rsp), %rcx
movq 0x8(%rbx), %r14
movq 0x18(%rbx), %rax
movq %rax, 0x60(%rsp)
movl $0xfffffc17, 0x38(%rsp) # imm = 0xFFFFFC17
cmpq 0x60(%rsp), %r14
je 0x992d
movq 0xc8(%rsp), %rbx
movq 0xd8(%rsp), %r15
imulq $0xf, %r14, %r12
movq %r14, 0x20(%rsp)
movq %r15, 0x40(%rsp)
movq %r12, 0x58(%rsp)
cmpq %r15, %rbx
je 0x9575
leaq (%rbx,%r12), %rax
cmpb $0x0, (%rcx,%rax)
jne 0x956d
movq %rbx, 0x28(%rsp)
xorl %esi, %esi
xorl %edx, %edx
xorl %r12d, %r12d
xorl %r14d, %r14d
cmpb $0x4, %sil
je 0x94e9
movq %rdx, 0x30(%rsp)
movq %rsi, 0x50(%rsp)
movzbl %sil, %ebp
leaq 0xe8(%rsp), %r13
movq %r13, %rdi
movq %rcx, %rbx
movq %rcx, %rsi
movq %rax, %r15
movq %rax, %rdx
movl %ebp, %ecx
callq 0x6124
movq %r13, %rdi
callq 0x6266
testb %al, %al
jne 0x953e
movq %r14, 0x48(%rsp)
leaq 0x70(%rsp), %r14
movq %r14, %rdi
movq %rbx, %rsi
movq %r13, %rdx
movq %r15, %rcx
movl %ebp, %r8d
callq 0x6406
leaq 0x68(%rsp), %rax
movq %rax, 0xa8(%rsp)
leaq 0x18(%rsp), %rax
movq %rax, 0xb0(%rsp)
leaq 0x88(%rsp), %rax
movq %rax, 0xb8(%rsp)
leaq 0xa8(%rsp), %rdi
movq %r14, %rsi
movq 0x48(%rsp), %r14
callq 0x6e2c
addq 0x88(%rsp), %r14
addq 0x18(%rsp), %r12
movq 0x30(%rsp), %rdx
addq 0x68(%rsp), %rdx
movq 0x50(%rsp), %rsi
incb %sil
movq %rbx, %rcx
movq %r15, %rax
jmp 0x941c
addq %r14, %r12
cmpq $0x1, %r12
movq 0x58(%rsp), %r12
ja 0x955e
cmpq $0x1, %rdx
movq 0x28(%rsp), %rbx
movq 0x40(%rsp), %r15
ja 0x9557
cmpq $0x1, %r14
movq 0x20(%rsp), %r14
je 0x9172
movq %rcx, %rdi
movq %rax, %rsi
pushq $0x1
popq %rdx
callq 0x8f18
movq 0x8(%rsp), %rcx
cmpl %eax, 0x38(%rsp)
jge 0x956d
movl %eax, 0x38(%rsp)
cmpl 0x14(%rsp), %eax
jl 0x956d
jmp 0x9172
movq %rbx, %rcx
movq 0x20(%rsp), %r14
movq 0x28(%rsp), %rbx
movq 0x40(%rsp), %r15
movq 0x58(%rsp), %r12
jmp 0x956d
movq 0x20(%rsp), %r14
jmp 0x956d
movq 0x20(%rsp), %r14
movq 0x28(%rsp), %rbx
movq 0x40(%rsp), %r15
incq %rbx
jmp 0x93f6
incq %r14
jmp 0x93c8
movq %rax, %rbx
cmpq 0x58(%rsp), %rbx
je 0x9889
movq 0xc8(%rsp), %rcx
movq 0xd8(%rsp), %rdx
imulq $0xf, %rbx, %rdi
movq %rdx, 0x50(%rsp)
movq %rdi, 0x48(%rsp)
movq %rbx, 0x20(%rsp)
cmpq %rdx, %rcx
je 0x96c6
leaq (%rcx,%rdi), %rax
movq %rax, 0x18(%rsp)
cmpb $0x0, (%rsi,%rax)
jne 0x96be
movq %rcx, 0x30(%rsp)
xorl %r15d, %r15d
xorl %r14d, %r14d
xorl %eax, %eax
cmpb $0x4, %al
je 0x9682
movq 0x18(%rsp), %rdx
movq %rax, %r13
movzbl %al, %ebx
movq %rbp, %rdi
movl %ebx, %ecx
callq 0x6124
movq %rbp, %rdi
callq 0x6266
testb %al, %al
jne 0x96ce
movq 0x18(%rsp), %rcx
movq %rbp, %rdx
leaq 0xa8(%rsp), %r12
movq %r12, %rdi
movq 0x8(%rsp), %rsi
movl %ebx, %r8d
callq 0x6406
leaq 0xc0(%rsp), %rax
movq %rax, 0x88(%rsp)
leaq 0xa0(%rsp), %rax
movq %rax, 0x90(%rsp)
leaq 0x68(%rsp), %rax
movq %rax, 0x98(%rsp)
leaq 0x88(%rsp), %rdi
movq %r12, %rsi
callq 0x6e2c
addq 0x68(%rsp), %r15
addq 0xa0(%rsp), %r14
movq %r13, %rax
incb %al
movq 0x8(%rsp), %rsi
movq 0x20(%rsp), %rbx
jmp 0x95d7
testq %r15, %r15
jne 0x96ce
cmpq $0x1, %r14
ja 0x96ce
movq 0x18(%rsp), %rax
movq 0x40(%rsp), %rcx
leaq (%rcx,%rax,8), %rdx
leaq 0x70(%rsp), %rdi
leaq 0x18(%rsp), %rsi
callq 0x9120
movq 0x8(%rsp), %rsi
movq 0x30(%rsp), %rcx
movq 0x50(%rsp), %rdx
movq 0x48(%rsp), %rdi
incq %rcx
jmp 0x95ae
incq %rbx
jmp 0x9580
movl $0x3e8, %r14d           # imm = 0x3E8
leaq 0x70(%rsp), %rdi
callq 0xa6a4
movl %r14d, %eax
addq $0x188, %rsp            # imm = 0x188
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
callq 0x7058
movq 0x8(%rbx), %rax
movq 0x18(%rbx), %rcx
movl $0xfffffc17, 0x28(%rsp) # imm = 0xFFFFFC17
movzbl %bpl, %edx
movl %edx, 0x58(%rsp)
movq %rcx, 0x60(%rsp)
cmpq %rcx, %rax
je 0x9940
movq 0xc8(%rsp), %rbx
movq 0xd8(%rsp), %r14
movq %rax, 0x38(%rsp)
imulq $0xf, %rax, %r15
movq 0x8(%rsp), %rcx
movq %r14, 0x20(%rsp)
movq %r15, 0x40(%rsp)
cmpq %r14, %rbx
je 0x9877
leaq (%rbx,%r15), %r12
cmpb $0x0, (%rcx,%r12)
je 0x975f
incq %rbx
jmp 0x9746
movq %rbx, 0x48(%rsp)
xorl %r14d, %r14d
xorl %r13d, %r13d
xorl %eax, %eax
cmpb $0x4, %r14b
je 0x9824
movq %rax, 0x30(%rsp)
movzbl %r14b, %ebx
leaq 0xe8(%rsp), %rbp
movq %rbp, %rdi
movq %rcx, %r15
movq %rcx, %rsi
movq %r12, %rdx
movl %ebx, %ecx
callq 0x6124
movq %rbp, %rdi
callq 0x6266
testb %al, %al
jne 0x9172
movq %r14, 0x50(%rsp)
leaq 0x70(%rsp), %r14
movq %r14, %rdi
movq %r15, %rsi
movq %rbp, %rdx
movq %r12, %rcx
movl %ebx, %r8d
callq 0x6406
leaq 0x68(%rsp), %rax
movq %rax, 0xa8(%rsp)
leaq 0x18(%rsp), %rax
movq %rax, 0xb0(%rsp)
leaq 0x88(%rsp), %rax
movq %rax, 0xb8(%rsp)
leaq 0xa8(%rsp), %rdi
movq %r14, %rsi
movq 0x50(%rsp), %r14
callq 0x6e2c
movq 0x30(%rsp), %rax
addq 0x88(%rsp), %rax
addq 0x18(%rsp), %r13
incb %r14b
movq %r15, %rcx
jmp 0x976c
testq %rax, %rax
movq 0x48(%rsp), %rbx
movq 0x20(%rsp), %r14
movq 0x40(%rsp), %r15
jne 0x9172
cmpq $0x1, %r13
ja 0x9172
movq %rcx, %rdi
movq %r12, %rsi
movl 0x58(%rsp), %edx
callq 0x8f18
movq 0x8(%rsp), %rcx
cmpl %eax, 0x28(%rsp)
jge 0x975a
movl %eax, 0x28(%rsp)
cmpl 0x14(%rsp), %eax
jl 0x975a
jmp 0x9172
movq 0x38(%rsp), %rax
incq %rax
movq 0x60(%rsp), %rcx
jmp 0x9715
movq 0x70(%rsp), %rdi
movq 0x78(%rsp), %rsi
callq 0xa1a7
movl 0x60(%rsp), %ecx
cmpb $0x1, %cl
sete %al
movq 0x70(%rsp), %r12
movq 0x78(%rsp), %rdx
movq %rdx, 0x30(%rsp)
incb %al
decq 0x38(%rsp)
movl $0xfffffc17, %r14d      # imm = 0xFFFFFC17
movzbl %al, %ebx
movzbl %cl, %ebp
movq 0x8(%rsp), %r13
cmpq 0x30(%rsp), %r12
je 0x96d4
movq (%r12), %rax
movb %cl, (%r13,%rax)
movq %r13, %rdi
movl %ebx, %esi
movq 0x38(%rsp), %rdx
movl $0xfffffc17, %ecx       # imm = 0xFFFFFC17
movl $0x3e9, %r8d            # imm = 0x3E9
callq 0x9148
movl %eax, %r15d
movq (%r12), %rsi
movq %r13, %rdi
movl %ebp, %edx
callq 0x8f18
subl %r15d, %eax
movq (%r12), %rcx
movb $0x0, (%r13,%rcx)
cmpl %eax, %r14d
jge 0x9923
movl %eax, %r14d
cmpl 0x14(%rsp), %eax
jge 0x9936
addq $0x10, %r12
movl 0x60(%rsp), %ecx
jmp 0x98c9
movl 0x38(%rsp), %eax
jmp 0x96e1
movl 0x14(%rsp), %r14d
jmp 0x96d4
movl 0x28(%rsp), %eax
jmp 0x96e1
jmp 0x9957
jmp 0x9957
jmp 0x9957
jmp 0x9957
jmp 0x9957
jmp 0x9957
jmp 0x9957
movq %rax, %rbx
leaq 0x70(%rsp), %rdi
callq 0xa6a4
movq %rbx, %rdi
callq 0x22f0