// File: ATOMIC-LICHESS[P]ATOMKRAFT/move.cpp
// Function: pretty_pv[abi:cxx11](Position&, int, Value, int, Move*)
const string pretty_pv(Position& pos, int depth, Value score, int time, Move pv[]) {

  const int64_t K = 1000;
  const int64_t M = 1000000;
  const int startColumn = 28;
  const size_t maxLength = 80 - startColumn;
  const string lf = string("\n") + string(startColumn, ' ');

  StateInfo state[PLY_MAX_PLUS_2], *st = state;
  Move* m = pv;
  string san;
  std::stringstream s;
  size_t length = 0;

  // First print depth, score, time and searched nodes...
  s << std::setw(2) << depth
    << std::setw(8) << score_string(score)
    << std::setw(8) << time_string(time);

  if (pos.nodes_searched() < M)
      s << std::setw(8) << pos.nodes_searched() / 1 << "  ";
  else if (pos.nodes_searched() < K * M)
      s << std::setw(7) << pos.nodes_searched() / K << "K  ";
  else
      s << std::setw(7) << pos.nodes_searched() / M << "M  ";

  // ...then print the full PV line in short algebraic notation
  while (*m != MOVE_NONE)
  {
      san = move_to_san(pos, *m);
      length += san.length() + 1;

      if (length > maxLength)
      {
          length = san.length() + 1;
          s << lf;
      }
      s << san << ' ';

      pos.do_move(*m++, *st++);
  }

  // Restore original position before to leave
  while (m != pv) pos.undo_move(*--m);

  return s.str();
}

// Assembly:
subq $0x43c8, %rsp           # imm = 0x43C8
movq %rdi, 0xe8(%rsp)
movq %rdi, %rax
movq %rax, 0xf0(%rsp)
movq %rdi, 0x43c0(%rsp)
movq %rsi, 0x43b8(%rsp)
movl %edx, 0x43b4(%rsp)
movl %ecx, 0x43b0(%rsp)
movl %r8d, 0x43ac(%rsp)
movq %r9, 0x43a0(%rsp)
movq $0x3e8, 0x4398(%rsp) # imm = 0x3E8
movq $0xf4240, 0x4390(%rsp) # imm = 0xF4240
movl $0x1c, 0x438c(%rsp)
movq $0x34, 0x4380(%rsp)
leaq 0x433f(%rsp), %rdi
movq %rdi, 0xf8(%rsp)
callq 0x6980
movq 0xf8(%rsp), %rdx
leaq 0x2d4a0(%rip), %rsi     # 0x5ac2b
leaq 0x4340(%rsp), %rdi
callq 0x12070
jmp 0x2d79a
leaq 0x4307(%rsp), %rdi
movq %rdi, 0xe0(%rsp)
callq 0x6980
movq 0xe0(%rsp), %rcx
leaq 0x4308(%rsp), %rdi
movl $0x1c, %esi
movl $0x20, %edx
callq 0x1c660
jmp 0x2d7d0
leaq 0x4360(%rsp), %rdi
leaq 0x4340(%rsp), %rsi
leaq 0x4308(%rsp), %rdx
callq 0x1c790
jmp 0x2d7ef
leaq 0x4308(%rsp), %rdi
callq 0x6a78
leaq 0x4307(%rsp), %rdi
callq 0x6550
leaq 0x4340(%rsp), %rdi
callq 0x6a78
leaq 0x433f(%rsp), %rdi
callq 0x6550
leaq 0x340(%rsp), %rax
movq %rax, 0x338(%rsp)
movq 0x43a0(%rsp), %rax
movq %rax, 0x330(%rsp)
leaq 0x310(%rsp), %rdi
callq 0x6730
leaq 0x188(%rsp), %rdi
callq 0x6340
jmp 0x2d85f
movq $0x0, 0x180(%rsp)
leaq 0x198(%rsp), %rax
movq %rax, 0xd0(%rsp)
movl $0x2, %edi
callq 0x28160
movl %eax, 0xdc(%rsp)
jmp 0x2d88e
movq 0xd0(%rsp), %rdi
movl 0xdc(%rsp), %eax
movl %eax, 0x17c(%rsp)
movl 0x17c(%rsp), %esi
callq 0x65a0
movq %rax, 0xc8(%rsp)
jmp 0x2d8ba
movq 0xc8(%rsp), %rdi
movl 0x43b4(%rsp), %esi
callq 0x6940
movq %rax, 0xc0(%rsp)
jmp 0x2d8d8
movl $0x8, %edi
callq 0x28160
movl %eax, 0xbc(%rsp)
jmp 0x2d8eb
movq 0xc0(%rsp), %rdi
movl 0xbc(%rsp), %eax
movl %eax, 0x178(%rsp)
movl 0x178(%rsp), %esi
callq 0x65a0
movq %rax, 0xb0(%rsp)
jmp 0x2d917
movl 0x43b0(%rsp), %esi
leaq 0x158(%rsp), %rdi
callq 0x2df00
jmp 0x2d92d
movq 0xb0(%rsp), %rdi
leaq 0x158(%rsp), %rsi
callq 0x6420
movq %rax, 0xa8(%rsp)
jmp 0x2d94c
movl $0x8, %edi
callq 0x28160
movl %eax, 0xa4(%rsp)
jmp 0x2d95f
movq 0xa8(%rsp), %rdi
movl 0xa4(%rsp), %eax
movl %eax, 0x154(%rsp)
movl 0x154(%rsp), %esi
callq 0x65a0
movq %rax, 0x98(%rsp)
jmp 0x2d98b
movl 0x43ac(%rsp), %esi
leaq 0x130(%rsp), %rdi
callq 0x2e150
jmp 0x2d9a1
movq 0x98(%rsp), %rdi
leaq 0x130(%rsp), %rsi
callq 0x6420
jmp 0x2d9b8
leaq 0x130(%rsp), %rdi
callq 0x6a78
leaq 0x158(%rsp), %rdi
callq 0x6a78
movq 0x43b8(%rsp), %rdi
callq 0x2e620
movq %rax, 0x90(%rsp)
jmp 0x2d9e9
movq 0x90(%rsp), %rax
cmpq $0xf4240, %rax          # imm = 0xF4240
jge 0x2db7f
leaq 0x198(%rsp), %rax
movq %rax, 0x80(%rsp)
movl $0x8, %edi
callq 0x28160
movl %eax, 0x8c(%rsp)
jmp 0x2da20
movq 0x80(%rsp), %rdi
movl 0x8c(%rsp), %eax
movl %eax, 0x12c(%rsp)
movl 0x12c(%rsp), %esi
callq 0x65a0
movq %rax, 0x78(%rsp)
jmp 0x2da49
movq 0x43b8(%rsp), %rdi
callq 0x2e620
movq %rax, 0x70(%rsp)
jmp 0x2da5d
movq 0x70(%rsp), %rsi
movq 0x78(%rsp), %rdi
callq 0x69e0
movq %rax, 0x68(%rsp)
jmp 0x2da73
movq 0x68(%rsp), %rdi
leaq 0x2bae0(%rip), %rsi     # 0x5955f
callq 0x64b0
jmp 0x2da86
jmp 0x2dce3
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x4330(%rsp)
movl %eax, 0x432c(%rsp)
jmp 0x2daf2
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x4330(%rsp)
movl %eax, 0x432c(%rsp)
jmp 0x2dad8
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x4330(%rsp)
movl %eax, 0x432c(%rsp)
leaq 0x4308(%rsp), %rdi
callq 0x6a78
leaq 0x4307(%rsp), %rdi
callq 0x6550
leaq 0x4340(%rsp), %rdi
callq 0x6a78
leaq 0x433f(%rsp), %rdi
callq 0x6550
jmp 0x2dee5
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x4330(%rsp)
movl %eax, 0x432c(%rsp)
jmp 0x2decb
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x4330(%rsp)
movl %eax, 0x432c(%rsp)
jmp 0x2debe
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x4330(%rsp)
movl %eax, 0x432c(%rsp)
jmp 0x2db6d
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x4330(%rsp)
movl %eax, 0x432c(%rsp)
leaq 0x130(%rsp), %rdi
callq 0x6a78
leaq 0x158(%rsp), %rdi
callq 0x6a78
jmp 0x2debe
movq 0x43b8(%rsp), %rdi
callq 0x2e620
movq %rax, 0x60(%rsp)
jmp 0x2db93
movq 0x60(%rsp), %rax
cmpq $0x3b9aca00, %rax       # imm = 0x3B9ACA00
jge 0x2dc44
leaq 0x198(%rsp), %rax
movq %rax, 0x50(%rsp)
movl $0x7, %edi
callq 0x28160
movl %eax, 0x5c(%rsp)
jmp 0x2dbc1
movq 0x50(%rsp), %rdi
movl 0x5c(%rsp), %eax
movl %eax, 0x128(%rsp)
movl 0x128(%rsp), %esi
callq 0x65a0
movq %rax, 0x48(%rsp)
jmp 0x2dbe4
movq 0x43b8(%rsp), %rdi
callq 0x2e620
movq %rax, 0x40(%rsp)
jmp 0x2dbf8
movq 0x48(%rsp), %rdi
movq 0x40(%rsp), %rax
movabsq $0x20c49ba5e353f7cf, %rcx # imm = 0x20C49BA5E353F7CF
imulq %rcx
movq %rdx, %rsi
movq %rsi, %rdx
shrq $0x3f, %rdx
sarq $0x7, %rsi
addq %rdx, %rsi
callq 0x69e0
movq %rax, 0x38(%rsp)
jmp 0x2dc2c
movq 0x38(%rsp), %rdi
leaq 0x2cc2c(%rip), %rsi     # 0x5a864
callq 0x64b0
jmp 0x2dc3f
jmp 0x2dce1
leaq 0x198(%rsp), %rax
movq %rax, 0x28(%rsp)
movl $0x7, %edi
callq 0x28160
movl %eax, 0x34(%rsp)
jmp 0x2dc61
movq 0x28(%rsp), %rdi
movl 0x34(%rsp), %eax
movl %eax, 0x124(%rsp)
movl 0x124(%rsp), %esi
callq 0x65a0
movq %rax, 0x20(%rsp)
jmp 0x2dc84
movq 0x43b8(%rsp), %rdi
callq 0x2e620
movq %rax, 0x18(%rsp)
jmp 0x2dc98
movq 0x20(%rsp), %rdi
movq 0x18(%rsp), %rax
movabsq $0x431bde82d7b634db, %rcx # imm = 0x431BDE82D7B634DB
imulq %rcx
movq %rdx, %rsi
movq %rsi, %rdx
shrq $0x3f, %rdx
sarq $0x12, %rsi
addq %rdx, %rsi
callq 0x69e0
movq %rax, 0x10(%rsp)
jmp 0x2dccc
movq 0x10(%rsp), %rdi
leaq 0x2cb90(%rip), %rsi     # 0x5a868
callq 0x64b0
jmp 0x2dcdf
jmp 0x2dce1
jmp 0x2dce3
jmp 0x2dce5
movq 0x330(%rsp), %rax
cmpl $0x0, (%rax)
je 0x2de31
movq 0x43b8(%rsp), %rsi
movq 0x330(%rsp), %rax
movl (%rax), %edx
leaq 0x100(%rsp), %rdi
callq 0x2cee0
jmp 0x2dd17
leaq 0x310(%rsp), %rdi
leaq 0x100(%rsp), %rsi
callq 0x6060
jmp 0x2dd2e
leaq 0x100(%rsp), %rdi
callq 0x6a78
leaq 0x310(%rsp), %rdi
callq 0x67b0
addq $0x1, %rax
addq 0x180(%rsp), %rax
movq %rax, 0x180(%rsp)
cmpq $0x34, 0x180(%rsp)
jbe 0x2ddbe
leaq 0x310(%rsp), %rdi
callq 0x67b0
incq %rax
movq %rax, 0x180(%rsp)
leaq 0x198(%rsp), %rdi
leaq 0x4360(%rsp), %rsi
callq 0x6420
jmp 0x2dd96
jmp 0x2ddbe
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x4330(%rsp)
movl %eax, 0x432c(%rsp)
leaq 0x100(%rsp), %rdi
callq 0x6a78
jmp 0x2debe
leaq 0x198(%rsp), %rdi
leaq 0x310(%rsp), %rsi
callq 0x6420
movq %rax, 0x8(%rsp)
jmp 0x2ddda
movq 0x8(%rsp), %rdi
movl $0x20, %esi
callq 0x65d0
jmp 0x2ddeb
movq 0x43b8(%rsp), %rdi
movq 0x330(%rsp), %rax
movq %rax, %rcx
addq $0x4, %rcx
movq %rcx, 0x330(%rsp)
movl (%rax), %esi
movq 0x338(%rsp), %rdx
movq %rdx, %rax
addq $0xa0, %rax
movq %rax, 0x338(%rsp)
callq 0x3a390
jmp 0x2de2c
jmp 0x2dce5
jmp 0x2de33
movq 0x330(%rsp), %rax
cmpq 0x43a0(%rsp), %rax
je 0x2de70
movq 0x43b8(%rsp), %rdi
movq 0x330(%rsp), %rax
movq %rax, %rcx
addq $-0x4, %rcx
movq %rcx, 0x330(%rsp)
movl -0x4(%rax), %esi
callq 0x3c620
jmp 0x2de6e
jmp 0x2de33
movq 0xe8(%rsp), %rdi
leaq 0x188(%rsp), %rsi
callq 0x64a0
jmp 0x2de87
leaq 0x188(%rsp), %rdi
callq 0x6a80
leaq 0x310(%rsp), %rdi
callq 0x6a78
leaq 0x4360(%rsp), %rdi
callq 0x6a78
movq 0xf0(%rsp), %rax
addq $0x43c8, %rsp           # imm = 0x43C8
retq
leaq 0x188(%rsp), %rdi
callq 0x6a80
leaq 0x310(%rsp), %rdi
callq 0x6a78
leaq 0x4360(%rsp), %rdi
callq 0x6a78
movq 0x4330(%rsp), %rdi
callq 0x6970
nopw %cs:(%rax,%rax)