// File: codeandkey[P]neocortex/src/position.cpp
// Function: neocortex::Position::pseudolegal_moves(neocortex::Move*)
int Position::pseudolegal_moves(Move* out) {
	if (check()) {
		return pseudolegal_moves_evasions(out);
	}

	int count = 0;

	bitboard ctm = board.get_color_occ(color_to_move);
	bitboard opp = board.get_color_occ(!color_to_move);
	
	bitboard ep_mask = 0;
	int ep_square = ply.back().en_passant_square;

	if (square::is_valid(ep_square)) {
		ep_mask = bb::mask(ep_square);
	}

	/* Pawn moves */
	bitboard pawns = ctm & board.get_piece_occ(piece::PAWN);

	bitboard promoting_rank = (color_to_move == piece::WHITE) ? RANK_7 : RANK_2;
	bitboard starting_rank = (color_to_move == piece::WHITE) ? RANK_2 : RANK_7;

	int adv_dir = (color_to_move == piece::WHITE) ? NORTH : SOUTH;
	int left_dir = (color_to_move == piece::WHITE) ? NORTHWEST : SOUTHWEST;
	int right_dir = (color_to_move == piece::WHITE) ? NORTHEAST : SOUTHEAST;

	bitboard promoting_pawns = pawns & promoting_rank;

	/* Promoting left captures */
	bitboard promoting_left_cap = bb::shift(promoting_pawns & ~FILE_A, left_dir) & opp;

	while (promoting_left_cap) {
		int dst = bb::poplsb(promoting_left_cap);
		out[count++] = Move(dst - left_dir, dst, piece::QUEEN);
		out[count++] = Move(dst - left_dir, dst, piece::KNIGHT);
		out[count++] = Move(dst - left_dir, dst, piece::ROOK);
		out[count++] = Move(dst - left_dir, dst, piece::BISHOP);
	}

	/* Promoting right captures */
	bitboard promoting_right_cap = bb::shift(promoting_pawns & ~FILE_H, right_dir) & opp;

	while (promoting_right_cap) {
		int dst = bb::poplsb(promoting_right_cap);
		out[count++] = Move(dst - right_dir, dst, piece::QUEEN);
		out[count++] = Move(dst - right_dir, dst, piece::KNIGHT);
		out[count++] = Move(dst - right_dir, dst, piece::ROOK);
		out[count++] = Move(dst - right_dir, dst, piece::BISHOP);
	}

	/* Promoting advances */
	bitboard promoting_advances = bb::shift(promoting_pawns, adv_dir) & ~board.get_global_occ();

	while (promoting_advances) {
		int dst = bb::poplsb(promoting_advances);
		out[count++] = Move(dst - adv_dir, dst, piece::QUEEN);
		out[count++] = Move(dst - adv_dir, dst, piece::KNIGHT);
		out[count++] = Move(dst - adv_dir, dst, piece::ROOK);
		out[count++] = Move(dst - adv_dir, dst, piece::BISHOP);
	}

	/* Nonpromoting pawn moves */
	bitboard npm_pawns = pawns & ~promoting_pawns;

	/* Advances */
	bitboard npm_advances = bb::shift(npm_pawns, adv_dir) & ~board.get_global_occ();

	while (npm_advances) {
		int dst = bb::poplsb(npm_advances);
		out[count++] = Move(dst - adv_dir, dst);
	}

	/* Left captures */
	bitboard npm_left_cap = bb::shift(npm_pawns & ~FILE_A, left_dir) & (opp | ep_mask);

	while (npm_left_cap) {
		int dst = bb::poplsb(npm_left_cap);
		out[count++] = Move(dst - left_dir, dst);
	}

	/* Right captures */
	bitboard npm_right_cap = bb::shift(npm_pawns & ~FILE_H, right_dir) & (opp | ep_mask);

	while (npm_right_cap) {
		int dst = bb::poplsb(npm_right_cap);
		out[count++] = Move(dst - right_dir, dst);
	}

	/* Jumps */
	bitboard npm_jumps = bb::shift(pawns & starting_rank, adv_dir) & ~board.get_global_occ();
	npm_jumps = bb::shift(npm_jumps, adv_dir) & ~board.get_global_occ();

	while (npm_jumps) {
		int dst = bb::poplsb(npm_jumps);
		out[count++] = Move(dst - 2 * adv_dir, dst);
	}

	/* Queen moves */
	bitboard queens = ctm & board.get_piece_occ(piece::QUEEN);
	
	while (queens) {
		int src = bb::poplsb(queens);
		bitboard moves = attacks::queen(src, board.get_global_occ()) & ~ctm;

		while (moves) {
			int dst = bb::poplsb(moves);
			out[count++] = Move(src, dst);
		}
	}

	/* Rook moves */
	bitboard rooks = ctm & board.get_piece_occ(piece::ROOK);

	while (rooks) {
		int src = bb::poplsb(rooks);
		bitboard moves = attacks::rook(src, board.get_global_occ()) & ~ctm;

		while (moves) {
			int dst = bb::poplsb(moves);
			out[count++] = Move(src, dst);
		}
	}

	/* Knight moves */
	bitboard knights = ctm & board.get_piece_occ(piece::KNIGHT);

	while (knights) {
		int src = bb::poplsb(knights);
		bitboard moves = attacks::knight(src) & ~ctm;

		while (moves) {
			int dst = bb::poplsb(moves);
			out[count++] = Move(src, dst);
		}
	}

	/* Bishop moves */
	bitboard bishops = ctm & board.get_piece_occ(piece::BISHOP);

	while (bishops) {
		int src = bb::poplsb(bishops);
		bitboard moves = attacks::bishop(src, board.get_global_occ()) & ~ctm;

		while (moves) {
			int dst = bb::poplsb(moves);
			out[count++] = Move(src, dst);
		}
	}

	/* King moves */
	bitboard kings = ctm & board.get_piece_occ(piece::KING);

	while (kings) {
		int src = bb::poplsb(kings);
		bitboard moves = attacks::king(src) & ~ctm;

		while (moves) {
			int dst = bb::poplsb(moves);
			out[count++] = Move(src, dst);
		}
	}

	/* Castling moves */

	/* We perform most of the legal move tests here, notably the noattack and occ tests */
	bitboard castle_rank = (color_to_move == piece::WHITE) ? RANK_1 : RANK_8;
	bitboard noattack_ks = castle_rank & (FILE_E | FILE_F | FILE_G);
	bitboard noattack_qs = castle_rank & (FILE_E | FILE_D | FILE_C);
	bitboard no_occ_ks = castle_rank & (FILE_F | FILE_G);
	bitboard no_occ_qs = castle_rank & (FILE_B | FILE_C | FILE_D);

	int king_src = (color_to_move == piece::WHITE) ? square::at(0, 4) : square::at(7, 4);
	int ks_dst = (color_to_move == piece::WHITE) ? square::at(0, 6) : square::at(7, 6);
	int qs_dst = (color_to_move == piece::WHITE) ? square::at(0, 2) : square::at(7, 2);

	/* Kingside */
	if (ply.back().castle_rights & (1 << (color_to_move * 2))) {
		/* occ test */
		if (!(board.get_global_occ() & no_occ_ks)) {
			/* noattack test */
			if (!board.mask_is_attacked(noattack_ks, !color_to_move)) {
				out[count++] = Move(king_src, ks_dst);
			}
		}
	}

	/* Queenside */
	if (ply.back().castle_rights & (1 << (color_to_move * 2 + 1))) {
		/* occ test */
		if (!(board.get_global_occ() & no_occ_qs)) {
			/* noattack test */
			if (!board.mask_is_attacked(noattack_qs, !color_to_move)) {
				out[count++] = Move(king_src, qs_dst);
			}
		}
	}

	assert(count <= MAX_PL_MOVES);
	return count;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x330, %rsp            # imm = 0x330
movq %rdi, -0x10(%rbp)
movq %rsi, -0x18(%rbp)
movq -0x10(%rbp), %rdi
movq %rdi, -0x2b8(%rbp)
callq 0xbc10
testb $0x1, %al
jne 0xe079
jmp 0xe091
movq -0x2b8(%rbp), %rdi
movq -0x18(%rbp), %rsi
callq 0xf0a0
movl %eax, -0x4(%rbp)
jmp 0xf088
movq -0x2b8(%rbp), %rdi
movl $0x0, -0x1c(%rbp)
movl 0x170(%rdi), %esi
callq 0x14e30
movq -0x2b8(%rbp), %rdi
movq %rax, -0x28(%rbp)
cmpl $0x0, 0x170(%rdi)
setne %al
xorb $-0x1, %al
andb $0x1, %al
movzbl %al, %esi
callq 0x14e30
movq -0x2b8(%rbp), %rdi
movq %rax, -0x30(%rbp)
movq $0x0, -0x38(%rbp)
addq $0x158, %rdi            # imm = 0x158
callq 0xbce0
movl 0xc(%rax), %eax
movl %eax, -0x3c(%rbp)
movl -0x3c(%rbp), %edi
callq 0x6d10
testb $0x1, %al
jne 0xe0fe
jmp 0xe10a
movl -0x3c(%rbp), %edi
callq 0x6bd0
movq %rax, -0x38(%rbp)
movq -0x2b8(%rbp), %rdi
movq -0x28(%rbp), %rax
movq %rax, -0x2c0(%rbp)
xorl %esi, %esi
callq 0x14e50
movq -0x2c0(%rbp), %rcx
movq %rax, %rdx
movq -0x2b8(%rbp), %rax
andq %rdx, %rcx
movq %rcx, -0x48(%rbp)
movl 0x170(%rax), %esi
movl $0xff00, %ecx           # imm = 0xFF00
movabsq $0xff000000000000, %rdx # imm = 0xFF000000000000
cmpl $0x0, %esi
cmoveq %rdx, %rcx
movq %rcx, -0x50(%rbp)
movl 0x170(%rax), %esi
movabsq $0xff000000000000, %rcx # imm = 0xFF000000000000
movl $0xff00, %edx           # imm = 0xFF00
cmpl $0x0, %esi
cmoveq %rdx, %rcx
movq %rcx, -0x58(%rbp)
movl 0x170(%rax), %esi
movl $0xfffffff8, %ecx       # imm = 0xFFFFFFF8
movl $0x8, %edx
cmpl $0x0, %esi
cmovel %edx, %ecx
movl %ecx, -0x5c(%rbp)
movl 0x170(%rax), %esi
movl $0xfffffff7, %ecx       # imm = 0xFFFFFFF7
movl $0x7, %edx
cmpl $0x0, %esi
cmovel %edx, %ecx
movl %ecx, -0x60(%rbp)
movl 0x170(%rax), %edx
movl $0xfffffff9, %eax       # imm = 0xFFFFFFF9
movl $0x9, %ecx
cmpl $0x0, %edx
cmovel %ecx, %eax
movl %eax, -0x64(%rbp)
movq -0x48(%rbp), %rax
andq -0x50(%rbp), %rax
movq %rax, -0x70(%rbp)
movabsq $-0x101010101010102, %rdi # imm = 0xFEFEFEFEFEFEFEFE
andq -0x70(%rbp), %rdi
movl -0x60(%rbp), %esi
callq 0x6ca0
andq -0x30(%rbp), %rax
movq %rax, -0x78(%rbp)
cmpq $0x0, -0x78(%rbp)
je 0xe321
leaq -0x78(%rbp), %rdi
callq 0x8f70
movl %eax, -0x7c(%rbp)
movl -0x7c(%rbp), %esi
subl -0x60(%rbp), %esi
movl -0x7c(%rbp), %edx
leaq -0x88(%rbp), %rdi
movl $0x4, %ecx
callq 0xa8a0
movq -0x18(%rbp), %rax
movl -0x1c(%rbp), %ecx
movl %ecx, %edx
addl $0x1, %edx
movl %edx, -0x1c(%rbp)
movslq %ecx, %rcx
imulq $0xc, %rcx, %rcx
addq %rcx, %rax
movq -0x88(%rbp), %rcx
movq %rcx, (%rax)
movl -0x80(%rbp), %ecx
movl %ecx, 0x8(%rax)
movl -0x7c(%rbp), %esi
subl -0x60(%rbp), %esi
movl -0x7c(%rbp), %edx
leaq -0x94(%rbp), %rdi
movl $0x2, %ecx
callq 0xa8a0
movq -0x18(%rbp), %rax
movl -0x1c(%rbp), %ecx
movl %ecx, %edx
addl $0x1, %edx
movl %edx, -0x1c(%rbp)
movslq %ecx, %rcx
imulq $0xc, %rcx, %rcx
addq %rcx, %rax
movq -0x94(%rbp), %rcx
movq %rcx, (%rax)
movl -0x8c(%rbp), %ecx
movl %ecx, 0x8(%rax)
movl -0x7c(%rbp), %esi
subl -0x60(%rbp), %esi
movl -0x7c(%rbp), %edx
leaq -0xa0(%rbp), %rdi
movl $0x3, %ecx
callq 0xa8a0
movq -0x18(%rbp), %rax
movl -0x1c(%rbp), %ecx
movl %ecx, %edx
addl $0x1, %edx
movl %edx, -0x1c(%rbp)
movslq %ecx, %rcx
imulq $0xc, %rcx, %rcx
addq %rcx, %rax
movq -0xa0(%rbp), %rcx
movq %rcx, (%rax)
movl -0x98(%rbp), %ecx
movl %ecx, 0x8(%rax)
movl -0x7c(%rbp), %esi
subl -0x60(%rbp), %esi
movl -0x7c(%rbp), %edx
leaq -0xac(%rbp), %rdi
movl $0x1, %ecx
callq 0xa8a0
movq -0x18(%rbp), %rax
movl -0x1c(%rbp), %ecx
movl %ecx, %edx
addl $0x1, %edx
movl %edx, -0x1c(%rbp)
movslq %ecx, %rcx
imulq $0xc, %rcx, %rcx
addq %rcx, %rax
movq -0xac(%rbp), %rcx
movq %rcx, (%rax)
movl -0xa4(%rbp), %ecx
movl %ecx, 0x8(%rax)
jmp 0xe1f0
movabsq $0x7f7f7f7f7f7f7f7f, %rdi # imm = 0x7F7F7F7F7F7F7F7F
andq -0x70(%rbp), %rdi
movl -0x64(%rbp), %esi
callq 0x6ca0
andq -0x30(%rbp), %rax
movq %rax, -0xb8(%rbp)
cmpq $0x0, -0xb8(%rbp)
je 0xe497
leaq -0xb8(%rbp), %rdi
callq 0x8f70
movl %eax, -0xbc(%rbp)
movl -0xbc(%rbp), %esi
subl -0x64(%rbp), %esi
movl -0xbc(%rbp), %edx
leaq -0xc8(%rbp), %rdi
movl $0x4, %ecx
callq 0xa8a0
movq -0x18(%rbp), %rax
movl -0x1c(%rbp), %ecx
movl %ecx, %edx
addl $0x1, %edx
movl %edx, -0x1c(%rbp)
movslq %ecx, %rcx
imulq $0xc, %rcx, %rcx
addq %rcx, %rax
movq -0xc8(%rbp), %rcx
movq %rcx, (%rax)
movl -0xc0(%rbp), %ecx
movl %ecx, 0x8(%rax)
movl -0xbc(%rbp), %esi
subl -0x64(%rbp), %esi
movl -0xbc(%rbp), %edx
leaq -0xd4(%rbp), %rdi
movl $0x2, %ecx
callq 0xa8a0
movq -0x18(%rbp), %rax
movl -0x1c(%rbp), %ecx
movl %ecx, %edx
addl $0x1, %edx
movl %edx, -0x1c(%rbp)
movslq %ecx, %rcx
imulq $0xc, %rcx, %rcx
addq %rcx, %rax
movq -0xd4(%rbp), %rcx
movq %rcx, (%rax)
movl -0xcc(%rbp), %ecx
movl %ecx, 0x8(%rax)
movl -0xbc(%rbp), %esi
subl -0x64(%rbp), %esi
movl -0xbc(%rbp), %edx
leaq -0xe0(%rbp), %rdi
movl $0x3, %ecx
callq 0xa8a0
movq -0x18(%rbp), %rax
movl -0x1c(%rbp), %ecx
movl %ecx, %edx
addl $0x1, %edx
movl %edx, -0x1c(%rbp)
movslq %ecx, %rcx
imulq $0xc, %rcx, %rcx
addq %rcx, %rax
movq -0xe0(%rbp), %rcx
movq %rcx, (%rax)
movl -0xd8(%rbp), %ecx
movl %ecx, 0x8(%rax)
movl -0xbc(%rbp), %esi
subl -0x64(%rbp), %esi
movl -0xbc(%rbp), %edx
leaq -0xec(%rbp), %rdi
movl $0x1, %ecx
callq 0xa8a0
movq -0x18(%rbp), %rax
movl -0x1c(%rbp), %ecx
movl %ecx, %edx
addl $0x1, %edx
movl %edx, -0x1c(%rbp)
movslq %ecx, %rcx
imulq $0xc, %rcx, %rcx
addq %rcx, %rax
movq -0xec(%rbp), %rcx
movq %rcx, (%rax)
movl -0xe4(%rbp), %ecx
movl %ecx, 0x8(%rax)
jmp 0xe342
movq -0x70(%rbp), %rdi
movl -0x5c(%rbp), %esi
callq 0x6ca0
movq -0x2b8(%rbp), %rdi
movq %rax, -0x2c8(%rbp)
callq 0x14e70
movq %rax, %rcx
movq -0x2c8(%rbp), %rax
xorq $-0x1, %rcx
andq %rcx, %rax
movq %rax, -0xf8(%rbp)
cmpq $0x0, -0xf8(%rbp)
je 0xe623
leaq -0xf8(%rbp), %rdi
callq 0x8f70
movl %eax, -0xfc(%rbp)
movl -0xfc(%rbp), %esi
subl -0x5c(%rbp), %esi
movl -0xfc(%rbp), %edx
leaq -0x108(%rbp), %rdi
movl $0x4, %ecx
callq 0xa8a0
movq -0x18(%rbp), %rax
movl -0x1c(%rbp), %ecx
movl %ecx, %edx
addl $0x1, %edx
movl %edx, -0x1c(%rbp)
movslq %ecx, %rcx
imulq $0xc, %rcx, %rcx
addq %rcx, %rax
movq -0x108(%rbp), %rcx
movq %rcx, (%rax)
movl -0x100(%rbp), %ecx
movl %ecx, 0x8(%rax)
movl -0xfc(%rbp), %esi
subl -0x5c(%rbp), %esi
movl -0xfc(%rbp), %edx
leaq -0x114(%rbp), %rdi
movl $0x2, %ecx
callq 0xa8a0
movq -0x18(%rbp), %rax
movl -0x1c(%rbp), %ecx
movl %ecx, %edx
addl $0x1, %edx
movl %edx, -0x1c(%rbp)
movslq %ecx, %rcx
imulq $0xc, %rcx, %rcx
addq %rcx, %rax
movq -0x114(%rbp), %rcx
movq %rcx, (%rax)
movl -0x10c(%rbp), %ecx
movl %ecx, 0x8(%rax)
movl -0xfc(%rbp), %esi
subl -0x5c(%rbp), %esi
movl -0xfc(%rbp), %edx
leaq -0x120(%rbp), %rdi
movl $0x3, %ecx
callq 0xa8a0
movq -0x18(%rbp), %rax
movl -0x1c(%rbp), %ecx
movl %ecx, %edx
addl $0x1, %edx
movl %edx, -0x1c(%rbp)
movslq %ecx, %rcx
imulq $0xc, %rcx, %rcx
addq %rcx, %rax
movq -0x120(%rbp), %rcx
movq %rcx, (%rax)
movl -0x118(%rbp), %ecx
movl %ecx, 0x8(%rax)
movl -0xfc(%rbp), %esi
subl -0x5c(%rbp), %esi
movl -0xfc(%rbp), %edx
leaq -0x12c(%rbp), %rdi
movl $0x1, %ecx
callq 0xa8a0
movq -0x18(%rbp), %rax
movl -0x1c(%rbp), %ecx
movl %ecx, %edx
addl $0x1, %edx
movl %edx, -0x1c(%rbp)
movslq %ecx, %rcx
imulq $0xc, %rcx, %rcx
addq %rcx, %rax
movq -0x12c(%rbp), %rcx
movq %rcx, (%rax)
movl -0x124(%rbp), %ecx
movl %ecx, 0x8(%rax)
jmp 0xe4ce
movq -0x48(%rbp), %rax
movq -0x70(%rbp), %rcx
xorq $-0x1, %rcx
andq %rcx, %rax
movq %rax, -0x138(%rbp)
movq -0x138(%rbp), %rdi
movl -0x5c(%rbp), %esi
callq 0x6ca0
movq -0x2b8(%rbp), %rdi
movq %rax, -0x2d0(%rbp)
callq 0x14e70
movq %rax, %rcx
movq -0x2d0(%rbp), %rax
xorq $-0x1, %rcx
andq %rcx, %rax
movq %rax, -0x140(%rbp)
cmpq $0x0, -0x140(%rbp)
je 0xe6dd
leaq -0x140(%rbp), %rdi
callq 0x8f70
movl %eax, -0x144(%rbp)
movl -0x144(%rbp), %esi
subl -0x5c(%rbp), %esi
movl -0x144(%rbp), %edx
leaq -0x150(%rbp), %rdi
movl $0xffffffff, %ecx       # imm = 0xFFFFFFFF
callq 0xa8a0
movq -0x18(%rbp), %rax
movl -0x1c(%rbp), %ecx
movl %ecx, %edx
addl $0x1, %edx
movl %edx, -0x1c(%rbp)
movslq %ecx, %rcx
imulq $0xc, %rcx, %rcx
addq %rcx, %rax
movq -0x150(%rbp), %rcx
movq %rcx, (%rax)
movl -0x148(%rbp), %ecx
movl %ecx, 0x8(%rax)
jmp 0xe673
movabsq $-0x101010101010102, %rdi # imm = 0xFEFEFEFEFEFEFEFE
andq -0x138(%rbp), %rdi
movl -0x60(%rbp), %esi
callq 0x6ca0
movq -0x30(%rbp), %rcx
orq -0x38(%rbp), %rcx
andq %rcx, %rax
movq %rax, -0x158(%rbp)
cmpq $0x0, -0x158(%rbp)
je 0xe772
leaq -0x158(%rbp), %rdi
callq 0x8f70
movl %eax, -0x15c(%rbp)
movl -0x15c(%rbp), %esi
subl -0x60(%rbp), %esi
movl -0x15c(%rbp), %edx
leaq -0x168(%rbp), %rdi
movl $0xffffffff, %ecx       # imm = 0xFFFFFFFF
callq 0xa8a0
movq -0x18(%rbp), %rax
movl -0x1c(%rbp), %ecx
movl %ecx, %edx
addl $0x1, %edx
movl %edx, -0x1c(%rbp)
movslq %ecx, %rcx
imulq $0xc, %rcx, %rcx
addq %rcx, %rax
movq -0x168(%rbp), %rcx
movq %rcx, (%rax)
movl -0x160(%rbp), %ecx
movl %ecx, 0x8(%rax)
jmp 0xe708
movabsq $0x7f7f7f7f7f7f7f7f, %rdi # imm = 0x7F7F7F7F7F7F7F7F
andq -0x138(%rbp), %rdi
movl -0x64(%rbp), %esi
callq 0x6ca0
movq -0x30(%rbp), %rcx
orq -0x38(%rbp), %rcx
andq %rcx, %rax
movq %rax, -0x170(%rbp)
cmpq $0x0, -0x170(%rbp)
je 0xe807
leaq -0x170(%rbp), %rdi
callq 0x8f70
movl %eax, -0x174(%rbp)
movl -0x174(%rbp), %esi
subl -0x64(%rbp), %esi
movl -0x174(%rbp), %edx
leaq -0x180(%rbp), %rdi
movl $0xffffffff, %ecx       # imm = 0xFFFFFFFF
callq 0xa8a0
movq -0x18(%rbp), %rax
movl -0x1c(%rbp), %ecx
movl %ecx, %edx
addl $0x1, %edx
movl %edx, -0x1c(%rbp)
movslq %ecx, %rcx
imulq $0xc, %rcx, %rcx
addq %rcx, %rax
movq -0x180(%rbp), %rcx
movq %rcx, (%rax)
movl -0x178(%rbp), %ecx
movl %ecx, 0x8(%rax)
jmp 0xe79d
movq -0x48(%rbp), %rdi
andq -0x58(%rbp), %rdi
movl -0x5c(%rbp), %esi
callq 0x6ca0
movq -0x2b8(%rbp), %rdi
movq %rax, -0x2e0(%rbp)
callq 0x14e70
movq %rax, %rcx
movq -0x2e0(%rbp), %rax
xorq $-0x1, %rcx
andq %rcx, %rax
movq %rax, -0x188(%rbp)
movq -0x188(%rbp), %rdi
movl -0x5c(%rbp), %esi
callq 0x6ca0
movq -0x2b8(%rbp), %rdi
movq %rax, -0x2d8(%rbp)
callq 0x14e70
movq %rax, %rcx
movq -0x2d8(%rbp), %rax
xorq $-0x1, %rcx
andq %rcx, %rax
movq %rax, -0x188(%rbp)
cmpq $0x0, -0x188(%rbp)
je 0xe8ea
leaq -0x188(%rbp), %rdi
callq 0x8f70
movl %eax, -0x18c(%rbp)
movl -0x18c(%rbp), %esi
movl -0x5c(%rbp), %eax
shll %eax
subl %eax, %esi
movl -0x18c(%rbp), %edx
leaq -0x198(%rbp), %rdi
movl $0xffffffff, %ecx       # imm = 0xFFFFFFFF
callq 0xa8a0
movq -0x18(%rbp), %rax
movl -0x1c(%rbp), %ecx
movl %ecx, %edx
addl $0x1, %edx
movl %edx, -0x1c(%rbp)
movslq %ecx, %rcx
imulq $0xc, %rcx, %rcx
addq %rcx, %rax
movq -0x198(%rbp), %rcx
movq %rcx, (%rax)
movl -0x190(%rbp), %ecx
movl %ecx, 0x8(%rax)
jmp 0xe87c
movq -0x2b8(%rbp), %rdi
movq -0x28(%rbp), %rax
movq %rax, -0x2e8(%rbp)
movl $0x4, %esi
callq 0x14e50
movq %rax, %rcx
movq -0x2e8(%rbp), %rax
andq %rcx, %rax
movq %rax, -0x1a0(%rbp)
cmpq $0x0, -0x1a0(%rbp)
je 0xe9de
leaq -0x1a0(%rbp), %rdi
callq 0x8f70
movq -0x2b8(%rbp), %rdi
movl %eax, -0x1a4(%rbp)
movl -0x1a4(%rbp), %eax
movl %eax, -0x2ec(%rbp)
callq 0x14e70
movl -0x2ec(%rbp), %edi
movq %rax, %rsi
callq 0x14e90
movq -0x28(%rbp), %rcx
xorq $-0x1, %rcx
andq %rcx, %rax
movq %rax, -0x1b0(%rbp)
cmpq $0x0, -0x1b0(%rbp)
je 0xe9d9
leaq -0x1b0(%rbp), %rdi
callq 0x8f70
movl %eax, -0x1b4(%rbp)
movl -0x1a4(%rbp), %esi
movl -0x1b4(%rbp), %edx
leaq -0x1c0(%rbp), %rdi
movl $0xffffffff, %ecx       # imm = 0xFFFFFFFF
callq 0xa8a0
movq -0x18(%rbp), %rax
movl -0x1c(%rbp), %ecx
movl %ecx, %edx
addl $0x1, %edx
movl %edx, -0x1c(%rbp)
movslq %ecx, %rcx
imulq $0xc, %rcx, %rcx
addq %rcx, %rax
movq -0x1c0(%rbp), %rcx
movq %rcx, (%rax)
movl -0x1b8(%rbp), %ecx
movl %ecx, 0x8(%rax)
jmp 0xe972
jmp 0xe91a
movq -0x2b8(%rbp), %rdi
movq -0x28(%rbp), %rax
movq %rax, -0x2f8(%rbp)
movl $0x3, %esi
callq 0x14e50
movq %rax, %rcx
movq -0x2f8(%rbp), %rax
andq %rcx, %rax
movq %rax, -0x1c8(%rbp)
cmpq $0x0, -0x1c8(%rbp)
je 0xead2
leaq -0x1c8(%rbp), %rdi
callq 0x8f70
movq -0x2b8(%rbp), %rdi
movl %eax, -0x1cc(%rbp)
movl -0x1cc(%rbp), %eax
movl %eax, -0x2fc(%rbp)
callq 0x14e70
movl -0x2fc(%rbp), %edi
movq %rax, %rsi
callq 0x8eb0
movq -0x28(%rbp), %rcx
xorq $-0x1, %rcx
andq %rcx, %rax
movq %rax, -0x1d8(%rbp)
cmpq $0x0, -0x1d8(%rbp)
je 0xeacd
leaq -0x1d8(%rbp), %rdi
callq 0x8f70
movl %eax, -0x1dc(%rbp)
movl -0x1cc(%rbp), %esi
movl -0x1dc(%rbp), %edx
leaq -0x1e8(%rbp), %rdi
movl $0xffffffff, %ecx       # imm = 0xFFFFFFFF
callq 0xa8a0
movq -0x18(%rbp), %rax
movl -0x1c(%rbp), %ecx
movl %ecx, %edx
addl $0x1, %edx
movl %edx, -0x1c(%rbp)
movslq %ecx, %rcx
imulq $0xc, %rcx, %rcx
addq %rcx, %rax
movq -0x1e8(%rbp), %rcx
movq %rcx, (%rax)
movl -0x1e0(%rbp), %ecx
movl %ecx, 0x8(%rax)
jmp 0xea66
jmp 0xea0e
movq -0x2b8(%rbp), %rdi
movq -0x28(%rbp), %rax
movq %rax, -0x308(%rbp)
movl $0x2, %esi
callq 0x14e50
movq %rax, %rcx
movq -0x308(%rbp), %rax
andq %rcx, %rax
movq %rax, -0x1f0(%rbp)
cmpq $0x0, -0x1f0(%rbp)
je 0xebab
leaq -0x1f0(%rbp), %rdi
callq 0x8f70
movl %eax, -0x1f4(%rbp)
movl -0x1f4(%rbp), %edi
callq 0x8df0
movq -0x28(%rbp), %rcx
xorq $-0x1, %rcx
andq %rcx, %rax
movq %rax, -0x200(%rbp)
cmpq $0x0, -0x200(%rbp)
je 0xeba6
leaq -0x200(%rbp), %rdi
callq 0x8f70
movl %eax, -0x204(%rbp)
movl -0x1f4(%rbp), %esi
movl -0x204(%rbp), %edx
leaq -0x210(%rbp), %rdi
movl $0xffffffff, %ecx       # imm = 0xFFFFFFFF
callq 0xa8a0
movq -0x18(%rbp), %rax
movl -0x1c(%rbp), %ecx
movl %ecx, %edx
addl $0x1, %edx
movl %edx, -0x1c(%rbp)
movslq %ecx, %rcx
imulq $0xc, %rcx, %rcx
addq %rcx, %rax
movq -0x210(%rbp), %rcx
movq %rcx, (%rax)
movl -0x208(%rbp), %ecx
movl %ecx, 0x8(%rax)
jmp 0xeb3f
jmp 0xeb02
movq -0x2b8(%rbp), %rdi
movq -0x28(%rbp), %rax
movq %rax, -0x310(%rbp)
movl $0x1, %esi
callq 0x14e50
movq %rax, %rcx
movq -0x310(%rbp), %rax
andq %rcx, %rax
movq %rax, -0x218(%rbp)
cmpq $0x0, -0x218(%rbp)
je 0xec9f
leaq -0x218(%rbp), %rdi
callq 0x8f70
movq -0x2b8(%rbp), %rdi
movl %eax, -0x21c(%rbp)
movl -0x21c(%rbp), %eax
movl %eax, -0x314(%rbp)
callq 0x14e70
movl -0x314(%rbp), %edi
movq %rax, %rsi
callq 0x8e10
movq -0x28(%rbp), %rcx
xorq $-0x1, %rcx
andq %rcx, %rax
movq %rax, -0x228(%rbp)
cmpq $0x0, -0x228(%rbp)
je 0xec9a
leaq -0x228(%rbp), %rdi
callq 0x8f70
movl %eax, -0x22c(%rbp)
movl -0x21c(%rbp), %esi
movl -0x22c(%rbp), %edx
leaq -0x238(%rbp), %rdi
movl $0xffffffff, %ecx       # imm = 0xFFFFFFFF
callq 0xa8a0
movq -0x18(%rbp), %rax
movl -0x1c(%rbp), %ecx
movl %ecx, %edx
addl $0x1, %edx
movl %edx, -0x1c(%rbp)
movslq %ecx, %rcx
imulq $0xc, %rcx, %rcx
addq %rcx, %rax
movq -0x238(%rbp), %rcx
movq %rcx, (%rax)
movl -0x230(%rbp), %ecx
movl %ecx, 0x8(%rax)
jmp 0xec33
jmp 0xebdb
movq -0x2b8(%rbp), %rdi
movq -0x28(%rbp), %rax
movq %rax, -0x320(%rbp)
movl $0x5, %esi
callq 0x14e50
movq %rax, %rcx
movq -0x320(%rbp), %rax
andq %rcx, %rax
movq %rax, -0x240(%rbp)
cmpq $0x0, -0x240(%rbp)
je 0xed78
leaq -0x240(%rbp), %rdi
callq 0x8f70
movl %eax, -0x244(%rbp)
movl -0x244(%rbp), %edi
callq 0x8f50
movq -0x28(%rbp), %rcx
xorq $-0x1, %rcx
andq %rcx, %rax
movq %rax, -0x250(%rbp)
cmpq $0x0, -0x250(%rbp)
je 0xed73
leaq -0x250(%rbp), %rdi
callq 0x8f70
movl %eax, -0x254(%rbp)
movl -0x244(%rbp), %esi
movl -0x254(%rbp), %edx
leaq -0x260(%rbp), %rdi
movl $0xffffffff, %ecx       # imm = 0xFFFFFFFF
callq 0xa8a0
movq -0x18(%rbp), %rax
movl -0x1c(%rbp), %ecx
movl %ecx, %edx
addl $0x1, %edx
movl %edx, -0x1c(%rbp)
movslq %ecx, %rcx
imulq $0xc, %rcx, %rcx
addq %rcx, %rax
movq -0x260(%rbp), %rcx
movq %rcx, (%rax)
movl -0x258(%rbp), %ecx
movl %ecx, 0x8(%rax)
jmp 0xed0c
jmp 0xeccf
movq -0x2b8(%rbp), %rax
movl 0x170(%rax), %esi
movabsq $-0x100000000000000, %rcx # imm = 0xFF00000000000000
movl $0xff, %edx
cmpl $0x0, %esi
cmoveq %rdx, %rcx
movq %rcx, -0x268(%rbp)
movabsq $0x7070707070707070, %rcx # imm = 0x7070707070707070
andq -0x268(%rbp), %rcx
movq %rcx, -0x270(%rbp)
movabsq $0x1c1c1c1c1c1c1c1c, %rcx # imm = 0x1C1C1C1C1C1C1C1C
andq -0x268(%rbp), %rcx
movq %rcx, -0x278(%rbp)
movabsq $0x6060606060606060, %rcx # imm = 0x6060606060606060
andq -0x268(%rbp), %rcx
movq %rcx, -0x280(%rbp)
movabsq $0xe0e0e0e0e0e0e0e, %rcx # imm = 0xE0E0E0E0E0E0E0E
andq -0x268(%rbp), %rcx
movq %rcx, -0x288(%rbp)
cmpl $0x0, 0x170(%rax)
jne 0xee1f
xorl %edi, %edi
movl $0x4, %esi
callq 0x6c20
movl %eax, -0x324(%rbp)
jmp 0xee34
movl $0x7, %edi
movl $0x4, %esi
callq 0x6c20
movl %eax, -0x324(%rbp)
movq -0x2b8(%rbp), %rax
movl -0x324(%rbp), %ecx
movl %ecx, -0x28c(%rbp)
cmpl $0x0, 0x170(%rax)
jne 0xee64
xorl %edi, %edi
movl $0x6, %esi
callq 0x6c20
movl %eax, -0x328(%rbp)
jmp 0xee79
movl $0x7, %edi
movl $0x6, %esi
callq 0x6c20
movl %eax, -0x328(%rbp)
movq -0x2b8(%rbp), %rax
movl -0x328(%rbp), %ecx
movl %ecx, -0x290(%rbp)
cmpl $0x0, 0x170(%rax)
jne 0xeea9
xorl %edi, %edi
movl $0x2, %esi
callq 0x6c20
movl %eax, -0x32c(%rbp)
jmp 0xeebe
movl $0x7, %edi
movl $0x2, %esi
callq 0x6c20
movl %eax, -0x32c(%rbp)
movq -0x2b8(%rbp), %rdi
movl -0x32c(%rbp), %eax
movl %eax, -0x294(%rbp)
addq $0x158, %rdi            # imm = 0x158
callq 0xbce0
movq -0x2b8(%rbp), %rcx
movl 0x10(%rax), %eax
movl 0x170(%rcx), %ecx
shll %ecx
movl $0x1, %edx
shll %cl, %edx
movl %edx, %ecx
andl %ecx, %eax
cmpl $0x0, %eax
je 0xef91
movq -0x2b8(%rbp), %rdi
callq 0x14e70
andq -0x280(%rbp), %rax
cmpq $0x0, %rax
jne 0xef8f
movq -0x2b8(%rbp), %rdi
movq -0x270(%rbp), %rsi
cmpl $0x0, 0x170(%rdi)
setne %al
xorb $-0x1, %al
andb $0x1, %al
movzbl %al, %edx
callq 0x8540
testb $0x1, %al
jne 0xef8d
movl -0x28c(%rbp), %esi
movl -0x290(%rbp), %edx
leaq -0x2a0(%rbp), %rdi
movl $0xffffffff, %ecx       # imm = 0xFFFFFFFF
callq 0xa8a0
movq -0x18(%rbp), %rax
movl -0x1c(%rbp), %ecx
movl %ecx, %edx
addl $0x1, %edx
movl %edx, -0x1c(%rbp)
movslq %ecx, %rcx
imulq $0xc, %rcx, %rcx
addq %rcx, %rax
movq -0x2a0(%rbp), %rcx
movq %rcx, (%rax)
movl -0x298(%rbp), %ecx
movl %ecx, 0x8(%rax)
jmp 0xef8f
jmp 0xef91
movq -0x2b8(%rbp), %rdi
addq $0x158, %rdi            # imm = 0x158
callq 0xbce0
movq -0x2b8(%rbp), %rcx
movl 0x10(%rax), %eax
movl 0x170(%rcx), %ecx
shll %ecx
addl $0x1, %ecx
movl $0x1, %edx
shll %cl, %edx
movl %edx, %ecx
andl %ecx, %eax
cmpl $0x0, %eax
je 0xf05b
movq -0x2b8(%rbp), %rdi
callq 0x14e70
andq -0x288(%rbp), %rax
cmpq $0x0, %rax
jne 0xf059
movq -0x2b8(%rbp), %rdi
movq -0x278(%rbp), %rsi
cmpl $0x0, 0x170(%rdi)
setne %al
xorb $-0x1, %al
andb $0x1, %al
movzbl %al, %edx
callq 0x8540
testb $0x1, %al
jne 0xf057
movl -0x28c(%rbp), %esi
movl -0x294(%rbp), %edx
leaq -0x2ac(%rbp), %rdi
movl $0xffffffff, %ecx       # imm = 0xFFFFFFFF
callq 0xa8a0
movq -0x18(%rbp), %rax
movl -0x1c(%rbp), %ecx
movl %ecx, %edx
addl $0x1, %edx
movl %edx, -0x1c(%rbp)
movslq %ecx, %rcx
imulq $0xc, %rcx, %rcx
addq %rcx, %rax
movq -0x2ac(%rbp), %rcx
movq %rcx, (%rax)
movl -0x2a4(%rbp), %ecx
movl %ecx, 0x8(%rax)
jmp 0xf059
jmp 0xf05b
cmpl $0x64, -0x1c(%rbp)
jg 0xf063
jmp 0xf082
leaq 0x188e9(%rip), %rdi     # 0x27953
leaq 0x18754(%rip), %rsi     # 0x277c5
movl $0x21b, %edx            # imm = 0x21B
leaq 0x188ec(%rip), %rcx     # 0x27969
callq 0x5290
movl -0x1c(%rbp), %eax
movl %eax, -0x4(%rbp)
movl -0x4(%rbp), %eax
addq $0x330, %rsp            # imm = 0x330
popq %rbp
retq
nopw %cs:(%rax,%rax)