// File: /workspace/github_cpp_makefile_star2_O2/jswaff[P]prophet3/src/perft.cpp
// Function: perft_test_fast()
void perft_test_fast() {
    print("starting perft_test_fast\n");
    int32 start_time = milli_timer();
    uint64 total_nodes = 0;

    position pos;
    total_nodes += test_case(&pos,"rnbqkbnr/pppppppp/8/8/8/8/PPPPPPPP/RNBQKBNR w KQkq - 0 1",4,197281);
    total_nodes += test_case(&pos,"r3k2r/p1ppqpb1/bn2pnp1/3PN3/1p2P3/2N2Q1p/PPPBBPPP/R3K2R w KQkq - 0 1",3,97862);
    total_nodes += test_case(&pos,"8/2p5/3p4/KP5r/1R3p1k/8/4P1P1/8 w - - 0 1",6,11030083L);
    total_nodes += test_case(&pos,"r3k2r/Pppp1ppp/1b3nbN/nP6/BBP1P3/q4N2/Pp1P2PP/R2Q1RK1 w kq - 0 1",5,15833292L);
    total_nodes += test_case(&pos,"rnbq1k1r/pp1Pbppp/2p5/8/2B5/8/PPP1NnPP/RNBQK2R w KQ - 1 8",4,2103487);
    total_nodes += test_case(&pos,"r4rk1/1pp1qppp/p1np1n2/2b1p1B1/2B1P1b1/P1NP1N2/1PP1QPPP/R4RK1 w - - 0 10",4,3894594L);

    // illegal EP
    total_nodes += test_case(&pos,"3k4/3p4/8/K1P4r/8/8/8/8 b - - 0 1", 6, 1134888);
    total_nodes += test_case(&pos,"8/8/8/8/k1p4R/8/3P4/3K4 w - - 0 1", 6, 1134888);
    total_nodes += test_case(&pos,"8/8/4k3/8/2p5/8/B2P2K1/8 w - - 0 1", 6, 1015133);
    total_nodes += test_case(&pos,"8/b2p2k1/8/2P5/8/4K3/8/8 b - - 0 1", 6, 1015133);

    // ep capture checks opponent
    total_nodes += test_case(&pos,"8/8/1k6/2b5/2pP4/8/5K2/8 b - d3 0 1", 6, 1440467);
    total_nodes += test_case(&pos,"8/5k2/8/2Pp4/2B5/1K6/8/8 w - d6 0 1", 6, 1440467);

    // short castle gives check
    total_nodes += test_case(&pos,"5k2/8/8/8/8/8/8/4K2R w K - 0 1", 6, 661072);
    total_nodes += test_case(&pos,"4k2r/8/8/8/8/8/8/5K2 b k - 0 1", 6, 661072);

    // long castle gives check
    total_nodes += test_case(&pos,"3k4/8/8/8/8/8/8/R3K3 w Q - 0 1", 6, 803711);
    total_nodes += test_case(&pos,"r3k3/8/8/8/8/8/8/3K4 b q - 0 1", 6, 803711);

    // losing castling rights
    total_nodes += test_case(&pos,"r3k2r/1b4bq/8/8/8/8/7B/R3K2R w KQkq - 0 1", 4, 1274206);
    total_nodes += test_case(&pos,"r3k2r/7b/8/8/8/8/1B4BQ/R3K2R b KQkq - 0 1", 4, 1274206);

    // castling prevented
    total_nodes += test_case(&pos,"r3k2r/8/3Q4/8/8/5q2/8/R3K2R b KQkq - 0 1", 4, 1720476);
    total_nodes += test_case(&pos,"r3k2r/8/5Q2/8/8/3q4/8/R3K2R w KQkq - 0 1", 4, 1720476);

    // promote out of check
    total_nodes += test_case(&pos,"2K2r2/4P3/8/8/8/8/8/3k4 w - - 0 1", 6, 3821001);
    total_nodes += test_case(&pos,"3K4/8/8/8/8/8/4p3/2k2R2 b - - 0 1", 6, 3821001);

    // discovered check
    total_nodes += test_case(&pos,"8/8/1P2K3/8/2n5/1q6/8/5k2 b - - 0 1", 5, 1004658);
    total_nodes += test_case(&pos,"5K2/8/1Q6/2N5/8/1p2k3/8/8 w - - 0 1", 5, 1004658);

    // promote to give check
    total_nodes += test_case(&pos,"4k3/1P6/8/8/8/8/K7/8 w - - 0 1", 6, 217342);
    total_nodes += test_case(&pos,"8/k7/8/8/8/8/1p6/4K3 b - - 0 1", 6, 217342);

    // unpromote to check
    total_nodes += test_case(&pos,"8/P1k5/K7/8/8/8/8/8 w - - 0 1", 6, 92683);
    total_nodes += test_case(&pos,"8/8/8/8/8/k7/p1K5/8 b - - 0 1", 6, 92683);

    // self stalemate
    total_nodes += test_case(&pos,"K1k5/8/P7/8/8/8/8/8 w - - 0 1", 6, 2217);
    total_nodes += test_case(&pos,"8/8/8/8/8/p7/8/k1K5 b - - 0 1", 6, 2217);

    // stalemate checkmate
    total_nodes += test_case(&pos,"8/k1P5/8/1K6/8/8/8/8 w - - 0 1", 7, 567584);
    total_nodes += test_case(&pos,"8/8/8/8/1k6/8/K1p5/8 b - - 0 1", 7, 567584);

    // double check
    total_nodes += test_case(&pos,"8/8/2k5/5q2/5n2/8/5K2/8 b - - 0 1", 4, 23527);
    total_nodes += test_case(&pos,"8/5k2/8/5N2/5Q2/2K5/8/8 w - - 0 1", 4, 23527);

    int32 elapsed = milli_timer() - start_time + 1; // div by 0
    print("\n\naverage nps: %lu\n\n",total_nodes*1000/elapsed);

    print("... perft_test_fast complete!\n");
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r12
pushq %rbx
subq $0x1d0, %rsp            # imm = 0x1D0
leaq 0x1fb83(%rip), %rdi     # 0x290da
xorl %eax, %eax
callq 0x5fdd
callq 0xd470
movl %eax, %ebx
leaq 0x1fb88(%rip), %rsi     # 0x290f4
leaq 0x8(%rsp), %r14
pushq $0x4
popq %rbp
movl $0x302a1, %ecx          # imm = 0x302A1
movq %r14, %rdi
movl %ebp, %edx
callq 0x94b2
leaq 0x1fba3(%rip), %rsi     # 0x2912d
pushq $0x3
popq %rdx
movl $0x17e46, %ecx          # imm = 0x17E46
movq %r14, %rdi
callq 0x94b2
leaq 0x1fbd1(%rip), %rsi     # 0x29172
pushq $0x6
popq %r15
movl $0xa84e43, %ecx         # imm = 0xA84E43
movq %r14, %rdi
movl %r15d, %edx
callq 0x94b2
leaq 0x1fbe0(%rip), %rsi     # 0x2919c
pushq $0x5
popq %r12
movl $0xf198cc, %ecx         # imm = 0xF198CC
movq %r14, %rdi
movl %r12d, %edx
callq 0x94b2
leaq 0x1fc06(%rip), %rsi     # 0x291dd
movl $0x2018bf, %ecx         # imm = 0x2018BF
movq %r14, %rdi
movl %ebp, %edx
callq 0x94b2
leaq 0x1fc2a(%rip), %rsi     # 0x29217
movl $0x3b6d42, %ecx         # imm = 0x3B6D42
movq %r14, %rdi
movl %ebp, %edx
callq 0x94b2
leaq 0x1fc5d(%rip), %rsi     # 0x29260
movl $0x115128, %ecx         # imm = 0x115128
movq %r14, %rdi
movl %r15d, %edx
callq 0x94b2
leaq 0x1fc68(%rip), %rsi     # 0x29282
movl $0x115128, %ecx         # imm = 0x115128
movq %r14, %rdi
movl %r15d, %edx
callq 0x94b2
leaq 0x1fc73(%rip), %rsi     # 0x292a4
movl $0xf7d5d, %ecx          # imm = 0xF7D5D
movq %r14, %rdi
movl %r15d, %edx
callq 0x94b2
leaq 0x1fc7f(%rip), %rsi     # 0x292c7
movl $0xf7d5d, %ecx          # imm = 0xF7D5D
movq %r14, %rdi
movl %r15d, %edx
callq 0x94b2
leaq 0x1fc8b(%rip), %rsi     # 0x292ea
movl $0x15fad3, %ecx         # imm = 0x15FAD3
movq %r14, %rdi
movl %r15d, %edx
callq 0x94b2
leaq 0x1fc98(%rip), %rsi     # 0x2930e
movl $0x15fad3, %ecx         # imm = 0x15FAD3
movq %r14, %rdi
movl %r15d, %edx
callq 0x94b2
leaq 0x1fca5(%rip), %rsi     # 0x29332
movl $0xa1650, %ecx          # imm = 0xA1650
movq %r14, %rdi
movl %r15d, %edx
callq 0x94b2
leaq 0x1fcad(%rip), %rsi     # 0x29351
movl $0xa1650, %ecx          # imm = 0xA1650
movq %r14, %rdi
movl %r15d, %edx
callq 0x94b2
leaq 0x1fcb5(%rip), %rsi     # 0x29370
movl $0xc437f, %ecx          # imm = 0xC437F
movq %r14, %rdi
movl %r15d, %edx
callq 0x94b2
leaq 0x1fcbd(%rip), %rsi     # 0x2938f
movl $0xc437f, %ecx          # imm = 0xC437F
movq %r14, %rdi
movl %r15d, %edx
callq 0x94b2
leaq 0x1fcc5(%rip), %rsi     # 0x293ae
movl $0x13715e, %ecx         # imm = 0x13715E
movq %r14, %rdi
movl %ebp, %edx
callq 0x94b2
leaq 0x1fcd9(%rip), %rsi     # 0x293d8
movl $0x13715e, %ecx         # imm = 0x13715E
movq %r14, %rdi
movl %ebp, %edx
callq 0x94b2
leaq 0x1fced(%rip), %rsi     # 0x29402
movl $0x1a409c, %ecx         # imm = 0x1A409C
movq %r14, %rdi
movl %ebp, %edx
callq 0x94b2
leaq 0x1fd00(%rip), %rsi     # 0x2942b
movl $0x1a409c, %ecx         # imm = 0x1A409C
movq %r14, %rdi
movl %ebp, %edx
callq 0x94b2
leaq 0x1fd13(%rip), %rsi     # 0x29454
movl $0x3a4dc9, %ecx         # imm = 0x3A4DC9
movq %r14, %rdi
movl %r15d, %edx
callq 0x94b2
leaq 0x1fd1e(%rip), %rsi     # 0x29476
movl $0x3a4dc9, %ecx         # imm = 0x3A4DC9
movq %r14, %rdi
movl %r15d, %edx
callq 0x94b2
leaq 0x1fd29(%rip), %rsi     # 0x29498
movl $0xf5472, %ecx          # imm = 0xF5472
movq %r14, %rdi
movl %r12d, %edx
callq 0x94b2
leaq 0x1fd36(%rip), %rsi     # 0x294bc
movl $0xf5472, %ecx          # imm = 0xF5472
movq %r14, %rdi
movl %r12d, %edx
callq 0x94b2
leaq 0x1fd43(%rip), %rsi     # 0x294e0
movl $0x350fe, %ecx          # imm = 0x350FE
movq %r14, %rdi
movl %r15d, %edx
callq 0x94b2
leaq 0x1fd4b(%rip), %rsi     # 0x294ff
movl $0x350fe, %ecx          # imm = 0x350FE
movq %r14, %rdi
movl %r15d, %edx
callq 0x94b2
leaq 0x1fd53(%rip), %rsi     # 0x2951e
movl $0x16a0b, %ecx          # imm = 0x16A0B
movq %r14, %rdi
movl %r15d, %edx
callq 0x94b2
leaq 0x1fd5a(%rip), %rsi     # 0x2953c
movl $0x16a0b, %ecx          # imm = 0x16A0B
movq %r14, %rdi
movl %r15d, %edx
callq 0x94b2
leaq 0x1fd61(%rip), %rsi     # 0x2955a
movl $0x8a9, %ecx            # imm = 0x8A9
movq %r14, %rdi
movl %r15d, %edx
callq 0x94b2
leaq 0x1fd68(%rip), %rsi     # 0x29578
movl $0x8a9, %ecx            # imm = 0x8A9
movq %r14, %rdi
movl %r15d, %edx
callq 0x94b2
leaq 0x1fd6f(%rip), %rsi     # 0x29596
pushq $0x7
popq %r15
movl $0x8a920, %ecx          # imm = 0x8A920
movq %r14, %rdi
movl %r15d, %edx
callq 0x94b2
leaq 0x1fd73(%rip), %rsi     # 0x295b5
movl $0x8a920, %ecx          # imm = 0x8A920
movq %r14, %rdi
movl %r15d, %edx
callq 0x94b2
leaq 0x1fd7b(%rip), %rsi     # 0x295d4
movl $0x5be7, %ecx           # imm = 0x5BE7
movq %r14, %rdi
movl %ebp, %edx
callq 0x94b2
leaq 0x1fd87(%rip), %rsi     # 0x295f6
movl $0x5be7, %ecx           # imm = 0x5BE7
movq %r14, %rdi
movl %ebp, %edx
callq 0x94b2
callq 0xd470
subl %ebx, %eax
incl %eax
movslq %eax, %rcx
movabsq $0xe22de30e8, %rax      # imm = 0xE22DE30E8
xorl %edx, %edx
divq %rcx
leaq 0x1fd78(%rip), %rdi     # 0x29618
movq %rax, %rsi
xorl %eax, %eax
callq 0x5fdd
leaq 0x1fd7c(%rip), %rdi     # 0x2962d
xorl %eax, %eax
callq 0x5fdd
addq $0x1d0, %rsp            # imm = 0x1D0
popq %rbx
popq %r12
popq %r14
popq %r15
popq %rbp
retq