// File: jswaff[P]prophet3/test/hash__test.cpp
// Function: test_store_and_probe()
void test_store_and_probe() {
    clear_hash_table(&htbl);
    position pos;
    reset_pos(&pos);

    uint64 key = build_hash_key(&pos);

    // shouldn't be anything
    uint64 val = get_hash_entry(&htbl,key);
    assert(val==0);

    move mv = to_move(PAWN,E2,E4);
    store_hash_entry(&htbl,key,build_hash_val(LOWER_BOUND,3,100,mv));
    val = get_hash_entry(&htbl,key);
    assert(val > 0);
    assert(get_hash_entry_type(val)==LOWER_BOUND);
    assert(get_hash_entry_depth(val)==3);
    assert(get_hash_entry_score(val)==100);
    assert(get_hash_entry_move(val)==mv);

    // now make move and reprobe
    apply_move(&pos,mv,gundos);
    uint64 key2 = build_hash_key(&pos);
    uint64 val2 = get_hash_entry(&htbl,key2);
    assert(val2==0);

    // finally undo and reprobe
    undo_last_move(&pos,gundos);
    key2 = build_hash_key(&pos);
    assert(key==key2);
    val2 = get_hash_entry(&htbl,key2);
    assert(val==val2);
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x200, %rsp            # imm = 0x200
leaq 0xe322e(%rip), %rdi     # 0x1030b0
callq 0x88c0
leaq -0x1c8(%rbp), %rdi
callq 0xf390
leaq -0x1c8(%rbp), %rdi
callq 0x81f0
movq %rax, -0x1d0(%rbp)
movq -0x1d0(%rbp), %rsi
leaq 0xe31fc(%rip), %rdi     # 0x1030b0
callq 0x8980
movq %rax, -0x1d8(%rbp)
cmpq $0x0, -0x1d8(%rbp)
jne 0x1fecc
jmp 0x1feeb
leaq 0x1e769(%rip), %rdi     # 0x3e63c
leaq 0x1e421(%rip), %rsi     # 0x3e2fb
movl $0x15b, %edx            # imm = 0x15B
leaq 0x1e75d(%rip), %rcx     # 0x3e643
callq 0x20c0
movl $0x1, %edi
movl $0x34, %esi
movl $0x24, %edx
callq 0xa830
movq %rax, -0x1e0(%rbp)
movq -0x1d0(%rbp), %rax
movq %rax, -0x1f8(%rbp)
movq -0x1e0(%rbp), %rcx
movl $0x1, %edi
movl $0x3, %esi
movl $0x64, %edx
callq 0x8470
movq -0x1f8(%rbp), %rsi
movq %rax, %rdx
leaq 0xe3170(%rip), %rdi     # 0x1030b0
callq 0x8a50
movq -0x1d0(%rbp), %rsi
leaq 0xe315d(%rip), %rdi     # 0x1030b0
callq 0x8980
movq %rax, -0x1d8(%rbp)
cmpq $0x0, -0x1d8(%rbp)
jbe 0x1ff6b
jmp 0x1ff8a
leaq 0x1536e(%rip), %rdi     # 0x352e0
leaq 0x1e382(%rip), %rsi     # 0x3e2fb
movl $0x160, %edx            # imm = 0x160
leaq 0x1e6be(%rip), %rcx     # 0x3e643
callq 0x20c0
movq -0x1d8(%rbp), %rdi
callq 0x8710
cmpl $0x1, %eax
jne 0x1ff9d
jmp 0x1ffbc
leaq 0x1e4d9(%rip), %rdi     # 0x3e47d
leaq 0x1e350(%rip), %rsi     # 0x3e2fb
movl $0x161, %edx            # imm = 0x161
leaq 0x1e68c(%rip), %rcx     # 0x3e643
callq 0x20c0
movq -0x1d8(%rbp), %rdi
callq 0x8730
cmpl $0x3, %eax
jne 0x1ffcf
jmp 0x1ffee
leaq 0x1e689(%rip), %rdi     # 0x3e65f
leaq 0x1e31e(%rip), %rsi     # 0x3e2fb
movl $0x162, %edx            # imm = 0x162
leaq 0x1e65a(%rip), %rcx     # 0x3e643
callq 0x20c0
movq -0x1d8(%rbp), %rdi
callq 0x8750
cmpl $0x64, %eax
jne 0x20001
jmp 0x20020
leaq 0x1e674(%rip), %rdi     # 0x3e67c
leaq 0x1e2ec(%rip), %rsi     # 0x3e2fb
movl $0x163, %edx            # imm = 0x163
leaq 0x1e628(%rip), %rcx     # 0x3e643
callq 0x20c0
movq -0x1d8(%rbp), %rdi
callq 0x87d0
cmpq -0x1e0(%rbp), %rax
jne 0x20037
jmp 0x20056
leaq 0x1e4c8(%rip), %rdi     # 0x3e506
leaq 0x1e2b6(%rip), %rsi     # 0x3e2fb
movl $0x164, %edx            # imm = 0x164
leaq 0x1e5f2(%rip), %rcx     # 0x3e643
callq 0x20c0
movq -0x1e0(%rbp), %rsi
leaq -0x1c8(%rbp), %rdi
leaq 0xb3c45(%rip), %rdx     # 0xd3cb0
callq 0x3620
leaq -0x1c8(%rbp), %rdi
callq 0x81f0
movq %rax, -0x1e8(%rbp)
movq -0x1e8(%rbp), %rsi
leaq 0xe301f(%rip), %rdi     # 0x1030b0
callq 0x8980
movq %rax, -0x1f0(%rbp)
cmpq $0x0, -0x1f0(%rbp)
jne 0x200a9
jmp 0x200c8
leaq 0x1e5eb(%rip), %rdi     # 0x3e69b
leaq 0x1e244(%rip), %rsi     # 0x3e2fb
movl $0x16a, %edx            # imm = 0x16A
leaq 0x1e580(%rip), %rcx     # 0x3e643
callq 0x20c0
leaq -0x1c8(%rbp), %rdi
leaq 0xb3bda(%rip), %rsi     # 0xd3cb0
callq 0x39a0
leaq -0x1c8(%rbp), %rdi
callq 0x81f0
movq %rax, -0x1e8(%rbp)
movq -0x1d0(%rbp), %rax
cmpq -0x1e8(%rbp), %rax
jne 0x20100
jmp 0x2011f
leaq 0x1e59c(%rip), %rdi     # 0x3e6a3
leaq 0x1e1ed(%rip), %rsi     # 0x3e2fb
movl $0x16f, %edx            # imm = 0x16F
leaq 0x1e529(%rip), %rcx     # 0x3e643
callq 0x20c0
movq -0x1e8(%rbp), %rsi
leaq 0xe2f83(%rip), %rdi     # 0x1030b0
callq 0x8980
movq %rax, -0x1f0(%rbp)
movq -0x1d8(%rbp), %rax
cmpq -0x1f0(%rbp), %rax
jne 0x2014b
jmp 0x2016a
leaq 0x1e55b(%rip), %rdi     # 0x3e6ad
leaq 0x1e1a2(%rip), %rsi     # 0x3e2fb
movl $0x171, %edx            # imm = 0x171
leaq 0x1e4de(%rip), %rcx     # 0x3e643
callq 0x20c0
addq $0x200, %rsp            # imm = 0x200
popq %rbp
retq
nopw %cs:(%rax,%rax)