// File: /workspace/github_cpp_makefile_star2_O3/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 0xdff37(%rip), %r15     # 0xf7ef0
movq %r15, %rdi
callq 0x62b6
leaq 0x1a34e(%rip), %rsi     # 0x32316
movq %rsp, %rbx
movq %rbx, %rdi
callq 0xaa82
movq %rbx, %rdi
callq 0x5ee8
movq %rax, %rbx
movl $0x1, %edi
movl $0x1c, %esi
movl $0x24, %edx
callq 0x775c
movq %rax, %r14
movl $0x1, %edi
movl $0x5, %esi
movl $0x3e9, %edx            # imm = 0x3E9
movq %rax, %rcx
callq 0x604f
movq %r15, %rdi
movq %rbx, %rsi
movq %rax, %rdx
callq 0x636f
movq %r15, %rdi
movq %rbx, %rsi
callq 0x6312
testq %rax, %rax
je 0x181a9
movq %rax, %r15
movq %rax, %rdi
callq 0x61e4
cmpl $0x1, %eax
jne 0x181c8
movq %r15, %rdi
callq 0x621c
cmpq %r14, %rax
jne 0x181e7
movq %r15, %rdi
callq 0x61f2
cmpl $0x3e9, %eax            # imm = 0x3E9
jne 0x18206
movq %r15, %rdi
callq 0x61eb
cmpl $0x5, %eax
jne 0x18225
movl $0x1, %edi
movl $0x6, %esi
movl $0x384, %edx            # imm = 0x384
movq %r14, %rcx
callq 0x604f
leaq 0xdfe5b(%rip), %r15     # 0xf7ef0
movq %r15, %rdi
movq %rbx, %rsi
movq %rax, %rdx
callq 0x636f
movq %r15, %rdi
movq %rbx, %rsi
callq 0x6312
testq %rax, %rax
je 0x18244
movq %rax, %r15
movq %rax, %rdi
callq 0x61e4
cmpl $0x1, %eax
jne 0x18263
movq %r15, %rdi
callq 0x621c
cmpq %r14, %rax
jne 0x18282
movq %r15, %rdi
callq 0x61f2
cmpl $0x384, %eax            # imm = 0x384
jne 0x182a1
movq %r15, %rdi
callq 0x61eb
cmpl $0x6, %eax
jne 0x182c0
movq %rbx, %r12
notq %r12
leaq 0xdfde3(%rip), %rdi     # 0xf7ef0
movq %r12, %rsi
callq 0x6312
testq %rax, %rax
jne 0x182df
movl $0x1, %edi
movl $0x7, %esi
movl $0x320, %edx            # imm = 0x320
movq %r14, %rcx
callq 0x604f
leaq 0xdfdb4(%rip), %r14     # 0xf7ef0
movq %r14, %rdi
movq %r12, %rsi
movq %rax, %rdx
callq 0x636f
movq %r14, %rdi
movq %r12, %rsi
callq 0x6312
testq %rax, %rax
je 0x182fe
movq %rax, %r14
leaq 0xdfd88(%rip), %rdi     # 0xf7ef0
movq %rbx, %rsi
callq 0x6312
cmpq %rax, %r15
jne 0x1831d
leaq 0xdfd70(%rip), %rdi     # 0xf7ef0
movq %r12, %rsi
callq 0x6312
cmpq %rax, %r14
jne 0x1833c
cmpq %r14, %r15
je 0x1835b
addq $0x1c8, %rsp            # imm = 0x1C8
popq %rbx
popq %r12
popq %r14
popq %r15
retq
leaq 0x19e26(%rip), %rdi     # 0x31fd6
leaq 0x199ee(%rip), %rsi     # 0x31ba5
leaq 0x1a17d(%rip), %rcx     # 0x3233b
movl $0x216, %edx            # imm = 0x216
callq 0x20d0
leaq 0x19b58(%rip), %rdi     # 0x31d27
leaq 0x199cf(%rip), %rsi     # 0x31ba5
leaq 0x1a15e(%rip), %rcx     # 0x3233b
movl $0x217, %edx            # imm = 0x217
callq 0x20d0
leaq 0x19bc2(%rip), %rdi     # 0x31db0
leaq 0x199b0(%rip), %rsi     # 0x31ba5
leaq 0x1a13f(%rip), %rcx     # 0x3233b
movl $0x218, %edx            # imm = 0x218
callq 0x20d0
leaq 0x1a144(%rip), %rdi     # 0x32351
leaq 0x19991(%rip), %rsi     # 0x31ba5
leaq 0x1a120(%rip), %rcx     # 0x3233b
movl $0x219, %edx            # imm = 0x219
callq 0x20d0
leaq 0x19e78(%rip), %rdi     # 0x320a4
leaq 0x19972(%rip), %rsi     # 0x31ba5
leaq 0x1a101(%rip), %rcx     # 0x3233b
movl $0x21a, %edx            # imm = 0x21A
callq 0x20d0
leaq 0x19d8b(%rip), %rdi     # 0x31fd6
leaq 0x19953(%rip), %rsi     # 0x31ba5
leaq 0x1a0e2(%rip), %rcx     # 0x3233b
movl $0x21f, %edx            # imm = 0x21F
callq 0x20d0
leaq 0x19abd(%rip), %rdi     # 0x31d27
leaq 0x19934(%rip), %rsi     # 0x31ba5
leaq 0x1a0c3(%rip), %rcx     # 0x3233b
movl $0x220, %edx            # imm = 0x220
callq 0x20d0
leaq 0x19b27(%rip), %rdi     # 0x31db0
leaq 0x19915(%rip), %rsi     # 0x31ba5
leaq 0x1a0a4(%rip), %rcx     # 0x3233b
movl $0x221, %edx            # imm = 0x221
callq 0x20d0
leaq 0x1a0c9(%rip), %rdi     # 0x32371
leaq 0x198f6(%rip), %rsi     # 0x31ba5
leaq 0x1a085(%rip), %rcx     # 0x3233b
movl $0x222, %edx            # imm = 0x222
callq 0x20d0
leaq 0x1a0c9(%rip), %rdi     # 0x32390
leaq 0x198d7(%rip), %rsi     # 0x31ba5
leaq 0x1a066(%rip), %rcx     # 0x3233b
movl $0x223, %edx            # imm = 0x223
callq 0x20d0
leaq 0x19c5f(%rip), %rdi     # 0x31f45
leaq 0x198b8(%rip), %rsi     # 0x31ba5
leaq 0x1a047(%rip), %rcx     # 0x3233b
movl $0x229, %edx            # imm = 0x229
callq 0x20d0
leaq 0x1a0a8(%rip), %rdi     # 0x323ad
leaq 0x19899(%rip), %rsi     # 0x31ba5
leaq 0x1a028(%rip), %rcx     # 0x3233b
movl $0x22c, %edx            # imm = 0x22C
callq 0x20d0
leaq 0x1a093(%rip), %rdi     # 0x323b7
leaq 0x1987a(%rip), %rsi     # 0x31ba5
leaq 0x1a009(%rip), %rcx     # 0x3233b
movl $0x22f, %edx            # imm = 0x22F
callq 0x20d0
leaq 0x1a093(%rip), %rdi     # 0x323d6
leaq 0x1985b(%rip), %rsi     # 0x31ba5
leaq 0x19fea(%rip), %rcx     # 0x3233b
movl $0x230, %edx            # imm = 0x230
callq 0x20d0
leaq 0x1a095(%rip), %rdi     # 0x323f7
leaq 0x1983c(%rip), %rsi     # 0x31ba5
leaq 0x19fcb(%rip), %rcx     # 0x3233b
movl $0x231, %edx            # imm = 0x231
callq 0x20d0