// File: /workspace/github_cpp_makefile_star2_O1/jswaff[P]prophet3/test/hash__test.cpp
// Function: test_hash_keys3()
void test_hash_keys3() {
    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));

    // Go through Queen's Gambit with b1
    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_move(PAWN,C2,C4),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(KNIGHT,B1,C3),gundos);
    keys[nkeys++] = build_hash_key(&pos);
    apply_move(&pos,to_move(KNIGHT,G8,F6),gundos);
    keys[nkeys++] = build_hash_key(&pos);

    // Step through English Opening with b2
    apply_move(&pos2,to_move(PAWN,C2,C4),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_move(KNIGHT,B1,C3),gundos);
    keys2[nkeys2++] = build_hash_key(&pos2);
    apply_move(&pos2,to_move(PAWN,E7,E6),gundos);
    keys2[nkeys2++] = build_hash_key(&pos2);
    apply_move(&pos2,to_move(PAWN,D2,D4),gundos);
    keys2[nkeys2++] = build_hash_key(&pos2);
    apply_move(&pos2,to_move(PAWN,D7,D5),gundos);
    keys2[nkeys2++] = build_hash_key(&pos2);

    // Positions would be equal at this point, except for move history, fifty counter and ep square
    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
    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));

    // keys should be equal at beginning and end only.  Neither were
    // saved in list so lists should contain completely different codes
    for (int i=0;i<nkeys;i++) {
        assert(!contains_key(keys[i],keys2,nkeys2));
    }
}

// Assembly:
pushq %r15
pushq %r14
pushq %r12
pushq %rbx
subq $0x4d8, %rsp            # imm = 0x4D8
leaq 0x310(%rsp), %rbx
movq %rbx, %rdi
callq 0xaa43
leaq 0x148(%rsp), %r14
movq %r14, %rdi
callq 0xaa43
movq %rbx, %rdi
callq 0x5e40
movq %rax, %rbx
movq %r14, %rdi
callq 0x5e40
cmpq %rax, %rbx
jne 0x16ec0
movl $0x1, %edi
movl $0x33, %esi
movl $0x23, %edx
callq 0x76b8
leaq 0xb1fb9(%rip), %r14     # 0xc8af0
leaq 0x310(%rsp), %rbx
movq %rbx, %rdi
movq %rax, %rsi
movq %r14, %rdx
callq 0x30e3
movq %rbx, %rdi
callq 0x5e40
movq %rax, 0xa0(%rsp)
movl $0x1, %edi
movl $0xb, %esi
movl $0x1b, %edx
callq 0x76b8
movq %rbx, %rdi
movq %rax, %rsi
movq %r14, %rdx
callq 0x30e3
movq %rbx, %rdi
callq 0x5e40
movq %rax, 0xa8(%rsp)
movl $0x1, %edi
movl $0x32, %esi
movl $0x22, %edx
callq 0x76b8
movq %rbx, %rdi
movq %rax, %rsi
movq %r14, %rdx
callq 0x30e3
movq %rbx, %rdi
callq 0x5e40
movq %rax, 0xb0(%rsp)
movl $0x1, %edi
movl $0xc, %esi
movl $0x14, %edx
callq 0x76b8
movq %rbx, %rdi
movq %rax, %rsi
movq %r14, %rdx
callq 0x30e3
movq %rbx, %rdi
callq 0x5e40
movq %rax, 0xb8(%rsp)
movl $0x2, %edi
movl $0x39, %esi
movl $0x2a, %edx
callq 0x76b8
movq %rbx, %rdi
movq %rax, %rsi
movq %r14, %rdx
callq 0x30e3
movq %rbx, %rdi
callq 0x5e40
movq %rax, 0xc0(%rsp)
movl $0x2, %edi
movl $0x6, %esi
movl $0x15, %edx
callq 0x76b8
movq %rbx, %rdi
movq %rax, %rsi
movq %r14, %rdx
callq 0x30e3
movq %rbx, %rdi
callq 0x5e40
movq %rax, 0xc8(%rsp)
movl $0x1, %edi
movl $0x32, %esi
movl $0x22, %edx
callq 0x76b8
leaq 0x148(%rsp), %r12
movq %r12, %rdi
movq %rax, %rsi
movq %r14, %rdx
callq 0x30e3
movq %r12, %rdi
callq 0x5e40
movq %rax, %r15
movq %rax, (%rsp)
movl $0x2, %edi
movl $0x6, %esi
movl $0x15, %edx
callq 0x76b8
movq %r12, %rdi
movq %rax, %rsi
movq %r14, %rdx
callq 0x30e3
movq %r12, %rdi
callq 0x5e40
movq %rax, 0x8(%rsp)
movl $0x2, %edi
movl $0x39, %esi
movl $0x2a, %edx
callq 0x76b8
movq %r12, %rdi
movq %rax, %rsi
movq %r14, %rdx
callq 0x30e3
movq %r12, %rdi
callq 0x5e40
movq %rax, 0x10(%rsp)
movl $0x1, %edi
movl $0xc, %esi
movl $0x14, %edx
callq 0x76b8
movq %r12, %rdi
movq %rax, %rsi
movq %r14, %rdx
callq 0x30e3
movq %r12, %rdi
callq 0x5e40
movq %rax, 0x18(%rsp)
movl $0x1, %edi
movl $0x33, %esi
movl $0x23, %edx
callq 0x76b8
movq %r12, %rdi
movq %rax, %rsi
movq %r14, %rdx
callq 0x30e3
movq %r12, %rdi
callq 0x5e40
movq %rax, 0x20(%rsp)
movl $0x1, %edi
movl $0xb, %esi
movl $0x1b, %edx
callq 0x76b8
movq %r12, %rdi
movq %rax, %rsi
movq %r14, %rdx
callq 0x30e3
movq %r12, %rdi
callq 0x5e40
movq %rax, 0x28(%rsp)
movq %rbx, %rdi
movq %r12, %rsi
movl $0x1, %edx
callq 0xa0e0
testb %al, %al
jne 0x16edf
leaq 0x310(%rsp), %rdi
callq 0x5e40
movq %rax, %rbx
leaq 0x148(%rsp), %rdi
callq 0x5e40
cmpq %rax, %rbx
je 0x16efe
movl $0x1, %edi
movl $0x36, %esi
movl $0x2e, %edx
callq 0x76b8
leaq 0xb1d1c(%rip), %rbx     # 0xc8af0
leaq 0x310(%rsp), %r14
movq %r14, %rdi
movq %rax, %rsi
movq %rbx, %rdx
callq 0x30e3
movl $0x1, %edi
movl $0x36, %esi
movl $0x2e, %edx
callq 0x76b8
leaq 0x148(%rsp), %r12
movq %r12, %rdi
movq %rax, %rsi
movq %rbx, %rdx
callq 0x30e3
movq %r14, %rdi
movq %r12, %rsi
movl $0x1, %edx
callq 0xa0e0
testb %al, %al
je 0x16f1d
leaq 0x310(%rsp), %rdi
callq 0x5e40
movq %rax, %rbx
leaq 0x148(%rsp), %rdi
callq 0x5e40
cmpq %rax, %rbx
jne 0x16f3c
xorl %eax, %eax
movq 0xa0(%rsp,%rax,8), %rcx
cmpq %rcx, %r15
je 0x16ea1
movq $-0x1, %rdx
cmpq $0x4, %rdx
je 0x16e7e
leaq 0x1(%rdx), %rsi
cmpq %rcx, 0x10(%rsp,%rdx,8)
movq %rsi, %rdx
jne 0x16e68
jmp 0x16e83
movl $0x5, %esi
cmpq $0x4, %rsi
jbe 0x16ea1
incq %rax
cmpq $0x6, %rax
jne 0x16e54
addq $0x4d8, %rsp            # imm = 0x4D8
popq %rbx
popq %r12
popq %r14
popq %r15
retq
leaq 0x1ad98(%rip), %rdi     # 0x31c40
leaq 0x1ac76(%rip), %rsi     # 0x31b25
leaq 0x1adae(%rip), %rcx     # 0x31c64
movl $0x124, %edx            # imm = 0x124
callq 0x20d0
leaq 0x1aca7(%rip), %rdi     # 0x31b6e
leaq 0x1ac57(%rip), %rsi     # 0x31b25
leaq 0x1ad8f(%rip), %rcx     # 0x31c64
movl $0xf9, %edx
callq 0x20d0
leaq 0x1accb(%rip), %rdi     # 0x31bb1
leaq 0x1ac38(%rip), %rsi     # 0x31b25
leaq 0x1ad70(%rip), %rcx     # 0x31c64
movl $0x118, %edx            # imm = 0x118
callq 0x20d0
leaq 0x1ad76(%rip), %rdi     # 0x31c7b
leaq 0x1ac19(%rip), %rsi     # 0x31b25
leaq 0x1ad51(%rip), %rcx     # 0x31c64
movl $0x119, %edx            # imm = 0x119
callq 0x20d0
leaq 0x1ac8e(%rip), %rdi     # 0x31bb2
leaq 0x1abfa(%rip), %rsi     # 0x31b25
leaq 0x1ad32(%rip), %rcx     # 0x31c64
movl $0x11e, %edx            # imm = 0x11E
callq 0x20d0
leaq 0x1ac2b(%rip), %rdi     # 0x31b6e
leaq 0x1abdb(%rip), %rsi     # 0x31b25
leaq 0x1ad13(%rip), %rcx     # 0x31c64
movl $0x11f, %edx            # imm = 0x11F
callq 0x20d0