// File: /workspace/github_cpp_makefile_star2_O1/jswaff[P]prophet3/test/next__test.cpp
// Function: test_promotions()
void test_promotions() {
    position pos;
    set_pos(&pos,"8/4Pk1p/6p1/1r6/8/5N2/2B2PPP/b5K1 w - - ");

    move moves[MAX_MOVES_PER_PLY];
    move *endp = gen_legal_moves(moves,&pos,true,true);

    move e7e8q = to_move(PAWN,E7,E8);
    set_promopiece(&e7e8q,QUEEN);

    move e7e8r = to_move(PAWN,E7,E8);
    set_promopiece(&e7e8r,ROOK);

    move e7e8b = to_move(PAWN,E7,E8);
    set_promopiece(&e7e8b,BISHOP);

    move e7e8n = to_move(PAWN,E7,E8);
    set_promopiece(&e7e8n,KNIGHT);

    move c2g6 = to_capture(BISHOP,C2,G6,PAWN);

    assert(is_in_move_list(e7e8q,moves,endp));
    assert(is_in_move_list(e7e8r,moves,endp));
    assert(is_in_move_list(e7e8b,moves,endp));
    assert(is_in_move_list(e7e8n,moves,endp));
    assert(is_in_move_list(c2g6,moves,endp));

    move_order_dto mo_dto;
    mo_dto.startp = mo_dto.currentp = mo_dto.endp = moves;
    mo_dto.pv_move = 0;
    mo_dto.hash_move = 0;
    mo_dto.killer1 = 0;
    mo_dto.killer2 = 0;
    mo_dto.next_stage = PVMOVE;

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

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

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

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

    // NOTE: C2G6 is a losing capture - in SEE it would be at bottom
    /*for (int i=5;i<24;i++) {
        assert(next(&pos,&nextp,&mo_dto));
    }*/

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

// Assembly:
pushq %r15
pushq %r14
pushq %r12
pushq %rbx
subq $0xb98, %rsp            # imm = 0xB98
leaq 0xf77f(%rip), %rsi      # 0x2edab
leaq 0x68(%rsp), %rbx
movq %rbx, %rdi
callq 0xaa74
leaq 0x230(%rsp), %r15
movq %r15, %rdi
movq %rbx, %rsi
movl $0x1, %edx
movl $0x1, %ecx
callq 0x7840
movq %rax, %r14
movl $0x1, %edi
movl $0xc, %esi
movl $0x4, %edx
callq 0x76b8
leaq 0x20(%rsp), %r12
movq %rax, (%r12)
movq %r12, %rdi
movl $0x5, %esi
callq 0x7780
movl $0x1, %edi
movl $0xc, %esi
movl $0x4, %edx
callq 0x76b8
leaq 0x18(%rsp), %rdi
movq %rax, (%rdi)
movl $0x4, %esi
callq 0x7780
movl $0x1, %edi
movl $0xc, %esi
movl $0x4, %edx
callq 0x76b8
leaq 0x10(%rsp), %rdi
movq %rax, (%rdi)
movl $0x3, %esi
callq 0x7780
movl $0x1, %edi
movl $0xc, %esi
movl $0x4, %edx
callq 0x76b8
leaq 0x8(%rsp), %rdi
movq %rax, (%rdi)
movl $0x2, %esi
callq 0x7780
movl $0x3, %edi
movl $0x32, %esi
movl $0x16, %edx
movl $0x1, %ecx
callq 0x76d7
movq %rax, %rbx
movq (%r12), %rdi
movq %r15, %rsi
movq %r14, %rdx
callq 0xe727
testb %al, %al
je 0x1f8bc
movq 0x18(%rsp), %rdi
leaq 0x230(%rsp), %rsi
movq %r14, %rdx
callq 0xe727
testb %al, %al
je 0x1f8db
movq 0x10(%rsp), %rdi
leaq 0x230(%rsp), %rsi
movq %r14, %rdx
callq 0xe727
testb %al, %al
je 0x1f8fa
movq 0x8(%rsp), %rdi
leaq 0x230(%rsp), %rsi
movq %r14, %rdx
callq 0xe727
testb %al, %al
je 0x1f919
leaq 0x230(%rsp), %r15
movq %rbx, %rdi
movq %r15, %rsi
movq %r14, %rdx
callq 0xe727
testb %al, %al
je 0x1f938
leaq 0x28(%rsp), %rdx
movq %r15, 0x30(%rdx)
movq %r15, 0x38(%rdx)
movq %r15, 0x28(%rdx)
movl $0x0, (%rdx)
xorps %xmm0, %xmm0
movups %xmm0, 0x8(%rdx)
movups %xmm0, 0x18(%rdx)
leaq 0x68(%rsp), %rdi
movq %rsp, %rsi
callq 0x8adc
testb %al, %al
je 0x1f957
movq (%rsp), %rax
movq (%rax), %rdi
callq 0x783c
cmpq 0x20(%rsp), %rax
jne 0x1f976
leaq 0x68(%rsp), %rdi
movq %rsp, %rsi
leaq 0x28(%rsp), %rdx
callq 0x8adc
testb %al, %al
je 0x1f995
movq (%rsp), %rax
movq (%rax), %rdi
callq 0x783c
cmpq 0x18(%rsp), %rax
jne 0x1f9b4
leaq 0x68(%rsp), %rdi
movq %rsp, %rsi
leaq 0x28(%rsp), %rdx
callq 0x8adc
testb %al, %al
je 0x1f9d3
movq (%rsp), %rax
movq (%rax), %rdi
callq 0x783c
cmpq 0x10(%rsp), %rax
jne 0x1f9f2
leaq 0x68(%rsp), %rdi
movq %rsp, %rsi
leaq 0x28(%rsp), %rdx
callq 0x8adc
testb %al, %al
je 0x1fa11
movq (%rsp), %rax
movq (%rax), %rdi
callq 0x783c
cmpq 0x8(%rsp), %rax
jne 0x1fa30
leaq 0x68(%rsp), %rdi
movq %rsp, %rsi
leaq 0x28(%rsp), %rdx
callq 0x8adc
testb %al, %al
je 0x1fa4f
movq (%rsp), %rax
movq (%rax), %rdi
callq 0x783c
cmpq %rbx, %rax
jne 0x1fa6e
addq $0xb98, %rsp            # imm = 0xB98
popq %rbx
popq %r12
popq %r14
popq %r15
retq
leaq 0x14af6(%rip), %rdi     # 0x343b9
leaq 0x1505e(%rip), %rsi     # 0x34928
leaq 0x152ff(%rip), %rcx     # 0x34bd0
movl $0xb4, %edx
callq 0x20d0
leaq 0x14b0d(%rip), %rdi     # 0x343ef
leaq 0x1503f(%rip), %rsi     # 0x34928
leaq 0x152e0(%rip), %rcx     # 0x34bd0
movl $0xb5, %edx
callq 0x20d0
leaq 0x14b10(%rip), %rdi     # 0x34411
leaq 0x15020(%rip), %rsi     # 0x34928
leaq 0x152c1(%rip), %rcx     # 0x34bd0
movl $0xb6, %edx
callq 0x20d0
leaq 0x14b13(%rip), %rdi     # 0x34433
leaq 0x15001(%rip), %rsi     # 0x34928
leaq 0x152a2(%rip), %rcx     # 0x34bd0
movl $0xb7, %edx
callq 0x20d0
leaq 0x14b16(%rip), %rdi     # 0x34455
leaq 0x14fe2(%rip), %rsi     # 0x34928
leaq 0x15283(%rip), %rcx     # 0x34bd0
movl $0xb8, %edx
callq 0x20d0
leaq 0x15258(%rip), %rdi     # 0x34bb6
leaq 0x14fc3(%rip), %rsi     # 0x34928
leaq 0x15264(%rip), %rcx     # 0x34bd0
movl $0xc3, %edx
callq 0x20d0
leaq 0x1526a(%rip), %rdi     # 0x34be7
leaq 0x14fa4(%rip), %rsi     # 0x34928
leaq 0x15245(%rip), %rcx     # 0x34bd0
movl $0xc4, %edx
callq 0x20d0
leaq 0x1521a(%rip), %rdi     # 0x34bb6
leaq 0x14f85(%rip), %rsi     # 0x34928
leaq 0x15226(%rip), %rcx     # 0x34bd0
movl $0xc6, %edx
callq 0x20d0
leaq 0x15247(%rip), %rdi     # 0x34c02
leaq 0x14f66(%rip), %rsi     # 0x34928
leaq 0x15207(%rip), %rcx     # 0x34bd0
movl $0xc7, %edx
callq 0x20d0
leaq 0x151dc(%rip), %rdi     # 0x34bb6
leaq 0x14f47(%rip), %rsi     # 0x34928
leaq 0x151e8(%rip), %rcx     # 0x34bd0
movl $0xc9, %edx
callq 0x20d0
leaq 0x15224(%rip), %rdi     # 0x34c1d
leaq 0x14f28(%rip), %rsi     # 0x34928
leaq 0x151c9(%rip), %rcx     # 0x34bd0
movl $0xca, %edx
callq 0x20d0
leaq 0x1519e(%rip), %rdi     # 0x34bb6
leaq 0x14f09(%rip), %rsi     # 0x34928
leaq 0x151aa(%rip), %rcx     # 0x34bd0
movl $0xcc, %edx
callq 0x20d0
leaq 0x15201(%rip), %rdi     # 0x34c38
leaq 0x14eea(%rip), %rsi     # 0x34928
leaq 0x1518b(%rip), %rcx     # 0x34bd0
movl $0xcd, %edx
callq 0x20d0
leaq 0x15160(%rip), %rdi     # 0x34bb6
leaq 0x14ecb(%rip), %rsi     # 0x34928
leaq 0x1516c(%rip), %rcx     # 0x34bd0
movl $0xd4, %edx
callq 0x20d0
leaq 0x151de(%rip), %rdi     # 0x34c53
leaq 0x14eac(%rip), %rsi     # 0x34928
leaq 0x1514d(%rip), %rcx     # 0x34bd0
movl $0xd5, %edx
callq 0x20d0