// File: ATOMIC-LICHESS[P]ATOMKRAFT/search.cpp
// Function: (anonymous namespace)::RootMove::pv_info_to_uci[abi:cxx11](Position&, int, int, Value, Value, int)
std::string RootMove::pv_info_to_uci(Position& pos, int depth, int selDepth, Value alpha,
                                   Value beta, int pvIdx) {

    std::stringstream s;

    
    s << "info depth " << depth
#ifdef UCI_VERSION
      << " seldepth " << selDepth
      << " multipv " << pvIdx + 1
#endif   
      << " score " << value_to_uci(pv_score)
      << (pv_score >= beta ? " lowerbound" : pv_score <= alpha ? " upperbound" : "")
#ifdef UCI_VERSION
      << speed_to_uci(pos.nodes_searched())
#endif
      << " pv ";

#if 0 // curtail repetitious PVs
    for (Move* m = pv; *m != MOVE_NONE; m++)
        s << *m << " ";
#else
    Key Z,SAVE[PLY_MAX_PLUS_2]; int H=0; int ply=0;
    StateInfo state[PLY_MAX_PLUS_2], *st = state;
    while (pv[ply]!=MOVE_NONE)
    {Z=pos.get_key();
     for (int h=0;h<H;h++) if (pos.get_key()==SAVE[h]) goto EXIT;
     SAVE[H++]=pos.get_key();    // modification so that reps are not repeated
     s << pv[ply] << " "; pos.do_move(pv[ply++],*st++);
    }
  EXIT:
    do pos.undo_move(pv[--ply]); while (ply);
#endif
    return s.str();
  }

// Assembly:
subq $0x4598, %rsp           # imm = 0x4598
movq %rdi, 0x60(%rsp)
movq %rdi, %rax
movq %rax, 0x68(%rsp)
movl 0x45a8(%rsp), %eax
movl 0x45a0(%rsp), %eax
movq %rdi, 0x4590(%rsp)
movq %rsi, 0x4588(%rsp)
movq %rdx, 0x4580(%rsp)
movl %ecx, 0x457c(%rsp)
movl %r8d, 0x4578(%rsp)
movl %r9d, 0x4574(%rsp)
movq 0x4588(%rsp), %rax
movq %rax, 0x70(%rsp)
leaq 0x43e8(%rsp), %rdi
callq 0x6340
leaq 0x43f8(%rsp), %rdi
leaq 0x13ef6(%rip), %rsi     # 0x5b380
callq 0x64b0
movq %rax, 0x78(%rsp)
jmp 0x47496
movq 0x78(%rsp), %rdi
movl 0x457c(%rsp), %esi
callq 0x6940
movq %rax, 0x58(%rsp)
jmp 0x474ae
movq 0x58(%rsp), %rdi
leaq 0x13f47(%rip), %rsi     # 0x5b401
callq 0x64b0
movq %rax, 0x50(%rsp)
jmp 0x474c6
movq 0x50(%rsp), %rdi
movl 0x4578(%rsp), %esi
callq 0x6940
movq %rax, 0x48(%rsp)
jmp 0x474de
movq 0x48(%rsp), %rdi
leaq 0x13f22(%rip), %rsi     # 0x5b40c
callq 0x64b0
movq %rax, 0x40(%rsp)
jmp 0x474f6
movq 0x40(%rsp), %rdi
movl 0x45a8(%rsp), %esi
incl %esi
callq 0x6940
movq %rax, 0x38(%rsp)
jmp 0x47510
movq 0x38(%rsp), %rdi
leaq 0x13e5c(%rip), %rsi     # 0x5b378
callq 0x64b0
movq %rax, 0x30(%rsp)
jmp 0x47528
movq 0x70(%rsp), %rax
movl 0x8(%rax), %esi
leaq 0x43b8(%rsp), %rdi
callq 0x45880
jmp 0x4753f
movq 0x30(%rsp), %rdi
leaq 0x43b8(%rsp), %rsi
callq 0x6420
movq %rax, 0x28(%rsp)
jmp 0x47558
movq 0x70(%rsp), %rax
movl 0x8(%rax), %eax
cmpl 0x45a0(%rsp), %eax
jl 0x47577
leaq 0x13ea6(%rip), %rax     # 0x5b416
movq %rax, 0x20(%rsp)
jmp 0x4759f
movq 0x70(%rsp), %rax
movl 0x8(%rax), %edx
movl 0x4574(%rsp), %esi
leaq 0xfca7(%rip), %rax      # 0x57234
leaq 0x13e8e(%rip), %rcx     # 0x5b422
cmpl %esi, %edx
cmovleq %rcx, %rax
movq %rax, 0x20(%rsp)
movq 0x28(%rsp), %rdi
movq 0x20(%rsp), %rsi
callq 0x64b0
movq %rax, 0x18(%rsp)
jmp 0x475b5
movq 0x4580(%rsp), %rdi
callq 0x2e620
movq %rax, %rsi
leaq 0x4398(%rsp), %rdi
callq 0x43120
jmp 0x475d4
movq 0x18(%rsp), %rdi
leaq 0x4398(%rsp), %rsi
callq 0x6420
movq %rax, 0x10(%rsp)
jmp 0x475ed
movq 0x10(%rsp), %rdi
leaq 0x13e35(%rip), %rsi     # 0x5b42e
callq 0x64b0
jmp 0x47600
leaq 0x4398(%rsp), %rdi
callq 0x6a78
leaq 0x43b8(%rsp), %rdi
callq 0x6a78
movl $0x0, 0x405c(%rsp)
movl $0x0, 0x4058(%rsp)
leaq 0x90(%rsp), %rax
movq %rax, 0x88(%rsp)
movq 0x70(%rsp), %rax
movslq 0x4058(%rsp), %rcx
cmpl $0x0, 0x10(%rax,%rcx,4)
je 0x477d6
movq 0x4580(%rsp), %rdi
callq 0x4ea00
movq %rax, 0x4390(%rsp)
movl $0x0, 0x84(%rsp)
movl 0x84(%rsp), %eax
cmpl 0x405c(%rsp), %eax
jge 0x4772a
movq 0x4580(%rsp), %rdi
callq 0x4ea00
movslq 0x84(%rsp), %rcx
cmpq 0x4060(%rsp,%rcx,8), %rax
jne 0x47712
jmp 0x477d8
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x43e0(%rsp)
movl %eax, 0x43dc(%rsp)
jmp 0x4783f
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x43e0(%rsp)
movl %eax, 0x43dc(%rsp)
jmp 0x47700
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x43e0(%rsp)
movl %eax, 0x43dc(%rsp)
leaq 0x4398(%rsp), %rdi
callq 0x6a78
leaq 0x43b8(%rsp), %rdi
callq 0x6a78
jmp 0x4783f
jmp 0x47714
movl 0x84(%rsp), %eax
addl $0x1, %eax
movl %eax, 0x84(%rsp)
jmp 0x47678
movq 0x4580(%rsp), %rdi
callq 0x4ea00
movq %rax, %rdx
movq 0x70(%rsp), %rax
movslq 0x405c(%rsp), %rcx
movl %ecx, %esi
incl %esi
movl %esi, 0x405c(%rsp)
movq %rdx, 0x4060(%rsp,%rcx,8)
leaq 0x43f8(%rsp), %rdi
movslq 0x4058(%rsp), %rcx
movl 0x10(%rax,%rcx,4), %esi
callq 0x421c0
movq %rax, 0x8(%rsp)
jmp 0x4777a
movq 0x8(%rsp), %rdi
leaq 0x11dda(%rip), %rsi     # 0x59560
callq 0x64b0
jmp 0x4778d
movq 0x70(%rsp), %rax
movq 0x4580(%rsp), %rdi
movslq 0x4058(%rsp), %rcx
movl %ecx, %edx
incl %edx
movl %edx, 0x4058(%rsp)
movl 0x10(%rax,%rcx,4), %esi
movq 0x88(%rsp), %rdx
movq %rdx, %rax
addq $0xa0, %rax
movq %rax, 0x88(%rsp)
callq 0x3a390
jmp 0x477d1
jmp 0x47640
jmp 0x477d8
jmp 0x477da
movq 0x70(%rsp), %rax
movq 0x4580(%rsp), %rdi
movslq 0x4058(%rsp), %rcx
movl %ecx, %edx
decl %edx
movl %edx, 0x4058(%rsp)
movl 0xc(%rax,%rcx,4), %esi
callq 0x3c620
jmp 0x47805
jmp 0x47807
cmpl $0x0, 0x4058(%rsp)
jne 0x477da
movq 0x60(%rsp), %rdi
leaq 0x43e8(%rsp), %rsi
callq 0x64a0
jmp 0x47825
leaq 0x43e8(%rsp), %rdi
callq 0x6a80
movq 0x68(%rsp), %rax
addq $0x4598, %rsp           # imm = 0x4598
retq
leaq 0x43e8(%rsp), %rdi
callq 0x6a80
movq 0x43e0(%rsp), %rdi
callq 0x6970
nopl (%rax)