// File: kobanium[P]Ray/src/mcts/UctRating.cpp
// Function: AnalyzeUctRating(game_info_t*, int, double*)
void
AnalyzeUctRating( game_info_t *game, int color, double rate[] )
{
  const int moves = game->moves;
  unsigned int tactical_features[BOARD_MAX * UCT_INDEX_MAX] = {0};  
  const int distance_index = CheckFeaturesForTree(game, color, tactical_features);

  CheckRemove2StonesForTree(game, color, tactical_features);
  if (moves > 2 && game->ko_move == moves - 2) {
    CheckCaptureAfterKoForTree(game, color, tactical_features);
    CheckKoConnectionForTree(game, tactical_features);
  } else if (moves > 3 && game->ko_move == moves - 3) {
    CheckKoRecaptureForTree(game, color, tactical_features);
  }

  for (int i = 0; i < pure_board_max; i++) {
    const int pos = onboard_pos[i];
    if (IsLegal(game, pos, color)) {
      CheckSelfAtariForTree(game, color, pos, tactical_features);
      CheckCaptureForTree(game, color, pos, tactical_features);
      CheckAtariForTree(game, color, pos, tactical_features);

      rate[i] = CalculateMoveScoreWithBTFM(game, pos, tactical_features, distance_index);
    } else {
      rate[i] = 0.0;
    }
  }
  rate[pure_board_max] = CalculateMoveScoreWithBTFM(game, PASS, tactical_features, distance_index);
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x5c30, %rsp           # imm = 0x5C30
movq %rdi, -0x8(%rbp)
movl %esi, -0xc(%rbp)
movq %rdx, -0x18(%rbp)
movq -0x8(%rbp), %rax
movl 0x43b0(%rax), %eax
movl %eax, -0x1c(%rbp)
leaq -0x5c20(%rbp), %rdi
xorl %esi, %esi
movl $0x5bfc, %edx           # imm = 0x5BFC
callq 0x72b0
movq -0x8(%rbp), %rdi
movl -0xc(%rbp), %esi
leaq -0x5c20(%rbp), %rdx
callq 0xa5cf0
movl %eax, -0x5c24(%rbp)
movq -0x8(%rbp), %rdi
movl -0xc(%rbp), %esi
leaq -0x5c20(%rbp), %rdx
callq 0xa7be0
cmpl $0x2, -0x1c(%rbp)
jle 0x86b51
movq -0x8(%rbp), %rax
movl 0x43c8(%rax), %eax
movl -0x1c(%rbp), %ecx
subl $0x2, %ecx
cmpl %ecx, %eax
jne 0x86b51
movq -0x8(%rbp), %rdi
movl -0xc(%rbp), %esi
leaq -0x5c20(%rbp), %rdx
callq 0xa7320
movq -0x8(%rbp), %rdi
leaq -0x5c20(%rbp), %rsi
callq 0xa7ab0
jmp 0x86b80
cmpl $0x3, -0x1c(%rbp)
jle 0x86b7e
movq -0x8(%rbp), %rax
movl 0x43c8(%rax), %eax
movl -0x1c(%rbp), %ecx
subl $0x3, %ecx
cmpl %ecx, %eax
jne 0x86b7e
movq -0x8(%rbp), %rdi
movl -0xc(%rbp), %esi
leaq -0x5c20(%rbp), %rdx
callq 0xa7b00
jmp 0x86b80
movl $0x0, -0x5c28(%rbp)
movl -0x5c28(%rbp), %eax
leaq 0x60ea9(%rip), %rcx     # 0xe7a40
cmpl (%rcx), %eax
jge 0x86c70
movslq -0x5c28(%rbp), %rcx
leaq 0x1ab4bcc3(%rip), %rax  # 0x1abd2870
movl (%rax,%rcx,4), %eax
movl %eax, -0x5c2c(%rbp)
movq -0x8(%rbp), %rdi
movl -0x5c2c(%rbp), %esi
movl -0xc(%rbp), %edx
callq 0x9d0b0
testb $0x1, %al
jne 0x86bce
jmp 0x86c47
movq -0x8(%rbp), %rdi
movl -0xc(%rbp), %esi
movl -0x5c2c(%rbp), %edx
leaq -0x5c20(%rbp), %rcx
callq 0xa7480
movq -0x8(%rbp), %rdi
movl -0xc(%rbp), %esi
movl -0x5c2c(%rbp), %edx
leaq -0x5c20(%rbp), %rcx
callq 0xa7870
movq -0x8(%rbp), %rdi
movl -0xc(%rbp), %esi
movl -0x5c2c(%rbp), %edx
leaq -0x5c20(%rbp), %rcx
callq 0xa79e0
movq -0x8(%rbp), %rdi
movl -0x5c2c(%rbp), %esi
leaq -0x5c20(%rbp), %rdx
movl -0x5c24(%rbp), %ecx
callq 0x85f40
movq -0x18(%rbp), %rax
movslq -0x5c28(%rbp), %rcx
movsd %xmm0, (%rax,%rcx,8)
jmp 0x86c5a
movq -0x18(%rbp), %rax
movslq -0x5c28(%rbp), %rcx
xorps %xmm0, %xmm0
movsd %xmm0, (%rax,%rcx,8)
jmp 0x86c5c
movl -0x5c28(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x5c28(%rbp)
jmp 0x86b8a
movq -0x8(%rbp), %rdi
leaq -0x5c20(%rbp), %rdx
movl -0x5c24(%rbp), %ecx
xorl %esi, %esi
callq 0x85f40
movq -0x18(%rbp), %rax
leaq 0x60dad(%rip), %rcx     # 0xe7a40
movslq (%rcx), %rcx
movsd %xmm0, (%rax,%rcx,8)
addq $0x5c30, %rsp           # imm = 0x5C30
popq %rbp
retq
nopw %cs:(%rax,%rax)