// File: /workspace/github_cpp_makefile_star2_O3/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 0xf973(%rip), %rsi      # 0x2ee2b
leaq 0x68(%rsp), %rbx
movq %rbx, %rdi
callq 0xaa82
leaq 0x230(%rsp), %r15
movq %r15, %rdi
movq %rbx, %rsi
movl $0x1, %edx
movl $0x1, %ecx
callq 0x78e0
movq %rax, %r14
movl $0x1, %edi
movl $0xc, %esi
movl $0x4, %edx
callq 0x775c
leaq 0x20(%rsp), %r12
movq %rax, (%r12)
movq %r12, %rdi
movl $0x5, %esi
callq 0x7824
movl $0x1, %edi
movl $0xc, %esi
movl $0x4, %edx
callq 0x775c
leaq 0x18(%rsp), %rdi
movq %rax, (%rdi)
movl $0x4, %esi
callq 0x7824
movl $0x1, %edi
movl $0xc, %esi
movl $0x4, %edx
callq 0x775c
leaq 0x10(%rsp), %rdi
movq %rax, (%rdi)
movl $0x3, %esi
callq 0x7824
movl $0x1, %edi
movl $0xc, %esi
movl $0x4, %edx
callq 0x775c
leaq 0x8(%rsp), %rdi
movq %rax, (%rdi)
movl $0x2, %esi
callq 0x7824
movl $0x3, %edi
movl $0x32, %esi
movl $0x16, %edx
movl $0x1, %ecx
callq 0x777b
movq %rax, %rbx
movq (%r12), %rdi
movq %r15, %rsi
movq %r14, %rdx
callq 0xe682
testb %al, %al
je 0x1f748
movq 0x18(%rsp), %rdi
leaq 0x230(%rsp), %rsi
movq %r14, %rdx
callq 0xe682
testb %al, %al
je 0x1f767
movq 0x10(%rsp), %rdi
leaq 0x230(%rsp), %rsi
movq %r14, %rdx
callq 0xe682
testb %al, %al
je 0x1f786
movq 0x8(%rsp), %rdi
leaq 0x230(%rsp), %rsi
movq %r14, %rdx
callq 0xe682
testb %al, %al
je 0x1f7a5
leaq 0x230(%rsp), %r15
movq %rbx, %rdi
movq %r15, %rsi
movq %r14, %rdx
callq 0xe682
testb %al, %al
je 0x1f7c4
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 0x8b70
testb %al, %al
je 0x1f7e3
movq (%rsp), %rax
movq (%rax), %rdi
callq 0x78dd
cmpq 0x20(%rsp), %rax
jne 0x1f802
leaq 0x68(%rsp), %rdi
movq %rsp, %rsi
leaq 0x28(%rsp), %rdx
callq 0x8b70
testb %al, %al
je 0x1f821
movq (%rsp), %rax
movq (%rax), %rdi
callq 0x78dd
cmpq 0x18(%rsp), %rax
jne 0x1f840
leaq 0x68(%rsp), %rdi
movq %rsp, %rsi
leaq 0x28(%rsp), %rdx
callq 0x8b70
testb %al, %al
je 0x1f85f
movq (%rsp), %rax
movq (%rax), %rdi
callq 0x78dd
cmpq 0x10(%rsp), %rax
jne 0x1f87e
leaq 0x68(%rsp), %rdi
movq %rsp, %rsi
leaq 0x28(%rsp), %rdx
callq 0x8b70
testb %al, %al
je 0x1f89d
movq (%rsp), %rax
movq (%rax), %rdi
callq 0x78dd
cmpq 0x8(%rsp), %rax
jne 0x1f8bc
leaq 0x68(%rsp), %rdi
movq %rsp, %rsi
leaq 0x28(%rsp), %rdx
callq 0x8b70
testb %al, %al
je 0x1f8db
movq (%rsp), %rax
movq (%rax), %rdi
callq 0x78dd
cmpq %rbx, %rax
jne 0x1f8fa
addq $0xb98, %rsp            # imm = 0xB98
popq %rbx
popq %r12
popq %r14
popq %r15
retq
leaq 0x14cea(%rip), %rdi     # 0x34439
leaq 0x15252(%rip), %rsi     # 0x349a8
leaq 0x154f3(%rip), %rcx     # 0x34c50
movl $0xb4, %edx
callq 0x20d0
leaq 0x14d01(%rip), %rdi     # 0x3446f
leaq 0x15233(%rip), %rsi     # 0x349a8
leaq 0x154d4(%rip), %rcx     # 0x34c50
movl $0xb5, %edx
callq 0x20d0
leaq 0x14d04(%rip), %rdi     # 0x34491
leaq 0x15214(%rip), %rsi     # 0x349a8
leaq 0x154b5(%rip), %rcx     # 0x34c50
movl $0xb6, %edx
callq 0x20d0
leaq 0x14d07(%rip), %rdi     # 0x344b3
leaq 0x151f5(%rip), %rsi     # 0x349a8
leaq 0x15496(%rip), %rcx     # 0x34c50
movl $0xb7, %edx
callq 0x20d0
leaq 0x14d0a(%rip), %rdi     # 0x344d5
leaq 0x151d6(%rip), %rsi     # 0x349a8
leaq 0x15477(%rip), %rcx     # 0x34c50
movl $0xb8, %edx
callq 0x20d0
leaq 0x1544c(%rip), %rdi     # 0x34c36
leaq 0x151b7(%rip), %rsi     # 0x349a8
leaq 0x15458(%rip), %rcx     # 0x34c50
movl $0xc3, %edx
callq 0x20d0
leaq 0x1545e(%rip), %rdi     # 0x34c67
leaq 0x15198(%rip), %rsi     # 0x349a8
leaq 0x15439(%rip), %rcx     # 0x34c50
movl $0xc4, %edx
callq 0x20d0
leaq 0x1540e(%rip), %rdi     # 0x34c36
leaq 0x15179(%rip), %rsi     # 0x349a8
leaq 0x1541a(%rip), %rcx     # 0x34c50
movl $0xc6, %edx
callq 0x20d0
leaq 0x1543b(%rip), %rdi     # 0x34c82
leaq 0x1515a(%rip), %rsi     # 0x349a8
leaq 0x153fb(%rip), %rcx     # 0x34c50
movl $0xc7, %edx
callq 0x20d0
leaq 0x153d0(%rip), %rdi     # 0x34c36
leaq 0x1513b(%rip), %rsi     # 0x349a8
leaq 0x153dc(%rip), %rcx     # 0x34c50
movl $0xc9, %edx
callq 0x20d0
leaq 0x15418(%rip), %rdi     # 0x34c9d
leaq 0x1511c(%rip), %rsi     # 0x349a8
leaq 0x153bd(%rip), %rcx     # 0x34c50
movl $0xca, %edx
callq 0x20d0
leaq 0x15392(%rip), %rdi     # 0x34c36
leaq 0x150fd(%rip), %rsi     # 0x349a8
leaq 0x1539e(%rip), %rcx     # 0x34c50
movl $0xcc, %edx
callq 0x20d0
leaq 0x153f5(%rip), %rdi     # 0x34cb8
leaq 0x150de(%rip), %rsi     # 0x349a8
leaq 0x1537f(%rip), %rcx     # 0x34c50
movl $0xcd, %edx
callq 0x20d0
leaq 0x15354(%rip), %rdi     # 0x34c36
leaq 0x150bf(%rip), %rsi     # 0x349a8
leaq 0x15360(%rip), %rcx     # 0x34c50
movl $0xd4, %edx
callq 0x20d0
leaq 0x153d2(%rip), %rdi     # 0x34cd3
leaq 0x150a0(%rip), %rsi     # 0x349a8
leaq 0x15341(%rip), %rcx     # 0x34c50
movl $0xd5, %edx
callq 0x20d0