// File: /workspace/github_cpp_makefile_star2_O3/jswaff[P]prophet3/test/next__test.cpp
// Function: test_winning_caps_before_noncaps()
void test_winning_caps_before_noncaps() {
    position pos;
    set_pos(&pos,"5b2/p4PPk/1p6/8/K7/1R6/1p6/8 w - -");
    move moves[MAX_MOVES_PER_PLY];
    move *endp = gen_legal_moves(moves,&pos,true,true);

    move b3f3 = to_move(ROOK,B3,F3);
    move b3a3 = to_move(ROOK,B3,A3);
    move b3c3 = to_move(ROOK,B3,C3);

    assert(is_in_move_list(b3f3,moves,endp));
    assert(is_in_move_list(b3a3,moves,endp));
    assert(is_in_move_list(b3c3,moves,endp));

    //// capturing promotions
    move g7f8q = to_capture(PAWN,G7,F8,BISHOP);
    set_promopiece(&g7f8q,QUEEN);

    move g7f8r = to_capture(PAWN,G7,F8,BISHOP);
    set_promopiece(&g7f8r,ROOK);

    move g7f8b = to_capture(PAWN,G7,F8,BISHOP);
    set_promopiece(&g7f8b,BISHOP);

    move g7f8n = to_capture(PAWN,G7,F8,BISHOP);
    set_promopiece(&g7f8n,KNIGHT);

    assert(is_in_move_list(g7f8q,moves,endp));
    assert(is_in_move_list(g7f8r,moves,endp));
    assert(is_in_move_list(g7f8b,moves,endp));
    assert(is_in_move_list(g7f8n,moves,endp));

    /// non-capturing promotions
    move g7g8q = to_move(PAWN,G7,G8);
    set_promopiece(&g7g8q,QUEEN);

    move g7g8r = to_move(PAWN,G7,G8);
    set_promopiece(&g7g8r,ROOK);

    move g7g8b = to_move(PAWN,G7,G8);
    set_promopiece(&g7g8b,BISHOP);

    move g7g8n = to_move(PAWN,G7,G8);
    set_promopiece(&g7g8n,KNIGHT);

    assert(is_in_move_list(g7g8q,moves,endp));
    assert(is_in_move_list(g7g8r,moves,endp));
    assert(is_in_move_list(g7g8b,moves,endp));
    assert(is_in_move_list(g7g8n,moves,endp));

    ///
    move b3b6 = to_capture(ROOK,B3,B6,PAWN);
    move b3b2 = to_capture(ROOK,B3,B2,PAWN);

    assert(is_in_move_list(b3b6,moves,endp));
    assert(is_in_move_list(b3b2,moves,endp));

    /////////

    move_order_dto mo_dto;
    mo_dto.startp = mo_dto.currentp = mo_dto.endp = moves;
    mo_dto.pv_move = b3f3;
    mo_dto.hash_move = b3a3;
    mo_dto.killer1 = b3f3;
    mo_dto.killer2 = b3c3;
    mo_dto.next_stage = PVMOVE;

    move *nextp;
    assert(next(&pos,&nextp,&mo_dto));
    assert(clear_score(*nextp)==b3f3);

    assert(next(&pos,&nextp,&mo_dto));
    assert(clear_score(*nextp)==b3a3);

    assert(next(&pos,&nextp,&mo_dto));
    assert(clear_score(*nextp)==g7f8q);

    assert(next(&pos,&nextp,&mo_dto));
    assert(clear_score(*nextp)==g7f8r);

    assert(next(&pos,&nextp,&mo_dto));
    assert(clear_score(*nextp)==g7f8b);

    assert(next(&pos,&nextp,&mo_dto));
    assert(clear_score(*nextp)==g7f8n);

    assert(next(&pos,&nextp,&mo_dto));
    assert(clear_score(*nextp)==g7g8q);

    assert(next(&pos,&nextp,&mo_dto));
    assert(clear_score(*nextp)==g7g8r);

    assert(next(&pos,&nextp,&mo_dto));
    assert(clear_score(*nextp)==g7g8b);

    assert(next(&pos,&nextp,&mo_dto));
    assert(clear_score(*nextp)==g7g8n);

    ///////////////
    // in MVV/LVA
    // these two moves are interchangeable
    assert(next(&pos,&nextp,&mo_dto));
    assert(clear_score(*nextp)==b3b2);

    assert(next(&pos,&nextp,&mo_dto));
    assert(clear_score(*nextp)==b3b6);
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0xbc8, %rsp            # imm = 0xBC8
leaq 0x150ac(%rip), %rsi     # 0x34da0
leaq 0x98(%rsp), %rbx
movq %rbx, %rdi
callq 0xaa82
leaq 0x260(%rsp), %r15
movq %r15, %rdi
movq %rbx, %rsi
movl $0x1, %edx
movl $0x1, %ecx
callq 0x78e0
movq %rax, %r12
movl $0x4, %edi
movl $0x29, %esi
movl $0x2d, %edx
callq 0x775c
movq %rax, %r14
movl $0x4, %edi
movl $0x29, %esi
movl $0x28, %edx
callq 0x775c
movq %rax, %rbx
movl $0x4, %edi
movl $0x29, %esi
movl $0x2a, %edx
callq 0x775c
movq %rax, %r13
movq %r14, %rdi
movq %r15, %rsi
movq %r12, %rdx
callq 0xe682
testb %al, %al
je 0x2031b
leaq 0x260(%rsp), %rsi
movq %rbx, %rdi
movq %r12, %rdx
callq 0xe682
testb %al, %al
je 0x2033a
leaq 0x260(%rsp), %rsi
movq %r13, %rdi
movq %r12, %rdx
callq 0xe682
testb %al, %al
je 0x20359
movl $0x1, %edi
movl $0xe, %esi
movl $0x5, %edx
movl $0x3, %ecx
callq 0x777b
leaq 0x50(%rsp), %r15
movq %rax, (%r15)
movq %r15, %rdi
movl $0x5, %esi
callq 0x7824
movl $0x1, %edi
movl $0xe, %esi
movl $0x5, %edx
movl $0x3, %ecx
callq 0x777b
leaq 0x38(%rsp), %rdi
movq %rax, (%rdi)
movl $0x4, %esi
callq 0x7824
movl $0x1, %edi
movl $0xe, %esi
movl $0x5, %edx
movl $0x3, %ecx
callq 0x777b
leaq 0x30(%rsp), %rdi
movq %rax, (%rdi)
movl $0x3, %esi
callq 0x7824
movl $0x1, %edi
movl $0xe, %esi
movl $0x5, %edx
movl $0x3, %ecx
callq 0x777b
leaq 0x28(%rsp), %rdi
movq %rax, (%rdi)
movl $0x2, %esi
callq 0x7824
movq (%r15), %rdi
leaq 0x260(%rsp), %rsi
movq %r12, %rdx
callq 0xe682
testb %al, %al
je 0x20378
movq 0x38(%rsp), %rdi
leaq 0x260(%rsp), %rsi
movq %r12, %rdx
callq 0xe682
testb %al, %al
je 0x20397
movq 0x30(%rsp), %rdi
leaq 0x260(%rsp), %rsi
movq %r12, %rdx
callq 0xe682
testb %al, %al
je 0x203b6
movq 0x28(%rsp), %rdi
leaq 0x260(%rsp), %rsi
movq %r12, %rdx
callq 0xe682
testb %al, %al
je 0x203d5
movl $0x1, %edi
movl $0xe, %esi
movl $0x6, %edx
callq 0x775c
leaq 0x48(%rsp), %r15
movq %rax, (%r15)
movq %r15, %rdi
movl $0x5, %esi
callq 0x7824
movl $0x1, %edi
movl $0xe, %esi
movl $0x6, %edx
callq 0x775c
leaq 0x20(%rsp), %rdi
movq %rax, (%rdi)
movl $0x4, %esi
callq 0x7824
movl $0x1, %edi
movl $0xe, %esi
movl $0x6, %edx
callq 0x775c
leaq 0x18(%rsp), %rdi
movq %rax, (%rdi)
movl $0x3, %esi
callq 0x7824
movl $0x1, %edi
movl $0xe, %esi
movl $0x6, %edx
callq 0x775c
leaq 0x10(%rsp), %rdi
movq %rax, (%rdi)
movl $0x2, %esi
callq 0x7824
movq (%r15), %rdi
leaq 0x260(%rsp), %rsi
movq %r12, %rdx
callq 0xe682
testb %al, %al
je 0x203f4
movq 0x20(%rsp), %rdi
leaq 0x260(%rsp), %rsi
movq %r12, %rdx
callq 0xe682
testb %al, %al
je 0x20413
movq 0x18(%rsp), %rdi
leaq 0x260(%rsp), %rsi
movq %r12, %rdx
callq 0xe682
testb %al, %al
je 0x20432
movq 0x10(%rsp), %rdi
leaq 0x260(%rsp), %rsi
movq %r12, %rdx
callq 0xe682
testb %al, %al
je 0x20451
movl $0x4, %edi
movl $0x29, %esi
movl $0x11, %edx
movl $0x1, %ecx
callq 0x777b
movq %rax, %r15
movl $0x4, %edi
movl $0x29, %esi
movl $0x31, %edx
movl $0x1, %ecx
callq 0x777b
movq %rax, %rbp
leaq 0x260(%rsp), %rsi
movq %r15, 0x40(%rsp)
movq %r15, %rdi
movq %r12, %rdx
callq 0xe682
testb %al, %al
je 0x20470
leaq 0x260(%rsp), %r15
movq %rbp, %rdi
movq %r15, %rsi
movq %r12, %rdx
callq 0xe682
testb %al, %al
je 0x2048f
leaq 0x58(%rsp), %rdx
movq %r15, 0x30(%rdx)
movq %r15, 0x38(%rdx)
movq %r15, 0x28(%rdx)
movq %r14, 0x8(%rdx)
movq %rbx, 0x10(%rdx)
movq %r14, 0x18(%rdx)
movq %r13, 0x20(%rdx)
movl $0x0, (%rdx)
leaq 0x98(%rsp), %rdi
leaq 0x8(%rsp), %rsi
callq 0x8b70
testb %al, %al
je 0x204ae
movq 0x8(%rsp), %rax
movq (%rax), %rdi
callq 0x78dd
cmpq %r14, %rax
jne 0x204cd
leaq 0x98(%rsp), %rdi
leaq 0x8(%rsp), %rsi
leaq 0x58(%rsp), %rdx
callq 0x8b70
testb %al, %al
je 0x204ec
movq 0x8(%rsp), %rax
movq (%rax), %rdi
callq 0x78dd
cmpq %rbx, %rax
jne 0x2050b
leaq 0x98(%rsp), %rdi
leaq 0x8(%rsp), %rsi
leaq 0x58(%rsp), %rdx
callq 0x8b70
testb %al, %al
je 0x2052a
movq 0x8(%rsp), %rax
movq (%rax), %rdi
callq 0x78dd
cmpq 0x50(%rsp), %rax
jne 0x20549
leaq 0x98(%rsp), %rdi
leaq 0x8(%rsp), %rsi
leaq 0x58(%rsp), %rdx
callq 0x8b70
testb %al, %al
je 0x20568
movq 0x8(%rsp), %rax
movq (%rax), %rdi
callq 0x78dd
cmpq 0x38(%rsp), %rax
jne 0x20587
leaq 0x98(%rsp), %rdi
leaq 0x8(%rsp), %rsi
leaq 0x58(%rsp), %rdx
callq 0x8b70
testb %al, %al
je 0x205a6
movq 0x8(%rsp), %rax
movq (%rax), %rdi
callq 0x78dd
cmpq 0x30(%rsp), %rax
jne 0x205c5
leaq 0x98(%rsp), %rdi
leaq 0x8(%rsp), %rsi
leaq 0x58(%rsp), %rdx
callq 0x8b70
testb %al, %al
je 0x205e4
movq 0x8(%rsp), %rax
movq (%rax), %rdi
callq 0x78dd
cmpq 0x28(%rsp), %rax
jne 0x20603
leaq 0x98(%rsp), %rdi
leaq 0x8(%rsp), %rsi
leaq 0x58(%rsp), %rdx
callq 0x8b70
testb %al, %al
je 0x20622
movq 0x8(%rsp), %rax
movq (%rax), %rdi
callq 0x78dd
cmpq 0x48(%rsp), %rax
jne 0x20641
leaq 0x98(%rsp), %rdi
leaq 0x8(%rsp), %rsi
leaq 0x58(%rsp), %rdx
callq 0x8b70
testb %al, %al
je 0x20660
movq 0x8(%rsp), %rax
movq (%rax), %rdi
callq 0x78dd
cmpq 0x20(%rsp), %rax
jne 0x2067f
leaq 0x98(%rsp), %rdi
leaq 0x8(%rsp), %rsi
leaq 0x58(%rsp), %rdx
callq 0x8b70
testb %al, %al
je 0x2069e
movq 0x8(%rsp), %rax
movq (%rax), %rdi
callq 0x78dd
cmpq 0x18(%rsp), %rax
jne 0x206bd
leaq 0x98(%rsp), %rdi
leaq 0x8(%rsp), %rsi
leaq 0x58(%rsp), %rdx
callq 0x8b70
testb %al, %al
je 0x206dc
movq 0x8(%rsp), %rax
movq (%rax), %rdi
callq 0x78dd
cmpq 0x10(%rsp), %rax
jne 0x206fb
leaq 0x98(%rsp), %rdi
leaq 0x8(%rsp), %rsi
leaq 0x58(%rsp), %rdx
callq 0x8b70
testb %al, %al
je 0x2071a
movq 0x8(%rsp), %rax
movq (%rax), %rdi
callq 0x78dd
cmpq %rbp, %rax
jne 0x20739
leaq 0x98(%rsp), %rdi
leaq 0x8(%rsp), %rsi
leaq 0x58(%rsp), %rdx
callq 0x8b70
testb %al, %al
je 0x20758
movq 0x8(%rsp), %rax
movq (%rax), %rdi
callq 0x78dd
cmpq 0x40(%rsp), %rax
jne 0x20777
addq $0xbc8, %rsp            # imm = 0xBC8
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
leaq 0x14aa1(%rip), %rdi     # 0x34dc3
leaq 0x1467f(%rip), %rsi     # 0x349a8
leaq 0x14ab4(%rip), %rcx     # 0x34de4
movl $0x10a, %edx            # imm = 0x10A
callq 0x20d0
leaq 0x14acb(%rip), %rdi     # 0x34e0c
leaq 0x14660(%rip), %rsi     # 0x349a8
leaq 0x14a95(%rip), %rcx     # 0x34de4
movl $0x10b, %edx            # imm = 0x10B
callq 0x20d0
leaq 0x14acd(%rip), %rdi     # 0x34e2d
leaq 0x14641(%rip), %rsi     # 0x349a8
leaq 0x14a76(%rip), %rcx     # 0x34de4
movl $0x10c, %edx            # imm = 0x10C
callq 0x20d0
leaq 0x14acf(%rip), %rdi     # 0x34e4e
leaq 0x14622(%rip), %rsi     # 0x349a8
leaq 0x14a57(%rip), %rcx     # 0x34de4
movl $0x11b, %edx            # imm = 0x11B
callq 0x20d0
leaq 0x14ad2(%rip), %rdi     # 0x34e70
leaq 0x14603(%rip), %rsi     # 0x349a8
leaq 0x14a38(%rip), %rcx     # 0x34de4
movl $0x11c, %edx            # imm = 0x11C
callq 0x20d0
leaq 0x14ad5(%rip), %rdi     # 0x34e92
leaq 0x145e4(%rip), %rsi     # 0x349a8
leaq 0x14a19(%rip), %rcx     # 0x34de4
movl $0x11d, %edx            # imm = 0x11D
callq 0x20d0
leaq 0x14ad8(%rip), %rdi     # 0x34eb4
leaq 0x145c5(%rip), %rsi     # 0x349a8
leaq 0x149fa(%rip), %rcx     # 0x34de4
movl $0x11e, %edx            # imm = 0x11E
callq 0x20d0
leaq 0x14adb(%rip), %rdi     # 0x34ed6
leaq 0x145a6(%rip), %rsi     # 0x349a8
leaq 0x149db(%rip), %rcx     # 0x34de4
movl $0x12d, %edx            # imm = 0x12D
callq 0x20d0
leaq 0x14ade(%rip), %rdi     # 0x34ef8
leaq 0x14587(%rip), %rsi     # 0x349a8
leaq 0x149bc(%rip), %rcx     # 0x34de4
movl $0x12e, %edx            # imm = 0x12E
callq 0x20d0
leaq 0x14ae1(%rip), %rdi     # 0x34f1a
leaq 0x14568(%rip), %rsi     # 0x349a8
leaq 0x1499d(%rip), %rcx     # 0x34de4
movl $0x12f, %edx            # imm = 0x12F
callq 0x20d0
leaq 0x14ae4(%rip), %rdi     # 0x34f3c
leaq 0x14549(%rip), %rsi     # 0x349a8
leaq 0x1497e(%rip), %rcx     # 0x34de4
movl $0x130, %edx            # imm = 0x130
callq 0x20d0
leaq 0x14ae7(%rip), %rdi     # 0x34f5e
leaq 0x1452a(%rip), %rsi     # 0x349a8
leaq 0x1495f(%rip), %rcx     # 0x34de4
movl $0x136, %edx            # imm = 0x136
callq 0x20d0
leaq 0x14ae9(%rip), %rdi     # 0x34f7f
leaq 0x1450b(%rip), %rsi     # 0x349a8
leaq 0x14940(%rip), %rcx     # 0x34de4
movl $0x137, %edx            # imm = 0x137
callq 0x20d0
leaq 0x14781(%rip), %rdi     # 0x34c36
leaq 0x144ec(%rip), %rsi     # 0x349a8
leaq 0x14921(%rip), %rcx     # 0x34de4
movl $0x144, %edx            # imm = 0x144
callq 0x20d0
leaq 0x14acc(%rip), %rdi     # 0x34fa0
leaq 0x144cd(%rip), %rsi     # 0x349a8
leaq 0x14902(%rip), %rcx     # 0x34de4
movl $0x145, %edx            # imm = 0x145
callq 0x20d0
leaq 0x14743(%rip), %rdi     # 0x34c36
leaq 0x144ae(%rip), %rsi     # 0x349a8
leaq 0x148e3(%rip), %rcx     # 0x34de4
movl $0x147, %edx            # imm = 0x147
callq 0x20d0
leaq 0x14aa8(%rip), %rdi     # 0x34fba
leaq 0x1448f(%rip), %rsi     # 0x349a8
leaq 0x148c4(%rip), %rcx     # 0x34de4
movl $0x148, %edx            # imm = 0x148
callq 0x20d0
leaq 0x14705(%rip), %rdi     # 0x34c36
leaq 0x14470(%rip), %rsi     # 0x349a8
leaq 0x148a5(%rip), %rcx     # 0x34de4
movl $0x14a, %edx            # imm = 0x14A
callq 0x20d0
leaq 0x14a84(%rip), %rdi     # 0x34fd4
leaq 0x14451(%rip), %rsi     # 0x349a8
leaq 0x14886(%rip), %rcx     # 0x34de4
movl $0x14b, %edx            # imm = 0x14B
callq 0x20d0
leaq 0x146c7(%rip), %rdi     # 0x34c36
leaq 0x14432(%rip), %rsi     # 0x349a8
leaq 0x14867(%rip), %rcx     # 0x34de4
movl $0x14d, %edx            # imm = 0x14D
callq 0x20d0
leaq 0x14a61(%rip), %rdi     # 0x34fef
leaq 0x14413(%rip), %rsi     # 0x349a8
leaq 0x14848(%rip), %rcx     # 0x34de4
movl $0x14e, %edx            # imm = 0x14E
callq 0x20d0
leaq 0x14689(%rip), %rdi     # 0x34c36
leaq 0x143f4(%rip), %rsi     # 0x349a8
leaq 0x14829(%rip), %rcx     # 0x34de4
movl $0x150, %edx            # imm = 0x150
callq 0x20d0
leaq 0x14a3e(%rip), %rdi     # 0x3500a
leaq 0x143d5(%rip), %rsi     # 0x349a8
leaq 0x1480a(%rip), %rcx     # 0x34de4
movl $0x151, %edx            # imm = 0x151
callq 0x20d0
leaq 0x1464b(%rip), %rdi     # 0x34c36
leaq 0x143b6(%rip), %rsi     # 0x349a8
leaq 0x147eb(%rip), %rcx     # 0x34de4
movl $0x153, %edx            # imm = 0x153
callq 0x20d0
leaq 0x14a1b(%rip), %rdi     # 0x35025
leaq 0x14397(%rip), %rsi     # 0x349a8
leaq 0x147cc(%rip), %rcx     # 0x34de4
movl $0x154, %edx            # imm = 0x154
callq 0x20d0
leaq 0x1460d(%rip), %rdi     # 0x34c36
leaq 0x14378(%rip), %rsi     # 0x349a8
leaq 0x147ad(%rip), %rcx     # 0x34de4
movl $0x156, %edx            # imm = 0x156
callq 0x20d0
leaq 0x149f8(%rip), %rdi     # 0x35040
leaq 0x14359(%rip), %rsi     # 0x349a8
leaq 0x1478e(%rip), %rcx     # 0x34de4
movl $0x157, %edx            # imm = 0x157
callq 0x20d0
leaq 0x145cf(%rip), %rdi     # 0x34c36
leaq 0x1433a(%rip), %rsi     # 0x349a8
leaq 0x1476f(%rip), %rcx     # 0x34de4
movl $0x159, %edx            # imm = 0x159
callq 0x20d0
leaq 0x149d5(%rip), %rdi     # 0x3505b
leaq 0x1431b(%rip), %rsi     # 0x349a8
leaq 0x14750(%rip), %rcx     # 0x34de4
movl $0x15a, %edx            # imm = 0x15A
callq 0x20d0
leaq 0x14591(%rip), %rdi     # 0x34c36
leaq 0x142fc(%rip), %rsi     # 0x349a8
leaq 0x14731(%rip), %rcx     # 0x34de4
movl $0x15c, %edx            # imm = 0x15C
callq 0x20d0
leaq 0x149b2(%rip), %rdi     # 0x35076
leaq 0x142dd(%rip), %rsi     # 0x349a8
leaq 0x14712(%rip), %rcx     # 0x34de4
movl $0x15d, %edx            # imm = 0x15D
callq 0x20d0
leaq 0x14553(%rip), %rdi     # 0x34c36
leaq 0x142be(%rip), %rsi     # 0x349a8
leaq 0x146f3(%rip), %rcx     # 0x34de4
movl $0x15f, %edx            # imm = 0x15F
callq 0x20d0
leaq 0x1498f(%rip), %rdi     # 0x35091
leaq 0x1429f(%rip), %rsi     # 0x349a8
leaq 0x146d4(%rip), %rcx     # 0x34de4
movl $0x160, %edx            # imm = 0x160
callq 0x20d0
leaq 0x14515(%rip), %rdi     # 0x34c36
leaq 0x14280(%rip), %rsi     # 0x349a8
leaq 0x146b5(%rip), %rcx     # 0x34de4
movl $0x165, %edx            # imm = 0x165
callq 0x20d0
leaq 0x1496c(%rip), %rdi     # 0x350ac
leaq 0x14261(%rip), %rsi     # 0x349a8
leaq 0x14696(%rip), %rcx     # 0x34de4
movl $0x166, %edx            # imm = 0x166
callq 0x20d0
leaq 0x144d7(%rip), %rdi     # 0x34c36
leaq 0x14242(%rip), %rsi     # 0x349a8
leaq 0x14677(%rip), %rcx     # 0x34de4
movl $0x168, %edx            # imm = 0x168
callq 0x20d0
leaq 0x14948(%rip), %rdi     # 0x350c6
leaq 0x14223(%rip), %rsi     # 0x349a8
leaq 0x14658(%rip), %rcx     # 0x34de4
movl $0x169, %edx            # imm = 0x169
callq 0x20d0