// File: /workspace/github_cpp_makefile_star2_O1/jswaff[P]prophet3/test/hash__test.cpp
// Function: test_hash_keys2()
void test_hash_keys2() {
    position pos;
    reset_pos(&pos);

    position pos2;
    reset_pos(&pos2);

    uint64 keys[20]; int nkeys=0;
    uint64 keys2[20]; int nkeys2=0;

    assert(build_hash_key(&pos)==build_hash_key(&pos2));

    // step through French Defense with pos1
    apply_move(&pos,to_move(PAWN,E2,E4),gundos);
    keys[nkeys++] = build_hash_key(&pos);
    apply_move(&pos,to_move(PAWN,E7,E6),gundos);
    keys[nkeys++] = build_hash_key(&pos);
    apply_move(&pos,to_move(PAWN,D2,D4),gundos);
    keys[nkeys++] = build_hash_key(&pos);
    apply_move(&pos,to_move(PAWN,D7,D5),gundos);
    keys[nkeys++] = build_hash_key(&pos);
    apply_move(&pos,to_capture(PAWN,E4,D5,PAWN),gundos);
    keys[nkeys++] = build_hash_key(&pos);
    apply_move(&pos,to_capture(PAWN,E6,D5,PAWN),gundos);
    keys[nkeys++] = build_hash_key(&pos);
    apply_move(&pos,to_move(KNIGHT,G1,F3),gundos);
    keys[nkeys++] = build_hash_key(&pos);
    apply_move(&pos,to_move(KNIGHT,G8,F6),gundos);
    keys[nkeys++] = build_hash_key(&pos);

    // step through the Petrov Defense with pos2
    apply_move(&pos2,to_move(PAWN,E2,E4),gundos);
    keys2[nkeys2++] = build_hash_key(&pos2);
    apply_move(&pos2,to_move(PAWN,E7,E5),gundos);
    keys2[nkeys2++] = build_hash_key(&pos2);
    apply_move(&pos2,to_move(KNIGHT,G1,F3),gundos);
    keys2[nkeys2++] = build_hash_key(&pos2);
    apply_move(&pos2,to_move(KNIGHT,G8,F6),gundos);
    keys2[nkeys2++] = build_hash_key(&pos2);
    apply_move(&pos2,to_capture(KNIGHT,F3,E5,PAWN),gundos);
    keys2[nkeys2++] = build_hash_key(&pos2);
    apply_move(&pos2,to_move(PAWN,D7,D6),gundos);
    keys2[nkeys2++] = build_hash_key(&pos2);
    apply_move(&pos2,to_move(KNIGHT,E5,F3),gundos);
    keys2[nkeys2++] = build_hash_key(&pos2);
    apply_move(&pos2,to_capture(KNIGHT,F6,E4,PAWN),gundos);
    keys2[nkeys2++] = build_hash_key(&pos2);
    apply_move(&pos2,to_move(PAWN,D2,D3),gundos);
    keys2[nkeys2++] = build_hash_key(&pos2);
    apply_move(&pos2,to_move(KNIGHT,E4,F6),gundos);
    keys2[nkeys2++] = build_hash_key(&pos2);
    apply_move(&pos2,to_move(PAWN,D3,D4),gundos);
    keys2[nkeys2++] = build_hash_key(&pos2);
    apply_move(&pos2,to_move(PAWN,D6,D5),gundos);
    keys2[nkeys2++] = build_hash_key(&pos2);

    // Positions would be equal at this point, except for move history and fifty counter
    assert(!equal_pos(&pos,&pos2,true));
    assert(build_hash_key(&pos)==build_hash_key(&pos2));

    // by adding a pawn move we should be equal except move history and number of moves
    apply_move(&pos,to_move(PAWN,G2,G3),gundos);
    apply_move(&pos2,to_move(PAWN,G2,G3),gundos);

    assert(!equal_pos(&pos,&pos2,true));
    assert(build_hash_key(&pos)==build_hash_key(&pos2));

    // hash codes should be equal at beginning, move 1, move 7 and end only.
    for (int i=0;i<nkeys;i++) {
        if (i==0) {
            assert(keys2[i]==keys[i]);
            assert(!contains_key(keys[i],keys2,nkeys2,1));
        } else if (i==7) {
            assert(keys2[11]==keys[i]);
            assert(!contains_key(keys[i],keys2,nkeys2-1,0));
        } else {
            assert(!contains_key(keys[i],keys2,nkeys2));
        }
    }

}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x4d8, %rsp            # imm = 0x4D8
leaq 0x148(%rsp), %rbx
movq %rbx, %rdi
callq 0xaa43
leaq 0x310(%rsp), %r14
movq %r14, %rdi
callq 0xaa43
movq %rbx, %rdi
callq 0x5e40
movq %rax, %rbx
movq %r14, %rdi
callq 0x5e40
cmpq %rax, %rbx
jne 0x16a37
movl $0x1, %edi
movl $0x34, %esi
movl $0x24, %edx
callq 0x76b8
leaq 0xb26e0(%rip), %r13     # 0xc8af0
leaq 0x148(%rsp), %r12
movq %r12, %rdi
movq %rax, %rsi
movq %r13, %rdx
callq 0x30e3
movq %r12, %rdi
callq 0x5e40
movq %rax, %rbx
movq %rax, 0xa0(%rsp)
movl $0x1, %edi
movl $0xc, %esi
movl $0x14, %edx
callq 0x76b8
movq %r12, %rdi
movq %rax, %rsi
movq %r13, %rdx
callq 0x30e3
movq %r12, %rdi
callq 0x5e40
movq %rax, 0xa8(%rsp)
movl $0x1, %edi
movl $0x33, %esi
movl $0x23, %edx
callq 0x76b8
movq %r12, %rdi
movq %rax, %rsi
movq %r13, %rdx
callq 0x30e3
movq %r12, %rdi
callq 0x5e40
movq %rax, 0xb0(%rsp)
movl $0x1, %edi
movl $0xb, %esi
movl $0x1b, %edx
callq 0x76b8
movq %r12, %rdi
movq %rax, %rsi
movq %r13, %rdx
callq 0x30e3
movq %r12, %rdi
callq 0x5e40
movq %rax, 0xb8(%rsp)
movl $0x1, %edi
movl $0x24, %esi
movl $0x1b, %edx
movl $0x1, %ecx
callq 0x76d7
movq %r12, %rdi
movq %rax, %rsi
movq %r13, %rdx
callq 0x30e3
movq %r12, %rdi
callq 0x5e40
movq %rax, 0xc0(%rsp)
movl $0x1, %edi
movl $0x14, %esi
movl $0x1b, %edx
movl $0x1, %ecx
callq 0x76d7
movq %r12, %rdi
movq %rax, %rsi
movq %r13, %rdx
callq 0x30e3
movq %r12, %rdi
callq 0x5e40
movq %rax, 0xc8(%rsp)
movl $0x2, %edi
movl $0x3e, %esi
movl $0x2d, %edx
callq 0x76b8
movq %r12, %rdi
movq %rax, %rsi
movq %r13, %rdx
callq 0x30e3
movq %r12, %rdi
callq 0x5e40
movq %rax, 0xd0(%rsp)
movl $0x2, %edi
movl $0x6, %esi
movl $0x15, %edx
callq 0x76b8
movq %r12, %rdi
movq %rax, %rsi
movq %r13, %rdx
callq 0x30e3
movq %r12, %rdi
callq 0x5e40
movq %rax, %r14
movq %rax, 0xd8(%rsp)
movl $0x1, %edi
movl $0x34, %esi
movl $0x24, %edx
callq 0x76b8
leaq 0x310(%rsp), %rbp
movq %rbp, %rdi
movq %rax, %rsi
movq %r13, %rdx
callq 0x30e3
movq %rbp, %rdi
callq 0x5e40
movq %rax, %r15
movq %rax, (%rsp)
movl $0x1, %edi
movl $0xc, %esi
movl $0x1c, %edx
callq 0x76b8
movq %rbp, %rdi
movq %rax, %rsi
movq %r13, %rdx
callq 0x30e3
movq %rbp, %rdi
callq 0x5e40
movq %rax, 0x8(%rsp)
movl $0x2, %edi
movl $0x3e, %esi
movl $0x2d, %edx
callq 0x76b8
movq %rbp, %rdi
movq %rax, %rsi
movq %r13, %rdx
callq 0x30e3
movq %rbp, %rdi
callq 0x5e40
movq %rax, 0x10(%rsp)
movl $0x2, %edi
movl $0x6, %esi
movl $0x15, %edx
callq 0x76b8
movq %rbp, %rdi
movq %rax, %rsi
movq %r13, %rdx
callq 0x30e3
movq %rbp, %rdi
callq 0x5e40
movq %rax, 0x18(%rsp)
movl $0x2, %edi
movl $0x2d, %esi
movl $0x1c, %edx
movl $0x1, %ecx
callq 0x76d7
movq %rbp, %rdi
movq %rax, %rsi
movq %r13, %rdx
callq 0x30e3
movq %rbp, %rdi
callq 0x5e40
movq %rax, 0x20(%rsp)
movl $0x1, %edi
movl $0xb, %esi
movl $0x13, %edx
callq 0x76b8
movq %rbp, %rdi
movq %rax, %rsi
movq %r13, %rdx
callq 0x30e3
movq %rbp, %rdi
callq 0x5e40
movq %rax, 0x28(%rsp)
movl $0x2, %edi
movl $0x1c, %esi
movl $0x2d, %edx
callq 0x76b8
movq %rbp, %rdi
movq %rax, %rsi
movq %r13, %rdx
callq 0x30e3
movq %rbp, %rdi
callq 0x5e40
movq %rax, 0x30(%rsp)
movl $0x2, %edi
movl $0x15, %esi
movl $0x24, %edx
movl $0x1, %ecx
callq 0x76d7
movq %rbp, %rdi
movq %rax, %rsi
movq %r13, %rdx
callq 0x30e3
movq %rbp, %rdi
callq 0x5e40
movq %rax, 0x38(%rsp)
movl $0x1, %edi
movl $0x33, %esi
movl $0x2b, %edx
callq 0x76b8
movq %rbp, %rdi
movq %rax, %rsi
movq %r13, %rdx
callq 0x30e3
movq %rbp, %rdi
callq 0x5e40
movq %rax, 0x40(%rsp)
movl $0x2, %edi
movl $0x24, %esi
movl $0x15, %edx
callq 0x76b8
movq %rbp, %rdi
movq %rax, %rsi
movq %r13, %rdx
callq 0x30e3
movq %rbp, %rdi
callq 0x5e40
movq %rax, 0x48(%rsp)
movl $0x1, %edi
movl $0x2b, %esi
movl $0x23, %edx
callq 0x76b8
movq %rbp, %rdi
movq %rax, %rsi
movq %r13, %rdx
callq 0x30e3
movq %rbp, %rdi
callq 0x5e40
movq %rax, 0x50(%rsp)
movl $0x1, %edi
movl $0x13, %esi
movl $0x1b, %edx
callq 0x76b8
movq %rbp, %rdi
movq %rax, %rsi
movq %r13, %rdx
callq 0x30e3
movq %rbp, %rdi
callq 0x5e40
movq %rax, %r13
movq %rax, 0x58(%rsp)
movq %r12, %rdi
movq %rbp, %rsi
movl $0x1, %edx
callq 0xa0e0
testb %al, %al
jne 0x16a56
leaq 0x148(%rsp), %rdi
callq 0x5e40
movq %rax, %r12
leaq 0x310(%rsp), %rdi
callq 0x5e40
cmpq %rax, %r12
jne 0x16a75
movl $0x1, %edi
movl $0x36, %esi
movl $0x2e, %edx
callq 0x76b8
leaq 0xb22a8(%rip), %r12     # 0xc8af0
leaq 0x148(%rsp), %rdi
movq %rax, %rsi
movq %r12, %rdx
callq 0x30e3
movl $0x1, %edi
movl $0x36, %esi
movl $0x2e, %edx
callq 0x76b8
leaq 0x310(%rsp), %rbp
movq %rbp, %rdi
movq %rax, %rsi
movq %r12, %rdx
callq 0x30e3
leaq 0x148(%rsp), %rdi
movq %rbp, %rsi
movl $0x1, %edx
callq 0xa0e0
testb %al, %al
jne 0x16a94
leaq 0x148(%rsp), %rdi
callq 0x5e40
movq %rax, %r12
leaq 0x310(%rsp), %rdi
callq 0x5e40
cmpq %rax, %r12
jne 0x16ab3
movq (%rsp), %rax
movq 0x8(%rsp), %rcx
xorl %edx, %edx
cmpl $0x7, %edx
je 0x16914
testl %edx, %edx
jne 0x16947
cmpq %rbx, %r15
jne 0x169f9
cmpq %rbx, %rcx
je 0x169bb
movl $0x2, %edi
movq %rdi, %rsi
cmpq $0xc, %rdi
je 0x16906
leaq 0x1(%rsi), %rdi
cmpq %rbx, (%rsp,%rsi,8)
jne 0x168f3
decq %rsi
cmpq $0xa, %rsi
ja 0x1697d
jmp 0x169bb
cmpq %r14, %r13
jne 0x16a18
cmpq %r14, %rax
je 0x169da
xorl %edi, %edi
movq %rdi, %rsi
cmpq $0xa, %rdi
je 0x1693c
leaq 0x1(%rsi), %rdi
cmpq %r14, 0x8(%rsp,%rsi,8)
jne 0x16928
cmpq $0x9, %rsi
ja 0x1697d
jmp 0x169da
movq 0xa0(%rsp,%rdx,8), %rsi
cmpq %rsi, %r15
je 0x1699c
movq $-0x1, %rdi
cmpq $0xa, %rdi
je 0x16971
leaq 0x1(%rdi), %r8
cmpq %rsi, 0x10(%rsp,%rdi,8)
movq %r8, %rdi
jne 0x1695b
jmp 0x16977
movl $0xb, %r8d
cmpq $0xa, %r8
jbe 0x1699c
incq %rdx
cmpq $0x8, %rdx
jne 0x168d3
addq $0x4d8, %rsp            # imm = 0x4D8
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
leaq 0x1b29d(%rip), %rdi     # 0x31c40
leaq 0x1b17b(%rip), %rsi     # 0x31b25
leaq 0x1b1e9(%rip), %rcx     # 0x31b9a
movl $0xe5, %edx
callq 0x20d0
leaq 0x1b21d(%rip), %rdi     # 0x31bdf
leaq 0x1b15c(%rip), %rsi     # 0x31b25
leaq 0x1b1ca(%rip), %rcx     # 0x31b9a
movl $0xe0, %edx
callq 0x20d0
leaq 0x1b237(%rip), %rdi     # 0x31c18
leaq 0x1b13d(%rip), %rsi     # 0x31b25
leaq 0x1b1ab(%rip), %rcx     # 0x31b9a
movl $0xe3, %edx
callq 0x20d0
leaq 0x1b1cd(%rip), %rdi     # 0x31bcd
leaq 0x1b11e(%rip), %rsi     # 0x31b25
leaq 0x1b18c(%rip), %rcx     # 0x31b9a
movl $0xdf, %edx
callq 0x20d0
leaq 0x1b1e6(%rip), %rdi     # 0x31c05
leaq 0x1b0ff(%rip), %rsi     # 0x31b25
leaq 0x1b16d(%rip), %rcx     # 0x31b9a
movl $0xe2, %edx
callq 0x20d0
leaq 0x1b130(%rip), %rdi     # 0x31b6e
leaq 0x1b0e0(%rip), %rsi     # 0x31b25
leaq 0x1b14e(%rip), %rcx     # 0x31b9a
movl $0xa3, %edx
callq 0x20d0
leaq 0x1b154(%rip), %rdi     # 0x31bb1
leaq 0x1b0c1(%rip), %rsi     # 0x31b25
leaq 0x1b12f(%rip), %rcx     # 0x31b9a
movl $0xd2, %edx
callq 0x20d0
leaq 0x1b0f2(%rip), %rdi     # 0x31b6e
leaq 0x1b0a2(%rip), %rsi     # 0x31b25
leaq 0x1b110(%rip), %rcx     # 0x31b9a
movl $0xd3, %edx
callq 0x20d0
leaq 0x1b116(%rip), %rdi     # 0x31bb1
leaq 0x1b083(%rip), %rsi     # 0x31b25
leaq 0x1b0f1(%rip), %rcx     # 0x31b9a
movl $0xd9, %edx
callq 0x20d0
leaq 0x1b0b4(%rip), %rdi     # 0x31b6e
leaq 0x1b064(%rip), %rsi     # 0x31b25
leaq 0x1b0d2(%rip), %rcx     # 0x31b9a
movl $0xda, %edx
callq 0x20d0