// File: /workspace/github_cpp_makefile_star2_O3/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 0xaa51
leaq 0xd34fb(%rip), %rdi     # 0xf7ef0
callq 0x62b6
leaq 0x268(%rsp), %r13
movl $0x4, (%r13)
movl $0x1, %edi
movl $0x32, %esi
movl $0x22, %edx
callq 0x775c
movq %rax, %rbx
movq %rax, 0x8(%r13)
movl $0x1, %edi
movl $0x9, %esi
movl $0x19, %edx
callq 0x775c
movq %rax, %r15
movq %rax, 0x10(%r13)
movl $0x1, %edi
movl $0x22, %esi
movl $0x19, %edx
callq 0x775c
leaq 0x8(%rsp), %r14
movq %rax, (%r14)
movq %r14, %rdi
movl $0x1, %esi
callq 0x77c0
movq (%r14), %rax
movq %rax, 0x18(%r13)
movl $0x2, %edi
movl $0x6, %esi
movl $0x17, %edx
callq 0x775c
movq %rax, %r12
movq %rax, 0x20(%r13)
leaq 0x10(%rsp), %rsi
movq %r13, %rdi
callq 0xdfef
movq $0x0, -0x10(%r13)
movl $0x2710, %edi           # imm = 0x2710
callq 0x244a4
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 0xa400d(%rip), %rax     # 0xc8af0
leaq 0x8912d6(%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 0xb394
addq $0x20, %rsp
movq %r14, %rdi
leaq 0x10(%rsp), %rsi
callq 0xdfef
cmpq %rbx, (%r13)
jne 0x24b5f
cmpq %r15, 0x5a0(%rsp)
jne 0x24b7e
movq 0x5a8(%rsp), %rax
cmpq 0x8(%rsp), %rax
jne 0x24b9d
cmpq %r12, 0x5b0(%rsp)
jne 0x24bbc
addq $0xbe8, %rsp            # imm = 0xBE8
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
leaq 0x11f6a(%rip), %rdi     # 0x36ad0
leaq 0x11de4(%rip), %rsi     # 0x36951
leaq 0x11f82(%rip), %rcx     # 0x36af6
movl $0x91, %edx
callq 0x20d0
leaq 0x11f92(%rip), %rdi     # 0x36b17
leaq 0x11dc5(%rip), %rsi     # 0x36951
leaq 0x11f63(%rip), %rcx     # 0x36af6
movl $0x92, %edx
callq 0x20d0
leaq 0x11f99(%rip), %rdi     # 0x36b3d
leaq 0x11da6(%rip), %rsi     # 0x36951
leaq 0x11f44(%rip), %rcx     # 0x36af6
movl $0x93, %edx
callq 0x20d0
leaq 0x11fa0(%rip), %rdi     # 0x36b63
leaq 0x11d87(%rip), %rsi     # 0x36951
leaq 0x11f25(%rip), %rcx     # 0x36af6
movl $0x94, %edx
callq 0x20d0