// File: jswaff[P]prophet3/test/next__test.cpp
// Function: test_pv_then_hash_then_captures()
void test_pv_then_hash_then_captures() {
    position pos;
    set_pos(&pos,"6R1/kp6/8/1KpP4/8/8/8/6B1 w - c6");

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

    move d5c6 = to_capture(PAWN,D5,C6,PAWN);
    set_epcapture(&d5c6);
    move b5c5 = to_capture(KING,B5,C5,PAWN);
    move g1c5 = to_capture(BISHOP,G1,C5,PAWN);
    move g8g7 = to_move(ROOK,G8,G7);

    assert(is_in_move_list(d5c6,moves,endp));
    assert(is_in_move_list(b5c5,moves,endp));
    assert(is_in_move_list(g1c5,moves,endp));
    assert(is_in_move_list(g8g7,moves,endp));

    move_order_dto mo_dto;
    mo_dto.startp = mo_dto.currentp = mo_dto.endp = moves;
    mo_dto.pv_move = g8g7;
    mo_dto.hash_move = d5c6;
    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)==g8g7);

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

    assert(next(&pos,&nextp,&mo_dto));
    assert(clear_score(*nextp)==g1c5 || clear_score(*nextp)==b5c5);

    assert(next(&pos,&nextp,&mo_dto));
    assert(clear_score(*nextp)==g1c5 || clear_score(*nextp)==b5c5);
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0xbb0, %rsp            # imm = 0xBB0
leaq -0x1c8(%rbp), %rdi
leaq 0x16f59(%rip), %rsi     # 0x41122
callq 0xf3e0
leaq -0xb30(%rbp), %rdi
leaq -0x1c8(%rbp), %rsi
movl $0x1, %ecx
movl %ecx, %edx
callq 0xac70
movq %rax, -0xb38(%rbp)
movl $0x1, %ecx
movl $0x1b, %esi
movl $0x12, %edx
movl %ecx, %edi
callq 0xa890
movq %rax, -0xb40(%rbp)
leaq -0xb40(%rbp), %rdi
callq 0xaa20
movl $0x6, %edi
movl $0x19, %esi
movl $0x1a, %edx
movl $0x1, %ecx
callq 0xa890
movq %rax, -0xb48(%rbp)
movl $0x3, %edi
movl $0x3e, %esi
movl $0x1a, %edx
movl $0x1, %ecx
callq 0xa890
movq %rax, -0xb50(%rbp)
movl $0x4, %edi
movl $0x6, %esi
movl $0xe, %edx
callq 0xa830
movq %rax, -0xb58(%rbp)
movq -0xb40(%rbp), %rdi
leaq -0xb30(%rbp), %rsi
movq -0xb38(%rbp), %rdx
callq 0x14c10
testb $0x1, %al
jne 0x2a293
jmp 0x2a295
jmp 0x2a2b4
leaq 0x16ea7(%rip), %rdi     # 0x41143
leaq 0x16fa7(%rip), %rsi     # 0x4124a
movl $0xe5, %edx
leaq 0x172e0(%rip), %rcx     # 0x4158f
callq 0x20c0
movq -0xb48(%rbp), %rdi
leaq -0xb30(%rbp), %rsi
movq -0xb38(%rbp), %rdx
callq 0x14c10
testb $0x1, %al
jne 0x2a2d4
jmp 0x2a2d6
jmp 0x2a2f5
leaq 0x16e9b(%rip), %rdi     # 0x41178
leaq 0x16f66(%rip), %rsi     # 0x4124a
movl $0xe6, %edx
leaq 0x1729f(%rip), %rcx     # 0x4158f
callq 0x20c0
movq -0xb50(%rbp), %rdi
leaq -0xb30(%rbp), %rsi
movq -0xb38(%rbp), %rdx
callq 0x14c10
testb $0x1, %al
jne 0x2a315
jmp 0x2a317
jmp 0x2a336
leaq 0x16e7b(%rip), %rdi     # 0x41199
leaq 0x16f25(%rip), %rsi     # 0x4124a
movl $0xe7, %edx
leaq 0x1725e(%rip), %rcx     # 0x4158f
callq 0x20c0
movq -0xb58(%rbp), %rdi
leaq -0xb30(%rbp), %rsi
movq -0xb38(%rbp), %rdx
callq 0x14c10
testb $0x1, %al
jne 0x2a356
jmp 0x2a358
jmp 0x2a377
leaq 0x17257(%rip), %rdi     # 0x415b6
leaq 0x16ee4(%rip), %rsi     # 0x4124a
movl $0xe8, %edx
leaq 0x1721d(%rip), %rcx     # 0x4158f
callq 0x20c0
leaq -0xb30(%rbp), %rax
movq %rax, -0xb68(%rbp)
movq %rax, -0xb60(%rbp)
movq %rax, -0xb70(%rbp)
movq -0xb58(%rbp), %rax
movq %rax, -0xb90(%rbp)
movq -0xb40(%rbp), %rax
movq %rax, -0xb88(%rbp)
movq $0x0, -0xb80(%rbp)
movq $0x0, -0xb78(%rbp)
movl $0x0, -0xb98(%rbp)
leaq -0x1c8(%rbp), %rdi
leaq -0xba0(%rbp), %rsi
leaq -0xb98(%rbp), %rdx
callq 0xc670
testb $0x1, %al
jne 0x2a3ef
jmp 0x2a3f1
jmp 0x2a410
leaq 0x170e0(%rip), %rdi     # 0x414d8
leaq 0x16e4b(%rip), %rsi     # 0x4124a
movl $0xf3, %edx
leaq 0x17184(%rip), %rcx     # 0x4158f
callq 0x20c0
movq -0xba0(%rbp), %rax
movq (%rax), %rdi
callq 0xac50
cmpq -0xb58(%rbp), %rax
jne 0x2a42a
jmp 0x2a449
leaq 0x171a6(%rip), %rdi     # 0x415d7
leaq 0x16e12(%rip), %rsi     # 0x4124a
movl $0xf4, %edx
leaq 0x1714b(%rip), %rcx     # 0x4158f
callq 0x20c0
leaq -0x1c8(%rbp), %rdi
leaq -0xba0(%rbp), %rsi
leaq -0xb98(%rbp), %rdx
callq 0xc670
testb $0x1, %al
jne 0x2a469
jmp 0x2a46b
jmp 0x2a48a
leaq 0x17066(%rip), %rdi     # 0x414d8
leaq 0x16dd1(%rip), %rsi     # 0x4124a
movl $0xf6, %edx
leaq 0x1710a(%rip), %rcx     # 0x4158f
callq 0x20c0
movq -0xba0(%rbp), %rax
movq (%rax), %rdi
callq 0xac50
cmpq -0xb40(%rbp), %rax
jne 0x2a4a4
jmp 0x2a4c3
leaq 0x17146(%rip), %rdi     # 0x415f1
leaq 0x16d98(%rip), %rsi     # 0x4124a
movl $0xf7, %edx
leaq 0x170d1(%rip), %rcx     # 0x4158f
callq 0x20c0
leaq -0x1c8(%rbp), %rdi
leaq -0xba0(%rbp), %rsi
leaq -0xb98(%rbp), %rdx
callq 0xc670
testb $0x1, %al
jne 0x2a4e3
jmp 0x2a4e5
jmp 0x2a504
leaq 0x16fec(%rip), %rdi     # 0x414d8
leaq 0x16d57(%rip), %rsi     # 0x4124a
movl $0xf9, %edx
leaq 0x17090(%rip), %rcx     # 0x4158f
callq 0x20c0
movq -0xba0(%rbp), %rax
movq (%rax), %rdi
callq 0xac50
movq %rax, %rcx
movb $0x1, %al
cmpq -0xb50(%rbp), %rcx
movb %al, -0xba1(%rbp)
je 0x2a546
movq -0xba0(%rbp), %rax
movq (%rax), %rdi
callq 0xac50
cmpq -0xb48(%rbp), %rax
sete %al
movb %al, -0xba1(%rbp)
movb -0xba1(%rbp), %al
testb $0x1, %al
jne 0x2a552
jmp 0x2a554
jmp 0x2a573
leaq 0x170b0(%rip), %rdi     # 0x4160b
leaq 0x16ce8(%rip), %rsi     # 0x4124a
movl $0xfa, %edx
leaq 0x17021(%rip), %rcx     # 0x4158f
callq 0x20c0
leaq -0x1c8(%rbp), %rdi
leaq -0xba0(%rbp), %rsi
leaq -0xb98(%rbp), %rdx
callq 0xc670
testb $0x1, %al
jne 0x2a593
jmp 0x2a595
jmp 0x2a5b4
leaq 0x16f3c(%rip), %rdi     # 0x414d8
leaq 0x16ca7(%rip), %rsi     # 0x4124a
movl $0xfc, %edx
leaq 0x16fe0(%rip), %rcx     # 0x4158f
callq 0x20c0
movq -0xba0(%rbp), %rax
movq (%rax), %rdi
callq 0xac50
movq %rax, %rcx
movb $0x1, %al
cmpq -0xb50(%rbp), %rcx
movb %al, -0xba2(%rbp)
je 0x2a5f6
movq -0xba0(%rbp), %rax
movq (%rax), %rdi
callq 0xac50
cmpq -0xb48(%rbp), %rax
sete %al
movb %al, -0xba2(%rbp)
movb -0xba2(%rbp), %al
testb $0x1, %al
jne 0x2a602
jmp 0x2a604
jmp 0x2a623
leaq 0x17000(%rip), %rdi     # 0x4160b
leaq 0x16c38(%rip), %rsi     # 0x4124a
movl $0xfd, %edx
leaq 0x16f71(%rip), %rcx     # 0x4158f
callq 0x20c0
addq $0xbb0, %rsp            # imm = 0xBB0
popq %rbp
retq
nopl (%rax)