// File: /workspace/github_cpp_makefile_star2_O1/kobanium[P]Ray/src/mcts/Rating.cpp
// Function: UpdateNeighborCoordinates(game_info_t*, int, long long*, long long*, long long*, int, int*, bool*)
static void
UpdateNeighborCoordinates( game_info_t *game, int color, long long *sum_rate, long long sum_rate_row[], long long rate[], int update_num, int update[], bool flag[] )
{
  for (int i = 0; i < update_num; i++) {
    for (int j = 0; j < UPDATE_NUM; j++) {
      const int pos = update[i] + neighbor[j];
      if (flag[pos]) continue;

      if (game->candidates[pos]) {
        const bool self_atari_flag = CheckSelfAtariForSimulation(game, color, pos);

        // 元あったレートを消去
        *sum_rate -= rate[pos];
        sum_rate_row[board_y[pos]] -= rate[pos];

        // パターン、戦術的特徴、距離のγ値
        if (!self_atari_flag){
          rate[pos] = 0;
        } else {
          CheckCaptureAndAtariForSimulation(game, color, pos);
          const double gamma = po_pattern[MD2(game->pat, pos)]
            * CalculateTacticalFeatures(&game->tactical_features[pos * ALL_MAX]);
          rate[pos] = static_cast<long long>(gamma) + 1;

          // 新たに計算したレートを代入
          *sum_rate += rate[pos];
          sum_rate_row[board_y[pos]] += rate[pos];
        }

      }
      ClearTacticalFeatures(&game->tactical_features[pos * ALL_MAX]);
      // 更新済みフラグを立てる
      flag[pos] = true;
    }
  }
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x28, %rsp
movq %rdx, %r10
movq %rdi, %r13
movq 0x60(%rsp), %rdx
leaq 0x4748(%rdi), %rax
movq %rax, 0x20(%rsp)
addq $0x97372, %rdi          # imm = 0x97372
xorl %r12d, %r12d
leaq 0x324ea(%rip), %r11     # 0x79ce0
leaq 0x1aac61b3(%rip), %rbx  # 0x1ab0d9b0
movq %r9, 0x10(%rsp)
movq %rdi, 0x8(%rsp)
movq %rcx, 0x18(%rsp)
movl %esi, 0x4(%rsp)
movslq (%r9), %rax
movslq (%r12,%r11), %r15
addq %rax, %r15
cmpb $0x0, (%rdx,%r15)
jne 0x479b2
cmpb $0x1, 0x96ce0(%r13,%r15)
jne 0x47996
movq %r13, %rdi
movl %r15d, %edx
movq %r8, %r14
movq %r10, %rbp
callq 0x57e1b
movq (%r14,%r15,8), %rcx
subq %rcx, (%rbp)
movq (%r14,%r15,8), %rcx
movslq (%rbx,%r15,4), %rdx
movq 0x18(%rsp), %rsi
subq %rcx, (%rsi,%rdx,8)
testb %al, %al
je 0x47967
movq %r13, %rdi
movl 0x4(%rsp), %esi
movl %r15d, %edx
callq 0x58300
movq 0x20(%rsp), %rdi
movl %r15d, %esi
callq 0x4f857
movq %rbp, %r10
movq %r14, %r8
movl %eax, %eax
leaq 0x3248f(%rip), %rcx     # 0x79d20
cvtss2sd (%rcx,%rax,4), %xmm0
movslq %r15d, %rax
leaq (%rax,%rax,2), %rax
movzbl 0x97372(%r13,%rax,2), %ecx
leaq 0x4032493(%rip), %rdx   # 0x4079d40
movss (%rdx,%rcx,4), %xmm1
movzbl 0x97373(%r13,%rax,2), %ecx
leaq 0x40324ce(%rip), %rdx   # 0x4079d90
mulss (%rdx,%rcx,4), %xmm1
movzbl 0x97374(%r13,%rax,2), %ecx
leaq 0x40324d9(%rip), %rdx   # 0x4079db0
mulss (%rdx,%rcx,4), %xmm1
movzbl 0x97375(%r13,%rax,2), %ecx
leaq 0x40324f4(%rip), %rdx   # 0x4079de0
mulss (%rdx,%rcx,4), %xmm1
movzbl 0x97376(%r13,%rax,2), %ecx
leaq 0x40324f3(%rip), %rdx   # 0x4079df4
mulss (%rdx,%rcx,4), %xmm1
movzbl 0x97377(%r13,%rax,2), %eax
leaq 0x40324ea(%rip), %rcx   # 0x4079e00
mulss (%rcx,%rax,4), %xmm1
cvtss2sd %xmm1, %xmm1
mulsd %xmm0, %xmm1
cvttsd2si %xmm1, %rax
incq %rax
movq %rax, (%r14,%r15,8)
addq %rax, (%rbp)
movq (%r14,%r15,8), %rax
leaq 0x1aac6072(%rip), %rbx  # 0x1ab0d9b0
movslq (%rbx,%r15,4), %rcx
movq 0x18(%rsp), %rdx
addq %rax, (%rdx,%rcx,8)
movq 0x10(%rsp), %r9
movl 0x4(%rsp), %esi
movq 0x60(%rsp), %rdx
movq 0x8(%rsp), %rdi
leaq 0x3237b(%rip), %r11     # 0x79ce0
jmp 0x47996
movq %rbp, %r10
movq %r14, %r8
movq $0x0, (%r14,%r15,8)
movq 0x10(%rsp), %r9
movl 0x4(%rsp), %esi
movq 0x60(%rsp), %rdx
movq 0x8(%rsp), %rdi
leaq 0x32351(%rip), %r11     # 0x79ce0
leaq 0x1aac601a(%rip), %rbx  # 0x1ab0d9b0
leal (%r15,%r15), %eax
leal (%rax,%rax,2), %eax
cltq
movw $0x0, 0x4(%rdi,%rax)
movl $0x0, (%rdi,%rax)
movb $0x1, (%rdx,%r15)
addq $0x4, %r12
cmpq $0x34, %r12
jne 0x47810
addq $0x28, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq