// File: /workspace/github_cpp_makefile_star2_O1/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 0x14eb8(%rip), %rsi     # 0x34d20
leaq 0x98(%rsp), %rbx
movq %rbx, %rdi
callq 0xaa74
leaq 0x260(%rsp), %r15
movq %r15, %rdi
movq %rbx, %rsi
movl $0x1, %edx
movl $0x1, %ecx
callq 0x7840
movq %rax, %r12
movl $0x4, %edi
movl $0x29, %esi
movl $0x2d, %edx
callq 0x76b8
movq %rax, %r14
movl $0x4, %edi
movl $0x29, %esi
movl $0x28, %edx
callq 0x76b8
movq %rax, %rbx
movl $0x4, %edi
movl $0x29, %esi
movl $0x2a, %edx
callq 0x76b8
movq %rax, %r13
movq %r14, %rdi
movq %r15, %rsi
movq %r12, %rdx
callq 0xe727
testb %al, %al
je 0x2048f
leaq 0x260(%rsp), %rsi
movq %rbx, %rdi
movq %r12, %rdx
callq 0xe727
testb %al, %al
je 0x204ae
leaq 0x260(%rsp), %rsi
movq %r13, %rdi
movq %r12, %rdx
callq 0xe727
testb %al, %al
je 0x204cd
movl $0x1, %edi
movl $0xe, %esi
movl $0x5, %edx
movl $0x3, %ecx
callq 0x76d7
leaq 0x50(%rsp), %r15
movq %rax, (%r15)
movq %r15, %rdi
movl $0x5, %esi
callq 0x7780
movl $0x1, %edi
movl $0xe, %esi
movl $0x5, %edx
movl $0x3, %ecx
callq 0x76d7
leaq 0x38(%rsp), %rdi
movq %rax, (%rdi)
movl $0x4, %esi
callq 0x7780
movl $0x1, %edi
movl $0xe, %esi
movl $0x5, %edx
movl $0x3, %ecx
callq 0x76d7
leaq 0x30(%rsp), %rdi
movq %rax, (%rdi)
movl $0x3, %esi
callq 0x7780
movl $0x1, %edi
movl $0xe, %esi
movl $0x5, %edx
movl $0x3, %ecx
callq 0x76d7
leaq 0x28(%rsp), %rdi
movq %rax, (%rdi)
movl $0x2, %esi
callq 0x7780
movq (%r15), %rdi
leaq 0x260(%rsp), %rsi
movq %r12, %rdx
callq 0xe727
testb %al, %al
je 0x204ec
movq 0x38(%rsp), %rdi
leaq 0x260(%rsp), %rsi
movq %r12, %rdx
callq 0xe727
testb %al, %al
je 0x2050b
movq 0x30(%rsp), %rdi
leaq 0x260(%rsp), %rsi
movq %r12, %rdx
callq 0xe727
testb %al, %al
je 0x2052a
movq 0x28(%rsp), %rdi
leaq 0x260(%rsp), %rsi
movq %r12, %rdx
callq 0xe727
testb %al, %al
je 0x20549
movl $0x1, %edi
movl $0xe, %esi
movl $0x6, %edx
callq 0x76b8
leaq 0x48(%rsp), %r15
movq %rax, (%r15)
movq %r15, %rdi
movl $0x5, %esi
callq 0x7780
movl $0x1, %edi
movl $0xe, %esi
movl $0x6, %edx
callq 0x76b8
leaq 0x20(%rsp), %rdi
movq %rax, (%rdi)
movl $0x4, %esi
callq 0x7780
movl $0x1, %edi
movl $0xe, %esi
movl $0x6, %edx
callq 0x76b8
leaq 0x18(%rsp), %rdi
movq %rax, (%rdi)
movl $0x3, %esi
callq 0x7780
movl $0x1, %edi
movl $0xe, %esi
movl $0x6, %edx
callq 0x76b8
leaq 0x10(%rsp), %rdi
movq %rax, (%rdi)
movl $0x2, %esi
callq 0x7780
movq (%r15), %rdi
leaq 0x260(%rsp), %rsi
movq %r12, %rdx
callq 0xe727
testb %al, %al
je 0x20568
movq 0x20(%rsp), %rdi
leaq 0x260(%rsp), %rsi
movq %r12, %rdx
callq 0xe727
testb %al, %al
je 0x20587
movq 0x18(%rsp), %rdi
leaq 0x260(%rsp), %rsi
movq %r12, %rdx
callq 0xe727
testb %al, %al
je 0x205a6
movq 0x10(%rsp), %rdi
leaq 0x260(%rsp), %rsi
movq %r12, %rdx
callq 0xe727
testb %al, %al
je 0x205c5
movl $0x4, %edi
movl $0x29, %esi
movl $0x11, %edx
movl $0x1, %ecx
callq 0x76d7
movq %rax, %r15
movl $0x4, %edi
movl $0x29, %esi
movl $0x31, %edx
movl $0x1, %ecx
callq 0x76d7
movq %rax, %rbp
leaq 0x260(%rsp), %rsi
movq %r15, 0x40(%rsp)
movq %r15, %rdi
movq %r12, %rdx
callq 0xe727
testb %al, %al
je 0x205e4
leaq 0x260(%rsp), %r15
movq %rbp, %rdi
movq %r15, %rsi
movq %r12, %rdx
callq 0xe727
testb %al, %al
je 0x20603
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 0x8adc
testb %al, %al
je 0x20622
movq 0x8(%rsp), %rax
movq (%rax), %rdi
callq 0x783c
cmpq %r14, %rax
jne 0x20641
leaq 0x98(%rsp), %rdi
leaq 0x8(%rsp), %rsi
leaq 0x58(%rsp), %rdx
callq 0x8adc
testb %al, %al
je 0x20660
movq 0x8(%rsp), %rax
movq (%rax), %rdi
callq 0x783c
cmpq %rbx, %rax
jne 0x2067f
leaq 0x98(%rsp), %rdi
leaq 0x8(%rsp), %rsi
leaq 0x58(%rsp), %rdx
callq 0x8adc
testb %al, %al
je 0x2069e
movq 0x8(%rsp), %rax
movq (%rax), %rdi
callq 0x783c
cmpq 0x50(%rsp), %rax
jne 0x206bd
leaq 0x98(%rsp), %rdi
leaq 0x8(%rsp), %rsi
leaq 0x58(%rsp), %rdx
callq 0x8adc
testb %al, %al
je 0x206dc
movq 0x8(%rsp), %rax
movq (%rax), %rdi
callq 0x783c
cmpq 0x38(%rsp), %rax
jne 0x206fb
leaq 0x98(%rsp), %rdi
leaq 0x8(%rsp), %rsi
leaq 0x58(%rsp), %rdx
callq 0x8adc
testb %al, %al
je 0x2071a
movq 0x8(%rsp), %rax
movq (%rax), %rdi
callq 0x783c
cmpq 0x30(%rsp), %rax
jne 0x20739
leaq 0x98(%rsp), %rdi
leaq 0x8(%rsp), %rsi
leaq 0x58(%rsp), %rdx
callq 0x8adc
testb %al, %al
je 0x20758
movq 0x8(%rsp), %rax
movq (%rax), %rdi
callq 0x783c
cmpq 0x28(%rsp), %rax
jne 0x20777
leaq 0x98(%rsp), %rdi
leaq 0x8(%rsp), %rsi
leaq 0x58(%rsp), %rdx
callq 0x8adc
testb %al, %al
je 0x20796
movq 0x8(%rsp), %rax
movq (%rax), %rdi
callq 0x783c
cmpq 0x48(%rsp), %rax
jne 0x207b5
leaq 0x98(%rsp), %rdi
leaq 0x8(%rsp), %rsi
leaq 0x58(%rsp), %rdx
callq 0x8adc
testb %al, %al
je 0x207d4
movq 0x8(%rsp), %rax
movq (%rax), %rdi
callq 0x783c
cmpq 0x20(%rsp), %rax
jne 0x207f3
leaq 0x98(%rsp), %rdi
leaq 0x8(%rsp), %rsi
leaq 0x58(%rsp), %rdx
callq 0x8adc
testb %al, %al
je 0x20812
movq 0x8(%rsp), %rax
movq (%rax), %rdi
callq 0x783c
cmpq 0x18(%rsp), %rax
jne 0x20831
leaq 0x98(%rsp), %rdi
leaq 0x8(%rsp), %rsi
leaq 0x58(%rsp), %rdx
callq 0x8adc
testb %al, %al
je 0x20850
movq 0x8(%rsp), %rax
movq (%rax), %rdi
callq 0x783c
cmpq 0x10(%rsp), %rax
jne 0x2086f
leaq 0x98(%rsp), %rdi
leaq 0x8(%rsp), %rsi
leaq 0x58(%rsp), %rdx
callq 0x8adc
testb %al, %al
je 0x2088e
movq 0x8(%rsp), %rax
movq (%rax), %rdi
callq 0x783c
cmpq %rbp, %rax
jne 0x208ad
leaq 0x98(%rsp), %rdi
leaq 0x8(%rsp), %rsi
leaq 0x58(%rsp), %rdx
callq 0x8adc
testb %al, %al
je 0x208cc
movq 0x8(%rsp), %rax
movq (%rax), %rdi
callq 0x783c
cmpq 0x40(%rsp), %rax
jne 0x208eb
addq $0xbc8, %rsp            # imm = 0xBC8
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
leaq 0x148ad(%rip), %rdi     # 0x34d43
leaq 0x1448b(%rip), %rsi     # 0x34928
leaq 0x148c0(%rip), %rcx     # 0x34d64
movl $0x10a, %edx            # imm = 0x10A
callq 0x20d0
leaq 0x148d7(%rip), %rdi     # 0x34d8c
leaq 0x1446c(%rip), %rsi     # 0x34928
leaq 0x148a1(%rip), %rcx     # 0x34d64
movl $0x10b, %edx            # imm = 0x10B
callq 0x20d0
leaq 0x148d9(%rip), %rdi     # 0x34dad
leaq 0x1444d(%rip), %rsi     # 0x34928
leaq 0x14882(%rip), %rcx     # 0x34d64
movl $0x10c, %edx            # imm = 0x10C
callq 0x20d0
leaq 0x148db(%rip), %rdi     # 0x34dce
leaq 0x1442e(%rip), %rsi     # 0x34928
leaq 0x14863(%rip), %rcx     # 0x34d64
movl $0x11b, %edx            # imm = 0x11B
callq 0x20d0
leaq 0x148de(%rip), %rdi     # 0x34df0
leaq 0x1440f(%rip), %rsi     # 0x34928
leaq 0x14844(%rip), %rcx     # 0x34d64
movl $0x11c, %edx            # imm = 0x11C
callq 0x20d0
leaq 0x148e1(%rip), %rdi     # 0x34e12
leaq 0x143f0(%rip), %rsi     # 0x34928
leaq 0x14825(%rip), %rcx     # 0x34d64
movl $0x11d, %edx            # imm = 0x11D
callq 0x20d0
leaq 0x148e4(%rip), %rdi     # 0x34e34
leaq 0x143d1(%rip), %rsi     # 0x34928
leaq 0x14806(%rip), %rcx     # 0x34d64
movl $0x11e, %edx            # imm = 0x11E
callq 0x20d0
leaq 0x148e7(%rip), %rdi     # 0x34e56
leaq 0x143b2(%rip), %rsi     # 0x34928
leaq 0x147e7(%rip), %rcx     # 0x34d64
movl $0x12d, %edx            # imm = 0x12D
callq 0x20d0
leaq 0x148ea(%rip), %rdi     # 0x34e78
leaq 0x14393(%rip), %rsi     # 0x34928
leaq 0x147c8(%rip), %rcx     # 0x34d64
movl $0x12e, %edx            # imm = 0x12E
callq 0x20d0
leaq 0x148ed(%rip), %rdi     # 0x34e9a
leaq 0x14374(%rip), %rsi     # 0x34928
leaq 0x147a9(%rip), %rcx     # 0x34d64
movl $0x12f, %edx            # imm = 0x12F
callq 0x20d0
leaq 0x148f0(%rip), %rdi     # 0x34ebc
leaq 0x14355(%rip), %rsi     # 0x34928
leaq 0x1478a(%rip), %rcx     # 0x34d64
movl $0x130, %edx            # imm = 0x130
callq 0x20d0
leaq 0x148f3(%rip), %rdi     # 0x34ede
leaq 0x14336(%rip), %rsi     # 0x34928
leaq 0x1476b(%rip), %rcx     # 0x34d64
movl $0x136, %edx            # imm = 0x136
callq 0x20d0
leaq 0x148f5(%rip), %rdi     # 0x34eff
leaq 0x14317(%rip), %rsi     # 0x34928
leaq 0x1474c(%rip), %rcx     # 0x34d64
movl $0x137, %edx            # imm = 0x137
callq 0x20d0
leaq 0x1458d(%rip), %rdi     # 0x34bb6
leaq 0x142f8(%rip), %rsi     # 0x34928
leaq 0x1472d(%rip), %rcx     # 0x34d64
movl $0x144, %edx            # imm = 0x144
callq 0x20d0
leaq 0x148d8(%rip), %rdi     # 0x34f20
leaq 0x142d9(%rip), %rsi     # 0x34928
leaq 0x1470e(%rip), %rcx     # 0x34d64
movl $0x145, %edx            # imm = 0x145
callq 0x20d0
leaq 0x1454f(%rip), %rdi     # 0x34bb6
leaq 0x142ba(%rip), %rsi     # 0x34928
leaq 0x146ef(%rip), %rcx     # 0x34d64
movl $0x147, %edx            # imm = 0x147
callq 0x20d0
leaq 0x148b4(%rip), %rdi     # 0x34f3a
leaq 0x1429b(%rip), %rsi     # 0x34928
leaq 0x146d0(%rip), %rcx     # 0x34d64
movl $0x148, %edx            # imm = 0x148
callq 0x20d0
leaq 0x14511(%rip), %rdi     # 0x34bb6
leaq 0x1427c(%rip), %rsi     # 0x34928
leaq 0x146b1(%rip), %rcx     # 0x34d64
movl $0x14a, %edx            # imm = 0x14A
callq 0x20d0
leaq 0x14890(%rip), %rdi     # 0x34f54
leaq 0x1425d(%rip), %rsi     # 0x34928
leaq 0x14692(%rip), %rcx     # 0x34d64
movl $0x14b, %edx            # imm = 0x14B
callq 0x20d0
leaq 0x144d3(%rip), %rdi     # 0x34bb6
leaq 0x1423e(%rip), %rsi     # 0x34928
leaq 0x14673(%rip), %rcx     # 0x34d64
movl $0x14d, %edx            # imm = 0x14D
callq 0x20d0
leaq 0x1486d(%rip), %rdi     # 0x34f6f
leaq 0x1421f(%rip), %rsi     # 0x34928
leaq 0x14654(%rip), %rcx     # 0x34d64
movl $0x14e, %edx            # imm = 0x14E
callq 0x20d0
leaq 0x14495(%rip), %rdi     # 0x34bb6
leaq 0x14200(%rip), %rsi     # 0x34928
leaq 0x14635(%rip), %rcx     # 0x34d64
movl $0x150, %edx            # imm = 0x150
callq 0x20d0
leaq 0x1484a(%rip), %rdi     # 0x34f8a
leaq 0x141e1(%rip), %rsi     # 0x34928
leaq 0x14616(%rip), %rcx     # 0x34d64
movl $0x151, %edx            # imm = 0x151
callq 0x20d0
leaq 0x14457(%rip), %rdi     # 0x34bb6
leaq 0x141c2(%rip), %rsi     # 0x34928
leaq 0x145f7(%rip), %rcx     # 0x34d64
movl $0x153, %edx            # imm = 0x153
callq 0x20d0
leaq 0x14827(%rip), %rdi     # 0x34fa5
leaq 0x141a3(%rip), %rsi     # 0x34928
leaq 0x145d8(%rip), %rcx     # 0x34d64
movl $0x154, %edx            # imm = 0x154
callq 0x20d0
leaq 0x14419(%rip), %rdi     # 0x34bb6
leaq 0x14184(%rip), %rsi     # 0x34928
leaq 0x145b9(%rip), %rcx     # 0x34d64
movl $0x156, %edx            # imm = 0x156
callq 0x20d0
leaq 0x14804(%rip), %rdi     # 0x34fc0
leaq 0x14165(%rip), %rsi     # 0x34928
leaq 0x1459a(%rip), %rcx     # 0x34d64
movl $0x157, %edx            # imm = 0x157
callq 0x20d0
leaq 0x143db(%rip), %rdi     # 0x34bb6
leaq 0x14146(%rip), %rsi     # 0x34928
leaq 0x1457b(%rip), %rcx     # 0x34d64
movl $0x159, %edx            # imm = 0x159
callq 0x20d0
leaq 0x147e1(%rip), %rdi     # 0x34fdb
leaq 0x14127(%rip), %rsi     # 0x34928
leaq 0x1455c(%rip), %rcx     # 0x34d64
movl $0x15a, %edx            # imm = 0x15A
callq 0x20d0
leaq 0x1439d(%rip), %rdi     # 0x34bb6
leaq 0x14108(%rip), %rsi     # 0x34928
leaq 0x1453d(%rip), %rcx     # 0x34d64
movl $0x15c, %edx            # imm = 0x15C
callq 0x20d0
leaq 0x147be(%rip), %rdi     # 0x34ff6
leaq 0x140e9(%rip), %rsi     # 0x34928
leaq 0x1451e(%rip), %rcx     # 0x34d64
movl $0x15d, %edx            # imm = 0x15D
callq 0x20d0
leaq 0x1435f(%rip), %rdi     # 0x34bb6
leaq 0x140ca(%rip), %rsi     # 0x34928
leaq 0x144ff(%rip), %rcx     # 0x34d64
movl $0x15f, %edx            # imm = 0x15F
callq 0x20d0
leaq 0x1479b(%rip), %rdi     # 0x35011
leaq 0x140ab(%rip), %rsi     # 0x34928
leaq 0x144e0(%rip), %rcx     # 0x34d64
movl $0x160, %edx            # imm = 0x160
callq 0x20d0
leaq 0x14321(%rip), %rdi     # 0x34bb6
leaq 0x1408c(%rip), %rsi     # 0x34928
leaq 0x144c1(%rip), %rcx     # 0x34d64
movl $0x165, %edx            # imm = 0x165
callq 0x20d0
leaq 0x14778(%rip), %rdi     # 0x3502c
leaq 0x1406d(%rip), %rsi     # 0x34928
leaq 0x144a2(%rip), %rcx     # 0x34d64
movl $0x166, %edx            # imm = 0x166
callq 0x20d0
leaq 0x142e3(%rip), %rdi     # 0x34bb6
leaq 0x1404e(%rip), %rsi     # 0x34928
leaq 0x14483(%rip), %rcx     # 0x34d64
movl $0x168, %edx            # imm = 0x168
callq 0x20d0
leaq 0x14754(%rip), %rdi     # 0x35046
leaq 0x1402f(%rip), %rsi     # 0x34928
leaq 0x14464(%rip), %rcx     # 0x34d64
movl $0x169, %edx            # imm = 0x169
callq 0x20d0