// File: kobanium[P]Ray/./include/mcts/AnalysisData.hpp
// Function: CgosAnalyzeData::CgosAnalyzeData(uct_node_t const&, int)
CgosAnalyzeData( const uct_node_t &root, const int color )
    : visits(root.move_count)
  {
    if (root.move_count == 0) {
      win_rate = 0.5;
      ownership = "";
      for (int i = 0; i < pure_board_max; i++) {
        ownership += owner_char[31];
      }
      comment = u8"Ray selected pass immediately.";
    } else {
      win_rate = static_cast<double>(root.win) / root.move_count;

      const child_node_t *children = root.child;

      for (int i = 0; i < root.child_num; i++) {
        if (children[i].move_count > 0) {
          pv_data.push_back(PrincipalVariationData(root, i));
        }
      }
      std::sort(pv_data.begin(), pv_data.end(), std::greater<PrincipalVariationData>());
      ownership = "";
      for (int i = 0; i < pure_board_max; i++) {
        const double owner = static_cast<double>(root.ownership[onboard_pos[i]]) / root.move_count;
        const int owner_index = static_cast<int>(owner * 62);
        ownership += owner_char[owner_index];
      }
      comment = u8"Ray selected next move based on Monte-Carlo tree search.";
    }

  }

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0xe0, %rsp
movq %rdi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
movl %edx, -0x14(%rbp)
movq -0x8(%rbp), %rax
movq %rax, -0xa8(%rbp)
movq -0x10(%rbp), %rdi
addq $0x8, %rdi
callq 0x25780
movq -0xa8(%rbp), %rdi
movl %eax, (%rdi)
addq $0x10, %rdi
movq %rdi, -0xb8(%rbp)
callq 0x28b40
movq -0xa8(%rbp), %rdi
addq $0x28, %rdi
leaq 0x84629(%rip), %rsi     # 0xac9f2
movl $0x40, %edx
callq 0x7430
movq -0xa8(%rbp), %rdi
addq $0x68, %rdi
movq %rdi, -0xb0(%rbp)
callq 0x7770
movq -0xa8(%rbp), %rdi
addq $0x88, %rdi
movq %rdi, -0xa0(%rbp)
callq 0x7770
movq -0x10(%rbp), %rdi
addq $0x8, %rdi
callq 0x25780
cmpl $0x0, %eax
jne 0x284ab
movq -0xa8(%rbp), %rdi
movabsq $0x3fe0000000000000, %rax # imm = 0x3FE0000000000000
movq %rax, 0x8(%rdi)
addq $0x68, %rdi
leaq 0x869f3(%rip), %rsi     # 0xaee2d
callq 0x7760
jmp 0x28441
movl $0x0, -0x28(%rbp)
movl -0x28(%rbp), %eax
leaq 0xbf5ee(%rip), %rcx     # 0xe7a40
cmpl (%rcx), %eax
jge 0x2848a
movq -0xa8(%rbp), %rdi
movsbl 0x47(%rdi), %esi
addq $0x68, %rdi
callq 0x7320
jmp 0x2846c
jmp 0x2846e
movl -0x28(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x28(%rbp)
jmp 0x28448
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x20(%rbp)
movl %eax, -0x24(%rbp)
jmp 0x286d2
movq -0xa8(%rbp), %rdi
addq $0x88, %rdi
leaq 0x84593(%rip), %rsi     # 0xaca32
callq 0x7760
jmp 0x284a6
jmp 0x286c9
movq -0x10(%rbp), %rdi
addq $0xc, %rdi
callq 0x25780
cvtsi2sd %eax, %xmm0
movsd %xmm0, -0xc0(%rbp)
movq -0x10(%rbp), %rdi
addq $0x8, %rdi
callq 0x25780
movsd -0xc0(%rbp), %xmm0
movl %eax, %ecx
movq -0xa8(%rbp), %rax
cvtsi2sd %ecx, %xmm1
divsd %xmm1, %xmm0
movsd %xmm0, 0x8(%rax)
movq -0x10(%rbp), %rax
addq $0x1c, %rax
movq %rax, -0x30(%rbp)
movl $0x0, -0x34(%rbp)
movl -0x34(%rbp), %eax
movq -0x10(%rbp), %rcx
cmpl 0x18(%rcx), %eax
jge 0x2859f
movq -0x30(%rbp), %rdi
movslq -0x34(%rbp), %rax
imulq $0x1c, %rax, %rax
addq %rax, %rdi
addq $0x4, %rdi
callq 0x25780
cmpl $0x0, %eax
jle 0x2858f
movq -0xa8(%rbp), %rax
addq $0x10, %rax
movq %rax, -0xc8(%rbp)
movq -0x10(%rbp), %rsi
movl -0x34(%rbp), %edx
leaq -0x70(%rbp), %rdi
movl $0x64, %ecx
callq 0x28b90
jmp 0x28558
movq -0xc8(%rbp), %rdi
leaq -0x70(%rbp), %rsi
callq 0x28b60
jmp 0x2856a
leaq -0x70(%rbp), %rdi
callq 0x28f40
jmp 0x2858f
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x20(%rbp)
movl %eax, -0x24(%rbp)
leaq -0x70(%rbp), %rdi
callq 0x28f40
jmp 0x286d2
jmp 0x28591
movl -0x34(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x34(%rbp)
jmp 0x28502
movq -0xa8(%rbp), %rdi
addq $0x10, %rdi
movq %rdi, -0xd0(%rbp)
callq 0x28fa0
movq -0xd0(%rbp), %rdi
movq %rax, -0x78(%rbp)
callq 0x28fd0
movq %rax, -0x80(%rbp)
movq -0x78(%rbp), %rdi
movq -0x80(%rbp), %rsi
callq 0x28f60
jmp 0x285d9
movq -0xa8(%rbp), %rdi
addq $0x68, %rdi
leaq 0x86842(%rip), %rsi     # 0xaee2d
callq 0x7760
jmp 0x285f2
movl $0x0, -0x88(%rbp)
movl -0x88(%rbp), %eax
leaq 0xbf437(%rip), %rcx     # 0xe7a40
cmpl (%rcx), %eax
jge 0x286ab
movq -0x10(%rbp), %rdi
movslq -0x88(%rbp), %rcx
leaq 0x1abaa24d(%rip), %rax  # 0x1abd2870
movslq (%rax,%rcx,4), %rax
movsd 0x2b00(%rdi,%rax,8), %xmm0
movsd %xmm0, -0xd8(%rbp)
addq $0x8, %rdi
callq 0x25780
movsd -0xd8(%rbp), %xmm0
movq -0xa8(%rbp), %rdi
cvtsi2sd %eax, %xmm1
divsd %xmm1, %xmm0
movsd %xmm0, -0x90(%rbp)
movsd -0x90(%rbp), %xmm0
movsd 0x83d58(%rip), %xmm1    # 0xac3c8
mulsd %xmm1, %xmm0
cvttsd2si %xmm0, %eax
movl %eax, -0x94(%rbp)
movslq -0x94(%rbp), %rax
movsbl 0x28(%rdi,%rax), %esi
addq $0x68, %rdi
callq 0x7320
jmp 0x28695
jmp 0x28697
movl -0x88(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x88(%rbp)
jmp 0x285fc
movq -0xa8(%rbp), %rdi
addq $0x88, %rdi
leaq 0x84391(%rip), %rsi     # 0xaca51
callq 0x7760
jmp 0x286c7
jmp 0x286c9
addq $0xe0, %rsp
popq %rbp
retq
movq -0xa0(%rbp), %rdi
callq 0x7ae8
movq -0xb0(%rbp), %rdi
callq 0x7ae8
movq -0xb8(%rbp), %rdi
callq 0x29000
movq -0x20(%rbp), %rdi
callq 0x79b0
nop