// File: /workspace/github_cpp_makefile_star2_O1/kobanium[P]Ray/src/mcts/UctSearch.cpp
// Function: InitializeUctSearch()
void
InitializeUctSearch( void )
{
  int i;

  // Progressive Wideningの初期化  
  pw[0] = 0;
  for (i = 1; i <= PURE_BOARD_MAX; i++) {  
    pw[i] = pw[i - 1] + static_cast<int>(40 * pow(PROGRESSIVE_WIDENING, i - 1));
    if (pw[i] > 10000000) break;
  }
  for (i = i + 1; i <= PURE_BOARD_MAX; i++) { 
    pw[i] = INT_MAX;
  }

  mutex_nodes = new std::mutex[uct_hash_size];

  // UCTのノードのメモリを確保
  uct_node = new uct_node_t[uct_hash_size];

  std::cerr << "Require " << uct_hash_size * sizeof(uct_node_t) / 1024 / 1024 << " Mbytes for Uct Node" << std::endl << std::endl;
  std::cerr << sizeof(uct_node_t) << std::endl;
  std::cerr << sizeof(child_node_t) * UCT_CHILD_MAX << std::endl;
  
  if (uct_node == NULL) {
    std::cerr << "Cannot allocate memory !!" << std::endl;
    std::cerr << "You must reduce tree size !!" << std::endl;
    exit(1);
  }

}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %rbx
pushq %rax
movl $0x0, 0x1aab78b1(%rip)  # 0x1ab01b50
xorl %r14d, %r14d
leaq 0x1aab78a7(%rip), %rbx  # 0x1ab01b50
movl (%rbx,%r14,4), %ebp
xorps %xmm1, %xmm1
cvtsi2sd %r14d, %xmm1
movsd 0x15ccb(%rip), %xmm0    # 0x5ff88
callq 0x6750
mulsd 0x15cc6(%rip), %xmm0    # 0x5ff90
cvttsd2si %xmm0, %eax
addl %ebp, %eax
movl %eax, 0x4(%rbx,%r14,4)
cmpl $0x989680, %eax         # imm = 0x989680
jg 0x4a2f0
incq %r14
cmpq $0x169, %r14            # imm = 0x169
jne 0x4a2a9
movl $0x16a, %r14d           # imm = 0x16A
jmp 0x4a2f3
incl %r14d
cmpl $0x168, %r14d           # imm = 0x168
ja 0x4a314
movl %r14d, %eax
incq %rax
movl $0x7fffffff, (%rbx,%rax,4) # imm = 0x7FFFFFFF
incq %rax
cmpq $0x16a, %rax            # imm = 0x16A
jne 0x4a302
leaq 0x2b5b5(%rip), %r14     # 0x758d0
movl (%r14), %ebp
movl %ebp, %r15d
leaq (,%r15,8), %rax
leaq (%rax,%rax,4), %rdi
callq 0x6030
movq %rax, %rbx
testl %ebp, %ebp
je 0x4a36c
leaq (%r15,%r15,4), %rax
leaq -0x28(,%rax,8), %rax
movabsq $-0x3333333333333333, %rcx # imm = 0xCCCCCCCCCCCCCCCD
mulq %rcx
shrq $0x5, %rdx
leaq (%rdx,%rdx,4), %rax
leaq 0x28(,%rax,8), %rdx
movq %rbx, %rdi
xorl %esi, %esi
callq 0x6210
movq %rbx, 0x1aab7d85(%rip)  # 0x1ab020f8
imulq $0x4548, %r15, %rdi     # imm = 0x4548
callq 0x6030
movq %rax, 0x1aa905aa(%rip)  # 0x1aada930
movq 0x2ac5b(%rip), %rbx     # 0x74fe8
leaq 0x15c14(%rip), %rsi     # 0x5ffa8
movl $0x8, %edx
movq %rbx, %rdi
callq 0x64a0
movl (%r14), %eax
imulq $0x4548, %rax, %rsi     # imm = 0x4548
shrq $0x14, %rsi
movq %rbx, %rdi
callq 0x6290
movq %rax, %r14
leaq 0x15bf0(%rip), %rsi     # 0x5ffb1
movl $0x14, %edx
movq %rax, %rdi
callq 0x64a0
movq (%r14), %rax
movq -0x18(%rax), %rdi
addq %r14, %rdi
movl $0xa, %esi
callq 0x63d0
movsbl %al, %esi
movq %r14, %rdi
callq 0x6040
movq %rax, %rdi
callq 0x62a0
movq %rax, %r14
movq (%rax), %rax
movq -0x18(%rax), %rdi
addq %r14, %rdi
movl $0xa, %esi
callq 0x63d0
movsbl %al, %esi
movq %r14, %rdi
callq 0x6040
movq %rax, %rdi
callq 0x62a0
movl $0x4548, %esi           # imm = 0x4548
movq %rbx, %rdi
callq 0x6290
movq %rax, %r14
movq (%rax), %rax
movq -0x18(%rax), %rdi
addq %r14, %rdi
movl $0xa, %esi
callq 0x63d0
movsbl %al, %esi
movq %r14, %rdi
callq 0x6040
movq %rax, %rdi
callq 0x62a0
movl $0x2798, %esi           # imm = 0x2798
movq %rbx, %rdi
callq 0x6290
movq %rax, %rbx
movq (%rax), %rax
movq -0x18(%rax), %rdi
addq %rbx, %rdi
movl $0xa, %esi
callq 0x63d0
movsbl %al, %esi
movq %rbx, %rdi
callq 0x6040
movq %rax, %rdi
callq 0x62a0
cmpq $0x0, 0x1aa9049b(%rip)  # 0x1aada930
je 0x4a4a2
addq $0x8, %rsp
popq %rbx
popq %r14
popq %r15
popq %rbp
retq
movq 0x2ab3f(%rip), %rbx     # 0x74fe8
leaq 0x15b16(%rip), %rsi     # 0x5ffc6
movq %rbx, %rdi
callq 0x63f0
movq %rax, %rdi
callq 0x61a0
leaq 0x15b19(%rip), %rsi     # 0x5ffe0
movq %rbx, %rdi
callq 0x63f0
movq %rax, %rdi
callq 0x61a0
movl $0x1, %edi
callq 0x64f0