// File: /workspace/github_cpp_makefile_star2_O2/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 %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x4d8, %rsp            # imm = 0x4D8
leaq 0x310(%rsp), %rbx
movq %rbx, %rdi
callq 0xa187
leaq 0x148(%rsp), %r14
movq %r14, %rdi
callq 0xa187
movq %rbx, %rdi
callq 0x5a50
movq %rax, %rbx
movq %r14, %rdi
callq 0x5a50
cmpq %rax, %rbx
jne 0x15737
pushq $0x1
popq %r13
pushq $0x33
popq %rsi
pushq $0x23
popq %rdx
movl %r13d, %edi
callq 0x7284
leaq 0xb66e2(%rip), %r15     # 0xcbaf0
leaq 0x310(%rsp), %r14
movq %r14, %rdi
movq %rax, %rsi
movq %r15, %rdx
callq 0x2fa5
movq %r14, %rdi
callq 0x5a50
movq %rax, 0xa0(%rsp)
pushq $0xb
popq %rsi
pushq $0x1b
popq %rdx
movl %r13d, %edi
callq 0x7284
movq %r14, %rdi
movq %rax, %rsi
movq %r15, %rdx
callq 0x2fa5
movq %r14, %rdi
callq 0x5a50
movq %rax, 0xa8(%rsp)
pushq $0x32
popq %rsi
pushq $0x22
popq %rdx
movl %r13d, %edi
callq 0x7284
movq %r14, %rdi
movq %rax, %rsi
movq %r15, %rdx
callq 0x2fa5
movq %r14, %rdi
callq 0x5a50
movq %rax, 0xb0(%rsp)
pushq $0xc
popq %rsi
pushq $0x14
popq %rdx
movl %r13d, %edi
callq 0x7284
movq %r14, %rdi
movq %rax, %rsi
movq %r15, %rdx
callq 0x2fa5
movq %r14, %rdi
callq 0x5a50
movq %rax, 0xb8(%rsp)
pushq $0x2
popq %r12
pushq $0x39
popq %rsi
pushq $0x2a
popq %rdx
movl %r12d, %edi
callq 0x7284
movq %r14, %rdi
movq %rax, %rsi
movq %r15, %rdx
callq 0x2fa5
movq %r14, %rdi
callq 0x5a50
movq %rax, 0xc0(%rsp)
pushq $0x6
popq %rbp
pushq $0x15
popq %rbx
movl %r12d, %edi
movl %ebp, %esi
movl %ebx, %edx
callq 0x7284
movq %r14, %rdi
movq %rax, %rsi
movq %r15, %rdx
callq 0x2fa5
movq %r14, %rdi
callq 0x5a50
movq %rax, 0xc8(%rsp)
movl %r13d, %edi
pushq $0x32
popq %rsi
pushq $0x22
popq %rdx
callq 0x7284
leaq 0x148(%rsp), %r13
movq %r13, %rdi
movq %rax, %rsi
movq %r15, %rdx
callq 0x2fa5
movq %r13, %rdi
callq 0x5a50
movq %rax, (%rsp)
movl %r12d, %edi
movl %ebp, %esi
movl %ebx, %edx
callq 0x7284
movq %r13, %rdi
movq %rax, %rsi
movq %r15, %rdx
callq 0x2fa5
movq %r13, %rdi
callq 0x5a50
movq %rax, 0x8(%rsp)
movl %r12d, %edi
pushq $0x39
popq %rsi
pushq $0x2a
popq %rdx
callq 0x7284
movq %r13, %rdi
movq %rax, %rsi
movq %r15, %rdx
callq 0x2fa5
movq %r13, %rdi
callq 0x5a50
movq %rax, 0x10(%rsp)
pushq $0x1
popq %rbx
movl %ebx, %edi
pushq $0xc
popq %rsi
pushq $0x14
popq %rdx
callq 0x7284
movq %r13, %rdi
movq %rax, %rsi
movq %r15, %rdx
callq 0x2fa5
movq %r13, %rdi
callq 0x5a50
movq %rax, 0x18(%rsp)
movl %ebx, %edi
pushq $0x33
popq %rsi
pushq $0x23
popq %rdx
callq 0x7284
movq %r13, %rdi
movq %rax, %rsi
movq %r15, %rdx
callq 0x2fa5
movq %r13, %rdi
callq 0x5a50
movq %rax, 0x20(%rsp)
movl %ebx, %edi
pushq $0xb
popq %rsi
pushq $0x1b
popq %rdx
callq 0x7284
movq %r13, %rdi
movq %rax, %rsi
movq %r15, %rdx
callq 0x2fa5
movq %r13, %rdi
callq 0x5a50
movq %rax, 0x28(%rsp)
movq %r14, %rdi
movq %r13, %rsi
movl %ebx, %edx
callq 0x98c8
testb %al, %al
jne 0x15756
leaq 0x310(%rsp), %rdi
callq 0x5a50
movq %rax, %rbx
leaq 0x148(%rsp), %rdi
callq 0x5a50
cmpq %rax, %rbx
je 0x15775
pushq $0x1
popq %rbx
pushq $0x36
popq %rbp
pushq $0x2e
popq %r14
movl %ebx, %edi
movl %ebp, %esi
movl %r14d, %edx
callq 0x7284
leaq 0xb6485(%rip), %r15     # 0xcbaf0
leaq 0x310(%rsp), %r12
movq %r12, %rdi
movq %rax, %rsi
movq %r15, %rdx
callq 0x2fa5
movl %ebx, %edi
movl %ebp, %esi
movl %r14d, %edx
callq 0x7284
leaq 0x148(%rsp), %r14
movq %r14, %rdi
movq %rax, %rsi
movq %r15, %rdx
callq 0x2fa5
movq %r12, %rdi
movq %r14, %rsi
movl %ebx, %edx
callq 0x98c8
testb %al, %al
je 0x15794
leaq 0x310(%rsp), %rdi
callq 0x5a50
movq %rax, %rbx
leaq 0x148(%rsp), %rdi
callq 0x5a50
cmpq %rax, %rbx
jne 0x157b3
xorl %r14d, %r14d
movq %rsp, %rbx
pushq $0x6
popq %rbp
cmpq $0x6, %r14
je 0x15725
movq 0xa0(%rsp,%r14,8), %rdi
movq %rbx, %rsi
movl %ebp, %edx
callq 0x141eb
incq %r14
testb %al, %al
je 0x156e7
leaq 0x1a563(%rip), %rdi     # 0x2fc70
leaq 0x1a441(%rip), %rsi     # 0x2fb55
leaq 0x1a579(%rip), %rcx     # 0x2fc94
movl $0x124, %edx            # imm = 0x124
callq 0x20c0
addq $0x4d8, %rsp            # imm = 0x4D8
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
leaq 0x1a460(%rip), %rdi     # 0x2fb9e
leaq 0x1a410(%rip), %rsi     # 0x2fb55
leaq 0x1a548(%rip), %rcx     # 0x2fc94
movl $0xf9, %edx
callq 0x20c0
leaq 0x1a484(%rip), %rdi     # 0x2fbe1
leaq 0x1a3f1(%rip), %rsi     # 0x2fb55
leaq 0x1a529(%rip), %rcx     # 0x2fc94
movl $0x118, %edx            # imm = 0x118
callq 0x20c0
leaq 0x1a52f(%rip), %rdi     # 0x2fcab
leaq 0x1a3d2(%rip), %rsi     # 0x2fb55
leaq 0x1a50a(%rip), %rcx     # 0x2fc94
movl $0x119, %edx            # imm = 0x119
callq 0x20c0
leaq 0x1a447(%rip), %rdi     # 0x2fbe2
leaq 0x1a3b3(%rip), %rsi     # 0x2fb55
leaq 0x1a4eb(%rip), %rcx     # 0x2fc94
movl $0x11e, %edx            # imm = 0x11E
callq 0x20c0
leaq 0x1a3e4(%rip), %rdi     # 0x2fb9e
leaq 0x1a394(%rip), %rsi     # 0x2fb55
leaq 0x1a4cc(%rip), %rcx     # 0x2fc94
movl $0x11f, %edx            # imm = 0x11F
callq 0x20c0