// File: /workspace/github_cpp_makefile_star2_O3/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 0x33276(%rip), %r11     # 0x7ace0
leaq 0x1aac6f3f(%rip), %rbx  # 0x1ab0e9b0
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 0x47c26
cmpb $0x1, 0x96ce0(%r13,%r15)
jne 0x47c0a
movq %r13, %rdi
movl %r15d, %edx
movq %r8, %r14
movq %r10, %rbp
callq 0x5871b
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 0x47bdb
movq %r13, %rdi
movl 0x4(%rsp), %esi
movl %r15d, %edx
callq 0x58c25
movq 0x20(%rsp), %rdi
movl %r15d, %esi
callq 0x4fc36
movq %rbp, %r10
movq %r14, %r8
movl %eax, %eax
leaq 0x3321b(%rip), %rcx     # 0x7ad20
cvtss2sd (%rcx,%rax,4), %xmm0
movslq %r15d, %rax
leaq (%rax,%rax,2), %rax
movzbl 0x97372(%r13,%rax,2), %ecx
leaq 0x403321f(%rip), %rdx   # 0x407ad40
movss (%rdx,%rcx,4), %xmm1
movzbl 0x97373(%r13,%rax,2), %ecx
leaq 0x403325a(%rip), %rdx   # 0x407ad90
mulss (%rdx,%rcx,4), %xmm1
movzbl 0x97374(%r13,%rax,2), %ecx
leaq 0x4033265(%rip), %rdx   # 0x407adb0
mulss (%rdx,%rcx,4), %xmm1
movzbl 0x97375(%r13,%rax,2), %ecx
leaq 0x4033280(%rip), %rdx   # 0x407ade0
mulss (%rdx,%rcx,4), %xmm1
movzbl 0x97376(%r13,%rax,2), %ecx
leaq 0x403327f(%rip), %rdx   # 0x407adf4
mulss (%rdx,%rcx,4), %xmm1
movzbl 0x97377(%r13,%rax,2), %eax
leaq 0x4033276(%rip), %rcx   # 0x407ae00
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 0x1aac6dfe(%rip), %rbx  # 0x1ab0e9b0
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 0x33107(%rip), %r11     # 0x7ace0
jmp 0x47c0a
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 0x330dd(%rip), %r11     # 0x7ace0
leaq 0x1aac6da6(%rip), %rbx  # 0x1ab0e9b0
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 0x47a84
addq $0x28, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq