// File: /workspace/github_cpp_makefile_star2_O2/codeandkey[P]neocortex/src/position.cpp
// Function: neocortex::Position::evaluate(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>>*)
int Position::evaluate(std::string* dbg) {
	int phase;
	int development;
	int center_control;
	int material_mg;
	int material_eg;
	int king_safety;
	int king_first_rank;
	int pawns_protecting_king;
	int passed_pawns;
	int passed_pawn_adv;
	int edge_knights;
	int open_file_r;
	int open_file_q;
	int p_iso_pawns;
	int p_bck_pawns;
	int p_dbl_pawns;
	int pawn_chain;

	int white_king_sq = bb::getlsb(board.get_color_occ(piece::WHITE) & board.get_piece_occ(piece::KING));
	int black_king_sq = bb::getlsb(board.get_color_occ(piece::BLACK) & board.get_piece_occ(piece::KING));

	bitboard wkattacks = attacks::king(white_king_sq);
	bitboard bkattacks = attacks::king(black_king_sq);

	++eval_counter;

	/* Start evaluation */
	int score = 0;

	/* Compute game phase */
	phase = eval::PHASE_TOTAL;

	for (int t = 0; t < 5; ++t) {
		phase -= bb::popcount(board.get_piece_occ(t)) * eval::PHASE_VALS[t];
	}

	phase = (phase * 256) / eval::PHASE_TOTAL;

	/* Compute material values */
	material_mg = (board.material_mg() * (256 - phase)) / 256;
	material_eg = (board.material_eg() * phase) / 256;

	score += material_mg;
	score += material_eg;

	/* Compute center square control */
	static const int center_squares[4] = { 27, 28, 35, 36 };
	center_control = 0;

	for (int i = 0; i < 4; ++i) {
		center_control += board.guard_value(center_squares[i]);
	}

	center_control *= eval::CENTER_CONTROL;
	score += center_control;

	/* Compute king safety */
	king_safety = 0;

	bitboard white_ksq = wkattacks;
	bitboard black_ksq = bkattacks;

	while (white_ksq) {
		int ksq = bb::poplsb(white_ksq);
		int gv = board.guard_value(ksq);

		/* don't incentivize overprotecting the king */
		if (gv > 0) {
			gv = 0;
		}

		king_safety += gv;
	}

	while (black_ksq) {
		int ksq = bb::poplsb(black_ksq);
		int gv = board.guard_value(ksq);

		/* don't incentivize overprotecting the king */
		if (gv < 0) {
			gv = 0;
		}

		king_safety += gv;
	}

	king_safety *= eval::KING_SAFETY;
	score += king_safety;

	/* Evaluate development */
	development = 0;

	bitboard minor_pieces = board.get_piece_occ(piece::KNIGHT) | board.get_piece_occ(piece::BISHOP);

	static const bitboard white_dev_ranks = RANK_3 | RANK_4 | RANK_5;
	static const bitboard black_dev_ranks = RANK_4 | RANK_5 | RANK_6;

	development += bb::popcount(minor_pieces & board.get_color_occ(piece::WHITE) & white_dev_ranks);
	development -= bb::popcount(minor_pieces & board.get_color_occ(piece::BLACK) & black_dev_ranks);

	development *= eval::DEVELOPMENT;
	score += development;

	/* Penalty for edge knights */
	edge_knights = 0;

	bitboard edge_knights_mask = board.get_piece_occ(piece::KNIGHT) & (FILE_A | FILE_H);

	edge_knights += bb::popcount(edge_knights_mask & board.get_color_occ(piece::WHITE));
	edge_knights -= bb::popcount(edge_knights_mask & board.get_color_occ(piece::BLACK));

	edge_knights *= eval::EDGE_KNIGHTS;
	score += edge_knights;

	/* Find passed pawns */
	bitboard passers[2];

	passers[piece::WHITE] = board.passedpawns(piece::WHITE);
	passers[piece::BLACK] = board.passedpawns(piece::BLACK);

	/* Apply passed pawn bonus */
	passed_pawns = 0;

	passed_pawns += bb::popcount(passers[piece::WHITE]);
	passed_pawns -= bb::popcount(passers[piece::BLACK]);

	passed_pawns *= eval::PASSED_PAWNS;
	score += passed_pawns;

	/* Apply bonus for king on first rank in MG */
	king_first_rank = 0;
	pawns_protecting_king = 0;

	bitboard wkmask = bb::mask(white_king_sq);
	bitboard bkmask = bb::mask(black_king_sq);

	if (wkmask & RANK_1) {
		king_first_rank += 1;
		pawns_protecting_king += bb::popcount(wkattacks & board.get_piece_occ(piece::PAWN) & RANK_2);
	}

	if (bkmask & RANK_8) {
		king_first_rank -= 1;
		pawns_protecting_king -= bb::popcount(bkattacks & board.get_piece_occ(piece::PAWN) & RANK_7);
	}

	pawns_protecting_king *= eval::PAWNS_PROT_KING_MG;
	pawns_protecting_king *= (256 - phase);
	pawns_protecting_king /= 256;

	king_first_rank *= eval::FIRST_RANK_KING_MG;
	king_first_rank *= (256 - phase);
	king_first_rank /= 256;

	score += king_first_rank;
	score += pawns_protecting_king;

	/* Apply advance bonus for passed pawns */
	bitboard tmp_passers;
	passed_pawn_adv = 0;

	tmp_passers = passers[piece::WHITE];
	while (tmp_passers) {
		int p = bb::poplsb(tmp_passers);
		passed_pawn_adv += square::rank(p);
	}

	tmp_passers = passers[piece::BLACK];
	while (tmp_passers) {
		int p = bb::poplsb(tmp_passers);
		passed_pawn_adv -= (7 - square::rank(p));
	}

	passed_pawn_adv *= eval::ADV_PASSEDPAWN;
	score += passed_pawn_adv;

	/* Apply file bonuses and penalties */
	open_file_r = 0;
	open_file_q = 0;
	p_dbl_pawns = 0;

	for (int f = 0; f < 8; ++f) {
		bitboard file = bb::file(f);
		bitboard file_pawns = board.get_piece_occ(piece::PAWN) & file;

		if (!file_pawns) {
			// Open file

			bitboard frooks = file & board.get_piece_occ(piece::ROOK);
			bitboard fqueens = file & board.get_piece_occ(piece::QUEEN);

			open_file_r += bb::popcount(frooks & board.get_color_occ(piece::WHITE));
			open_file_q += bb::popcount(fqueens & board.get_color_occ(piece::WHITE));
			open_file_r -= bb::popcount(frooks & board.get_color_occ(piece::BLACK));
			open_file_q -= bb::popcount(fqueens & board.get_color_occ(piece::BLACK));
		}

		int n_white_pawns = bb::popcount(file_pawns & board.get_color_occ(piece::WHITE));
		int n_black_pawns = bb::popcount(file_pawns & board.get_color_occ(piece::BLACK));

		if (n_white_pawns > 1) {
			p_dbl_pawns += (n_white_pawns - 1);
		}

		if (n_black_pawns > 1) {
			p_dbl_pawns -= (n_black_pawns - 1);
		}
	}

	open_file_r *= eval::OPEN_FILE_ROOK;
	open_file_q *= eval::OPEN_FILE_QUEEN;

	score += open_file_r + open_file_q;

	p_dbl_pawns *= eval::DOUBLED_PAWNS;
	score += p_dbl_pawns;

	/* Apply bonus for chained pawns */
	bitboard w_pawns = board.get_piece_occ(piece::PAWN) & board.get_color_occ(piece::WHITE);
	bitboard b_pawns = board.get_piece_occ(piece::PAWN) & board.get_color_occ(piece::BLACK);

	pawn_chain = 0;

	pawn_chain += bb::popcount((bb::shift(w_pawns & ~FILE_A, NORTHWEST) | bb::shift(w_pawns & ~FILE_H, NORTHEAST)) & w_pawns);
	pawn_chain -= bb::popcount((bb::shift(b_pawns & ~FILE_A, SOUTHWEST) | bb::shift(b_pawns & ~FILE_H, SOUTHEAST)) & b_pawns);

	pawn_chain *= eval::PAWN_CHAIN;
	score += pawn_chain;

	/* Apply penalty for isolated pawns */
	p_iso_pawns = 0;

	p_iso_pawns += bb::popcount(board.isolated_pawns(piece::WHITE));
	p_iso_pawns -= bb::popcount(board.isolated_pawns(piece::BLACK));

	p_iso_pawns *= eval::ISOLATED_PAWNS;
	score += p_iso_pawns;

	/* Apply penalty for backward pawns */
	p_bck_pawns = 0;

	p_bck_pawns += bb::popcount(board.backward_pawns(piece::WHITE));
	p_bck_pawns -= bb::popcount(board.backward_pawns(piece::BLACK));

	p_bck_pawns *= eval::BACKWARD_PAWNS;
	score += p_bck_pawns;

	/* Write debug if needed */
	if (dbg) {
		std::string output;

		output +=              "+-----------------------------+\n";
		output +=              "|   evaluation debug (WPOV)   |\n";
		output +=              "|-------------+------+--------|\n";
		output += util::format("| material_mg | %13d |\n", material_mg);
		output += util::format("| material_eg | %13d |\n", material_eg);
		output += util::format("| ctr_control | %13d |\n", center_control);
		output += util::format("| development | %13d |\n", development);
		output += util::format("| king_safety | %13d |\n", king_safety);
		output += util::format("| adv_passed  | %13d |\n", passed_pawn_adv);
		output += util::format("| edge_knghts | %13d |\n", edge_knights);
		output += util::format("| pawn_prot_k | %13d |\n", pawns_protecting_king);
		output += util::format("| first_r_kng | %13d |\n", king_first_rank);
		output += util::format("| passed_pns  | %13d |\n", passed_pawns);
		output += util::format("| open_file_r | %13d |\n", open_file_r);
		output += util::format("| open_file_q | %13d |\n", open_file_q);
		output += util::format("| p_iso_pawns | %13d |\n", p_iso_pawns);
		output += util::format("| p_bck_pawns | %13d |\n", p_bck_pawns);
		output += util::format("| p_dbl_pawns | %13d |\n", p_dbl_pawns);
		output += util::format("| pawn_chain  | %13d |\n", pawn_chain);
		output += util::format("| phase       | %13d |\n", phase);
		output += util::format("| (total)     | %13d |\n", score);
		output +=              "+-------------+------+--------+\n";

		*dbg = output;
	}

	/* Flip eval if BTM */
	if (color_to_move == piece::BLACK) {
		score *= -1;
	}

	return score + eval::TEMPO_BONUS;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x318, %rsp            # imm = 0x318
movq %rsi, %r14
movq %rdi, %rbx
movq 0x40(%rdi), %rdi
andq 0x8(%rbx), %rdi
callq 0x6515
movl %eax, %ebp
movq 0x40(%rbx), %rdi
andq 0x10(%rbx), %rdi
callq 0x6515
movl %eax, %edx
movl %ebp, 0x38(%rsp)
movslq %ebp, %rax
leaq 0x11f89(%rip), %rcx     # 0x1d5c0
movq (%rcx,%rax,8), %rax
movq %rax, 0x60(%rsp)
movl %edx, 0x30(%rsp)
movslq %edx, %rax
movq (%rcx,%rax,8), %rax
movq %rax, 0x78(%rsp)
incl 0x174(%rbx)
leaq 0x9323(%rip), %rax      # 0x14980
movl (%rax), %ecx
pushq $0x3
popq %rdx
movabsq $0x5555555555555555, %r15 # imm = 0x5555555555555555
movabsq $0x3333333333333333, %r11 # imm = 0x3333333333333333
movabsq $0xf0f0f0f0f0f0f0f, %r10 # imm = 0xF0F0F0F0F0F0F0F
movabsq $0x101010101010101, %r9 # imm = 0x101010101010101
leaq 0x929f(%rip), %rsi      # 0x14930
movl %ecx, %eax
cmpq $0x8, %rdx
je 0xb6dc
movq (%rbx,%rdx,8), %rdi
movq %rdi, %r8
shrq %r8
andq %r15, %r8
subq %r8, %rdi
movq %rdi, %r8
andq %r11, %r8
shrq $0x2, %rdi
andq %r11, %rdi
addq %r8, %rdi
movq %rdi, %r8
shrq $0x4, %r8
addq %rdi, %r8
andq %r10, %r8
imulq %r9, %r8
shrq $0x38, %r8
imull -0xc(%rsi,%rdx,4), %r8d
subl %r8d, %eax
incq %rdx
jmp 0xb693
movq %r14, 0xc0(%rsp)
shll $0x8, %eax
cltd
idivl %ecx
movl %eax, %r14d
movl $0x100, %ecx            # imm = 0x100
subl %eax, %ecx
movl 0x148(%rbx), %ebp
movl %eax, 0xbc(%rsp)
imull 0x14c(%rbx), %r14d
movl %ecx, 0x34(%rsp)
imull %ecx, %ebp
xorl %r15d, %r15d
leaq 0x95b6(%rip), %r12      # 0x14cd0
xorl %r13d, %r13d
cmpq $0x10, %r15
je 0xb738
movl (%r15,%r12), %esi
movq %rbx, %rdi
callq 0x5fb0
addl %eax, %r13d
addq $0x4, %r15
jmp 0xb71d
movl $0x100, %ecx            # imm = 0x100
movl %ebp, %eax
cltd
idivl %ecx
movl %eax, 0x8c(%rsp)
leaq 0xd0(%rsp), %r12
movq 0x60(%rsp), %rcx
movq %rcx, (%r12)
movq 0x78(%rsp), %rax
movq %rax, 0xc8(%rsp)
xorl %ebp, %ebp
movq %rcx, %rax
testq %rax, %rax
je 0xb796
movq %r12, %rdi
callq 0x64fc
movq %rbx, %rdi
movl %eax, %esi
callq 0x5fb0
movl %eax, %ecx
sarl $0x1f, %ecx
andl %eax, %ecx
addl %ecx, %ebp
movq 0xd0(%rsp), %rax
jmp 0xb76c
leaq 0xc8(%rsp), %r12
cmpq $0x0, 0xc8(%rsp)
je 0xb7c5
movq %r12, %rdi
callq 0x64fc
movq %rbx, %rdi
movl %eax, %esi
callq 0x5fb0
testl %eax, %eax
jg 0xb7c1
xorl %eax, %eax
addl %eax, %ebp
jmp 0xb79e
movl %r13d, 0x84(%rsp)
movl $0x100, %ecx            # imm = 0x100
movl %r14d, %eax
cltd
idivl %ecx
movl %eax, 0x88(%rsp)
movq 0x28(%rbx), %rdx
movq 0x20(%rbx), %rsi
orq %rdx, %rsi
movq 0x8(%rbx), %rcx
movq 0x10(%rbx), %rax
movq %rcx, %rdi
andq %rsi, %rdi
movabsq $0xffffff0000, %r8      # imm = 0xFFFFFF0000
andq %rdi, %r8
shrq %rdi
movabsq $0x5555550000, %r9      # imm = 0x5555550000
andq %rdi, %r9
subq %r9, %r8
movabsq $0x3333333333330000, %rdi # imm = 0x3333333333330000
movq %r8, %r9
andq %rdi, %r9
shrq $0x2, %r8
andq %rdi, %r8
addq %r9, %r8
movq %r8, %r9
shrq $0x4, %r9
addq %r8, %r9
movabsq $0xf0f0f0f0f0f0f0f, %rdi # imm = 0xF0F0F0F0F0F0F0F
andq %rdi, %r9
movq %rdi, %r10
movabsq $0x101010101010101, %rdi # imm = 0x101010101010101
imulq %rdi, %r9
movq %rdi, %r11
shrq $0x38, %r9
movq %r9, 0xa0(%rsp)
andq %rax, %rsi
movabsq $0xffffff000000, %rdi   # imm = 0xFFFFFF000000
andq %rsi, %rdi
shrq %rsi
movabsq $0x555555000000, %r8    # imm = 0x555555000000
andq %rsi, %r8
subq %r8, %rdi
movabsq $0x3333333333000000, %rsi # imm = 0x3333333333000000
movq %rdi, %r8
andq %rsi, %r8
shrq $0x2, %rdi
andq %rsi, %rdi
addq %r8, %rdi
movq %rdi, %rsi
shrq $0x4, %rsi
addq %rdi, %rsi
andq %r10, %rsi
imulq %r11, %rsi
shrq $0x38, %rsi
movq %rsi, 0xa8(%rsp)
movabsq $-0x7e7e7e7e7e7e7e7f, %rsi # imm = 0x8181818181818181
andq %rdx, %rsi
andq %rsi, %rcx
movq %rcx, %rdx
shrq %rdx
movabsq $0x4040404040404040, %rdi # imm = 0x4040404040404040
andq %rdi, %rdx
subq %rdx, %rcx
movabsq $0x3333333333333301, %rdx # imm = 0x3333333333333301
movq %rcx, %r8
andq %rdx, %r8
shrq $0x2, %rcx
movabsq $0x3333333333333330, %r9 # imm = 0x3333333333333330
andq %r9, %rcx
addq %r8, %rcx
movq %rcx, %r8
shrq $0x4, %r8
addq %rcx, %r8
andq %r10, %r8
imulq %r11, %r8
shrq $0x38, %r8
movq %r8, 0x98(%rsp)
andq %rax, %rsi
movq %rsi, %rax
shrq %rax
andq %rdi, %rax
subq %rax, %rsi
andq %rsi, %rdx
shrq $0x2, %rsi
andq %r9, %rsi
addq %rdx, %rsi
movq %rsi, %rax
shrq $0x4, %rax
addq %rsi, %rax
andq %r10, %rax
movq %r10, %r13
imulq %r11, %rax
shrq $0x38, %rax
movq %rax, 0x90(%rsp)
movl $0x0, 0x2c(%rsp)
movq %rbx, %rdi
xorl %esi, %esi
callq 0x6244
movq %rax, %r14
pushq $0x1
popq %rsi
movq %rbx, %rdi
callq 0x6244
movq %rax, %r12
movq %r14, %rax
shrq %rax
movabsq $0x5555555555555555, %rsi # imm = 0x5555555555555555
andq %rsi, %rax
movq %r14, %rcx
subq %rax, %rcx
movq %rcx, %rax
movabsq $0x3333333333333333, %rdx # imm = 0x3333333333333333
andq %rdx, %rax
shrq $0x2, %rcx
andq %rdx, %rcx
addq %rax, %rcx
movq %rcx, %r15
shrq $0x4, %r15
addq %rcx, %r15
movq %r13, %rdi
andq %r13, %r15
movabsq $0x101010101010101, %r8 # imm = 0x101010101010101
imulq %r8, %r15
shrq $0x38, %r15
movq %r12, %rax
shrq %rax
andq %rsi, %rax
movq %r12, %rcx
subq %rax, %rcx
movq %rcx, %rax
andq %rdx, %rax
shrq $0x2, %rcx
andq %rdx, %rcx
addq %rax, %rcx
movq %rcx, %r13
shrq $0x4, %r13
addq %rcx, %r13
andq %rdi, %r13
imulq %r8, %r13
shrq $0x38, %r13
movl 0x38(%rsp), %edi
callq 0x5103
movq %rax, 0x38(%rsp)
movl 0x30(%rsp), %edi
callq 0x5103
movl $0x0, %ecx
cmpb $0x0, 0x38(%rsp)
je 0xba62
movzwl 0x18(%rbx), %ecx
movq 0x60(%rsp), %rdx
andl %ecx, %edx
shrl $0x8, %edx
imull $0x8040201, %edx, %ecx  # imm = 0x8040201
shrl $0x3, %ecx
andl $0x11111111, %ecx       # imm = 0x11111111
imull $0x11111111, %ecx, %ecx # imm = 0x11111111
shrl $0x1c, %ecx
movl %ecx, 0x2c(%rsp)
pushq $0x1
popq %rcx
movq 0xa0(%rsp), %rdx
subl 0xa8(%rsp), %edx
movq 0x98(%rsp), %rsi
subl 0x90(%rsp), %esi
subl %r13d, %r15d
shrq $0x38, %rax
jne 0xba8f
movl 0x2c(%rsp), %edi
jmp 0xbabe
decl %ecx
movq 0x78(%rsp), %rax
andq 0x18(%rbx), %rax
shrq $0x30, %rax
movzbl %al, %eax
imull $0x8040201, %eax, %eax  # imm = 0x8040201
shrl $0x3, %eax
andl $0x11111111, %eax       # imm = 0x11111111
imull $0x11111111, %eax, %eax # imm = 0x11111111
shrl $0x1c, %eax
movl 0x2c(%rsp), %edi
subl %eax, %edi
imull $0x7, %ebp, %eax
movl %eax, 0x78(%rsp)
imull $0xf, %edx, %eax
movl %eax, 0x2c(%rsp)
imull $-0x3, %esi, %eax
movq %rax, 0x38(%rsp)
imull $0xb, %r15d, %eax
movq %rax, 0xa0(%rsp)
movl 0x34(%rsp), %eax
imull %eax, %edi
addl %edi, %edi
imull %eax, %ecx
imull $0x7, %ecx, %eax
movl %eax, 0x60(%rsp)
leaq 0xb0(%rsp), %r13
movq %r14, (%r13)
xorl %ebp, %ebp
movl %edi, %r15d
testq %r14, %r14
je 0xbb24
movq %r13, %rdi
callq 0x64fc
movl %eax, %edi
callq 0x50b1
addl %eax, %ebp
movq 0xb0(%rsp), %r14
jmp 0xbb04
movl $0x100, %ecx            # imm = 0x100
movl %r15d, %eax
cltd
idivl %ecx
movl %eax, 0x34(%rsp)
leaq 0xb0(%rsp), %r14
movq %r12, (%r14)
testq %r12, %r12
je 0xbb61
movq %r14, %rdi
callq 0x64fc
movl %eax, %edi
callq 0x50b1
addl %eax, %ebp
addl $-0x7, %ebp
movq 0xb0(%rsp), %r12
jmp 0xbb3e
movl $0x100, %ecx            # imm = 0x100
movl 0x60(%rsp), %eax
cltd
idivl %ecx
movl %eax, 0x30(%rsp)
xorl %r12d, %r12d
pushq $0x1
popq %r15
xorl %r13d, %r13d
xorl %r14d, %r14d
xorpd %xmm0, %xmm0
movapd %xmm0, 0x60(%rsp)
cmpl $0x8, %r14d
je 0xbd29
movl %r14d, %edi
callq 0x566c
movq 0x18(%rbx), %rcx
movdqu 0x8(%rbx), %xmm0
andq %rax, %rcx
je 0xbbc9
pxor %xmm4, %xmm4
movdqa 0x90dc(%rip), %xmm5     # 0x14c90
movdqa 0x90e4(%rip), %xmm6     # 0x14ca0
movdqa 0x90ec(%rip), %xmm7     # 0x14cb0
jmp 0xbc9e
movdqu 0x30(%rbx), %xmm2
movq %rax, %xmm1
pshufd $0x44, %xmm1, %xmm1     # xmm1 = xmm1[0,1,0,1]
pand %xmm2, %xmm1
pshufd $0x44, %xmm0, %xmm2     # xmm2 = xmm0[0,1,0,1]
pand %xmm1, %xmm2
movdqa %xmm2, %xmm3
psrlw $0x1, %xmm3
movdqa 0x909a(%rip), %xmm5     # 0x14c90
pand %xmm5, %xmm3
psubb %xmm3, %xmm2
movdqa %xmm2, %xmm3
movdqa 0x9096(%rip), %xmm6     # 0x14ca0
pand %xmm6, %xmm3
psrlw $0x2, %xmm2
pand %xmm6, %xmm2
paddb %xmm3, %xmm2
movdqa %xmm2, %xmm3
psrlw $0x4, %xmm3
paddb %xmm2, %xmm3
movdqa 0x9080(%rip), %xmm7     # 0x14cb0
pand %xmm7, %xmm3
pxor %xmm4, %xmm4
psadbw %xmm4, %xmm3
pshufd $0xe8, %xmm3, %xmm2     # xmm2 = xmm3[0,2,2,3]
movdqa 0x60(%rsp), %xmm3
paddd %xmm2, %xmm3
pshufd $0xee, %xmm0, %xmm2     # xmm2 = xmm0[2,3,2,3]
pand %xmm1, %xmm2
movdqa %xmm2, %xmm1
psrlw $0x1, %xmm1
pand %xmm5, %xmm1
psubb %xmm1, %xmm2
movdqa %xmm2, %xmm1
pand %xmm6, %xmm1
psrlw $0x2, %xmm2
pand %xmm6, %xmm2
paddb %xmm1, %xmm2
movdqa %xmm2, %xmm1
psrlw $0x4, %xmm1
paddb %xmm2, %xmm1
pand %xmm7, %xmm1
psadbw %xmm4, %xmm1
pshufd $0xe8, %xmm1, %xmm1     # xmm1 = xmm1[0,2,2,3]
psubd %xmm1, %xmm3
movdqa %xmm3, 0x60(%rsp)
movq %rcx, %xmm1
pshufd $0x44, %xmm1, %xmm1     # xmm1 = xmm1[0,1,0,1]
pand %xmm1, %xmm0
movdqa %xmm0, %xmm1
psrlw $0x1, %xmm1
pand %xmm5, %xmm1
psubb %xmm1, %xmm0
movdqa %xmm0, %xmm1
pand %xmm6, %xmm1
psrlw $0x2, %xmm0
pand %xmm6, %xmm0
paddb %xmm1, %xmm0
movdqa %xmm0, %xmm1
psrlw $0x4, %xmm1
paddb %xmm0, %xmm1
pand %xmm7, %xmm1
psadbw %xmm4, %xmm1
movd %xmm1, %eax
pshufd $0xee, %xmm1, %xmm0     # xmm0 = xmm1[2,3,2,3]
movd %xmm0, %ecx
decl %eax
pshufd $0xa0, %xmm1, %xmm0     # xmm0 = xmm1[0,0,2,2]
pcmpgtd 0x8fbd(%rip), %xmm0     # 0x14cc0
movmskpd %xmm0, %edx
testb $0x1, %dl
cmovel %r12d, %eax
addl %r13d, %eax
movl %r15d, %r13d
subl %ecx, %r13d
testb $0x2, %dl
cmovel %r12d, %r13d
addl %eax, %r13d
incl %r14d
jmp 0xbb88
movdqa 0x60(%rsp), %xmm0
movd %xmm0, %eax
movq %rax, 0xa8(%rsp)
pshufd $0x55, %xmm0, %xmm0     # xmm0 = xmm0[1,1,1,1]
movd %xmm0, %eax
movq %rax, 0x60(%rsp)
imull $-0x6, %r13d, %eax
movl %eax, 0x98(%rsp)
movq 0x18(%rbx), %rax
movq 0x8(%rbx), %rcx
andq %rax, %rcx
andq 0x10(%rbx), %rax
movq %rcx, %rdx
shlq $0x7, %rdx
movabsq $0x7f7f7f7f7f7f7f00, %rsi # imm = 0x7F7F7F7F7F7F7F00
andq %rdx, %rsi
movq %rcx, %rdx
shlq $0x9, %rdx
movabsq $-0x101010101010200, %rdi # imm = 0xFEFEFEFEFEFEFE00
andq %rdx, %rdi
orq %rsi, %rdi
andq %rcx, %rdi
movq %rdi, %rcx
shrq %rcx
movabsq $0x5555555555555500, %rdx # imm = 0x5555555555555500
andq %rcx, %rdx
subq %rdx, %rdi
movabsq $0x3333333333333300, %rcx # imm = 0x3333333333333300
movq %rdi, %rdx
andq %rcx, %rdx
shrq $0x2, %rdi
andq %rcx, %rdi
addq %rdx, %rdi
movq %rdi, %r14
shrq $0x4, %r14
addq %rdi, %r14
movabsq $0xf0f0f0f0f0f0f0f, %rcx # imm = 0xF0F0F0F0F0F0F0F
andq %rcx, %r14
movq %rcx, %rdi
movabsq $0x101010101010101, %r12 # imm = 0x101010101010101
imulq %r12, %r14
movq %r12, %r8
shrq $0x38, %r14
movq %rax, %rcx
shrq $0x9, %rcx
movabsq $0x7f7f7f7f7f7f7f, %rdx # imm = 0x7F7F7F7F7F7F7F
andq %rcx, %rdx
movq %rax, %rcx
shrq $0x7, %rcx
movabsq $0xfefefefefefefe, %rsi # imm = 0xFEFEFEFEFEFEFE
andq %rcx, %rsi
orq %rdx, %rsi
andq %rax, %rsi
movq %rsi, %rax
shrq %rax
movabsq $0x55555555555555, %rcx # imm = 0x55555555555555
andq %rax, %rcx
subq %rcx, %rsi
movq %rsi, %rax
movabsq $0x3333333333333333, %r13 # imm = 0x3333333333333333
andq %r13, %rax
shrq $0x2, %rsi
andq %r13, %rsi
addq %rax, %rsi
movq %rsi, %rax
shrq $0x4, %rax
addq %rsi, %rax
movq %rdi, %r12
andq %rdi, %rax
imulq %r8, %rax
shrq $0x38, %rax
subl %eax, %r14d
movq %rbx, %rdi
xorl %esi, %esi
callq 0x6150
movq %rax, %rcx
shrq %rcx
movabsq $0x5555555555555555, %rdx # imm = 0x5555555555555555
andq %rdx, %rcx
subq %rcx, %rax
movq %rax, %rcx
andq %r13, %rcx
shrq $0x2, %rax
andq %r13, %rax
addq %rcx, %rax
movq %rax, %r15
shrq $0x4, %r15
addq %rax, %r15
andq %r12, %r15
movabsq $0x101010101010101, %rax # imm = 0x101010101010101
imulq %rax, %r15
shrq $0x38, %r15
pushq $0x1
popq %rsi
movq %rbx, %rdi
callq 0x6150
movq %rax, %rcx
shrq %rcx
movabsq $0x5555555555555555, %rdx # imm = 0x5555555555555555
andq %rdx, %rcx
subq %rcx, %rax
movq %rax, %rcx
andq %r13, %rcx
shrq $0x2, %rax
andq %r13, %rax
addq %rcx, %rax
movq %rax, %r12
shrq $0x4, %r12
addq %rax, %r12
movabsq $0xf0f0f0f0f0f0f0f, %rax # imm = 0xF0F0F0F0F0F0F0F
andq %rax, %r12
movabsq $0x101010101010101, %rax # imm = 0x101010101010101
imulq %rax, %r12
shrq $0x38, %r12
subl %r15d, %r12d
movq %rbx, %rdi
xorl %esi, %esi
callq 0x61b0
movq %rax, %rcx
shrq %rcx
movabsq $0x5555555555555555, %rdx # imm = 0x5555555555555555
andq %rdx, %rcx
subq %rcx, %rax
movq %rax, %rcx
andq %r13, %rcx
shrq $0x2, %rax
andq %r13, %rax
addq %rcx, %rax
movq %rax, %r15
shrq $0x4, %r15
addq %rax, %r15
movabsq $0xf0f0f0f0f0f0f0f, %rax # imm = 0xF0F0F0F0F0F0F0F
andq %rax, %r15
movabsq $0x101010101010101, %rax # imm = 0x101010101010101
imulq %rax, %r15
shrq $0x38, %r15
movq %rbx, %rdi
pushq $0x1
popq %rsi
callq 0x61b0
movq %rax, %rcx
shrq %rcx
movabsq $0x5555555555555555, %rdx # imm = 0x5555555555555555
andq %rdx, %rcx
subq %rcx, %rax
movq %rax, %rcx
andq %r13, %rcx
shrq $0x2, %rax
andq %r13, %rax
addq %rcx, %rax
movq %rax, %r13
shrq $0x4, %r13
addq %rax, %r13
movabsq $0xf0f0f0f0f0f0f0f, %rax # imm = 0xF0F0F0F0F0F0F0F
andq %rax, %r13
movabsq $0x101010101010101, %rax # imm = 0x101010101010101
imulq %rax, %r13
shrq $0x38, %r13
subl %r15d, %r13d
movq 0xa0(%rsp), %rax
movq 0x38(%rsp), %rcx
addl %ecx, %eax
movl 0x34(%rsp), %ecx
addl %eax, %ecx
movl 0x88(%rsp), %eax
addl 0x8c(%rsp), %eax
addl 0x84(%rsp), %eax
addl 0x78(%rsp), %eax
addl 0x2c(%rsp), %eax
addl 0x30(%rsp), %ecx
addl %eax, %ecx
leal (%rcx,%rbp,8), %eax
addl 0x98(%rsp), %eax
movq 0x60(%rsp), %rcx
leal (%rax,%rcx,4), %eax
movq 0xa8(%rsp), %rcx
movq %rcx, %r15
leal (%rax,%rcx,8), %eax
leal (%rax,%r12,8), %eax
leal (%rax,%r13,8), %eax
leal (%rax,%r14,2), %ecx
movq 0xc0(%rsp), %rax
testq %rax, %rax
je 0xc6e0
movl %ecx, 0x90(%rsp)
leaq 0x50(%rsp), %rax
movq %rax, -0x10(%rax)
andq $0x0, -0x8(%rax)
movb $0x0, (%rax)
leaq 0x9006(%rip), %rsi      # 0x15065
leaq 0x40(%rsp), %rdi
callq 0x45a0
leaq 0x9016(%rip), %rsi      # 0x15086
leaq 0x40(%rsp), %rdi
callq 0x45a0
leaq 0x9026(%rip), %rsi      # 0x150a7
leaq 0x40(%rsp), %rdi
callq 0x45a0
leaq 0x9036(%rip), %rsi      # 0x150c8
leaq 0x2f8(%rsp), %rdi
leaq 0x7(%rsp), %rdx
callq 0x6302
leaq 0x8(%rsp), %rdi
leaq 0x2f8(%rsp), %rsi
movl 0x8c(%rsp), %edx
callq 0x6ad1
leaq 0x40(%rsp), %rdi
leaq 0x8(%rsp), %rsi
callq 0x45c0
leaq 0x8(%rsp), %rdi
callq 0x4120
leaq 0x2f8(%rsp), %rdi
callq 0x4120
leaq 0x8ff6(%rip), %rsi      # 0x150e0
leaq 0x2d8(%rsp), %rdi
leaq 0x7(%rsp), %rdx
callq 0x6302
leaq 0x8(%rsp), %rdi
leaq 0x2d8(%rsp), %rsi
movl 0x88(%rsp), %edx
callq 0x6ad1
leaq 0x40(%rsp), %rdi
leaq 0x8(%rsp), %rsi
callq 0x45c0
leaq 0x8(%rsp), %rdi
callq 0x4120
leaq 0x2d8(%rsp), %rdi
callq 0x4120
leaq 0x8fb6(%rip), %rsi      # 0x150f8
leaq 0x2b8(%rsp), %rdi
leaq 0x7(%rsp), %rdx
callq 0x6302
leaq 0x8(%rsp), %rdi
leaq 0x2b8(%rsp), %rsi
movl 0x84(%rsp), %edx
callq 0x6ad1
leaq 0x40(%rsp), %rdi
leaq 0x8(%rsp), %rsi
callq 0x45c0
leaq 0x8(%rsp), %rdi
callq 0x4120
leaq 0x2b8(%rsp), %rdi
callq 0x4120
leaq 0x8f76(%rip), %rsi      # 0x15110
leaq 0x298(%rsp), %rdi
leaq 0x7(%rsp), %rdx
callq 0x6302
leaq 0x8(%rsp), %rdi
leaq 0x298(%rsp), %rsi
movl 0x2c(%rsp), %edx
callq 0x6ad1
leaq 0x40(%rsp), %rdi
leaq 0x8(%rsp), %rsi
callq 0x45c0
leaq 0x8(%rsp), %rdi
callq 0x4120
leaq 0x298(%rsp), %rdi
callq 0x4120
leaq 0x8f39(%rip), %rsi      # 0x15128
leaq 0x278(%rsp), %rdi
leaq 0x7(%rsp), %rdx
callq 0x6302
leaq 0x8(%rsp), %rdi
leaq 0x278(%rsp), %rsi
movl 0x78(%rsp), %edx
callq 0x6ad1
leaq 0x40(%rsp), %rdi
leaq 0x8(%rsp), %rsi
callq 0x45c0
leaq 0x8(%rsp), %rdi
callq 0x4120
leaq 0x278(%rsp), %rdi
callq 0x4120
leaq 0x8efc(%rip), %rsi      # 0x15140
leaq 0x258(%rsp), %rdi
leaq 0x7(%rsp), %rdx
callq 0x6302
shll $0x3, %ebp
leaq 0x8(%rsp), %rdi
leaq 0x258(%rsp), %rsi
movl %ebp, %edx
callq 0x6ad1
leaq 0x40(%rsp), %rdi
leaq 0x8(%rsp), %rsi
callq 0x45c0
leaq 0x8(%rsp), %rdi
callq 0x4120
leaq 0x258(%rsp), %rdi
callq 0x4120
leaq 0x8ebe(%rip), %rsi      # 0x15158
leaq 0x238(%rsp), %rdi
leaq 0x7(%rsp), %rdx
callq 0x6302
leaq 0x8(%rsp), %rdi
leaq 0x238(%rsp), %rsi
movq 0x38(%rsp), %rdx
callq 0x6ad1
leaq 0x40(%rsp), %rdi
leaq 0x8(%rsp), %rsi
callq 0x45c0
leaq 0x8(%rsp), %rdi
callq 0x4120
leaq 0x238(%rsp), %rdi
callq 0x4120
leaq 0x8e80(%rip), %rsi      # 0x15170
leaq 0x218(%rsp), %rdi
leaq 0x7(%rsp), %rdx
callq 0x6302
leaq 0x8(%rsp), %rdi
leaq 0x218(%rsp), %rsi
movl 0x34(%rsp), %edx
callq 0x6ad1
leaq 0x40(%rsp), %rdi
leaq 0x8(%rsp), %rsi
callq 0x45c0
leaq 0x8(%rsp), %rdi
callq 0x4120
leaq 0x218(%rsp), %rdi
callq 0x4120
leaq 0x8e43(%rip), %rsi      # 0x15188
leaq 0x1f8(%rsp), %rdi
leaq 0x7(%rsp), %rdx
callq 0x6302
leaq 0x8(%rsp), %rdi
leaq 0x1f8(%rsp), %rsi
movl 0x30(%rsp), %edx
callq 0x6ad1
leaq 0x40(%rsp), %rdi
leaq 0x8(%rsp), %rsi
callq 0x45c0
leaq 0x8(%rsp), %rdi
callq 0x4120
leaq 0x1f8(%rsp), %rdi
callq 0x4120
leaq 0x8e06(%rip), %rsi      # 0x151a0
leaq 0x1d8(%rsp), %rdi
leaq 0x7(%rsp), %rdx
callq 0x6302
leaq 0x8(%rsp), %rdi
leaq 0x1d8(%rsp), %rsi
movq 0xa0(%rsp), %rdx
callq 0x6ad1
leaq 0x40(%rsp), %rdi
leaq 0x8(%rsp), %rsi
callq 0x45c0
leaq 0x8(%rsp), %rdi
callq 0x4120
leaq 0x1d8(%rsp), %rdi
callq 0x4120
leaq 0x8dc5(%rip), %rsi      # 0x151b8
leaq 0x1b8(%rsp), %rdi
leaq 0x7(%rsp), %rdx
callq 0x6302
shll $0x3, %r15d
leaq 0x8(%rsp), %rdi
leaq 0x1b8(%rsp), %rsi
movl %r15d, %edx
callq 0x6ad1
leaq 0x40(%rsp), %rdi
leaq 0x8(%rsp), %rsi
callq 0x45c0
leaq 0x8(%rsp), %rdi
callq 0x4120
leaq 0x1b8(%rsp), %rdi
callq 0x4120
leaq 0x8d85(%rip), %rsi      # 0x151d0
leaq 0x198(%rsp), %rdi
leaq 0x7(%rsp), %rdx
callq 0x6302
movq 0x60(%rsp), %rdx
shll $0x2, %edx
leaq 0x8(%rsp), %rdi
leaq 0x198(%rsp), %rsi
callq 0x6ad1
leaq 0x40(%rsp), %rdi
leaq 0x8(%rsp), %rsi
callq 0x45c0
leaq 0x8(%rsp), %rdi
callq 0x4120
leaq 0x198(%rsp), %rdi
callq 0x4120
leaq 0x8d44(%rip), %rsi      # 0x151e8
leaq 0x178(%rsp), %rdi
leaq 0x7(%rsp), %rdx
callq 0x6302
shll $0x3, %r12d
leaq 0x8(%rsp), %rdi
leaq 0x178(%rsp), %rsi
movl %r12d, %edx
callq 0x6ad1
leaq 0x40(%rsp), %rdi
leaq 0x8(%rsp), %rsi
callq 0x45c0
leaq 0x8(%rsp), %rdi
callq 0x4120
leaq 0x178(%rsp), %rdi
callq 0x4120
leaq 0x8d04(%rip), %rsi      # 0x15200
leaq 0x158(%rsp), %rdi
leaq 0x7(%rsp), %rdx
callq 0x6302
shll $0x3, %r13d
leaq 0x8(%rsp), %rdi
leaq 0x158(%rsp), %rsi
movl %r13d, %edx
callq 0x6ad1
leaq 0x40(%rsp), %rdi
leaq 0x8(%rsp), %rsi
callq 0x45c0
leaq 0x8(%rsp), %rdi
callq 0x4120
leaq 0x158(%rsp), %rdi
callq 0x4120
leaq 0x8cc4(%rip), %rsi      # 0x15218
leaq 0x138(%rsp), %rdi
leaq 0x7(%rsp), %rdx
callq 0x6302
leaq 0x8(%rsp), %rdi
leaq 0x138(%rsp), %rsi
movl 0x98(%rsp), %edx
callq 0x6ad1
leaq 0x40(%rsp), %rdi
leaq 0x8(%rsp), %rsi
callq 0x45c0
leaq 0x8(%rsp), %rdi
callq 0x4120
leaq 0x138(%rsp), %rdi
callq 0x4120
leaq 0x8c84(%rip), %rsi      # 0x15230
leaq 0x118(%rsp), %rdi
leaq 0x7(%rsp), %rdx
callq 0x6302
addl %r14d, %r14d
leaq 0x8(%rsp), %rdi
leaq 0x118(%rsp), %rsi
movl %r14d, %edx
callq 0x6ad1
leaq 0x40(%rsp), %rdi
leaq 0x8(%rsp), %rsi
callq 0x45c0
leaq 0x8(%rsp), %rdi
callq 0x4120
leaq 0x118(%rsp), %rdi
callq 0x4120
leaq 0x8c45(%rip), %rsi      # 0x15248
leaq 0xf8(%rsp), %rdi
leaq 0x7(%rsp), %rdx
callq 0x6302
leaq 0x8(%rsp), %rdi
leaq 0xf8(%rsp), %rsi
movl 0xbc(%rsp), %edx
callq 0x6ad1
leaq 0x40(%rsp), %rdi
leaq 0x8(%rsp), %rsi
callq 0x45c0
leaq 0x8(%rsp), %rdi
callq 0x4120
leaq 0xf8(%rsp), %rdi
callq 0x4120
leaq 0x8c05(%rip), %rsi      # 0x15260
leaq 0xd8(%rsp), %rdi
leaq 0x7(%rsp), %rdx
callq 0x6302
leaq 0x8(%rsp), %rdi
leaq 0xd8(%rsp), %rsi
movl 0x90(%rsp), %edx
callq 0x6ad1
leaq 0x40(%rsp), %rdi
leaq 0x8(%rsp), %rsi
callq 0x45c0
leaq 0x8(%rsp), %rdi
callq 0x4120
leaq 0xd8(%rsp), %rdi
callq 0x4120
leaq 0x8bc5(%rip), %rsi      # 0x15278
leaq 0x40(%rsp), %rdi
callq 0x45a0
leaq 0x40(%rsp), %rsi
movq 0xc0(%rsp), %rdi
callq 0x4190
leaq 0x40(%rsp), %rdi
callq 0x4120
movl 0x90(%rsp), %ecx
movl %ecx, %eax
negl %eax
cmpl $0x1, 0x170(%rbx)
cmovnel %ecx, %eax
addl $0x4, %eax
addq $0x318, %rsp            # imm = 0x318
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq %rax, %rbx
leaq 0x8(%rsp), %rdi
callq 0x4120
jmp 0xc715
movq %rax, %rbx
leaq 0xd8(%rsp), %rdi
jmp 0xc969
jmp 0xc972
movq %rax, %rbx
leaq 0x8(%rsp), %rdi
callq 0x4120
jmp 0xc739
movq %rax, %rbx
leaq 0xf8(%rsp), %rdi
jmp 0xc969
jmp 0xc972
movq %rax, %rbx
leaq 0x8(%rsp), %rdi
callq 0x4120
jmp 0xc75d
movq %rax, %rbx
leaq 0x118(%rsp), %rdi
jmp 0xc969
jmp 0xc972
movq %rax, %rbx
leaq 0x8(%rsp), %rdi
callq 0x4120
jmp 0xc781
movq %rax, %rbx
leaq 0x138(%rsp), %rdi
jmp 0xc969
jmp 0xc972
movq %rax, %rbx
leaq 0x8(%rsp), %rdi
callq 0x4120
jmp 0xc7a5
movq %rax, %rbx
leaq 0x158(%rsp), %rdi
jmp 0xc969
jmp 0xc972
movq %rax, %rbx
leaq 0x8(%rsp), %rdi
callq 0x4120
jmp 0xc7c9
movq %rax, %rbx
leaq 0x178(%rsp), %rdi
jmp 0xc969
jmp 0xc972
movq %rax, %rbx
leaq 0x8(%rsp), %rdi
callq 0x4120
jmp 0xc7ed
movq %rax, %rbx
leaq 0x198(%rsp), %rdi
jmp 0xc969
jmp 0xc972
movq %rax, %rbx
leaq 0x8(%rsp), %rdi
callq 0x4120
jmp 0xc811
movq %rax, %rbx
leaq 0x1b8(%rsp), %rdi
jmp 0xc969
jmp 0xc972
movq %rax, %rbx
leaq 0x8(%rsp), %rdi
callq 0x4120
jmp 0xc835
movq %rax, %rbx
leaq 0x1d8(%rsp), %rdi
jmp 0xc969
jmp 0xc972
movq %rax, %rbx
leaq 0x8(%rsp), %rdi
callq 0x4120
jmp 0xc859
movq %rax, %rbx
leaq 0x1f8(%rsp), %rdi
jmp 0xc969
jmp 0xc972
movq %rax, %rbx
leaq 0x8(%rsp), %rdi
callq 0x4120
jmp 0xc87d
movq %rax, %rbx
leaq 0x218(%rsp), %rdi
jmp 0xc969
jmp 0xc972
movq %rax, %rbx
leaq 0x8(%rsp), %rdi
callq 0x4120
jmp 0xc8a1
movq %rax, %rbx
leaq 0x238(%rsp), %rdi
jmp 0xc969
jmp 0xc972
movq %rax, %rbx
leaq 0x8(%rsp), %rdi
callq 0x4120
jmp 0xc8c5
movq %rax, %rbx
leaq 0x258(%rsp), %rdi
jmp 0xc969
jmp 0xc972
movq %rax, %rbx
leaq 0x8(%rsp), %rdi
callq 0x4120
jmp 0xc8e9
movq %rax, %rbx
leaq 0x278(%rsp), %rdi
jmp 0xc969
jmp 0xc972
movq %rax, %rbx
leaq 0x8(%rsp), %rdi
callq 0x4120
jmp 0xc907
movq %rax, %rbx
leaq 0x298(%rsp), %rdi
jmp 0xc969
jmp 0xc972
movq %rax, %rbx
leaq 0x8(%rsp), %rdi
callq 0x4120
jmp 0xc925
movq %rax, %rbx
leaq 0x2b8(%rsp), %rdi
jmp 0xc969
jmp 0xc972
movq %rax, %rbx
leaq 0x8(%rsp), %rdi
callq 0x4120
jmp 0xc943
movq %rax, %rbx
leaq 0x2d8(%rsp), %rdi
jmp 0xc969
jmp 0xc972
movq %rax, %rbx
leaq 0x8(%rsp), %rdi
callq 0x4120
jmp 0xc961
movq %rax, %rbx
leaq 0x2f8(%rsp), %rdi
callq 0x4120
jmp 0xc975
jmp 0xc972
movq %rax, %rbx
leaq 0x40(%rsp), %rdi
callq 0x4120
movq %rbx, %rdi
callq 0x4550
nop