// File: /workspace/github_cpp_makefile_star2_O2/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), %r15
movq %r15, %rdi
callq 0xa187
leaq 0xd83ce(%rip), %rdi     # 0xfaef0
callq 0x5dd9
leaq 0x3a0(%rsp), %rdi
movl $0x1c8, %edx            # imm = 0x1C8
movq %r15, %rsi
callq 0x20f0
andq $0x0, 0xa40(%rsp)
andl $0x0, 0xa50(%rsp)
movl $0x2710, %edi           # imm = 0x2710
callq 0x22420
andl $0x0, 0xd78(%rsp)
xorl %edi, %edi
callq 0xa94e
pushq $0x1
popq %rbx
pushq $0x30
popq %rsi
pushq $0x20
popq %rdx
movl %ebx, %edi
callq 0x7284
leaq 0xa8f73(%rip), %rdx     # 0xcbaf0
movq %r15, %rdi
movq %rax, 0x8(%rsp)
movq %rax, %rsi
callq 0x2fa5
leaq 0x1d8(%rsp), %rdi
movl $0x1c8, %edx            # imm = 0x1C8
movq %r15, %rsi
callq 0x20f0
pushq $0x8
popq %rsi
pushq $0x18
popq %rdx
movl %ebx, %edi
callq 0x7284
movq %rax, %r14
leaq 0x890(%rsp), %r12
movq %r12, %rdi
movq %r15, %rsi
movl %ebx, %edx
movl %ebx, %ecx
callq 0x73f8
movq %rax, %r13
movq %r14, %rdi
movq %r12, %rsi
movq %rax, %rdx
callq 0xdacb
testb %al, %al
je 0x22ce6
leaq 0x10(%rsp), %rbp
leaq 0x1d8(%rsp), %r15
cmpq %r13, %r12
jae 0x22c56
movq (%r12), %rsi
movq %rbp, %rdi
leaq 0xa8eee(%rip), %rdx     # 0xcbaf0
callq 0x2fa5
movq (%r12), %rcx
cmpq %r14, %rcx
movl $0x384, %edx            # imm = 0x384
movl $0x1f4, %eax            # imm = 0x1F4
cmovel %eax, %edx
movq 0x1c8(%rsp), %rbx
pushq $0x3
popq %rdi
pushq $0x1
popq %rsi
callq 0x5b8a
leaq 0xd82bb(%rip), %rdi     # 0xfaef0
movq %rbx, %rsi
movq %rax, %rdx
callq 0x5e8b
movl $0x1c8, %edx            # imm = 0x1C8
movq %rbp, %rdi
movq %r15, %rsi
callq 0x20f0
addq $0x8, %r12
jmp 0x22bef
leaq 0x10(%rsp), %rbx
leaq 0x3a0(%rsp), %rsi
movl $0x1c8, %edx            # imm = 0x1C8
movq %rbx, %rdi
callq 0x20f0
leaq 0x568(%rsp), %r15
andl $0x0, (%r15)
subq $0x8, %rsp
leaq 0x896139(%rip), %rax    # 0x8b8dc0
pushq $0x3
popq %r8
leaq 0xa30(%rsp), %r9
movq %rbx, %rdi
movq %r15, %rsi
movl $0xfffcf2c0, %edx       # imm = 0xFFFCF2C0
movl $0x30d40, %ecx          # imm = 0x30D40
pushq $0x0
pushq 0x2232d(%rip)           # 0x44fd8
pushq %rax
callq 0xaa1d
addq $0x20, %rsp
cmpl $0x2, (%r15)
jne 0x22d05
movq 0x8(%rsp), %rax
cmpq 0x570(%rsp), %rax
jne 0x22d24
cmpq 0x578(%rsp), %r14
jne 0x22d43
addq $0x10a8, %rsp           # imm = 0x10A8
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
leaq 0x11f60(%rip), %rdi     # 0x34c4d
leaq 0x11d21(%rip), %rsi     # 0x34a15
leaq 0x11f73(%rip), %rcx     # 0x34c6e
movl $0xb0, %edx
callq 0x20c0
leaq 0x11f79(%rip), %rdi     # 0x34c85
leaq 0x11d02(%rip), %rsi     # 0x34a15
leaq 0x11f54(%rip), %rcx     # 0x34c6e
movl $0xc1, %edx
callq 0x20c0
leaq 0x11f62(%rip), %rdi     # 0x34c8d
leaq 0x11ce3(%rip), %rsi     # 0x34a15
leaq 0x11f35(%rip), %rcx     # 0x34c6e
movl $0xc2, %edx
callq 0x20c0
leaq 0x11f52(%rip), %rdi     # 0x34c9c
leaq 0x11cc4(%rip), %rsi     # 0x34a15
leaq 0x11f16(%rip), %rcx     # 0x34c6e
movl $0xc3, %edx
callq 0x20c0