// File: /workspace/github_cpp_makefile_star2_O3/kobanium[P]Ray/src/mcts/Rating.cpp
// Function: AnalyzePoRating(game_info_t*, int, double*)
void
AnalyzePoRating( game_info_t *game, int color, double rate[] )
{
  const int moves = game->moves;
  const int pm1 = game->record[moves - 1].pos;
  double gamma;
  int update_pos[BOARD_MAX], update_num = 0;  
  
  for (int i = 0; i < pure_board_max; i++) {
    const int pos = onboard_pos[i];
    ClearTacticalFeatures(&game->tactical_features[pos * ALL_MAX]);
  }
  
  CheckFeaturesForSimulation(game, color, update_pos, update_num);
  CheckRemove2StonesForSimulation(game, color, update_pos, update_num);
  if (game->ko_move == moves - 2) {
    CheckCaptureAfterKoForSimulation(game, color, update_pos, update_num);
  }
  
  for (int i = 0; i < pure_board_max; i++) {
    const int pos = onboard_pos[i];
    
    if (!IsLegal(game, pos, color)) {
      rate[i] = 0.0;
      continue;
    }
    
    CheckSelfAtariForSimulation(game, color, pos);
    CheckCaptureAndAtariForSimulation(game, color, pos);
    
    gamma = 1.0;
    
    if (pm1 != PASS) {
      const int distance = DIS(pos, pm1);
      if (distance == 2) {
        gamma *= po_neighbor_orig[0];
      } else if (distance == 3) {
        gamma *= po_neighbor_orig[1];
      } else if (distance == 4) {
        gamma *= po_neighbor_orig[2];
      }
    }
    
    gamma *= CalculateTacticalFeatures(&game->tactical_features[pos * ALL_MAX]);
    gamma *= po_pattern[MD2(game->pat, pos)];
    rate[i] = gamma;
  }
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0xd48, %rsp            # imm = 0xD48
movq %rdx, 0x18(%rsp)
movl %esi, %ebp
movq %rdi, %r14
movslq 0x43b0(%rdi), %rbx
movq %rbx, %rax
shlq $0x4, %rax
movslq -0xc(%rax,%rdi), %r15
movl $0x0, 0x4(%rsp)
leaq 0x2e775(%rip), %rdi     # 0x768b0
cmpl $0x0, (%rdi)
jle 0x48171
leaq 0x97372(%r14), %rax
xorl %ecx, %ecx
leaq 0x1ab195a0(%rip), %rdx  # 0x1ab616f0
movslq (%rdx,%rcx,4), %rsi
leaq (%rsi,%rsi,2), %rsi
movw $0x0, 0x4(%rax,%rsi,2)
movl $0x0, (%rax,%rsi,2)
incq %rcx
movslq (%rdi), %rsi
cmpq %rsi, %rcx
jl 0x48150
leaq 0x20(%rsp), %r13
leaq 0x4(%rsp), %r12
movq %r14, %rdi
movl %ebp, %esi
movq %r13, %rdx
movq %r12, %rcx
callq 0x5712c
movq %r14, %rdi
movl %ebp, %esi
movq %r13, %rdx
movq %r12, %rcx
callq 0x58dc7
leal -0x2(%rbx), %eax
cmpl %eax, 0x43c8(%r14)
jne 0x481bb
leaq 0x20(%rsp), %rdx
leaq 0x4(%rsp), %rcx
movq %r14, %rdi
movl %ebp, %esi
callq 0x58535
leaq 0x2e6ee(%rip), %r12     # 0x768b0
cmpl $0x0, (%r12)
jle 0x48374
leaq 0x4748(%r14), %rax
movq %rax, 0x8(%rsp)
xorl %ebx, %ebx
leaq 0x1ab1950e(%rip), %rax  # 0x1ab616f0
movl (%rax,%rbx,4), %r13d
movq %r14, %rdi
movl %r13d, %esi
movl %ebp, %edx
callq 0x55478
xorpd %xmm0, %xmm0
testb %al, %al
je 0x4835a
movslq %r13d, %r12
movq %r14, %rdi
movl %ebp, %esi
movl %r13d, %edx
callq 0x5871b
movq %r14, %rdi
movl %ebp, %esi
movl %r12d, %edx
callq 0x58c25
movsd 0x14de4(%rip), %xmm0    # 0x5d008
testl %r15d, %r15d
je 0x4829f
leaq 0x1aac5a50(%rip), %rcx  # 0x1ab0dc80
movl (%rcx,%r12,4), %eax
subl (%rcx,%r15,4), %eax
movl %eax, %ecx
negl %ecx
cmovsl %eax, %ecx
leaq 0x1aac676a(%rip), %rdx  # 0x1ab0e9b0
movl (%rdx,%r12,4), %eax
subl (%rdx,%r15,4), %eax
movl %eax, %edx
negl %edx
cmovsl %eax, %edx
imulq $0x4c, %rcx, %rax
addq 0x2dd10(%rip), %rax     # 0x75f70
movl (%rax,%rdx,4), %eax
cmpl $0x4, %eax
je 0x48294
cmpl $0x3, %eax
je 0x48287
movsd 0x14d93(%rip), %xmm0    # 0x5d008
cmpl $0x2, %eax
jne 0x4829f
xorps %xmm0, %xmm0
cvtss2sd 0x4032aab(%rip), %xmm0  # 0x407ad30
jmp 0x4829f
xorps %xmm0, %xmm0
cvtss2sd 0x4032aa2(%rip), %xmm0  # 0x407ad34
jmp 0x4829f
xorps %xmm0, %xmm0
cvtss2sd 0x4032a99(%rip), %xmm0  # 0x407ad38
leaq (%r12,%r12,2), %rax
movzbl 0x97372(%r14,%rax,2), %ecx
leaq 0x4032a8d(%rip), %rdx   # 0x407ad40
movss (%rdx,%rcx,4), %xmm1
movzbl 0x97373(%r14,%rax,2), %ecx
leaq 0x4032ac8(%rip), %rdx   # 0x407ad90
mulss (%rdx,%rcx,4), %xmm1
movzbl 0x97374(%r14,%rax,2), %ecx
leaq 0x4032ad3(%rip), %rdx   # 0x407adb0
mulss (%rdx,%rcx,4), %xmm1
movzbl 0x97375(%r14,%rax,2), %ecx
leaq 0x4032aee(%rip), %rdx   # 0x407ade0
mulss (%rdx,%rcx,4), %xmm1
movzbl 0x97376(%r14,%rax,2), %ecx
leaq 0x4032aed(%rip), %rdx   # 0x407adf4
mulss (%rdx,%rcx,4), %xmm1
movzbl 0x97377(%r14,%rax,2), %eax
leaq 0x4032ae4(%rip), %rcx   # 0x407ae00
mulss (%rcx,%rax,4), %xmm1
cvtss2sd %xmm1, %xmm1
mulsd %xmm0, %xmm1
movsd %xmm1, 0x10(%rsp)
movq 0x8(%rsp), %rdi
movl %r12d, %esi
callq 0x4fc36
movl %eax, %eax
leaq 0x329db(%rip), %rcx     # 0x7ad20
xorps %xmm0, %xmm0
cvtss2sd (%rcx,%rax,4), %xmm0
mulsd 0x10(%rsp), %xmm0
leaq 0x2e556(%rip), %r12     # 0x768b0
movq 0x18(%rsp), %rax
movsd %xmm0, (%rax,%rbx,8)
incq %rbx
movslq (%r12), %rax
cmpq %rax, %rbx
jl 0x481db
addq $0xd48, %rsp            # imm = 0xD48
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq