// File: /workspace/github_cpp_makefile_star2_O1/kobanium[P]Ray/src/mcts/UctSearch.cpp
// Function: UctSearchPondering(game_info_t*, int, int)
void
UctSearchPondering( game_info_t *game, int color, int lz_analysis_cs )
{
  if (!pondering_mode) {
    return;
  }

  // 探索情報をクリア
  for (int i = 0; i < board_max; i++) {
    statistic[i].clear();
  }
  statistic_count = 0;
  std::fill_n(criticality_index, board_max, 0);  
  for (int i = 0; i < board_max; i++) {
    criticality[i] = 0.0;    
  }

  ResetPoCount();

  for (int i = 0; i < pure_board_max; i++) {
    const int pos = onboard_pos[i];
    owner[pos] = 50;
    owner_index[pos] = 5;
    candidates[pos] = true;
  }

  // UCTの初期化
  current_root = ExpandRoot(game, color);

  pondered = false;

  // 子ノードが1つ(パスのみ)ならPASSを返す
  if (uct_node[current_root].child_num <= 1) {
    ponder = false;
    pondering_stop = true;
    return;
  }

  ponder = true;
  pondering_stop = false;

  // Dynamic Komiの算出(置碁のときのみ)
  DynamicKomi(game, &uct_node[current_root], color);

  for (int i = 0; i < threads; i++) {
    t_arg[i].thread_id = i;
    t_arg[i].game = game;
    t_arg[i].color = color;
    t_arg[i].lz_analysis_cs = lz_analysis_cs;
    worker[i] = new std::thread(ParallelUctSearchPondering, &t_arg[i]);
  }

  return;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x18, %rsp
movl %edx, 0x4(%rsp)
cmpb $0x1, 0x1aa8f937(%rip)  # 0x1aada93c
jne 0x4b1c0
movl %esi, %r13d
leaq 0x2a8a3(%rip), %rax     # 0x758b8
cmpl $0x0, (%rax)
jle 0x4b044
leaq 0x1aab9daf(%rip), %rcx  # 0x1ab04dd0
xorl %edx, %edx
xorl %esi, %esi
xorl %r8d, %r8d
xchgl %r8d, (%rcx,%rsi,4)
incq %rsi
cmpq $0x4, %rsi
jne 0x4b025
incq %rdx
movslq (%rax), %rsi
addq $0x10, %rcx
cmpq %rsi, %rdx
jl 0x4b023
movq %rdi, 0x8(%rsp)
xorl %ecx, %ecx
xchgl %ecx, 0x1aabd20f(%rip)  # 0x1ab08260
movslq (%rax), %r15
testq %r15, %r15
jle 0x4b06f
leaq (,%r15,4), %rdx
leaq 0x1aabd208(%rip), %rdi  # 0x1ab08270
xorl %esi, %esi
callq 0x6210
testl %r15d, %r15d
jle 0x4b089
shlq $0x3, %r15
leaq 0x1aabdf21(%rip), %rdi  # 0x1ab08fa0
xorl %esi, %esi
movq %r15, %rdx
callq 0x6210
callq 0x4d5a9
leaq 0x2a81b(%rip), %rax     # 0x758b0
movslq (%rax), %rax
testq %rax, %rax
jle 0x4b0e2
xorl %ecx, %ecx
leaq 0x1ab1564a(%rip), %rdx  # 0x1ab606f0
leaq 0x1aab7053(%rip), %rsi  # 0x1ab02100
movabsq $0x4049000000000000, %rdi # imm = 0x4049000000000000
leaq 0x1aab8a92(%rip), %r8   # 0x1ab03b50
leaq 0x1aab97bb(%rip), %r9   # 0x1ab04880
movslq (%rdx,%rcx,4), %r10
movq %rdi, (%rsi,%r10,8)
movl $0x5, (%r8,%r10,4)
movb $0x1, (%r10,%r9)
incq %rcx
cmpq %rcx, %rax
jne 0x4b0c5
movq 0x8(%rsp), %r15
movq %r15, %rdi
movl %r13d, %esi
callq 0x4aa7a
movl %eax, 0x1aa8f840(%rip)  # 0x1aada938
movb $0x0, 0x1aab9aca(%rip)  # 0x1ab04bc9
movq 0x1aa8f82a(%rip), %rsi  # 0x1aada930
cltq
imulq $0x4548, %rax, %rax     # imm = 0x4548
cmpl $0x2, 0x18(%rsi,%rax)
jge 0x4b129
movb $0x0, 0x1aab9aae(%rip)  # 0x1ab04bcb
movb $0x1, 0x1aab9aa6(%rip)  # 0x1ab04bca
jmp 0x4b1c0
movb $0x1, 0x1aab9a9b(%rip)  # 0x1ab04bcb
movb $0x0, 0x1aab9a93(%rip)  # 0x1ab04bca
addq %rax, %rsi
movq %r15, %rdi
movl %r13d, %edx
callq 0x5635d
cmpl $0x0, 0x2a72c(%rip)     # 0x75878
jle 0x4b1c0
leaq 0x1aab9a7b(%rip), %rbx  # 0x1ab04bd0
leaq 0x1aabf894(%rip), %rbp  # 0x1ab0a9f0
xorl %r14d, %r14d
leaq 0x10(%rsp), %r12
movl %r14d, 0x8(%rbp)
movq %r15, (%rbp)
movl %r13d, %r15d
movl %r13d, 0xc(%rbp)
movl 0x4(%rsp), %eax
movl %eax, 0x10(%rbp)
movl $0x8, %edi
callq 0x6410
movq %rax, %r13
movq %rbp, 0x10(%rsp)
movq %rax, %rdi
leaq 0x51(%rip), %rsi        # 0x4b1e7
movq %r12, %rdx
callq 0x4c976
movq %r13, (%rbx)
incq %r14
movslq 0x2a6cd(%rip), %rax     # 0x75878
addq $0x8, %rbx
addq $0x18, %rbp
cmpq %rax, %r14
movl %r15d, %r13d
movq 0x8(%rsp), %r15
jl 0x4b164
addq $0x18, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq %rax, %rbx
movl $0x8, %esi
movq %r13, %rdi
callq 0x6420
movq %rbx, %rdi
callq 0x6770