// File: /workspace/github_cpp_makefile_star2_O1/jswaff[P]prophet3/test/search__test.cpp
// Function: test_hash_table()
void test_hash_table() {
    position pos;
    reset_pos(&pos);
    clear_hash_table(&htbl);

    position save_pos;
    memcpy(&save_pos,&pos,sizeof(position));

    search_stats stats; stats.nodes=0; stats.last_pv.n=0;
    start_timer(10000);
    stats.first_line_searched.n=0;
    set_abort_search(false);

    // make a (ridiculous) entry up.  the program would never play 1. a4, UNLESS of course it would be a piece up!
    // make 1. ... a5 a rook up for white, everything else a queen up, and verify PV is 1. a4 a5
    move a2a4 = to_move(PAWN,A2,A4);
    apply_move(&pos,a2a4,gundos);
    position save_pos2;
    memcpy(&save_pos2,&pos,sizeof(position));

    move a7a5 = to_move(PAWN,A7,A5);

    move moves[50];
    move *endp = gen_legal_moves(moves,&pos,true,true);
    assert(is_in_move_list(a7a5,moves,endp));

    for (move *mp=moves;mp<endp;mp++) {
        apply_move(&pos,*mp,gundos);

        int32 score = 900;
        if (*mp == a7a5) {
            score = 500;
        }
        store_hash_entry(&htbl,pos.hash_key,build_hash_val(EXACT_SCORE,1,score,*mp));

        memcpy(&pos,&save_pos2,sizeof(position));
    }
    memcpy(&pos,&save_pos,sizeof(position));

    move_line pv; pv.n=0;
    search(&pos,&pv,-INF,INF,3,&stats,move_stack,gundos,false);
    assert(pv.n==2);
    assert(a2a4==pv.mv[0]);
    assert(a7a5==pv.mv[1]);
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x10a8, %rsp           # imm = 0x10A8
leaq 0x10(%rsp), %r13
movq %r13, %rdi
callq 0xaa43
leaq 0xd3144(%rip), %rdi     # 0xf7ef0
callq 0x6207
leaq 0x3a0(%rsp), %rdi
movl $0x1c8, %edx            # imm = 0x1C8
movq %r13, %rsi
callq 0x2100
movq $0x0, 0xa40(%rsp)
xorl %ebx, %ebx
movl %ebx, 0xa50(%rsp)
movl $0x2710, %edi           # imm = 0x2710
callq 0x24650
movl %ebx, 0xd78(%rsp)
xorl %edi, %edi
callq 0xb2be
movl $0x1, %edi
movl $0x30, %esi
movl $0x20, %edx
callq 0x76b8
movq %rax, %rbx
leaq 0xa3cdf(%rip), %rdx     # 0xc8af0
movq %r13, %rdi
movq %rax, %rsi
callq 0x30e3
leaq 0x1d8(%rsp), %rdi
movl $0x1c8, %edx            # imm = 0x1C8
movq %r13, %rsi
callq 0x2100
movl $0x1, %edi
movl $0x8, %esi
movl $0x18, %edx
callq 0x76b8
movq %rax, %r15
leaq 0x890(%rsp), %r12
movq %r12, %rdi
movq %r13, %rsi
movl $0x1, %edx
movl $0x1, %ecx
callq 0x7840
movq %rax, %r13
movq %r15, %rdi
movq %r12, %rsi
movq %rax, %rdx
callq 0xe727
testb %al, %al
je 0x24f91
movq %rbx, 0x8(%rsp)
cmpq %r13, %r12
jae 0x24efe
leaq 0x10(%rsp), %r14
leaq 0x1d8(%rsp), %rbp
movq (%r12), %rsi
movq %r14, %rdi
leaq 0xa3c4d(%rip), %rdx     # 0xc8af0
callq 0x30e3
movq (%r12), %rcx
cmpq %r15, %rcx
movl $0x384, %edx            # imm = 0x384
movl $0x1f4, %eax            # imm = 0x1F4
cmovel %eax, %edx
movq 0x1c8(%rsp), %rbx
movl $0x3, %edi
movl $0x1, %esi
callq 0x5fa7
leaq 0xd3016(%rip), %rdi     # 0xf7ef0
movq %rbx, %rsi
movq %rax, %rdx
callq 0x62c0
movl $0x1c8, %edx            # imm = 0x1C8
movq %r14, %rdi
movq %rbp, %rsi
callq 0x2100
addq $0x8, %r12
cmpq %r13, %r12
jb 0x24e95
leaq 0x10(%rsp), %rbx
leaq 0x3a0(%rsp), %rsi
movl $0x1c8, %edx            # imm = 0x1C8
movq %rbx, %rdi
callq 0x2100
xorl %eax, %eax
leaq 0x568(%rsp), %r14
movl %eax, (%r14)
subq $0x8, %rsp
leaq 0x890e90(%rip), %r10    # 0x8b5dc0
leaq 0xa30(%rsp), %r9
movq %rbx, %rdi
movq %r14, %rsi
movl $0xfffcf2c0, %edx       # imm = 0xFFFCF2C0
movl $0x30d40, %ecx          # imm = 0x30D40
movl $0x3, %r8d
pushq %rax
pushq 0x1d083(%rip)           # 0x41fd8
pushq %r10
callq 0xb398
addq $0x20, %rsp
cmpl $0x2, (%r14)
jne 0x24fb0
movq 0x8(%rsp), %rax
cmpq 0x570(%rsp), %rax
jne 0x24fcf
cmpq 0x578(%rsp), %r15
jne 0x24fee
addq $0x10a8, %rsp           # imm = 0x10A8
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
leaq 0x11b71(%rip), %rdi     # 0x36b09
leaq 0x11932(%rip), %rsi     # 0x368d1
leaq 0x11b84(%rip), %rcx     # 0x36b2a
movl $0xb0, %edx
callq 0x20d0
leaq 0x11b8a(%rip), %rdi     # 0x36b41
leaq 0x11913(%rip), %rsi     # 0x368d1
leaq 0x11b65(%rip), %rcx     # 0x36b2a
movl $0xc1, %edx
callq 0x20d0
leaq 0x11b73(%rip), %rdi     # 0x36b49
leaq 0x118f4(%rip), %rsi     # 0x368d1
leaq 0x11b46(%rip), %rcx     # 0x36b2a
movl $0xc2, %edx
callq 0x20d0
leaq 0x11b63(%rip), %rdi     # 0x36b58
leaq 0x118d5(%rip), %rsi     # 0x368d1
leaq 0x11b27(%rip), %rcx     # 0x36b2a
movl $0xc3, %edx
callq 0x20d0