// File: /workspace/github_cpp_makefile_star2_O1/kobanium[P]Ray/./include/mcts/AnalysisData.hpp
// Function: PrincipalVariationData::PrincipalVariationData(uct_node_t const&, int, int)
PrincipalVariationData( const uct_node_t &root, const int child_index, const int depth_limit = 100 )
    : move(root.child[child_index].pos), playout_win_rate(CalculateWinningRate(root.child[child_index])),
      prior(root.child[child_index].rate), visits(root.child[child_index].move_count.load()), pv_depth_limit(depth_limit)
  {
    const child_node_t &child = root.child[child_index];

    pv.push_back(ParsePoint(child.pos));

    int index = child.index;

    while (pv.size() < pv_depth_limit && index != NOT_EXPANDED) {
      const uct_node_t &node = GetNode(index);
      const child_node_t *children = node.child;
      const int num_children = node.child_num;

      if (node.move_count == 0) {
        break;
      }

      int max_count = children[PASS_INDEX].move_count;
      int max_index = PASS_INDEX;

      for (int i = 1; i < num_children; i++) {
        if (children[i].move_count > max_count) {
          max_count = children[i].move_count;
          max_index = i;
        }
      }

      pv.push_back(ParsePoint(children[max_index].pos));
      index= children[max_index].index;
    }
  }

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x28, %rsp
movl %ecx, %ebx
movq %rdi, %r14
movslq %edx, %rax
leaq (%rax,%rax,8), %rcx
leaq (%rcx,%rcx,2), %rcx
addq %rax, %rcx
leaq (%rsi,%rcx), %r15
addq $0x1c, %r15
movswl (%r15), %eax
movl %eax, (%rdi)
movq %r15, %rdi
callq 0x49ed7
movsd %xmm0, 0x8(%r14)
xorps %xmm0, %xmm0
cvtss2sd 0x14(%r15), %xmm0
movsd %xmm0, 0x10(%r14)
movl 0x4(%r15), %eax
movl %eax, 0x18(%r14)
movl %ebx, 0x1c(%r14)
leaq 0x20(%r14), %rbx
xorps %xmm0, %xmm0
movups %xmm0, 0x20(%r14)
movq $0x0, 0x30(%r14)
movswl (%r15), %esi
leaq 0x8(%rsp), %rdi
callq 0x55b22
leaq 0x8(%rsp), %rsi
movq %rbx, %rdi
callq 0x22a14
leaq 0x18(%rsp), %rax
movq -0x10(%rax), %rdi
cmpq %rax, %rdi
je 0x225d2
movq 0x18(%rsp), %rsi
incq %rsi
callq 0x6420
movl 0x10(%r15), %ebp
leaq 0x8(%rsp), %r15
movq 0x28(%r14), %rax
subq 0x20(%r14), %rax
sarq $0x5, %rax
movl 0x1c(%r14), %ecx
cmpq %rcx, %rax
jae 0x226a1
cmpl $-0x1, %ebp
je 0x226a1
movl %ebp, %edi
callq 0x4a220
movq %rax, %r12
movl 0x18(%rax), %eax
movl 0x8(%r12), %r13d
testl %r13d, %r13d
je 0x22698
movl 0x20(%r12), %ecx
cmpl $0x2, %eax
jl 0x2264b
leaq 0x3c(%r12), %rdx
xorl %edi, %edi
movl $0x1, %esi
movl (%rdx), %r8d
cmpl %ecx, %r8d
jle 0x2263a
movl (%rdx), %ecx
movl %esi, %edi
incq %rsi
addq $0x1c, %rdx
cmpq %rsi, %rax
jne 0x2262e
movslq %edi, %rax
jmp 0x2264d
xorl %eax, %eax
addq $0x1c, %r12
leaq (%rax,%rax,8), %rcx
leaq (%rcx,%rcx,2), %rbp
addq %rax, %rbp
movswl (%r12,%rbp), %esi
movq %r15, %rdi
callq 0x55b22
movq %rbx, %rdi
movq %r15, %rsi
callq 0x22a14
movq 0x8(%rsp), %rdi
leaq 0x18(%rsp), %rax
cmpq %rax, %rdi
je 0x22690
movq 0x18(%rsp), %rsi
incq %rsi
callq 0x6420
addq %rbp, %r12
movl 0x10(%r12), %ebp
testl %r13d, %r13d
jne 0x225db
addq $0x28, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq %rax, %r14
leaq 0x18(%rsp), %rax
movq -0x10(%rax), %rdi
jmp 0x226cd
jmp 0x226e3
movq %rax, %r14
movq 0x8(%rsp), %rdi
leaq 0x18(%rsp), %rax
cmpq %rax, %rdi
je 0x226e6
movq 0x18(%rsp), %rsi
incq %rsi
callq 0x6420
jmp 0x226e6
jmp 0x226e3
movq %rax, %r14
movq %rbx, %rdi
callq 0x229b8
movq %r14, %rdi
callq 0x6770