// File: jswaff[P]prophet3/test/eval__test.cpp
// Function: test_king_endgame_pst()
void test_king_endgame_pst() {
    position pos;

    set_pos(&pos,"8/8/8/4k3/8/8/8/RNB2K2 w - - 0 1");

    int32_pair npmat = eval_nonpawn_material(&pos);
    int32 expected = rook_val + knight_val + bishop_val;
    assert(expected==npmat.val1);
    assert(0==npmat.val2);

    expected += rook_open_file + knight_pst[B1]
            + knight_tropism * distance(B1,pos.black_king)
            + king_endgame_pst[F1] - king_pst[E5]
            - eval_scale(king_safety_middle_open_file,rook_val+knight_val+bishop_val);
    assert(expected==eval(&pos,false));

    // by removing a bishop both sides should be evaluated as in the endgame
    set_pos(&pos,"8/8/8/4k3/8/8/8/RN3K2 b - - 0 1");

    expected = -rook_val - knight_val - rook_open_file
            - knight_pst[B1]
            - knight_tropism * distance(B1,pos.black_king)
            - king_endgame_pst[F1]
            + king_endgame_pst[E5];
    assert(expected==eval(&pos,false));
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x1f0, %rsp            # imm = 0x1F0
leaq -0x1c8(%rbp), %rdi
leaq 0x216a5(%rip), %rsi     # 0x3bc2e
callq 0xf3e0
leaq -0x1c8(%rbp), %rdi
callq 0x73f0
movq %rax, -0x1d0(%rbp)
movl $0x460, -0x1d4(%rbp)    # imm = 0x460
movl -0x1d4(%rbp), %eax
cmpl -0x1d0(%rbp), %eax
jne 0x1a5bb
jmp 0x1a5da
leaq 0x2168d(%rip), %rdi     # 0x3bc4f
leaq 0x20a87(%rip), %rsi     # 0x3b050
movl $0xbd, %edx
leaq 0x2168f(%rip), %rcx     # 0x3bc64
callq 0x20c0
xorl %eax, %eax
cmpl -0x1cc(%rbp), %eax
jne 0x1a5e6
jmp 0x1a605
leaq 0x21694(%rip), %rdi     # 0x3bc81
leaq 0x20a5c(%rip), %rsi     # 0x3b050
movl $0xbe, %edx
leaq 0x21664(%rip), %rcx     # 0x3bc64
callq 0x20c0
movl 0x22789(%rip), %eax     # 0x3cd94
addl $0x19, %eax
movl %eax, -0x1e0(%rbp)
movl -0x78(%rbp), %esi
movl $0x39, %edi
callq 0x12350
movl %eax, %ecx
movl -0x1e0(%rbp), %eax
imull $0xfffffffe, %ecx, %ecx # imm = 0xFFFFFFFE
addl %ecx, %eax
addl 0x22e6d(%rip), %eax     # 0x3d4a4
subl 0x229e3(%rip), %eax     # 0x3d020
movl %eax, -0x1dc(%rbp)
movl $0xffffffce, %edi       # imm = 0xFFFFFFCE
movl $0x460, %esi            # imm = 0x460
callq 0x7170
movl %eax, %ecx
movl -0x1dc(%rbp), %eax
subl %ecx, %eax
addl -0x1d4(%rbp), %eax
movl %eax, -0x1d4(%rbp)
movl -0x1d4(%rbp), %eax
movl %eax, -0x1d8(%rbp)
leaq -0x1c8(%rbp), %rdi
xorl %esi, %esi
callq 0x7630
movl %eax, %ecx
movl -0x1d8(%rbp), %eax
cmpl %ecx, %eax
jne 0x1a690
jmp 0x1a6af
leaq 0x215f8(%rip), %rdi     # 0x3bc8f
leaq 0x209b2(%rip), %rsi     # 0x3b050
movl $0xc4, %edx
leaq 0x215ba(%rip), %rcx     # 0x3bc64
callq 0x20c0
leaq -0x1c8(%rbp), %rdi
leaq 0x215ed(%rip), %rsi     # 0x3bcaa
callq 0xf3e0
movl $0xfffffcc7, %eax       # imm = 0xFFFFFCC7
subl 0x226c7(%rip), %eax     # 0x3cd94
movl %eax, -0x1e8(%rbp)
movl -0x78(%rbp), %esi
movl $0x39, %edi
callq 0x12350
movl %eax, %ecx
movl -0x1e8(%rbp), %eax
imull $0xfffffffe, %ecx, %ecx # imm = 0xFFFFFFFE
subl %ecx, %eax
subl 0x22dae(%rip), %eax     # 0x3d4a4
addl 0x22d24(%rip), %eax     # 0x3d420
movl %eax, -0x1d4(%rbp)
movl -0x1d4(%rbp), %eax
movl %eax, -0x1e4(%rbp)
leaq -0x1c8(%rbp), %rdi
xorl %esi, %esi
callq 0x7630
movl %eax, %ecx
movl -0x1e4(%rbp), %eax
cmpl %ecx, %eax
jne 0x1a72a
jmp 0x1a749
leaq 0x2155e(%rip), %rdi     # 0x3bc8f
leaq 0x20918(%rip), %rsi     # 0x3b050
movl $0xce, %edx
leaq 0x21520(%rip), %rcx     # 0x3bc64
callq 0x20c0
addq $0x1f0, %rsp            # imm = 0x1F0
popq %rbp
retq
nopw %cs:(%rax,%rax)