// File: /workspace/github_cpp_makefile_star2_O1/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 %r13
pushq %r12
pushq %rbx
subq $0x1c8, %rsp            # imm = 0x1C8
leaq 0x21445(%rip), %rdi     # 0x2b0aa
xorl %eax, %eax
callq 0x640d
callq 0xdf58
movl %eax, %ebx
leaq 0x2144a(%rip), %rsi     # 0x2b0c4
movq %rsp, %r14
movl $0x302a1, %ecx          # imm = 0x302A1
movq %r14, %rdi
movl $0x4, %edx
callq 0x9bbc
movq %rax, %r15
leaq 0x21464(%rip), %rsi     # 0x2b0fd
movl $0x17e46, %ecx          # imm = 0x17E46
movq %r14, %rdi
movl $0x3, %edx
callq 0x9bbc
movq %rax, %r12
addq %r15, %r12
leaq 0x2148a(%rip), %rsi     # 0x2b142
movl $0xa84e43, %ecx         # imm = 0xA84E43
movq %r14, %rdi
movl $0x6, %edx
callq 0x9bbc
movq %rax, %r13
leaq 0x21498(%rip), %rsi     # 0x2b16c
movl $0xf198cc, %ecx         # imm = 0xF198CC
movq %r14, %rdi
movl $0x5, %edx
callq 0x9bbc
movq %rax, %r15
addq %r13, %r15
addq %r12, %r15
leaq 0x214b7(%rip), %rsi     # 0x2b1ad
movl $0x2018bf, %ecx         # imm = 0x2018BF
movq %r14, %rdi
movl $0x4, %edx
callq 0x9bbc
movq %rax, %r12
leaq 0x214d5(%rip), %rsi     # 0x2b1e7
movl $0x3b6d42, %ecx         # imm = 0x3B6D42
movq %r14, %rdi
movl $0x4, %edx
callq 0x9bbc
movq %rax, %r13
addq %r12, %r13
leaq 0x214ff(%rip), %rsi     # 0x2b230
movl $0x115128, %ecx         # imm = 0x115128
movq %r14, %rdi
movl $0x6, %edx
callq 0x9bbc
movq %rax, %r12
addq %r13, %r12
addq %r15, %r12
leaq 0x214ff(%rip), %rsi     # 0x2b252
movl $0x115128, %ecx         # imm = 0x115128
movq %r14, %rdi
movl $0x6, %edx
callq 0x9bbc
movq %rax, %r15
leaq 0x21505(%rip), %rsi     # 0x2b274
movl $0xf7d5d, %ecx          # imm = 0xF7D5D
movq %r14, %rdi
movl $0x6, %edx
callq 0x9bbc
movq %rax, %r13
addq %r15, %r13
leaq 0x21509(%rip), %rsi     # 0x2b297
movl $0xf7d5d, %ecx          # imm = 0xF7D5D
movq %r14, %rdi
movl $0x6, %edx
callq 0x9bbc
movq %rax, %rbp
addq %r13, %rbp
leaq 0x2150d(%rip), %rsi     # 0x2b2ba
movl $0x15fad3, %ecx         # imm = 0x15FAD3
movq %r14, %rdi
movl $0x6, %edx
callq 0x9bbc
movq %rax, %r15
addq %rbp, %r15
addq %r12, %r15
leaq 0x2150f(%rip), %rsi     # 0x2b2de
movl $0x15fad3, %ecx         # imm = 0x15FAD3
movq %r14, %rdi
movl $0x6, %edx
callq 0x9bbc
movq %rax, %r12
leaq 0x21517(%rip), %rsi     # 0x2b302
movl $0xa1650, %ecx          # imm = 0xA1650
movq %r14, %rdi
movl $0x6, %edx
callq 0x9bbc
movq %rax, %r13
addq %r12, %r13
leaq 0x21517(%rip), %rsi     # 0x2b321
movl $0xa1650, %ecx          # imm = 0xA1650
movq %r14, %rdi
movl $0x6, %edx
callq 0x9bbc
movq %rax, %r12
addq %r13, %r12
leaq 0x21517(%rip), %rsi     # 0x2b340
movl $0xc437f, %ecx          # imm = 0xC437F
movq %r14, %rdi
movl $0x6, %edx
callq 0x9bbc
movq %rax, %r13
addq %r12, %r13
leaq 0x21517(%rip), %rsi     # 0x2b35f
movl $0xc437f, %ecx          # imm = 0xC437F
movq %r14, %rdi
movl $0x6, %edx
callq 0x9bbc
movq %rax, %r12
addq %r13, %r12
addq %r15, %r12
leaq 0x21514(%rip), %rsi     # 0x2b37e
movl $0x13715e, %ecx         # imm = 0x13715E
movq %r14, %rdi
movl $0x4, %edx
callq 0x9bbc
movq %rax, %r15
leaq 0x21522(%rip), %rsi     # 0x2b3a8
movl $0x13715e, %ecx         # imm = 0x13715E
movq %r14, %rdi
movl $0x4, %edx
callq 0x9bbc
movq %rax, %r13
addq %r15, %r13
leaq 0x2152d(%rip), %rsi     # 0x2b3d2
movl $0x1a409c, %ecx         # imm = 0x1A409C
movq %r14, %rdi
movl $0x4, %edx
callq 0x9bbc
movq %rax, %r15
addq %r13, %r15
leaq 0x21537(%rip), %rsi     # 0x2b3fb
movl $0x1a409c, %ecx         # imm = 0x1A409C
movq %r14, %rdi
movl $0x4, %edx
callq 0x9bbc
movq %rax, %r13
addq %r15, %r13
leaq 0x21541(%rip), %rsi     # 0x2b424
movl $0x3a4dc9, %ecx         # imm = 0x3A4DC9
movq %r14, %rdi
movl $0x6, %edx
callq 0x9bbc
movq %rax, %rbp
addq %r13, %rbp
leaq 0x21544(%rip), %rsi     # 0x2b446
movl $0x3a4dc9, %ecx         # imm = 0x3A4DC9
movq %r14, %rdi
movl $0x6, %edx
callq 0x9bbc
movq %rax, %r15
addq %rbp, %r15
addq %r12, %r15
leaq 0x21544(%rip), %rsi     # 0x2b468
movl $0xf5472, %ecx          # imm = 0xF5472
movq %r14, %rdi
movl $0x5, %edx
callq 0x9bbc
movq %rax, %r12
leaq 0x2154c(%rip), %rsi     # 0x2b48c
movl $0xf5472, %ecx          # imm = 0xF5472
movq %r14, %rdi
movl $0x5, %edx
callq 0x9bbc
movq %rax, %r13
addq %r12, %r13
leaq 0x21551(%rip), %rsi     # 0x2b4b0
movl $0x350fe, %ecx          # imm = 0x350FE
movq %r14, %rdi
movl $0x6, %edx
callq 0x9bbc
movq %rax, %r12
addq %r13, %r12
leaq 0x21551(%rip), %rsi     # 0x2b4cf
movl $0x350fe, %ecx          # imm = 0x350FE
movq %r14, %rdi
movl $0x6, %edx
callq 0x9bbc
movq %rax, %r13
addq %r12, %r13
leaq 0x21551(%rip), %rsi     # 0x2b4ee
movl $0x16a0b, %ecx          # imm = 0x16A0B
movq %r14, %rdi
movl $0x6, %edx
callq 0x9bbc
movq %rax, %r12
addq %r13, %r12
leaq 0x21550(%rip), %rsi     # 0x2b50c
movl $0x16a0b, %ecx          # imm = 0x16A0B
movq %r14, %rdi
movl $0x6, %edx
callq 0x9bbc
movq %rax, %r13
addq %r12, %r13
leaq 0x2154f(%rip), %rsi     # 0x2b52a
movl $0x8a9, %ecx            # imm = 0x8A9
movq %r14, %rdi
movl $0x6, %edx
callq 0x9bbc
movq %rax, %r12
addq %r13, %r12
addq %r15, %r12
leaq 0x2154b(%rip), %rsi     # 0x2b548
movl $0x8a9, %ecx            # imm = 0x8A9
movq %r14, %rdi
movl $0x6, %edx
callq 0x9bbc
movq %rax, %r15
leaq 0x2154d(%rip), %rsi     # 0x2b566
movl $0x8a920, %ecx          # imm = 0x8A920
movq %r14, %rdi
movl $0x7, %edx
callq 0x9bbc
movq %rax, %r13
addq %r15, %r13
leaq 0x2154d(%rip), %rsi     # 0x2b585
movl $0x8a920, %ecx          # imm = 0x8A920
movq %r14, %rdi
movl $0x7, %edx
callq 0x9bbc
movq %rax, %r15
addq %r13, %r15
leaq 0x2154d(%rip), %rsi     # 0x2b5a4
movl $0x5be7, %ecx           # imm = 0x5BE7
movq %r14, %rdi
movl $0x4, %edx
callq 0x9bbc
movq %rax, %r13
addq %r15, %r13
leaq 0x21550(%rip), %rsi     # 0x2b5c6
movl $0x5be7, %ecx           # imm = 0x5BE7
movq %r14, %rdi
movl $0x4, %edx
callq 0x9bbc
movq %rax, %r14
addq %r13, %r14
addq %r12, %r14
callq 0xdf58
subl %ebx, %eax
incl %eax
imulq $0x3e8, %r14, %rcx      # imm = 0x3E8
movslq %eax, %rsi
movq %rcx, %rax
xorl %edx, %edx
divq %rsi
leaq 0x21535(%rip), %rdi     # 0x2b5e8
movq %rax, %rsi
xorl %eax, %eax
callq 0x640d
leaq 0x21539(%rip), %rdi     # 0x2b5fd
xorl %eax, %eax
callq 0x640d
addq $0x1c8, %rsp            # imm = 0x1C8
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
nopl (%rax)