// File: /workspace/github_cpp_makefile_star2_O1/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 0xaa43
leaq 0xd334f(%rip), %rdi     # 0xf7ef0
callq 0x6207
leaq 0x268(%rsp), %r13
movl $0x4, (%r13)
movl $0x1, %edi
movl $0x32, %esi
movl $0x22, %edx
callq 0x76b8
movq %rax, %rbx
movq %rax, 0x8(%r13)
movl $0x1, %edi
movl $0x9, %esi
movl $0x19, %edx
callq 0x76b8
movq %rax, %r15
movq %rax, 0x10(%r13)
movl $0x1, %edi
movl $0x22, %esi
movl $0x19, %edx
callq 0x76b8
leaq 0x8(%rsp), %r14
movq %rax, (%r14)
movq %r14, %rdi
movl $0x1, %esi
callq 0x771c
movq (%r14), %rax
movq %rax, 0x18(%r13)
movl $0x2, %edi
movl $0x6, %esi
movl $0x17, %edx
callq 0x76b8
movq %rax, %r12
movq %rax, 0x20(%r13)
leaq 0x10(%rsp), %rsi
movq %r13, %rdi
callq 0xe045
movq $0x0, -0x10(%r13)
movl $0x2710, %edi           # imm = 0x2710
callq 0x24650
leaq 0x590(%rsp), %r14
xorl %ebp, %ebp
movl %ebp, (%r14)
leaq 0x598(%rsp), %r13
movl $0x320, %edx            # imm = 0x320
movq %r13, %rdi
xorl %esi, %esi
callq 0x20c0
leaq 0x8c0(%rsp), %rsi
movl %ebp, (%rsi)
subq $0x8, %rsp
leaq 0xa3e61(%rip), %rax     # 0xc8af0
leaq 0x89112a(%rip), %r10    # 0x8b5dc0
leaq 0x248(%rsp), %r9
leaq 0x80(%rsp), %rdi
movl $0xfffcf2c0, %edx       # imm = 0xFFFCF2C0
movl $0x30d40, %ecx          # imm = 0x30D40
movl $0x5, %r8d
pushq %rbp
pushq %rax
pushq %r10
callq 0xb398
addq $0x20, %rsp
movq %r14, %rdi
leaq 0x10(%rsp), %rsi
callq 0xe045
cmpq %rbx, (%r13)
jne 0x24d0b
cmpq %r15, 0x5a0(%rsp)
jne 0x24d2a
movq 0x5a8(%rsp), %rax
cmpq 0x8(%rsp), %rax
jne 0x24d49
cmpq %r12, 0x5b0(%rsp)
jne 0x24d68
addq $0xbe8, %rsp            # imm = 0xBE8
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
leaq 0x11d3e(%rip), %rdi     # 0x36a50
leaq 0x11bb8(%rip), %rsi     # 0x368d1
leaq 0x11d56(%rip), %rcx     # 0x36a76
movl $0x91, %edx
callq 0x20d0
leaq 0x11d66(%rip), %rdi     # 0x36a97
leaq 0x11b99(%rip), %rsi     # 0x368d1
leaq 0x11d37(%rip), %rcx     # 0x36a76
movl $0x92, %edx
callq 0x20d0
leaq 0x11d6d(%rip), %rdi     # 0x36abd
leaq 0x11b7a(%rip), %rsi     # 0x368d1
leaq 0x11d18(%rip), %rcx     # 0x36a76
movl $0x93, %edx
callq 0x20d0
leaq 0x11d74(%rip), %rdi     # 0x36ae3
leaq 0x11b5b(%rip), %rsi     # 0x368d1
leaq 0x11cf9(%rip), %rcx     # 0x36a76
movl $0x94, %edx
callq 0x20d0