// File: /workspace/github_cpp_makefile_star2_O3/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 0xaa51
leaq 0x148(%rsp), %r14
movq %r14, %rdi
callq 0xaa51
movq %rbx, %rdi
callq 0x5ee8
movq %rax, %rbx
movq %r14, %rdi
callq 0x5ee8
cmpq %rax, %rbx
jne 0x16d71
movl $0x1, %edi
movl $0x33, %esi
movl $0x23, %edx
callq 0x775c
leaq 0xb2101(%rip), %r14     # 0xc8af0
leaq 0x310(%rsp), %rbx
movq %rbx, %rdi
movq %rax, %rsi
movq %r14, %rdx
callq 0x30e1
movq %rbx, %rdi
callq 0x5ee8
movq %rax, 0xa0(%rsp)
movl $0x1, %edi
movl $0xb, %esi
movl $0x1b, %edx
callq 0x775c
movq %rbx, %rdi
movq %rax, %rsi
movq %r14, %rdx
callq 0x30e1
movq %rbx, %rdi
callq 0x5ee8
movq %rax, 0xa8(%rsp)
movl $0x1, %edi
movl $0x32, %esi
movl $0x22, %edx
callq 0x775c
movq %rbx, %rdi
movq %rax, %rsi
movq %r14, %rdx
callq 0x30e1
movq %rbx, %rdi
callq 0x5ee8
movq %rax, 0xb0(%rsp)
movl $0x1, %edi
movl $0xc, %esi
movl $0x14, %edx
callq 0x775c
movq %rbx, %rdi
movq %rax, %rsi
movq %r14, %rdx
callq 0x30e1
movq %rbx, %rdi
callq 0x5ee8
movq %rax, 0xb8(%rsp)
movl $0x2, %edi
movl $0x39, %esi
movl $0x2a, %edx
callq 0x775c
movq %rbx, %rdi
movq %rax, %rsi
movq %r14, %rdx
callq 0x30e1
movq %rbx, %rdi
callq 0x5ee8
movq %rax, 0xc0(%rsp)
movl $0x2, %edi
movl $0x6, %esi
movl $0x15, %edx
callq 0x775c
movq %rbx, %rdi
movq %rax, %rsi
movq %r14, %rdx
callq 0x30e1
movq %rbx, %rdi
callq 0x5ee8
movq %rax, 0xc8(%rsp)
movl $0x1, %edi
movl $0x32, %esi
movl $0x22, %edx
callq 0x775c
leaq 0x148(%rsp), %r12
movq %r12, %rdi
movq %rax, %rsi
movq %r14, %rdx
callq 0x30e1
movq %r12, %rdi
callq 0x5ee8
movq %rax, %r15
movq %rax, (%rsp)
movl $0x2, %edi
movl $0x6, %esi
movl $0x15, %edx
callq 0x775c
movq %r12, %rdi
movq %rax, %rsi
movq %r14, %rdx
callq 0x30e1
movq %r12, %rdi
callq 0x5ee8
movq %rax, 0x8(%rsp)
movl $0x2, %edi
movl $0x39, %esi
movl $0x2a, %edx
callq 0x775c
movq %r12, %rdi
movq %rax, %rsi
movq %r14, %rdx
callq 0x30e1
movq %r12, %rdi
callq 0x5ee8
movq %rax, 0x10(%rsp)
movl $0x1, %edi
movl $0xc, %esi
movl $0x14, %edx
callq 0x775c
movq %r12, %rdi
movq %rax, %rsi
movq %r14, %rdx
callq 0x30e1
movq %r12, %rdi
callq 0x5ee8
movq %rax, 0x18(%rsp)
movl $0x1, %edi
movl $0x33, %esi
movl $0x23, %edx
callq 0x775c
movq %r12, %rdi
movq %rax, %rsi
movq %r14, %rdx
callq 0x30e1
movq %r12, %rdi
callq 0x5ee8
movq %rax, 0x20(%rsp)
movl $0x1, %edi
movl $0xb, %esi
movl $0x1b, %edx
callq 0x775c
movq %r12, %rdi
movq %rax, %rsi
movq %r14, %rdx
callq 0x30e1
movq %r12, %rdi
callq 0x5ee8
movq %rax, 0x28(%rsp)
movq %rbx, %rdi
movq %r12, %rsi
movl $0x1, %edx
callq 0xa0b8
testb %al, %al
jne 0x16d90
leaq 0x310(%rsp), %rdi
callq 0x5ee8
movq %rax, %rbx
leaq 0x148(%rsp), %rdi
callq 0x5ee8
cmpq %rax, %rbx
je 0x16daf
movl $0x1, %edi
movl $0x36, %esi
movl $0x2e, %edx
callq 0x775c
leaq 0xb1e64(%rip), %rbx     # 0xc8af0
leaq 0x310(%rsp), %r14
movq %r14, %rdi
movq %rax, %rsi
movq %rbx, %rdx
callq 0x30e1
movl $0x1, %edi
movl $0x36, %esi
movl $0x2e, %edx
callq 0x775c
leaq 0x148(%rsp), %r12
movq %r12, %rdi
movq %rax, %rsi
movq %rbx, %rdx
callq 0x30e1
movq %r14, %rdi
movq %r12, %rsi
movl $0x1, %edx
callq 0xa0b8
testb %al, %al
je 0x16dce
leaq 0x310(%rsp), %rdi
callq 0x5ee8
movq %rax, %rbx
leaq 0x148(%rsp), %rdi
callq 0x5ee8
cmpq %rax, %rbx
jne 0x16ded
xorl %eax, %eax
movq 0xa0(%rsp,%rax,8), %rcx
cmpq %rcx, %r15
je 0x16d52
movq $-0x1, %rdx
cmpq $0x4, %rdx
je 0x16d3a
leaq 0x1(%rdx), %rsi
cmpq %rcx, 0x10(%rsp,%rdx,8)
movq %rsi, %rdx
jne 0x16d20
cmpq $0x4, %rsi
jbe 0x16d52
incq %rax
cmpq $0x6, %rax
jne 0x16d0c
addq $0x4d8, %rsp            # imm = 0x4D8
popq %rbx
popq %r12
popq %r14
popq %r15
retq
leaq 0x1af67(%rip), %rdi     # 0x31cc0
leaq 0x1ae45(%rip), %rsi     # 0x31ba5
leaq 0x1af7d(%rip), %rcx     # 0x31ce4
movl $0x124, %edx            # imm = 0x124
callq 0x20d0
leaq 0x1ae76(%rip), %rdi     # 0x31bee
leaq 0x1ae26(%rip), %rsi     # 0x31ba5
leaq 0x1af5e(%rip), %rcx     # 0x31ce4
movl $0xf9, %edx
callq 0x20d0
leaq 0x1ae9a(%rip), %rdi     # 0x31c31
leaq 0x1ae07(%rip), %rsi     # 0x31ba5
leaq 0x1af3f(%rip), %rcx     # 0x31ce4
movl $0x118, %edx            # imm = 0x118
callq 0x20d0
leaq 0x1af45(%rip), %rdi     # 0x31cfb
leaq 0x1ade8(%rip), %rsi     # 0x31ba5
leaq 0x1af20(%rip), %rcx     # 0x31ce4
movl $0x119, %edx            # imm = 0x119
callq 0x20d0
leaq 0x1ae5d(%rip), %rdi     # 0x31c32
leaq 0x1adc9(%rip), %rsi     # 0x31ba5
leaq 0x1af01(%rip), %rcx     # 0x31ce4
movl $0x11e, %edx            # imm = 0x11E
callq 0x20d0
leaq 0x1adfa(%rip), %rdi     # 0x31bee
leaq 0x1adaa(%rip), %rsi     # 0x31ba5
leaq 0x1aee2(%rip), %rcx     # 0x31ce4
movl $0x11f, %edx            # imm = 0x11F
callq 0x20d0