// File: /workspace/github_cpp_makefile_star2_O1/jswaff[P]prophet3/test/hash__test.cpp
// Function: test_overwrite()
void test_overwrite() {
    clear_hash_table(&htbl);
    position pos;
    set_pos(&pos,"8/k7/p7/3Qp2P/n1P5/3KP3/1q6/8 b - - ");

    uint64 key = build_hash_key(&pos);
    move mv = to_move(PAWN,E5,E4);
    store_hash_entry(&htbl,key,build_hash_val(LOWER_BOUND,5,1001,mv));

    uint64 val = get_hash_entry(&htbl,key);
    assert(val!=0);
    assert(get_hash_entry_type(val)==LOWER_BOUND);
    assert(get_hash_entry_move(val)==mv);
    assert(get_hash_entry_score(val)==1001);
    assert(get_hash_entry_depth(val)==5);

    // overwrite with different score/depth
    store_hash_entry(&htbl,key,build_hash_val(LOWER_BOUND,6,900,mv));
    val = get_hash_entry(&htbl,key);
    assert(val!=0);
    assert(get_hash_entry_type(val)==LOWER_BOUND);
    assert(get_hash_entry_move(val)==mv);
    assert(get_hash_entry_score(val)==900);
    assert(get_hash_entry_depth(val)==6);

    // use different key to store new entry
    uint64 key2 = ~key;

    uint64 val2 = get_hash_entry(&htbl,key2);
    assert(val2==0);
    store_hash_entry(&htbl,key2,build_hash_val(LOWER_BOUND,7,800,mv));
    val2 = get_hash_entry(&htbl,key2);
    assert(val2 != 0);

    // make sure we didn't overwrite earlier entry
    assert(val==get_hash_entry(&htbl,key));
    assert(val2==get_hash_entry(&htbl,key2));
    assert(val != val2);
}

// Assembly:
pushq %r15
pushq %r14
pushq %r12
pushq %rbx
subq $0x1c8, %rsp            # imm = 0x1C8
leaq 0xdfde8(%rip), %r15     # 0xf7ef0
movq %r15, %rdi
callq 0x6207
leaq 0x1a17f(%rip), %rsi     # 0x32296
movq %rsp, %rbx
movq %rbx, %rdi
callq 0xaa74
movq %rbx, %rdi
callq 0x5e40
movq %rax, %rbx
movl $0x1, %edi
movl $0x1c, %esi
movl $0x24, %edx
callq 0x76b8
movq %rax, %r14
movl $0x1, %edi
movl $0x5, %esi
movl $0x3e9, %edx            # imm = 0x3E9
movq %rax, %rcx
callq 0x5fa7
movq %r15, %rdi
movq %rbx, %rsi
movq %rax, %rdx
callq 0x62c0
movq %r15, %rdi
movq %rbx, %rsi
callq 0x6263
testq %rax, %rax
je 0x182f8
movq %rax, %r15
movq %rax, %rdi
callq 0x6135
cmpl $0x1, %eax
jne 0x18317
movq %r15, %rdi
callq 0x616d
cmpq %r14, %rax
jne 0x18336
movq %r15, %rdi
callq 0x6143
cmpl $0x3e9, %eax            # imm = 0x3E9
jne 0x18355
movq %r15, %rdi
callq 0x613c
cmpl $0x5, %eax
jne 0x18374
movl $0x1, %edi
movl $0x6, %esi
movl $0x384, %edx            # imm = 0x384
movq %r14, %rcx
callq 0x5fa7
leaq 0xdfd0c(%rip), %r15     # 0xf7ef0
movq %r15, %rdi
movq %rbx, %rsi
movq %rax, %rdx
callq 0x62c0
movq %r15, %rdi
movq %rbx, %rsi
callq 0x6263
testq %rax, %rax
je 0x18393
movq %rax, %r15
movq %rax, %rdi
callq 0x6135
cmpl $0x1, %eax
jne 0x183b2
movq %r15, %rdi
callq 0x616d
cmpq %r14, %rax
jne 0x183d1
movq %r15, %rdi
callq 0x6143
cmpl $0x384, %eax            # imm = 0x384
jne 0x183f0
movq %r15, %rdi
callq 0x613c
cmpl $0x6, %eax
jne 0x1840f
movq %rbx, %r12
notq %r12
leaq 0xdfc94(%rip), %rdi     # 0xf7ef0
movq %r12, %rsi
callq 0x6263
testq %rax, %rax
jne 0x1842e
movl $0x1, %edi
movl $0x7, %esi
movl $0x320, %edx            # imm = 0x320
movq %r14, %rcx
callq 0x5fa7
leaq 0xdfc65(%rip), %r14     # 0xf7ef0
movq %r14, %rdi
movq %r12, %rsi
movq %rax, %rdx
callq 0x62c0
movq %r14, %rdi
movq %r12, %rsi
callq 0x6263
testq %rax, %rax
je 0x1844d
movq %rax, %r14
leaq 0xdfc39(%rip), %rdi     # 0xf7ef0
movq %rbx, %rsi
callq 0x6263
cmpq %rax, %r15
jne 0x1846c
leaq 0xdfc21(%rip), %rdi     # 0xf7ef0
movq %r12, %rsi
callq 0x6263
cmpq %rax, %r14
jne 0x1848b
cmpq %r14, %r15
je 0x184aa
addq $0x1c8, %rsp            # imm = 0x1C8
popq %rbx
popq %r12
popq %r14
popq %r15
retq
leaq 0x19c57(%rip), %rdi     # 0x31f56
leaq 0x1981f(%rip), %rsi     # 0x31b25
leaq 0x19fae(%rip), %rcx     # 0x322bb
movl $0x216, %edx            # imm = 0x216
callq 0x20d0
leaq 0x19989(%rip), %rdi     # 0x31ca7
leaq 0x19800(%rip), %rsi     # 0x31b25
leaq 0x19f8f(%rip), %rcx     # 0x322bb
movl $0x217, %edx            # imm = 0x217
callq 0x20d0
leaq 0x199f3(%rip), %rdi     # 0x31d30
leaq 0x197e1(%rip), %rsi     # 0x31b25
leaq 0x19f70(%rip), %rcx     # 0x322bb
movl $0x218, %edx            # imm = 0x218
callq 0x20d0
leaq 0x19f75(%rip), %rdi     # 0x322d1
leaq 0x197c2(%rip), %rsi     # 0x31b25
leaq 0x19f51(%rip), %rcx     # 0x322bb
movl $0x219, %edx            # imm = 0x219
callq 0x20d0
leaq 0x19ca9(%rip), %rdi     # 0x32024
leaq 0x197a3(%rip), %rsi     # 0x31b25
leaq 0x19f32(%rip), %rcx     # 0x322bb
movl $0x21a, %edx            # imm = 0x21A
callq 0x20d0
leaq 0x19bbc(%rip), %rdi     # 0x31f56
leaq 0x19784(%rip), %rsi     # 0x31b25
leaq 0x19f13(%rip), %rcx     # 0x322bb
movl $0x21f, %edx            # imm = 0x21F
callq 0x20d0
leaq 0x198ee(%rip), %rdi     # 0x31ca7
leaq 0x19765(%rip), %rsi     # 0x31b25
leaq 0x19ef4(%rip), %rcx     # 0x322bb
movl $0x220, %edx            # imm = 0x220
callq 0x20d0
leaq 0x19958(%rip), %rdi     # 0x31d30
leaq 0x19746(%rip), %rsi     # 0x31b25
leaq 0x19ed5(%rip), %rcx     # 0x322bb
movl $0x221, %edx            # imm = 0x221
callq 0x20d0
leaq 0x19efa(%rip), %rdi     # 0x322f1
leaq 0x19727(%rip), %rsi     # 0x31b25
leaq 0x19eb6(%rip), %rcx     # 0x322bb
movl $0x222, %edx            # imm = 0x222
callq 0x20d0
leaq 0x19efa(%rip), %rdi     # 0x32310
leaq 0x19708(%rip), %rsi     # 0x31b25
leaq 0x19e97(%rip), %rcx     # 0x322bb
movl $0x223, %edx            # imm = 0x223
callq 0x20d0
leaq 0x19a90(%rip), %rdi     # 0x31ec5
leaq 0x196e9(%rip), %rsi     # 0x31b25
leaq 0x19e78(%rip), %rcx     # 0x322bb
movl $0x229, %edx            # imm = 0x229
callq 0x20d0
leaq 0x19ed9(%rip), %rdi     # 0x3232d
leaq 0x196ca(%rip), %rsi     # 0x31b25
leaq 0x19e59(%rip), %rcx     # 0x322bb
movl $0x22c, %edx            # imm = 0x22C
callq 0x20d0
leaq 0x19ec4(%rip), %rdi     # 0x32337
leaq 0x196ab(%rip), %rsi     # 0x31b25
leaq 0x19e3a(%rip), %rcx     # 0x322bb
movl $0x22f, %edx            # imm = 0x22F
callq 0x20d0
leaq 0x19ec4(%rip), %rdi     # 0x32356
leaq 0x1968c(%rip), %rsi     # 0x31b25
leaq 0x19e1b(%rip), %rcx     # 0x322bb
movl $0x230, %edx            # imm = 0x230
callq 0x20d0
leaq 0x19ec6(%rip), %rdi     # 0x32377
leaq 0x1966d(%rip), %rsi     # 0x31b25
leaq 0x19dfc(%rip), %rcx     # 0x322bb
movl $0x231, %edx            # imm = 0x231
callq 0x20d0