// File: /workspace/github_cpp_makefile_star2_O2/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 %rbp
pushq %r15
pushq %r14
pushq %r12
pushq %rbx
subq $0x1d0, %rsp            # imm = 0x1D0
leaq 0xe45db(%rip), %r15     # 0xfaef0
movq %r15, %rdi
callq 0x5dd9
leaq 0x199a2(%rip), %rsi     # 0x302c6
leaq 0x8(%rsp), %rbx
movq %rbx, %rdi
callq 0xa1b8
movq %rbx, %rdi
callq 0x5a50
movq %rax, %rbx
pushq $0x1
popq %rbp
pushq $0x1c
popq %rsi
pushq $0x24
popq %rdx
movl %ebp, %edi
callq 0x7284
movq %rax, %r14
pushq $0x5
popq %rsi
movl %ebp, %edi
movl $0x3e9, %edx            # imm = 0x3E9
movq %rax, %rcx
callq 0x5b8a
movq %r15, %rdi
movq %rbx, %rsi
movq %rax, %rdx
callq 0x5e8b
movq %r15, %rdi
movq %rbx, %rsi
callq 0x5e2e
testq %rax, %rax
je 0x16af7
movq %rax, %r15
movq %rax, %rdi
callq 0x5d09
cmpl $0x1, %eax
jne 0x16b16
movq %r15, %rdi
callq 0x5d41
cmpq %r14, %rax
jne 0x16b35
movq %r15, %rdi
callq 0x5d17
cmpl $0x3e9, %eax            # imm = 0x3E9
jne 0x16b54
movq %r15, %rdi
callq 0x5d10
cmpl $0x5, %eax
jne 0x16b73
pushq $0x1
popq %rdi
pushq $0x6
popq %rsi
movl $0x384, %edx            # imm = 0x384
movq %r14, %rcx
callq 0x5b8a
leaq 0xe450a(%rip), %r15     # 0xfaef0
movq %r15, %rdi
movq %rbx, %rsi
movq %rax, %rdx
callq 0x5e8b
movq %r15, %rdi
movq %rbx, %rsi
callq 0x5e2e
testq %rax, %rax
je 0x16b92
movq %rax, %r15
movq %rax, %rdi
callq 0x5d09
cmpl $0x1, %eax
jne 0x16bb1
movq %r15, %rdi
callq 0x5d41
cmpq %r14, %rax
jne 0x16bd0
movq %r15, %rdi
callq 0x5d17
cmpl $0x384, %eax            # imm = 0x384
jne 0x16bef
movq %r15, %rdi
callq 0x5d10
cmpl $0x6, %eax
jne 0x16c0e
movq %rbx, %r12
notq %r12
leaq 0xe4492(%rip), %rdi     # 0xfaef0
movq %r12, %rsi
callq 0x5e2e
testq %rax, %rax
jne 0x16c2d
pushq $0x1
popq %rdi
pushq $0x7
popq %rsi
movl $0x320, %edx            # imm = 0x320
movq %r14, %rcx
callq 0x5b8a
leaq 0xe4467(%rip), %r14     # 0xfaef0
movq %r14, %rdi
movq %r12, %rsi
movq %rax, %rdx
callq 0x5e8b
movq %r14, %rdi
movq %r12, %rsi
callq 0x5e2e
testq %rax, %rax
je 0x16c4c
movq %rax, %r14
leaq 0xe443b(%rip), %rdi     # 0xfaef0
movq %rbx, %rsi
callq 0x5e2e
cmpq %rax, %r15
jne 0x16c6b
leaq 0xe4423(%rip), %rdi     # 0xfaef0
movq %r12, %rsi
callq 0x5e2e
cmpq %rax, %r14
jne 0x16c8a
cmpq %r14, %r15
je 0x16ca9
addq $0x1d0, %rsp            # imm = 0x1D0
popq %rbx
popq %r12
popq %r14
popq %r15
popq %rbp
retq
leaq 0x19488(%rip), %rdi     # 0x2ff86
leaq 0x19050(%rip), %rsi     # 0x2fb55
leaq 0x197df(%rip), %rcx     # 0x302eb
movl $0x216, %edx            # imm = 0x216
callq 0x20c0
leaq 0x191ba(%rip), %rdi     # 0x2fcd7
leaq 0x19031(%rip), %rsi     # 0x2fb55
leaq 0x197c0(%rip), %rcx     # 0x302eb
movl $0x217, %edx            # imm = 0x217
callq 0x20c0
leaq 0x19224(%rip), %rdi     # 0x2fd60
leaq 0x19012(%rip), %rsi     # 0x2fb55
leaq 0x197a1(%rip), %rcx     # 0x302eb
movl $0x218, %edx            # imm = 0x218
callq 0x20c0
leaq 0x197a6(%rip), %rdi     # 0x30301
leaq 0x18ff3(%rip), %rsi     # 0x2fb55
leaq 0x19782(%rip), %rcx     # 0x302eb
movl $0x219, %edx            # imm = 0x219
callq 0x20c0
leaq 0x194da(%rip), %rdi     # 0x30054
leaq 0x18fd4(%rip), %rsi     # 0x2fb55
leaq 0x19763(%rip), %rcx     # 0x302eb
movl $0x21a, %edx            # imm = 0x21A
callq 0x20c0
leaq 0x193ed(%rip), %rdi     # 0x2ff86
leaq 0x18fb5(%rip), %rsi     # 0x2fb55
leaq 0x19744(%rip), %rcx     # 0x302eb
movl $0x21f, %edx            # imm = 0x21F
callq 0x20c0
leaq 0x1911f(%rip), %rdi     # 0x2fcd7
leaq 0x18f96(%rip), %rsi     # 0x2fb55
leaq 0x19725(%rip), %rcx     # 0x302eb
movl $0x220, %edx            # imm = 0x220
callq 0x20c0
leaq 0x19189(%rip), %rdi     # 0x2fd60
leaq 0x18f77(%rip), %rsi     # 0x2fb55
leaq 0x19706(%rip), %rcx     # 0x302eb
movl $0x221, %edx            # imm = 0x221
callq 0x20c0
leaq 0x1972b(%rip), %rdi     # 0x30321
leaq 0x18f58(%rip), %rsi     # 0x2fb55
leaq 0x196e7(%rip), %rcx     # 0x302eb
movl $0x222, %edx            # imm = 0x222
callq 0x20c0
leaq 0x1972b(%rip), %rdi     # 0x30340
leaq 0x18f39(%rip), %rsi     # 0x2fb55
leaq 0x196c8(%rip), %rcx     # 0x302eb
movl $0x223, %edx            # imm = 0x223
callq 0x20c0
leaq 0x192c1(%rip), %rdi     # 0x2fef5
leaq 0x18f1a(%rip), %rsi     # 0x2fb55
leaq 0x196a9(%rip), %rcx     # 0x302eb
movl $0x229, %edx            # imm = 0x229
callq 0x20c0
leaq 0x1970a(%rip), %rdi     # 0x3035d
leaq 0x18efb(%rip), %rsi     # 0x2fb55
leaq 0x1968a(%rip), %rcx     # 0x302eb
movl $0x22c, %edx            # imm = 0x22C
callq 0x20c0
leaq 0x196f5(%rip), %rdi     # 0x30367
leaq 0x18edc(%rip), %rsi     # 0x2fb55
leaq 0x1966b(%rip), %rcx     # 0x302eb
movl $0x22f, %edx            # imm = 0x22F
callq 0x20c0
leaq 0x196f5(%rip), %rdi     # 0x30386
leaq 0x18ebd(%rip), %rsi     # 0x2fb55
leaq 0x1964c(%rip), %rcx     # 0x302eb
movl $0x230, %edx            # imm = 0x230
callq 0x20c0
leaq 0x196f7(%rip), %rdi     # 0x303a7
leaq 0x18e9e(%rip), %rsi     # 0x2fb55
leaq 0x1962d(%rip), %rcx     # 0x302eb
movl $0x231, %edx            # imm = 0x231
callq 0x20c0