// File: SethKasmann[P]clever-girl/src/state.h
// Function: State::movePiece(Color, PieceType, Square, Square)
inline void State::movePiece(Color pColor, PieceType pPiece, Square pSrc, Square pDst)
{
    mPieces[pColor][pPiece] ^= square_bb[pSrc] | square_bb[pDst];
    mOccupancy[pColor] ^= square_bb[pSrc] | square_bb[pDst];
    mBoard[pDst] = pPiece;
    mBoard[pSrc] = none;
    mPieceIndex[pDst] = mPieceIndex[pSrc];
    mPieceList[pColor][pPiece][mPieceIndex[pDst]] = pDst;

    mPstScore[pColor][middle] -= PieceSquareTable::getScore(pPiece, middle, pColor, pSrc);
    mPstScore[pColor][late] -= PieceSquareTable::getScore(pPiece, late, pColor, pSrc);
    mPstScore[pColor][middle] += PieceSquareTable::getScore(pPiece, middle, pColor, pDst);
    mPstScore[pColor][late] += PieceSquareTable::getScore(pPiece, late, pColor, pDst);

    mKey ^= Zobrist::key(pColor, pPiece, pSrc, pDst);
}

// Assembly:
subq $0x58, %rsp
movq %rdi, 0x50(%rsp)
movl %esi, 0x4c(%rsp)
movl %edx, 0x48(%rsp)
movl %ecx, 0x44(%rsp)
movl %r8d, 0x40(%rsp)
movq 0x50(%rsp), %rdi
movq %rdi, 0x38(%rsp)
movl 0x44(%rsp), %eax
movl %eax, %ecx
leaq 0x119c2f(%rip), %rax    # 0x154b10
movq (%rax,%rcx,8), %rax
movl 0x40(%rsp), %ecx
movl %ecx, %edx
leaq 0x119c1e(%rip), %rcx    # 0x154b10
orq (%rcx,%rdx,8), %rax
movq %rax, (%rsp)
addq $0x288, %rdi            # imm = 0x288
movl 0x4c(%rsp), %eax
movl %eax, %esi
callq 0x24c10
movq %rax, %rdi
movl 0x48(%rsp), %eax
movl %eax, %esi
callq 0x24c40
movq (%rsp), %rcx
movq 0x38(%rsp), %rdi
xorq (%rax), %rcx
movq %rcx, (%rax)
movl 0x44(%rsp), %eax
movl %eax, %ecx
leaq 0x119bda(%rip), %rax    # 0x154b10
movq (%rax,%rcx,8), %rax
movl 0x40(%rsp), %ecx
movl %ecx, %edx
leaq 0x119bc9(%rip), %rcx    # 0x154b10
orq (%rcx,%rdx,8), %rax
movq %rax, 0x8(%rsp)
addq $0x78, %rdi
movl 0x4c(%rsp), %eax
movl %eax, %esi
callq 0x24c70
movq 0x8(%rsp), %rcx
movq 0x38(%rsp), %rdi
xorq (%rax), %rcx
movq %rcx, (%rax)
movl 0x48(%rsp), %eax
movl %eax, 0x10(%rsp)
addq $0x188, %rdi            # imm = 0x188
movl 0x40(%rsp), %eax
movl %eax, %esi
callq 0x3b530
movl 0x10(%rsp), %ecx
movq 0x38(%rsp), %rdi
movl %ecx, (%rax)
addq $0x188, %rdi            # imm = 0x188
movl 0x44(%rsp), %eax
movl %eax, %esi
callq 0x3b530
movq 0x38(%rsp), %rdi
movl $0x6, (%rax)
addq $0x88, %rdi
movl 0x44(%rsp), %eax
movl %eax, %esi
callq 0x35f20
movq 0x38(%rsp), %rdi
movl (%rax), %eax
movl %eax, 0x14(%rsp)
addq $0x88, %rdi
movl 0x40(%rsp), %eax
movl %eax, %esi
callq 0x35f20
movl 0x14(%rsp), %ecx
movq 0x38(%rsp), %rdi
movl %ecx, (%rax)
movl 0x40(%rsp), %eax
movl %eax, 0x24(%rsp)
addq $0x328, %rdi            # imm = 0x328
movl 0x4c(%rsp), %eax
movl %eax, %esi
callq 0x3b5c0
movq %rax, %rdi
movl 0x48(%rsp), %eax
movl %eax, %esi
callq 0x3b5f0
movq 0x38(%rsp), %rdi
movq %rax, 0x18(%rsp)
addq $0x88, %rdi
movl 0x40(%rsp), %eax
movl %eax, %esi
callq 0x35f20
movq 0x18(%rsp), %rdi
movslq (%rax), %rsi
callq 0x3b620
movl 0x24(%rsp), %ecx
movl %ecx, (%rax)
movl 0x48(%rsp), %edi
movl 0x4c(%rsp), %edx
movl 0x44(%rsp), %ecx
xorl %esi, %esi
callq 0x3b650
movq 0x38(%rsp), %rdi
movl %eax, 0x28(%rsp)
addq $0x318, %rdi            # imm = 0x318
movl 0x4c(%rsp), %eax
movl %eax, %esi
callq 0x3b6a0
movq %rax, %rdi
xorl %eax, %eax
movl %eax, %esi
callq 0x24cb0
movl 0x28(%rsp), %edx
movl (%rax), %ecx
subl %edx, %ecx
movl %ecx, (%rax)
movl 0x48(%rsp), %edi
movl 0x4c(%rsp), %edx
movl 0x44(%rsp), %ecx
movl $0x1, %esi
callq 0x3b650
movq 0x38(%rsp), %rdi
movl %eax, 0x2c(%rsp)
addq $0x318, %rdi            # imm = 0x318
movl 0x4c(%rsp), %eax
movl %eax, %esi
callq 0x3b6a0
movq %rax, %rdi
movl $0x1, %esi
callq 0x24cb0
movl 0x2c(%rsp), %edx
movl (%rax), %ecx
subl %edx, %ecx
movl %ecx, (%rax)
movl 0x48(%rsp), %edi
movl 0x4c(%rsp), %edx
movl 0x40(%rsp), %ecx
xorl %esi, %esi
callq 0x3b650
movq 0x38(%rsp), %rdi
movl %eax, 0x30(%rsp)
addq $0x318, %rdi            # imm = 0x318
movl 0x4c(%rsp), %eax
movl %eax, %esi
callq 0x3b6a0
movq %rax, %rdi
xorl %eax, %eax
movl %eax, %esi
callq 0x24cb0
movl 0x30(%rsp), %ecx
addl (%rax), %ecx
movl %ecx, (%rax)
movl 0x48(%rsp), %edi
movl 0x4c(%rsp), %edx
movl 0x40(%rsp), %ecx
movl $0x1, %esi
callq 0x3b650
movq 0x38(%rsp), %rdi
movl %eax, 0x34(%rsp)
addq $0x318, %rdi            # imm = 0x318
movl 0x4c(%rsp), %eax
movl %eax, %esi
callq 0x3b6a0
movq %rax, %rdi
movl $0x1, %esi
callq 0x24cb0
movl 0x34(%rsp), %ecx
addl (%rax), %ecx
movl %ecx, (%rax)
movl 0x4c(%rsp), %edi
movl 0x48(%rsp), %esi
movl 0x44(%rsp), %edx
movl 0x40(%rsp), %ecx
callq 0x3b180
movq %rax, %rcx
movq 0x38(%rsp), %rax
xorq 0x18(%rax), %rcx
movq %rcx, 0x18(%rax)
addq $0x58, %rsp
retq