// File: kobanium[P]Ray/src/mcts/Rating.cpp
// Function: PartialRating(game_info_t*, int, long long*, long long*, long long*)
void
PartialRating( game_info_t *game, int color, long long *sum_rate, long long *sum_rate_row, long long *rate )
{
  const int other = GetOppositeColor(color);
  int pm1 = PASS, pm2 = PASS, pm3 = PASS;
  int distance_2[4], distance_3[4], distance_4[4];
  bool flag[BOARD_MAX] = { false };  
  int *update_pos = game->update_pos[color - 1];
  int &update_num = game->update_num[color - 1];
  int nakade_pos[4] = { 0 };
  int nakade_num = 0;
  const int prev_feature = game->update_num[color - 1];
  int prev_feature_pos[PURE_BOARD_MAX];

  for (int i = 0; i < prev_feature; i++){
    prev_feature_pos[i] = update_pos[i];
  }

  game->update_num[color - 1] = 0;

  pm1 = game->record[game->moves - 1].pos;
  if (game->moves > 2) pm2 = game->record[game->moves - 2].pos;
  if (game->moves > 3) pm3 = game->record[game->moves - 3].pos;

  if (game->ko_move == game->moves - 2){
    CheckCaptureAfterKoForSimulation(game, color, update_pos, update_num);
  }

  if (pm1 != PASS) {
    Neighbor12(pm1, distance_2, distance_3, distance_4);
    CheckFeaturesForSimulation(game, color, update_pos, update_num);
    CheckRemove2StonesForSimulation(game, color, update_pos, update_num);

    SearchNakade(game, &nakade_num, nakade_pos);
    UpdateCriticalPoint(game, color, sum_rate, sum_rate_row, rate, nakade_pos, nakade_num, flag, pm1);
    // 着手距離2の更新
    UpdateAroundPreviousMove(game, color, sum_rate, sum_rate_row, rate, distance_2, flag, 0);
    // 着手距離3の更新
    UpdateAroundPreviousMove(game, color, sum_rate, sum_rate_row, rate, distance_3, flag, 1);
    // 着手距離4の更新
    UpdateAroundPreviousMove(game, color, sum_rate, sum_rate_row, rate, distance_4, flag, 2);
  }

  // 2手前の着手の12近傍の更新
  if (pm2 != PASS) UpdateNeighborCoordinates(game, color, sum_rate, sum_rate_row, rate, 1, &pm2, flag);
  // 3手前の着手の12近傍の更新
  if (pm3 != PASS) UpdateNeighborCoordinates(game, color, sum_rate, sum_rate_row, rate, 1, &pm3, flag);

  // 以前の着手で戦術的特徴が現れた箇所の更新
  OtherUpdate(game, color, sum_rate, sum_rate_row, rate, prev_feature, prev_feature_pos, flag);
  // 最近の自分の着手の時に戦術的特徴が現れた箇所の更新
  OtherUpdate(game, color, sum_rate, sum_rate_row, rate, game->update_num[color - 1], game->update_pos[color - 1], flag);
  // 最近の相手の着手の時に戦術的特徴が現れた箇所の更新
  OtherUpdate(game, color, sum_rate, sum_rate_row, rate, game->update_num[other - 1], game->update_pos[other - 1], flag);
  // 自分の着手で石を打ち上げた箇所のとその周囲の更新
  CaptureUpdateColor(game, color, sum_rate, sum_rate_row, rate, game->capture_pos[color - 1], flag);
  // 相手の着手で石を打ち上げられた箇所とその周囲の更新
  CaptureUpdateOther(game, color, sum_rate, sum_rate_row, rate, game->capture_pos[other - 1], flag);

}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x9b0, %rsp            # imm = 0x9B0
movq %rdi, -0x8(%rbp)
movl %esi, -0xc(%rbp)
movq %rdx, -0x18(%rbp)
movq %rcx, -0x20(%rbp)
movq %r8, -0x28(%rbp)
movl -0xc(%rbp), %edi
callq 0x25810
movl %eax, -0x2c(%rbp)
movl $0x0, -0x30(%rbp)
movl $0x0, -0x34(%rbp)
movl $0x0, -0x38(%rbp)
leaq -0x3c0(%rbp), %rdi
xorl %esi, %esi
movl $0x349, %edx            # imm = 0x349
callq 0x72b0
movq -0x8(%rbp), %rax
addq $0x99d00, %rax          # imm = 0x99D00
movl -0xc(%rbp), %ecx
subl $0x1, %ecx
movslq %ecx, %rcx
imulq $0x5a4, %rcx, %rcx      # imm = 0x5A4
addq %rcx, %rax
movq %rax, -0x3c8(%rbp)
movq -0x8(%rbp), %rax
addq $0x99cf8, %rax          # imm = 0x99CF8
movl -0xc(%rbp), %ecx
subl $0x1, %ecx
movslq %ecx, %rcx
shlq $0x2, %rcx
addq %rcx, %rax
movq %rax, -0x3d0(%rbp)
leaq -0x3e0(%rbp), %rdi
xorl %esi, %esi
movl $0x10, %edx
callq 0x72b0
movl $0x0, -0x3e4(%rbp)
movq -0x8(%rbp), %rax
movl -0xc(%rbp), %ecx
subl $0x1, %ecx
movslq %ecx, %rcx
movl 0x99cf8(%rax,%rcx,4), %eax
movl %eax, -0x3e8(%rbp)
movl $0x0, -0x994(%rbp)
movl -0x994(%rbp), %eax
cmpl -0x3e8(%rbp), %eax
jge 0x83645
movq -0x3c8(%rbp), %rax
movslq -0x994(%rbp), %rcx
movl (%rax,%rcx,4), %ecx
movslq -0x994(%rbp), %rax
movl %ecx, -0x990(%rbp,%rax,4)
movl -0x994(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x994(%rbp)
jmp 0x83607
movq -0x8(%rbp), %rax
movl -0xc(%rbp), %ecx
subl $0x1, %ecx
movslq %ecx, %rcx
movl $0x0, 0x99cf8(%rax,%rcx,4)
movq -0x8(%rbp), %rax
movq -0x8(%rbp), %rcx
movl 0x43b0(%rcx), %ecx
subl $0x1, %ecx
movslq %ecx, %rcx
shlq $0x4, %rcx
addq %rcx, %rax
movl 0x4(%rax), %eax
movl %eax, -0x30(%rbp)
movq -0x8(%rbp), %rax
cmpl $0x2, 0x43b0(%rax)
jle 0x836ac
movq -0x8(%rbp), %rax
movq -0x8(%rbp), %rcx
movl 0x43b0(%rcx), %ecx
subl $0x2, %ecx
movslq %ecx, %rcx
shlq $0x4, %rcx
addq %rcx, %rax
movl 0x4(%rax), %eax
movl %eax, -0x34(%rbp)
movq -0x8(%rbp), %rax
cmpl $0x3, 0x43b0(%rax)
jle 0x836da
movq -0x8(%rbp), %rax
movq -0x8(%rbp), %rcx
movl 0x43b0(%rcx), %ecx
subl $0x3, %ecx
movslq %ecx, %rcx
shlq $0x4, %rcx
addq %rcx, %rax
movl 0x4(%rax), %eax
movl %eax, -0x38(%rbp)
movq -0x8(%rbp), %rax
movl 0x43c8(%rax), %eax
movq -0x8(%rbp), %rcx
movl 0x43b0(%rcx), %ecx
subl $0x2, %ecx
cmpl %ecx, %eax
jne 0x8370f
movq -0x8(%rbp), %rdi
movl -0xc(%rbp), %esi
movq -0x3c8(%rbp), %rdx
movq -0x3d0(%rbp), %rcx
callq 0xa24d0
cmpl $0x0, -0x30(%rbp)
je 0x83845
movl -0x30(%rbp), %edi
leaq -0x50(%rbp), %rsi
leaq -0x60(%rbp), %rdx
leaq -0x70(%rbp), %rcx
callq 0x83a30
movq -0x8(%rbp), %rdi
movl -0xc(%rbp), %esi
movq -0x3c8(%rbp), %rdx
movq -0x3d0(%rbp), %rcx
callq 0xa0820
movq -0x8(%rbp), %rdi
movl -0xc(%rbp), %esi
movq -0x3c8(%rbp), %rdx
movq -0x3d0(%rbp), %rcx
callq 0xa3400
movq -0x8(%rbp), %rdi
leaq -0x3e0(%rbp), %rdx
leaq -0x3e4(%rbp), %rsi
callq 0xa4b00
movq -0x8(%rbp), %rdi
movl -0xc(%rbp), %esi
movq -0x18(%rbp), %rdx
movq -0x20(%rbp), %rcx
movq -0x28(%rbp), %r8
leaq -0x3e0(%rbp), %r9
movl -0x3e4(%rbp), %r11d
leaq -0x3c0(%rbp), %r10
movl -0x30(%rbp), %eax
movl %r11d, (%rsp)
movq %r10, 0x8(%rsp)
movl %eax, 0x10(%rsp)
callq 0x83b10
movq -0x8(%rbp), %rdi
movl -0xc(%rbp), %esi
movq -0x18(%rbp), %rdx
movq -0x20(%rbp), %rcx
movq -0x28(%rbp), %r8
leaq -0x50(%rbp), %r9
leaq -0x3c0(%rbp), %rax
xorl %r10d, %r10d
movq %rax, (%rsp)
movl $0x0, 0x8(%rsp)
callq 0x83d80
movq -0x8(%rbp), %rdi
movl -0xc(%rbp), %esi
movq -0x18(%rbp), %rdx
movq -0x20(%rbp), %rcx
movq -0x28(%rbp), %r8
leaq -0x60(%rbp), %r9
leaq -0x3c0(%rbp), %rax
movq %rax, (%rsp)
movl $0x1, 0x8(%rsp)
callq 0x83d80
movq -0x8(%rbp), %rdi
movl -0xc(%rbp), %esi
movq -0x18(%rbp), %rdx
movq -0x20(%rbp), %rcx
movq -0x28(%rbp), %r8
leaq -0x70(%rbp), %r9
leaq -0x3c0(%rbp), %rax
movq %rax, (%rsp)
movl $0x2, 0x8(%rsp)
callq 0x83d80
cmpl $0x0, -0x34(%rbp)
je 0x8387d
movq -0x8(%rbp), %rdi
movl -0xc(%rbp), %esi
movq -0x18(%rbp), %rdx
movq -0x20(%rbp), %rcx
movq -0x28(%rbp), %r8
leaq -0x3c0(%rbp), %rax
movl $0x1, %r9d
leaq -0x34(%rbp), %r10
movq %r10, (%rsp)
movq %rax, 0x8(%rsp)
callq 0x840d0
cmpl $0x0, -0x38(%rbp)
je 0x838b5
movq -0x8(%rbp), %rdi
movl -0xc(%rbp), %esi
movq -0x18(%rbp), %rdx
movq -0x20(%rbp), %rcx
movq -0x28(%rbp), %r8
leaq -0x3c0(%rbp), %rax
movl $0x1, %r9d
leaq -0x38(%rbp), %r10
movq %r10, (%rsp)
movq %rax, 0x8(%rsp)
callq 0x840d0
movq -0x8(%rbp), %rdi
movl -0xc(%rbp), %esi
movq -0x18(%rbp), %rdx
movq -0x20(%rbp), %rcx
movq -0x28(%rbp), %r8
movl -0x3e8(%rbp), %r9d
leaq -0x990(%rbp), %r10
leaq -0x3c0(%rbp), %rax
movq %r10, (%rsp)
movq %rax, 0x8(%rsp)
callq 0x842e0
movq -0x8(%rbp), %rdi
movl -0xc(%rbp), %esi
movq -0x18(%rbp), %rdx
movq -0x20(%rbp), %rcx
movq -0x28(%rbp), %r8
movq -0x8(%rbp), %rax
movl -0xc(%rbp), %r9d
subl $0x1, %r9d
movslq %r9d, %r9
movl 0x99cf8(%rax,%r9,4), %r9d
movq -0x8(%rbp), %r10
addq $0x99d00, %r10          # imm = 0x99D00
movl -0xc(%rbp), %eax
subl $0x1, %eax
cltq
imulq $0x5a4, %rax, %rax      # imm = 0x5A4
addq %rax, %r10
leaq -0x3c0(%rbp), %rax
movq %r10, (%rsp)
movq %rax, 0x8(%rsp)
callq 0x842e0
movq -0x8(%rbp), %rdi
movl -0xc(%rbp), %esi
movq -0x18(%rbp), %rdx
movq -0x20(%rbp), %rcx
movq -0x28(%rbp), %r8
movq -0x8(%rbp), %rax
movl -0x2c(%rbp), %r9d
subl $0x1, %r9d
movslq %r9d, %r9
movl 0x99cf8(%rax,%r9,4), %r9d
movq -0x8(%rbp), %r10
addq $0x99d00, %r10          # imm = 0x99D00
movl -0x2c(%rbp), %eax
subl $0x1, %eax
cltq
imulq $0x5a4, %rax, %rax      # imm = 0x5A4
addq %rax, %r10
leaq -0x3c0(%rbp), %rax
movq %r10, (%rsp)
movq %rax, 0x8(%rsp)
callq 0x842e0
movq -0x8(%rbp), %rdi
movl -0xc(%rbp), %esi
movq -0x18(%rbp), %rdx
movq -0x20(%rbp), %rcx
movq -0x28(%rbp), %r8
movq -0x8(%rbp), %r9
addq $0x98738, %r9           # imm = 0x98738
movl -0xc(%rbp), %eax
subl $0x1, %eax
cltq
imulq $0xae0, %rax, %rax      # imm = 0xAE0
addq %rax, %r9
leaq -0x3c0(%rbp), %rax
movq %rax, (%rsp)
callq 0x844c0
movq -0x8(%rbp), %rdi
movl -0xc(%rbp), %esi
movq -0x18(%rbp), %rdx
movq -0x20(%rbp), %rcx
movq -0x28(%rbp), %r8
movq -0x8(%rbp), %r9
addq $0x98738, %r9           # imm = 0x98738
movl -0x2c(%rbp), %eax
subl $0x1, %eax
cltq
imulq $0xae0, %rax, %rax      # imm = 0xAE0
addq %rax, %r9
leaq -0x3c0(%rbp), %rax
movq %rax, (%rsp)
callq 0x846e0
addq $0x9b0, %rsp            # imm = 0x9B0
popq %rbp
retq
nopl (%rax)