// File: /workspace/github_cpp_makefile_star2_O2/SethKasmann[P]clever-girl/src/state.cpp
// Function: State::make_t(unsigned short)
void State::make_t(Move pMove)
{
    assert(pMove != nullMove);
    assert(getSrc(pMove) < no_sq);
    assert(getDst(pMove) < no_sq);
    Square src, dst;
    PieceType moved, captured;
    bool epFlag = false;
    bool gamePhase = false;


    src = getSrc(pMove);
    dst = getDst(pMove);
    moved = onSquare(src);
    assert(moved != none);
    captured = onSquare(dst);
    assert(captured != king);

    // Update the Fifty Move Rule
    mFiftyMoveRule++;

    // Remove the ep file and castle rights from the zobrist key.
    if (mEnPassant)
        mKey ^= Zobrist::key(get_file(mEnPassant));

    mKey ^= Zobrist::key(mCastleRights);

    if (captured != none && !isCastle(pMove))
    {
        mFiftyMoveRule = 0;
        removePiece(mThem, captured, dst);
        if (captured == pawn)
            mPawnKey ^= Zobrist::key(mThem, pawn, dst);
        gamePhase = true;
    }

    if (isCastle(pMove))
    {
        // Kingside Castle
        if (dst < src)
        {
            movePiece(mUs, rook, src-3, dst+1);
            movePiece(mUs, king, src, dst);
        }
        // Queenside Castle
        else
        {
            movePiece(mUs, rook, src+4, dst-1);
            movePiece(mUs, king, src, dst);
        }
    }
    else
        movePiece(mUs, moved, src, dst);

    if (moved == pawn)
    {
        mFiftyMoveRule = 0;
        mPawnKey ^= Zobrist::key(mUs, pawn, src, dst);

        // Check for double pawn push.
        if (int(std::max(src, dst)) - int(std::min(src, dst)) == 16)
        {
            mEnPassant = mUs == white ? square_bb[dst - 8]
                                      : square_bb[dst + 8];

            mKey ^= Zobrist::key(get_file(mEnPassant));
            epFlag = true;
        }
        else if (getPiecePromo(pMove))
        {
            mPawnKey ^= Zobrist::key(mUs, pawn, dst);
            removePiece(mUs, pawn, dst);
            addPiece(mUs, getPiecePromo(pMove), dst);
            gamePhase = true;
        }
        else if (mEnPassant & square_bb[dst])
        {
            Square epCapture = (mUs == white) ? dst - 8 : dst + 8;
            mPawnKey ^= Zobrist::key(mThem, pawn, epCapture);
            removePiece(mThem, pawn, epCapture);
            gamePhase = true;
        }
    }

    if (!epFlag)
        mEnPassant = 0;

    if (gamePhase)
        setGamePhase();

    // Update castle rights.
    mCastleRights &= Castle_rights[src];
    mCastleRights &= Castle_rights[dst];

    mKey ^= Zobrist::key(mCastleRights);

    assert(!check());
    assert((mEnPassant & getOccupancyBB()) == 0);
    swapTurn();

    setPins(white);
    setPins(black);
    setCheckers();
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
pushq %rax
movl %esi, %ebp
movq %rdi, %rbx
movl %esi, %r15d
andl $0x3f, %r15d
movl %esi, %r14d
shrl $0x6, %r14d
andl $0x3f, %r14d
movl 0x188(%rdi,%r15,4), %r13d
movl 0x188(%rdi,%r14,4), %r12d
incl 0x8(%rdi)
movq 0x30(%rdi), %rax
testq %rax, %rax
je 0x136ee
bsfq %rax, %rcx
andl $0x7, %ecx
leaq 0x241780(%rip), %rdx    # 0x254e60
movq 0x18(%rbx), %rax
xorq (%rdx,%rcx,8), %rax
movq %rax, 0x18(%rbx)
jmp 0x136f2
movq 0x18(%rbx), %rax
movslq 0xc(%rbx), %rcx
leaq 0x2417a3(%rip), %rdx    # 0x254ea0
xorq (%rdx,%rcx,8), %rax
movq %rax, 0x18(%rbx)
cmpl $0x6, %r12d
setne %al
movl %eax, 0x4(%rsp)
je 0x1374f
testw %bp, %bp
js 0x13757
andl $0x0, 0x8(%rbx)
movl 0x4(%rbx), %esi
movq %rbx, %rdi
movl %r12d, %edx
movl %r14d, %ecx
callq 0x1445a
testl %r12d, %r12d
jne 0x1374a
movl 0x4(%rbx), %eax
imulq $0xc00, %rax, %rax      # imm = 0xC00
addq 0xf84e(%rip), %rax      # 0x22f90
movq (%rax,%r14,8), %rax
xorq %rax, 0x20(%rbx)
movl %r13d, %edx
jmp 0x13787
movl %r13d, %edx
testw %bp, %bp
jns 0x13787
movl (%rbx), %esi
cmpw %r15w, %r14w
jae 0x13769
leal -0x3(%r15), %ecx
leal 0x1(%r14), %r8d
jmp 0x13771
leal 0x4(%r15), %ecx
leal -0x1(%r14), %r8d
pushq $0x3
popq %rdx
movq %rbx, %rdi
callq 0x14540
pushq $0x5
popq %rdx
movl $0x0, 0x4(%rsp)
movl (%rbx), %esi
movq %rbx, %rdi
movl %r15d, %ecx
movl %r14d, %r8d
callq 0x14540
testl %r13d, %r13d
je 0x137a3
andq $0x0, 0x30(%rbx)
jmp 0x13814
andl $0x0, 0x8(%rbx)
movl (%rbx), %esi
imulq $0xc00, %rsi, %rcx      # imm = 0xC00
addq 0xf7d9(%rip), %rcx      # 0x22f90
movq (%rcx,%r14,8), %rax
xorq (%rcx,%r15,8), %rax
xorq 0x20(%rbx), %rax
movq %rax, 0x20(%rbx)
movl %r14d, %edx
movl %r15d, %edi
subq %rdx, %rdi
movq %rdi, %rdx
negq %rdx
cmovsq %rdi, %rdx
cmpl $0x10, %edx
jne 0x13824
xorl %eax, %eax
testl %esi, %esi
setne %al
shll $0x4, %eax
addl %r14d, %eax
addl $-0x8, %eax
leaq 0x11328a(%rip), %rcx    # 0x126a80
movq (%rcx,%rax,8), %rax
movq %rax, 0x30(%rbx)
bsfq %rax, %rax
andl $0x7, %eax
leaq 0x241654(%rip), %rcx    # 0x254e60
movq (%rcx,%rax,8), %rax
xorq %rax, 0x18(%rbx)
cmpb $0x0, 0x4(%rsp)
jne 0x138a9
jmp 0x138b1
movzwl %bp, %edx
shrl $0xc, %edx
andw $0x7, %dx
je 0x1385c
leaq (%rcx,%r14,8), %rcx
movzwl %dx, %ebp
xorq (%rcx), %rax
movq %rax, 0x20(%rbx)
movq %rbx, %rdi
xorl %edx, %edx
movl %r14d, %ecx
callq 0x1445a
movl (%rbx), %esi
movq %rbx, %rdi
movl %ebp, %edx
movl %r14d, %ecx
callq 0x13d8a
jmp 0x138a4
leaq 0x11321d(%rip), %rcx    # 0x126a80
movq (%rcx,%r14,8), %rcx
testq %rcx, 0x30(%rbx)
je 0x1379c
xorl %ecx, %ecx
testl %esi, %esi
setne %cl
shll $0x4, %ecx
movl 0x4(%rbx), %esi
imulq $0xc00, %rsi, %rdx      # imm = 0xC00
addq 0xf704(%rip), %rdx      # 0x22f90
addl %r14d, %ecx
addl $-0x8, %ecx
xorq (%rdx,%rcx,8), %rax
movq %rax, 0x20(%rbx)
movq %rbx, %rdi
xorl %edx, %edx
callq 0x1445a
andq $0x0, 0x30(%rbx)
movq %rbx, %rdi
callq 0x13ed2
leaq 0x5ac8(%rip), %rax      # 0x19380
movl 0xc(%rbx), %ecx
andl (%rax,%r15,4), %ecx
movslq %ecx, %rcx
movslq (%rax,%r14,4), %rax
andq %rcx, %rax
movl %eax, 0xc(%rbx)
leaq 0x2415cd(%rip), %rcx    # 0x254ea0
movq (%rcx,%rax,8), %rax
xorq %rax, 0x18(%rbx)
movq %rbx, %rdi
callq 0x14626
movq %rbx, %rdi
xorl %esi, %esi
callq 0x12db2
pushq $0x1
popq %rsi
movq %rbx, %rdi
callq 0x12db2
movq %rbx, %rdi
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
jmp 0x13e48