// File: /workspace/github_cpp_makefile_star2_O3/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 0xaa51
leaq 0xd32f0(%rip), %rdi     # 0xf7ef0
callq 0x62b6
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 0x244a4
movl %ebx, 0xd78(%rsp)
xorl %edi, %edi
callq 0xb2ba
movl $0x1, %edi
movl $0x30, %esi
movl $0x20, %edx
callq 0x775c
movq %rax, %rbx
leaq 0xa3e8b(%rip), %rdx     # 0xc8af0
movq %r13, %rdi
movq %rax, %rsi
callq 0x30e1
leaq 0x1d8(%rsp), %rdi
movl $0x1c8, %edx            # imm = 0x1C8
movq %r13, %rsi
callq 0x2100
movl $0x1, %edi
movl $0x8, %esi
movl $0x18, %edx
callq 0x775c
movq %rax, %r15
leaq 0x890(%rsp), %r12
movq %r12, %rdi
movq %r13, %rsi
movl $0x1, %edx
movl $0x1, %ecx
callq 0x78e0
movq %rax, %r13
movq %r15, %rdi
movq %r12, %rsi
movq %rax, %rdx
callq 0xe682
testb %al, %al
je 0x24de5
movq %rbx, 0x8(%rsp)
cmpq %r13, %r12
jae 0x24d52
leaq 0x10(%rsp), %r14
leaq 0x1d8(%rsp), %rbp
movq (%r12), %rsi
movq %r14, %rdi
leaq 0xa3df9(%rip), %rdx     # 0xc8af0
callq 0x30e1
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 0x604f
leaq 0xd31c2(%rip), %rdi     # 0xf7ef0
movq %rbx, %rsi
movq %rax, %rdx
callq 0x636f
movl $0x1c8, %edx            # imm = 0x1C8
movq %r14, %rdi
movq %rbp, %rsi
callq 0x2100
addq $0x8, %r12
cmpq %r13, %r12
jb 0x24ce9
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 0x89103c(%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 0x1d22f(%rip)           # 0x41fd8
pushq %r10
callq 0xb394
addq $0x20, %rsp
cmpl $0x2, (%r14)
jne 0x24e04
movq 0x8(%rsp), %rax
cmpq 0x570(%rsp), %rax
jne 0x24e23
cmpq 0x578(%rsp), %r15
jne 0x24e42
addq $0x10a8, %rsp           # imm = 0x10A8
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
leaq 0x11d9d(%rip), %rdi     # 0x36b89
leaq 0x11b5e(%rip), %rsi     # 0x36951
leaq 0x11db0(%rip), %rcx     # 0x36baa
movl $0xb0, %edx
callq 0x20d0
leaq 0x11db6(%rip), %rdi     # 0x36bc1
leaq 0x11b3f(%rip), %rsi     # 0x36951
leaq 0x11d91(%rip), %rcx     # 0x36baa
movl $0xc1, %edx
callq 0x20d0
leaq 0x11d9f(%rip), %rdi     # 0x36bc9
leaq 0x11b20(%rip), %rsi     # 0x36951
leaq 0x11d72(%rip), %rcx     # 0x36baa
movl $0xc2, %edx
callq 0x20d0
leaq 0x11d8f(%rip), %rdi     # 0x36bd8
leaq 0x11b01(%rip), %rsi     # 0x36951
leaq 0x11d53(%rip), %rcx     # 0x36baa
movl $0xc3, %edx
callq 0x20d0