// File: cpirc[P]Monochrome/src/search.cpp
// Function: score_moves(Position const&, SearchStack*, int, unsigned int)
void score_moves(const Position& pos, SearchStack* ss, int size,
                 Move hash_move) {
    assert(ss);

    for (int i = 0; i < size; i++) {
        Move move = ss->ml[i];

        if (move == hash_move) {
            ss->score[i] = 20000;
            continue;
        }

        int mt = move_type(move);
        if (mt == CAPTURE)
            ss->score[i] = 9000 + mvv_lva(pos, move);
        else if (mt == PROM_CAPTURE)
            ss->score[i] = 9000 + mvv_lva(pos, move) +
                           piecevals[OPENING][promotion_type(move)];
        else if (mt == ENPASSANT)
            ss->score[i] = 9000 + piecevals[OPENING][PAWN] - PAWN + 10;
        else if (ss->killers[0] == move)
            ss->score[i] = 7000;
        else if (ss->killers[1] == move)
            ss->score[i] = 6000;
        else
            ss->score[i] = 0;
    }
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x30, %rsp
movq %rdi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
movl %edx, -0x14(%rbp)
movl %ecx, -0x18(%rbp)
cmpq $0x0, -0x10(%rbp)
je 0xb01f
jmp 0xb03e
leaq 0x903b(%rip), %rdi      # 0x14061
leaq 0x9037(%rip), %rsi      # 0x14064
movl $0x30, %edx
leaq 0x903a(%rip), %rcx      # 0x14073
callq 0x3150
movl $0x0, -0x1c(%rbp)
movl -0x1c(%rbp), %eax
cmpl -0x14(%rbp), %eax
jge 0xb1ba
movq -0x10(%rbp), %rax
movslq -0x1c(%rbp), %rcx
movl 0x4(%rax,%rcx,4), %eax
movl %eax, -0x20(%rbp)
movl -0x20(%rbp), %eax
cmpl -0x18(%rbp), %eax
jne 0xb080
movq -0x10(%rbp), %rax
movslq -0x1c(%rbp), %rcx
movl $0x4e20, 0x404(%rax,%rcx,4) # imm = 0x4E20
jmp 0xb1ac
movl -0x20(%rbp), %edi
callq 0x66e0
movl %eax, -0x24(%rbp)
cmpl $0x2000, -0x24(%rbp)    # imm = 0x2000
jne 0xb0bc
movq -0x8(%rbp), %rdi
movl -0x20(%rbp), %esi
callq 0xaf90
movl %eax, %edx
addl $0x2328, %edx           # imm = 0x2328
movq -0x10(%rbp), %rax
movslq -0x1c(%rbp), %rcx
movl %edx, 0x404(%rax,%rcx,4)
jmp 0xb1aa
cmpl $0x6000, -0x24(%rbp)    # imm = 0x6000
jne 0xb107
movq -0x8(%rbp), %rdi
movl -0x20(%rbp), %esi
callq 0xaf90
addl $0x2328, %eax           # imm = 0x2328
movl %eax, -0x28(%rbp)
movl -0x20(%rbp), %edi
callq 0x68f0
movl -0x28(%rbp), %edx
movzbl %al, %eax
movl %eax, %ecx
leaq 0x6f60(%rip), %rax      # 0x12050
addl (%rax,%rcx,4), %edx
movq -0x10(%rbp), %rax
movslq -0x1c(%rbp), %rcx
movl %edx, 0x404(%rax,%rcx,4)
jmp 0xb1a8
cmpl $0x3000, -0x24(%rbp)    # imm = 0x3000
jne 0xb147
leaq 0x6f39(%rip), %rax      # 0x12050
movl (%rax), %edi
addl $0x2328, %edi           # imm = 0x2328
xorl %esi, %esi
callq 0xbc50
movl $0xa, %esi
movzbl %al, %edi
callq 0xbc70
movzbl %al, %edx
movq -0x10(%rbp), %rax
movslq -0x1c(%rbp), %rcx
movl %edx, 0x404(%rax,%rcx,4)
jmp 0xb1a6
movq -0x10(%rbp), %rax
movl 0x804(%rax), %eax
cmpl -0x20(%rbp), %eax
jne 0xb16b
movq -0x10(%rbp), %rax
movslq -0x1c(%rbp), %rcx
movl $0x1b58, 0x404(%rax,%rcx,4) # imm = 0x1B58
jmp 0xb1a4
movq -0x10(%rbp), %rax
movl 0x808(%rax), %eax
cmpl -0x20(%rbp), %eax
jne 0xb18f
movq -0x10(%rbp), %rax
movslq -0x1c(%rbp), %rcx
movl $0x1770, 0x404(%rax,%rcx,4) # imm = 0x1770
jmp 0xb1a2
movq -0x10(%rbp), %rax
movslq -0x1c(%rbp), %rcx
movl $0x0, 0x404(%rax,%rcx,4)
jmp 0xb1a4
jmp 0xb1a6
jmp 0xb1a8
jmp 0xb1aa
jmp 0xb1ac
movl -0x1c(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x1c(%rbp)
jmp 0xb045
addq $0x30, %rsp
popq %rbp
retq