// File: /workspace/github_cpp_makefile_star2_O3/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 0x4a155
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 0x564cc
leaq 0x8(%rsp), %rsi
movq %rbx, %rdi
callq 0x22800
leaq 0x18(%rsp), %r13
movq -0x10(%r13), %rdi
cmpq %r13, %rdi
je 0x223be
movq 0x18(%rsp), %rsi
incq %rsi
callq 0x6410
movl 0x10(%r15), %edi
movq 0x28(%r14), %rax
subq 0x20(%r14), %rax
sarq $0x5, %rax
movl 0x1c(%r14), %ecx
cmpq %rcx, %rax
setb %al
cmpl $-0x1, %edi
setne %cl
andb %al, %cl
cmpb $0x1, %cl
jne 0x2249f
leaq 0x8(%rsp), %r15
callq 0x4a49c
movq %rax, %r12
movl 0x18(%rax), %eax
movl 0x8(%r12), %ecx
testl %ecx, %ecx
je 0x2249f
movl 0x20(%r12), %ecx
cmpl $0x2, %eax
jl 0x22439
leaq 0x3c(%r12), %rdx
xorl %edi, %edi
movl $0x1, %esi
movl (%rdx), %r8d
cmpl %ecx, %r8d
jle 0x22428
movl (%rdx), %ecx
movl %esi, %edi
incq %rsi
addq $0x1c, %rdx
cmpq %rsi, %rax
jne 0x2241c
movslq %edi, %rax
jmp 0x2243b
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 0x564cc
movq %rbx, %rdi
movq %r15, %rsi
callq 0x22800
movq 0x8(%rsp), %rdi
cmpq %r13, %rdi
je 0x22479
movq 0x18(%rsp), %rsi
incq %rsi
callq 0x6410
movq 0x28(%r14), %rax
subq 0x20(%r14), %rax
sarq $0x5, %rax
movl 0x1c(%r14), %ecx
cmpq %rcx, %rax
jae 0x2249f
addq %rbp, %r12
movl 0x10(%r12), %edi
cmpl $-0x1, %edi
jne 0x223ee
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
cmpq %rax, %rdi
jne 0x224d0
jmp 0x224e4
jmp 0x224e1
movq %rax, %r14
movq 0x8(%rsp), %rdi
cmpq %r13, %rdi
je 0x224e4
movq 0x18(%rsp), %rsi
incq %rsi
callq 0x6410
jmp 0x224e4
jmp 0x224e1
movq %rax, %r14
movq %rbx, %rdi
callq 0x227a2
movq %r14, %rdi
callq 0x6760