// File: SethKasmann[P]clever-girl/src/move_generator.cpp
// Function: MoveList::MoveList(State const&, unsigned short, History*, int, bool)
MoveList::MoveList(const State& pState, Move pBest, History* pHistory, int pPly, bool pQSearch)
: mState(pState), mValid(Full), mBest(pBest), mQSearch(pQSearch), mKiller1(nullMove), mKiller2(nullMove)
, mSize(0), mHistory(pHistory), mPly(pPly)
{
    if (pHistory)
    {
        mKiller1 = mHistory->getKiller(pPly).first;
        mKiller2 = mHistory->getKiller(pPly).second;
    }

    if (mState.inCheck())
    {
        Square k = mState.getKingSquare(mState.getOurColor());
        Square c = get_lsb(mState.getCheckersBB());
        mValid = between[k][c] | mState.getCheckersBB();
        mStage = nEvadeBestMove;
    }
    else
        mStage = mQSearch ? qBestMove : nBestMove;
}

// Assembly:
subq $0x98, %rsp
movb %r9b, %al
movq %rdi, 0x90(%rsp)
movq %rsi, 0x88(%rsp)
movw %dx, 0x86(%rsp)
movq %rcx, 0x78(%rsp)
movl %r8d, 0x74(%rsp)
andb $0x1, %al
movb %al, 0x73(%rsp)
movq 0x90(%rsp), %rdi
movq %rdi, 0x50(%rsp)
movb 0x73(%rsp), %al
andb $0x1, %al
movb %al, (%rdi)
movq $-0x1, 0x8(%rdi)
movq 0x88(%rsp), %rax
movq %rax, 0x18(%rdi)
movq 0x78(%rsp), %rax
movq %rax, 0x20(%rdi)
movl 0x74(%rsp), %eax
movl %eax, 0x28(%rdi)
addq $0x830, %rdi            # imm = 0x830
movq %rdi, 0x48(%rsp)
callq 0x28640
movq 0x50(%rsp), %rax
movq $0x0, 0x848(%rax)
movw 0x86(%rsp), %cx
movw %cx, 0x850(%rax)
movw $0x0, 0x852(%rax)
movw $0x0, 0x854(%rax)
cmpq $0x0, 0x78(%rsp)
je 0x26cca
movq 0x50(%rsp), %rax
movq 0x20(%rax), %rdi
movl 0x74(%rsp), %esi
callq 0x28650
movq %rax, 0x40(%rsp)
jmp 0x26c6e
movq 0x50(%rsp), %rax
movq 0x40(%rsp), %rcx
movw (%rcx), %cx
movw %cx, 0x852(%rax)
movq 0x20(%rax), %rdi
movl 0x74(%rsp), %esi
callq 0x28650
movq %rax, 0x38(%rsp)
jmp 0x26c96
movq 0x50(%rsp), %rax
movq 0x38(%rsp), %rcx
movw 0x2(%rcx), %cx
movw %cx, 0x854(%rax)
jmp 0x26cca
movq 0x48(%rsp), %rdi
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x68(%rsp)
movl %eax, 0x64(%rsp)
callq 0x26610
jmp 0x26dc1
movq 0x50(%rsp), %rax
movq 0x18(%rax), %rdi
callq 0x28680
movb %al, 0x37(%rsp)
jmp 0x26cde
movb 0x37(%rsp), %al
testb $0x1, %al
jne 0x26ceb
jmp 0x26da0
movq 0x50(%rsp), %rax
movq 0x18(%rax), %rdi
movq %rdi, 0x28(%rsp)
callq 0x24ca0
movl %eax, 0x30(%rsp)
jmp 0x26d04
movl 0x30(%rsp), %esi
movq 0x28(%rsp), %rdi
callq 0x24ea0
movl %eax, 0x24(%rsp)
jmp 0x26d18
movq 0x50(%rsp), %rax
movl 0x24(%rsp), %ecx
movl %ecx, 0x60(%rsp)
movq 0x18(%rax), %rdi
callq 0x286a0
movq %rax, 0x18(%rsp)
jmp 0x26d35
movq 0x18(%rsp), %rdi
callq 0x25a20
movl %eax, 0x14(%rsp)
jmp 0x26d45
movq 0x50(%rsp), %rax
movl 0x14(%rsp), %ecx
movl %ecx, 0x5c(%rsp)
movl 0x60(%rsp), %ecx
movl %ecx, %edx
shlq $0x9, %rdx
leaq 0x13efad(%rip), %rcx    # 0x165d10
addq %rdx, %rcx
movl 0x5c(%rsp), %edx
movq (%rcx,%rdx,8), %rcx
movq %rcx, (%rsp)
movq 0x18(%rax), %rdi
callq 0x286a0
movq %rax, 0x8(%rsp)
jmp 0x26d82
movq 0x50(%rsp), %rax
movq 0x8(%rsp), %rdx
movq (%rsp), %rcx
orq %rdx, %rcx
movq %rcx, 0x8(%rax)
movl $0xc, 0x2c(%rax)
jmp 0x26db9
movq 0x50(%rsp), %rax
movb (%rax), %sil
xorl %ecx, %ecx
movl $0x7, %edx
testb $0x1, %sil
cmovnel %edx, %ecx
movl %ecx, 0x2c(%rax)
addq $0x98, %rsp
retq
movq 0x68(%rsp), %rdi
callq 0x54b0
nopl (%rax,%rax)