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

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

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

// Assembly:
subq $0x58, %rsp
movq %rdi, 0x50(%rsp)
movl %esi, 0x4c(%rsp)
movl %edx, 0x48(%rsp)
movl %ecx, 0x44(%rsp)
movq 0x50(%rsp), %rdi
movq %rdi, 0x38(%rsp)
movl 0x44(%rsp), %eax
movl %eax, %ecx
leaq 0x11b294(%rip), %rax    # 0x154b10
movq (%rax,%rcx,8), %rax
movq %rax, 0x8(%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 0x8(%rsp), %rcx
movq 0x38(%rsp), %rdi
orq (%rax), %rcx
movq %rcx, (%rax)
movl 0x44(%rsp), %eax
movl %eax, %ecx
leaq 0x11b24e(%rip), %rax    # 0x154b10
movq (%rax,%rcx,8), %rax
movq %rax, 0x10(%rsp)
addq $0x78, %rdi
movl 0x4c(%rsp), %eax
movl %eax, %esi
callq 0x24c70
movq 0x10(%rsp), %rcx
movq 0x38(%rsp), %rdi
orq (%rax), %rcx
movq %rcx, (%rax)
movl 0x48(%rsp), %eax
movl %eax, 0x18(%rsp)
addq $0x188, %rdi            # imm = 0x188
movl 0x44(%rsp), %eax
movl %eax, %esi
callq 0x3b530
movl 0x18(%rsp), %ecx
movq 0x38(%rsp), %rdi
movl %ecx, (%rax)
addq $0x2e8, %rdi            # imm = 0x2E8
movl 0x4c(%rsp), %eax
movl %eax, %esi
callq 0x3b560
movq %rax, %rdi
movl 0x48(%rsp), %eax
movl %eax, %esi
callq 0x3b590
movq 0x38(%rsp), %rdi
movl (%rax), %ecx
movl %ecx, 0x1c(%rsp)
addl $0x1, %ecx
movl %ecx, (%rax)
addq $0x88, %rdi
movl 0x44(%rsp), %eax
movl %eax, %esi
callq 0x35f20
movl 0x1c(%rsp), %ecx
movq 0x38(%rsp), %rdi
movl %ecx, (%rax)
movl 0x44(%rsp), %eax
movl %eax, 0x2c(%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, 0x20(%rsp)
addq $0x88, %rdi
movl 0x44(%rsp), %eax
movl %eax, %esi
callq 0x35f20
movq 0x20(%rsp), %rdi
movslq (%rax), %rsi
callq 0x3b620
movl 0x2c(%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, 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 0x44(%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
callq 0x39a70
movq %rax, %rcx
movq 0x38(%rsp), %rax
xorq 0x18(%rax), %rcx
movq %rcx, 0x18(%rax)
addq $0x58, %rsp
retq
nopw %cs:(%rax,%rax)
nopl (%rax,%rax)