// File: /workspace/github_cpp_makefile_star2_O2/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 %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0xb98, %rsp            # imm = 0xB98
leaq 0xf715(%rip), %rsi      # 0x2cddb
leaq 0x68(%rsp), %r14
movq %r14, %rdi
callq 0xa1b8
leaq 0x230(%rsp), %rdi
pushq $0x1
popq %rbx
movq %r14, %rsi
movl %ebx, %edx
movl %ebx, %ecx
callq 0x73f8
movq %rax, %r14
pushq $0xc
popq %rbp
pushq $0x4
popq %r13
movl %ebx, %edi
movl %ebp, %esi
movl %r13d, %edx
callq 0x7284
leaq 0x20(%rsp), %r12
movq %rax, (%r12)
pushq $0x5
popq %rsi
movq %r12, %rdi
callq 0x733b
movl %ebx, %edi
movl %ebp, %esi
movl %r13d, %edx
callq 0x7284
leaq 0x18(%rsp), %rdi
movq %rax, (%rdi)
movl %r13d, %esi
callq 0x733b
movl %ebx, %edi
movl %ebp, %esi
movl %r13d, %edx
callq 0x7284
leaq 0x10(%rsp), %rdi
movq %rax, (%rdi)
pushq $0x3
popq %r15
movl %r15d, %esi
callq 0x733b
movl %ebx, %edi
movl %ebp, %esi
movl %r13d, %edx
callq 0x7284
leaq 0x8(%rsp), %rdi
movq %rax, (%rdi)
pushq $0x2
popq %rsi
callq 0x733b
pushq $0x32
popq %rsi
pushq $0x16
popq %rdx
movl %r15d, %edi
movl %ebx, %ecx
callq 0x72a3
movq %rax, %rbx
movq (%r12), %rdi
leaq 0x230(%rsp), %rsi
movq %r14, %rdx
callq 0xdacb
testb %al, %al
je 0x1d92f
movq 0x18(%rsp), %rdi
leaq 0x230(%rsp), %rsi
movq %r14, %rdx
callq 0xdacb
testb %al, %al
je 0x1d94e
movq 0x10(%rsp), %rdi
leaq 0x230(%rsp), %rsi
movq %r14, %rdx
callq 0xdacb
testb %al, %al
je 0x1d96d
movq 0x8(%rsp), %rdi
leaq 0x230(%rsp), %rsi
movq %r14, %rdx
callq 0xdacb
testb %al, %al
je 0x1d98c
leaq 0x230(%rsp), %r15
movq %rbx, %rdi
movq %r15, %rsi
movq %r14, %rdx
callq 0xdacb
testb %al, %al
je 0x1d9ab
leaq 0x28(%rsp), %rdx
movq %r15, 0x30(%rdx)
movq %r15, 0x38(%rdx)
movq %r15, 0x28(%rdx)
andl $0x0, (%rdx)
xorps %xmm0, %xmm0
movups %xmm0, 0x8(%rdx)
movups %xmm0, 0x18(%rdx)
leaq 0x68(%rsp), %rdi
movq %rsp, %rsi
callq 0x8490
testb %al, %al
je 0x1d9ca
movq (%rsp), %rax
movq (%rax), %rdi
callq 0x73f4
cmpq 0x20(%rsp), %rax
jne 0x1d9e9
leaq 0x68(%rsp), %rdi
movq %rsp, %rsi
leaq 0x28(%rsp), %rdx
callq 0x8490
testb %al, %al
je 0x1da08
movq (%rsp), %rax
movq (%rax), %rdi
callq 0x73f4
cmpq 0x18(%rsp), %rax
jne 0x1da27
leaq 0x68(%rsp), %rdi
movq %rsp, %rsi
leaq 0x28(%rsp), %rdx
callq 0x8490
testb %al, %al
je 0x1da46
movq (%rsp), %rax
movq (%rax), %rdi
callq 0x73f4
cmpq 0x10(%rsp), %rax
jne 0x1da65
leaq 0x68(%rsp), %rdi
movq %rsp, %rsi
leaq 0x28(%rsp), %rdx
callq 0x8490
testb %al, %al
je 0x1da84
movq (%rsp), %rax
movq (%rax), %rdi
callq 0x73f4
cmpq 0x8(%rsp), %rax
jne 0x1daa3
leaq 0x68(%rsp), %rdi
movq %rsp, %rsi
leaq 0x28(%rsp), %rdx
callq 0x8490
testb %al, %al
je 0x1dac2
movq (%rsp), %rax
movq (%rax), %rdi
callq 0x73f4
cmpq %rbx, %rax
jne 0x1dae1
addq $0xb98, %rsp            # imm = 0xB98
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
leaq 0x14bc6(%rip), %rdi     # 0x324fc
leaq 0x1512e(%rip), %rsi     # 0x32a6b
leaq 0x153cf(%rip), %rcx     # 0x32d13
movl $0xb4, %edx
callq 0x20c0
leaq 0x14bdd(%rip), %rdi     # 0x32532
leaq 0x1510f(%rip), %rsi     # 0x32a6b
leaq 0x153b0(%rip), %rcx     # 0x32d13
movl $0xb5, %edx
callq 0x20c0
leaq 0x14be0(%rip), %rdi     # 0x32554
leaq 0x150f0(%rip), %rsi     # 0x32a6b
leaq 0x15391(%rip), %rcx     # 0x32d13
movl $0xb6, %edx
callq 0x20c0
leaq 0x14be3(%rip), %rdi     # 0x32576
leaq 0x150d1(%rip), %rsi     # 0x32a6b
leaq 0x15372(%rip), %rcx     # 0x32d13
movl $0xb7, %edx
callq 0x20c0
leaq 0x14be6(%rip), %rdi     # 0x32598
leaq 0x150b2(%rip), %rsi     # 0x32a6b
leaq 0x15353(%rip), %rcx     # 0x32d13
movl $0xb8, %edx
callq 0x20c0
leaq 0x15328(%rip), %rdi     # 0x32cf9
leaq 0x15093(%rip), %rsi     # 0x32a6b
leaq 0x15334(%rip), %rcx     # 0x32d13
movl $0xc3, %edx
callq 0x20c0
leaq 0x1533a(%rip), %rdi     # 0x32d2a
leaq 0x15074(%rip), %rsi     # 0x32a6b
leaq 0x15315(%rip), %rcx     # 0x32d13
movl $0xc4, %edx
callq 0x20c0
leaq 0x152ea(%rip), %rdi     # 0x32cf9
leaq 0x15055(%rip), %rsi     # 0x32a6b
leaq 0x152f6(%rip), %rcx     # 0x32d13
movl $0xc6, %edx
callq 0x20c0
leaq 0x15317(%rip), %rdi     # 0x32d45
leaq 0x15036(%rip), %rsi     # 0x32a6b
leaq 0x152d7(%rip), %rcx     # 0x32d13
movl $0xc7, %edx
callq 0x20c0
leaq 0x152ac(%rip), %rdi     # 0x32cf9
leaq 0x15017(%rip), %rsi     # 0x32a6b
leaq 0x152b8(%rip), %rcx     # 0x32d13
movl $0xc9, %edx
callq 0x20c0
leaq 0x152f4(%rip), %rdi     # 0x32d60
leaq 0x14ff8(%rip), %rsi     # 0x32a6b
leaq 0x15299(%rip), %rcx     # 0x32d13
movl $0xca, %edx
callq 0x20c0
leaq 0x1526e(%rip), %rdi     # 0x32cf9
leaq 0x14fd9(%rip), %rsi     # 0x32a6b
leaq 0x1527a(%rip), %rcx     # 0x32d13
movl $0xcc, %edx
callq 0x20c0
leaq 0x152d1(%rip), %rdi     # 0x32d7b
leaq 0x14fba(%rip), %rsi     # 0x32a6b
leaq 0x1525b(%rip), %rcx     # 0x32d13
movl $0xcd, %edx
callq 0x20c0
leaq 0x15230(%rip), %rdi     # 0x32cf9
leaq 0x14f9b(%rip), %rsi     # 0x32a6b
leaq 0x1523c(%rip), %rcx     # 0x32d13
movl $0xd4, %edx
callq 0x20c0
leaq 0x152ae(%rip), %rdi     # 0x32d96
leaq 0x14f7c(%rip), %rsi     # 0x32a6b
leaq 0x1521d(%rip), %rcx     # 0x32d13
movl $0xd5, %edx
callq 0x20c0