// File: /workspace/github_cpp_makefile_star2_O2/jswaff[P]prophet3/test/search__test.cpp
// Function: test_search_last_pv_first()
void test_search_last_pv_first() {
    position pos;
    reset_pos(&pos);
    clear_hash_table(&htbl);

    // create an artificial PV and ensure the search examines it first
    search_stats stats;
    stats.last_pv.n=4;
    move c2c4 = stats.last_pv.mv[0] = to_move(PAWN,C2,C4);
    move b7b5 = stats.last_pv.mv[1] = to_move(PAWN,B7,B5);
    move c4b5 = to_move(PAWN,C4,B5);
    set_capture(&c4b5,PAWN);
    stats.last_pv.mv[2] = c4b5;
    move g8h6 = stats.last_pv.mv[3] = to_move(KNIGHT,G8,H6);

    char pv_text[100];
    line_to_str(&stats.last_pv,pv_text);
    //print("last pv: %s\n",pv_text);

    stats.nodes=0;
    start_timer(10000);
    stats.first_line_searched.n=0;
    for (int i=0;i<MAX_PLY;i++) {
        stats.first_line_searched.mv[i] = BADMOVE;
    }
    move_line pv; pv.n=0;
    search(&pos,&pv,-INF,INF,5,&stats,move_stack,gundos,false);

    line_to_str(&stats.first_line_searched,pv_text);
    //print("first line length: %d\n",stats.first_line_searched.n);
    //print("first line: %s\n",pv_text);

    assert(stats.first_line_searched.mv[0]==c2c4);
    assert(stats.first_line_searched.mv[1]==b7b5);
    assert(stats.first_line_searched.mv[2]==c4b5);
    assert(stats.first_line_searched.mv[3]==g8h6);
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0xbe8, %rsp            # imm = 0xBE8
leaq 0x78(%rsp), %rdi
callq 0xa187
leaq 0xd85d0(%rip), %rdi     # 0xfaef0
callq 0x5dd9
leaq 0x268(%rsp), %r12
movl $0x4, (%r12)
pushq $0x1
popq %rbp
pushq $0x32
popq %rsi
pushq $0x22
popq %r15
movl %ebp, %edi
movl %r15d, %edx
callq 0x7284
movq %rax, %rbx
movq %rax, 0x8(%r12)
pushq $0x9
popq %rsi
pushq $0x19
popq %r13
movl %ebp, %edi
movl %r13d, %edx
callq 0x7284
movq %rax, %r14
movq %rax, 0x10(%r12)
movl %ebp, %edi
movl %r15d, %esi
movl %r13d, %edx
callq 0x7284
leaq 0x8(%rsp), %r15
movq %rax, (%r15)
movq %r15, %rdi
movl %ebp, %esi
callq 0x72df
movq (%r15), %rax
movq %rax, 0x18(%r12)
pushq $0x2
popq %rdi
pushq $0x6
popq %rsi
pushq $0x17
popq %rdx
callq 0x7284
movq %rax, %r15
movq %rax, 0x20(%r12)
leaq 0x10(%rsp), %rsi
movq %r12, %rdi
callq 0xd551
andq $0x0, -0x10(%r12)
movl $0x2710, %edi           # imm = 0x2710
callq 0x22420
leaq 0x590(%rsp), %r12
andl $0x0, (%r12)
pushq $0x6b
popq %rax
cmpq $0xcf, %rax
je 0x229ea
andq $0x0, 0x240(%rsp,%rax,8)
incq %rax
jmp 0x229d4
leaq 0x8c0(%rsp), %rsi
andl $0x0, (%rsi)
subq $0x8, %rsp
leaq 0xa90f0(%rip), %rax     # 0xcbaf0
leaq 0x8963b9(%rip), %r10    # 0x8b8dc0
leaq 0x80(%rsp), %rdi
pushq $0x5
popq %r8
leaq 0x248(%rsp), %r13
movl $0xfffcf2c0, %edx       # imm = 0xFFFCF2C0
movl $0x30d40, %ecx          # imm = 0x30D40
movq %r13, %r9
pushq $0x0
pushq %rax
pushq %r10
callq 0xaa1d
addq $0x20, %rsp
leaq 0x10(%rsp), %rsi
movq %r12, %rdi
callq 0xd551
cmpq %rbx, 0x358(%r13)
jne 0x22a81
cmpq %r14, 0x5a0(%rsp)
jne 0x22aa0
movq 0x5a8(%rsp), %rax
cmpq 0x8(%rsp), %rax
jne 0x22abf
cmpq %r15, 0x5b0(%rsp)
jne 0x22ade
addq $0xbe8, %rsp            # imm = 0xBE8
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
leaq 0x1210c(%rip), %rdi     # 0x34b94
leaq 0x11f86(%rip), %rsi     # 0x34a15
leaq 0x12124(%rip), %rcx     # 0x34bba
movl $0x91, %edx
callq 0x20c0
leaq 0x12134(%rip), %rdi     # 0x34bdb
leaq 0x11f67(%rip), %rsi     # 0x34a15
leaq 0x12105(%rip), %rcx     # 0x34bba
movl $0x92, %edx
callq 0x20c0
leaq 0x1213b(%rip), %rdi     # 0x34c01
leaq 0x11f48(%rip), %rsi     # 0x34a15
leaq 0x120e6(%rip), %rcx     # 0x34bba
movl $0x93, %edx
callq 0x20c0
leaq 0x12142(%rip), %rdi     # 0x34c27
leaq 0x11f29(%rip), %rsi     # 0x34a15
leaq 0x120c7(%rip), %rcx     # 0x34bba
movl $0x94, %edx
callq 0x20c0