// File: 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
movq %rsp, %rbp
subq $0x50, %rsp
movq %rdi, -0x8(%rbp)
movl %esi, -0xc(%rbp)
movl %edx, -0x10(%rbp)
testb $0x1, 0x1aac2a23(%rip)  # 0x1ab4cabc
jne 0x8a0a0
jmp 0x8a2f9
movl $0x0, -0x14(%rbp)
movl -0x14(%rbp), %eax
leaq 0x5d997(%rip), %rcx     # 0xe7a48
cmpl (%rcx), %eax
jge 0x8a0d7
movslq -0x14(%rbp), %rax
leaq 0x1aaece90(%rip), %rdi  # 0x1ab76f50
shlq $0x4, %rax
addq %rax, %rdi
callq 0x8cf10
movl -0x14(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x14(%rbp)
jmp 0x8a0a7
leaq 0x1aaf0302(%rip), %rdi  # 0x1ab7a3e0
xorl %esi, %esi
callq 0x88450
leaq 0x5d95c(%rip), %rax     # 0xe7a48
movl (%rax), %esi
movl $0x0, -0x18(%rbp)
leaq 0x1aaf02f4(%rip), %rdi  # 0x1ab7a3f0
leaq -0x18(%rbp), %rdx
callq 0x80790
movl $0x0, -0x1c(%rbp)
movl -0x1c(%rbp), %eax
leaq 0x5d932(%rip), %rcx     # 0xe7a48
cmpl (%rcx), %eax
jge 0x8a138
movslq -0x1c(%rbp), %rcx
leaq 0x1aaf0ffb(%rip), %rax  # 0x1ab7b120
xorps %xmm0, %xmm0
movsd %xmm0, (%rax,%rcx,8)
movl -0x1c(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x1c(%rbp)
jmp 0x8a10c
callq 0x8f880
movl $0x0, -0x20(%rbp)
movl -0x20(%rbp), %eax
leaq 0x5d8f2(%rip), %rcx     # 0xe7a40
cmpl (%rcx), %eax
jge 0x8a1a7
movslq -0x20(%rbp), %rcx
leaq 0x1ab48713(%rip), %rax  # 0x1abd2870
movl (%rax,%rcx,4), %eax
movl %eax, -0x24(%rbp)
movslq -0x24(%rbp), %rcx
leaq 0x1aaea112(%rip), %rax  # 0x1ab74280
movsd 0x24ff2(%rip), %xmm0    # 0xaf168
movsd %xmm0, (%rax,%rcx,8)
movslq -0x24(%rbp), %rcx
leaq 0x1aaebb4a(%rip), %rax  # 0x1ab75cd0
movl $0x5, (%rax,%rcx,4)
movslq -0x24(%rbp), %rcx
leaq 0x1aaec868(%rip), %rax  # 0x1ab76a00
movb $0x1, (%rax,%rcx)
movl -0x20(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x20(%rbp)
jmp 0x8a144
movq -0x8(%rbp), %rdi
movl -0xc(%rbp), %esi
callq 0x89930
movl %eax, 0x1aac28ff(%rip)  # 0x1ab4cab8
movb $0x0, 0x1aaecb89(%rip)  # 0x1ab76d49
movq 0x1aac28e9(%rip), %rax  # 0x1ab4cab0
movslq 0x1aac28ea(%rip), %rcx  # 0x1ab4cab8
imulq $0x4548, %rcx, %rcx     # imm = 0x4548
addq %rcx, %rax
cmpl $0x1, 0x18(%rax)
jg 0x8a1f1
movb $0x0, 0x1aaecb66(%rip)  # 0x1ab76d4b
movb $0x1, 0x1aaecb5e(%rip)  # 0x1ab76d4a
jmp 0x8a2f9
movb $0x1, 0x1aaecb53(%rip)  # 0x1ab76d4b
movb $0x0, 0x1aaecb4b(%rip)  # 0x1ab76d4a
movq -0x8(%rbp), %rdi
movq 0x1aac28a6(%rip), %rsi  # 0x1ab4cab0
movslq 0x1aac28a7(%rip), %rax  # 0x1ab4cab8
imulq $0x4548, %rax, %rax     # imm = 0x4548
addq %rax, %rsi
movl -0xc(%rbp), %edx
callq 0x9fe50
movl $0x0, -0x28(%rbp)
movl -0x28(%rbp), %eax
cmpl 0x5d7cd(%rip), %eax     # 0xe7a00
jge 0x8a2f7
movslq -0x28(%rbp), %rax
movl %eax, %edx
leaq (%rax,%rax,2), %rcx
leaq 0x1aaf2926(%rip), %rax  # 0x1ab7cb70
movq %rax, -0x50(%rbp)
movl %edx, 0x8(%rax,%rcx,8)
movq -0x8(%rbp), %rdx
movslq -0x28(%rbp), %rcx
leaq (%rcx,%rcx,2), %rcx
movq %rdx, (%rax,%rcx,8)
movl -0xc(%rbp), %edx
movslq -0x28(%rbp), %rcx
leaq (%rcx,%rcx,2), %rcx
movl %edx, 0xc(%rax,%rcx,8)
movl -0x10(%rbp), %edx
movslq -0x28(%rbp), %rcx
leaq (%rcx,%rcx,2), %rcx
movl %edx, 0x10(%rax,%rcx,8)
movl $0x8, %edi
callq 0x7550
movq %rax, %rdi
movq -0x50(%rbp), %rax
movq %rdi, %rcx
movq %rcx, -0x48(%rbp)
movslq -0x28(%rbp), %rcx
leaq (%rcx,%rcx,2), %rcx
leaq (%rax,%rcx,8), %rax
movq %rax, -0x30(%rbp)
leaq 0x61(%rip), %rsi        # 0x8a310
leaq -0x30(%rbp), %rdx
callq 0x8cf60
jmp 0x8a2ba
movq -0x48(%rbp), %rdx
movslq -0x28(%rbp), %rcx
leaq 0x1aaeca87(%rip), %rax  # 0x1ab76d50
movq %rdx, (%rax,%rcx,8)
movl -0x28(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x28(%rbp)
jmp 0x8a22a
movq -0x48(%rbp), %rdi
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x38(%rbp)
movl %eax, -0x3c(%rbp)
movl $0x8, %esi
callq 0x7560
jmp 0x8a2ff
jmp 0x8a2f9
addq $0x50, %rsp
popq %rbp
retq
movq -0x38(%rbp), %rdi
callq 0x79b0
nopl (%rax,%rax)