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

    // no pawns advanced
    set_pos(&pos,"rnbq1rk1/pppppppp/8/8/8/8/PPPPPPPP/RNBQ1RK1 w kq - 0 1");
    assert(eval(&pos,false)==0);

    // white pawn on f4
    set_pos(&pos,"rnbq1rk1/pppppppp/8/8/8/5P2/PPPPP1PP/RNBQ1RK1 w kq - 0 1");
    assert(eval(&pos,false)==pawn_pst[F3]-pawn_pst[F2]
        + eval_scale(king_safety_pawn_one_away,rook_val*2+knight_val+bishop_val+queen_val));

    // white pawn on g4
    set_pos(&pos,"rnbq1rk1/pppppppp/8/8/6P1/8/PPPPPP1P/RNBQ1RK1 w kq - 0 1");
    assert(eval(&pos,false)==pawn_pst[G4]-pawn_pst[G2]+eval_scale(king_safety_pawn_two_away,rook_val*2+knight_val+bishop_val+queen_val));

    // black pawn on h4
    set_pos(&pos,"rnbq1rk1/ppppppp1/8/8/7p/8/PPPPPPPP/RNBQ1RK1 b KQkq - 0 1");
    assert(eval(&pos,false)==pawn_pst[fliprank[H4]]-pawn_pst[fliprank[H7]]
         +eval_scale(king_safety_pawn_far_away/2,rook_val*2+knight_val+bishop_val+queen_val));
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x1e0, %rsp            # imm = 0x1E0
leaq -0x1c8(%rbp), %rdi
leaq 0x21567(%rip), %rsi     # 0x3be30
callq 0xf3e0
leaq -0x1c8(%rbp), %rdi
xorl %esi, %esi
callq 0x7630
cmpl $0x0, %eax
jne 0x1a8e3
jmp 0x1a902
leaq 0x2157d(%rip), %rdi     # 0x3be67
leaq 0x2075f(%rip), %rsi     # 0x3b050
movl $0xea, %edx
leaq 0x2157e(%rip), %rcx     # 0x3be7b
callq 0x20c0
leaq -0x1c8(%rbp), %rdi
leaq 0x2158c(%rip), %rsi     # 0x3be9c
callq 0xf3e0
leaq -0x1c8(%rbp), %rdi
xorl %esi, %esi
callq 0x7630
movl %eax, -0x1cc(%rbp)
movl 0x22835(%rip), %eax     # 0x3d164
subl 0x2284f(%rip), %eax     # 0x3d184
movl %eax, -0x1d0(%rbp)
movl $0xfffffff6, %edi       # imm = 0xFFFFFFF6
movl $0x9d8, %esi            # imm = 0x9D8
callq 0x7170
movl -0x1d0(%rbp), %ecx
movl %eax, %edx
movl -0x1cc(%rbp), %eax
addl %edx, %ecx
cmpl %ecx, %eax
jne 0x1a960
jmp 0x1a97f
leaq 0x2156e(%rip), %rdi     # 0x3bed5
leaq 0x206e2(%rip), %rsi     # 0x3b050
movl $0xef, %edx
leaq 0x21501(%rip), %rcx     # 0x3be7b
callq 0x20c0
leaq -0x1c8(%rbp), %rdi
leaq 0x215c7(%rip), %rsi     # 0x3bf54
callq 0xf3e0
leaq -0x1c8(%rbp), %rdi
xorl %esi, %esi
callq 0x7630
movl %eax, -0x1d4(%rbp)
movl 0x2279c(%rip), %eax     # 0x3d148
subl 0x227d6(%rip), %eax     # 0x3d188
movl %eax, -0x1d8(%rbp)
movl $0xffffffec, %edi       # imm = 0xFFFFFFEC
movl $0x9d8, %esi            # imm = 0x9D8
callq 0x7170
movl -0x1d8(%rbp), %ecx
movl %eax, %edx
movl -0x1d4(%rbp), %eax
addl %edx, %ecx
cmpl %ecx, %eax
jne 0x1a9dd
jmp 0x1a9fc
leaq 0x215a9(%rip), %rdi     # 0x3bf8d
leaq 0x20665(%rip), %rsi     # 0x3b050
movl $0xf3, %edx
leaq 0x21484(%rip), %rcx     # 0x3be7b
callq 0x20c0
leaq -0x1c8(%rbp), %rdi
leaq 0x21600(%rip), %rsi     # 0x3c00a
callq 0xf3e0
leaq -0x1c8(%rbp), %rdi
xorl %esi, %esi
callq 0x7630
movl %eax, -0x1dc(%rbp)
movslq 0x22422(%rip), %rcx     # 0x3ce4c
leaq 0x2267f(%rip), %rax     # 0x3d0b0
movl (%rax,%rcx,4), %eax
movslq 0x223b1(%rip), %rdx     # 0x3cdec
leaq 0x2266e(%rip), %rcx     # 0x3d0b0
subl (%rcx,%rdx,4), %eax
movl %eax, -0x1e0(%rbp)
movl $0xfffffff1, %edi       # imm = 0xFFFFFFF1
movl $0x9d8, %esi            # imm = 0x9D8
callq 0x7170
movl -0x1e0(%rbp), %ecx
movl %eax, %edx
movl -0x1dc(%rbp), %eax
addl %edx, %ecx
cmpl %ecx, %eax
jne 0x1aa70
jmp 0x1aa8f
leaq 0x215cd(%rip), %rdi     # 0x3c044
leaq 0x205d2(%rip), %rsi     # 0x3b050
movl $0xf8, %edx
leaq 0x213f1(%rip), %rcx     # 0x3be7b
callq 0x20c0
addq $0x1e0, %rsp            # imm = 0x1E0
popq %rbp
retq
nopl (%rax,%rax)