// File: /workspace/github_cpp_makefile_star2_O2/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
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x9b8, %rsp            # imm = 0x9B8
movq %r8, 0x20(%rsp)
movq %rcx, 0x8(%rsp)
movq %rdx, 0x18(%rsp)
movl %esi, %r15d
andl $0x0, 0x44(%rsp)
movq %rdi, %r12
andl $0x0, 0x40(%rsp)
leaq 0xc0(%rsp), %r13
xorl %ebx, %ebx
movl $0x349, %edx            # imm = 0x349
movq %r13, %rdi
xorl %esi, %esi
callq 0x61f0
leaq 0x99d00(%r12), %rax
movq %rax, 0xa8(%rsp)
movslq %r15d, %rax
leaq -0x1(%rax), %rcx
movq %rcx, 0x68(%rsp)
imulq $0x5a4, %rcx, %rcx      # imm = 0x5A4
leaq (%r12,%rcx), %r14
addq $0x99d00, %r14          # imm = 0x99D00
leaq (%r12,%rax,4), %rcx
addq $0x99cf4, %rcx          # imm = 0x99CF4
xorpd %xmm0, %xmm0
movapd %xmm0, 0xb0(%rsp)
andl $0x0, 0x64(%rsp)
movl (%rcx), %edx
testl %edx, %edx
movl $0x0, %eax
movl %edx, 0x60(%rsp)
cmovgl %edx, %eax
cmpq %rbx, %rax
je 0x2fedb
movl (%r14,%rbx,4), %edx
movl %edx, 0x410(%rsp,%rbx,4)
incq %rbx
jmp 0x2fec6
andl $0x0, (%rcx)
movslq 0x43b0(%r12), %rdx
movq %rdx, %rax
shlq $0x4, %rax
leal -0x2(%rdx), %edi
xorl %esi, %esi
movb $0x1, %bpl
cmpq $0x2, %rdx
jle 0x2ff2a
movl %edi, %esi
shlq $0x4, %rsi
movl 0x4(%r12,%rsi), %esi
movl %esi, 0x44(%rsp)
cmpl $0x3, %edx
jne 0x2ff14
pushq $0x1
popq %rdi
jmp 0x2ff2a
addl $-0x3, %edx
shlq $0x4, %rdx
movl 0x4(%r12,%rdx), %edx
movl %edx, 0x40(%rsp)
testl %edx, %edx
sete %bpl
movslq -0xc(%rax,%r12), %rdx
cmpl %edi, 0x43c8(%r12)
movq %rdx, 0x38(%rsp)
movl %esi, 0x48(%rsp)
jne 0x2ff5f
movq %r12, %rdi
movl %r15d, %esi
movq %r14, %rdx
movq %rcx, %rbx
callq 0x3ea88
movq %rbx, %rcx
movq 0x38(%rsp), %rdx
movl 0x48(%rsp), %esi
testl %edx, %edx
movl %r15d, 0x14(%rsp)
movq %r14, 0xa0(%rsp)
movq %r12, 0x58(%rsp)
je 0x30291
movb %bpl, 0x7(%rsp)
movl 0x35d64(%rip), %eax     # 0x65ce8
addl %edx, %eax
movl %eax, 0x90(%rsp)
movl 0x35d61(%rip), %eax     # 0x65cf4
addl %edx, %eax
movl %eax, 0x94(%rsp)
movl 0x35d5a(%rip), %eax     # 0x65cfc
addl %edx, %eax
movl %eax, 0x98(%rsp)
movl 0x35d57(%rip), %eax     # 0x65d08
addl %edx, %eax
movl %eax, 0x9c(%rsp)
movl 0x35d24(%rip), %eax     # 0x65ce4
addl %edx, %eax
movl %eax, 0x80(%rsp)
movl 0x35d1d(%rip), %eax     # 0x65cec
addl %edx, %eax
movl %eax, 0x84(%rsp)
movl 0x35d26(%rip), %eax     # 0x65d04
addl %edx, %eax
movl %eax, 0x88(%rsp)
movl 0x35d1f(%rip), %eax     # 0x65d0c
addl %edx, %eax
movl %eax, 0x8c(%rsp)
movl 0x35ce4(%rip), %eax     # 0x65ce0
addl %edx, %eax
movl %eax, 0x70(%rsp)
movl 0x35ce8(%rip), %eax     # 0x65cf0
addl %edx, %eax
movl %eax, 0x74(%rsp)
movl 0x35cec(%rip), %eax     # 0x65d00
addl %edx, %eax
movl %eax, 0x78(%rsp)
movl 0x35cf0(%rip), %eax     # 0x65d10
addl %edx, %eax
movl %eax, 0x7c(%rsp)
movq %r12, %rdi
movl %r15d, %esi
movq %r14, %rdx
movq %rcx, %rbx
callq 0x3d72a
movq %r12, %rdi
movl %r15d, %esi
movq %r14, %rdx
movq %rbx, %rcx
callq 0x3f312
leaq 0x64(%rsp), %r13
leaq 0xb0(%rsp), %rdx
movq %r12, %rdi
movq %r13, %rsi
callq 0x3fd14
movl (%r13), %r14d
leaq 0x4748(%r12), %rax
movq %rax, 0x50(%rsp)
leaq 0x97372(%r12), %rax
movq %rax, 0x30(%rsp)
xorl %ebp, %ebp
testl %r14d, %r14d
cmovlel %ebp, %r14d
leaq 0x1aac9922(%rip), %r8   # 0x1aaf99b0
cmpq %rbp, %r14
je 0x3020a
movslq 0xb0(%rsp,%rbp,4), %r13
cmpq $-0x1, %r13
je 0x30202
cmpb $0x1, 0x96ce0(%r12,%r13)
jne 0x30202
movq %r12, %rdi
movl 0x14(%rsp), %ebx
movl %ebx, %esi
movl %r13d, %edx
movq %r8, %r15
callq 0x3ec62
movq %r15, %r8
movq 0x20(%rsp), %rsi
movq (%rsi,%r13,8), %rcx
movq 0x18(%rsp), %rdx
subq %rcx, (%rdx)
movq (%rsi,%r13,8), %rcx
movslq (%r15,%r13,4), %rdx
movq 0x8(%rsp), %rdi
subq %rcx, (%rdi,%rdx,8)
testb %al, %al
je 0x301da
movq %r12, %rdi
movl %ebx, %esi
movl %r13d, %edx
movq %r8, %rbx
callq 0x3f18e
movq 0x38(%rsp), %rdx
leaq 0x1aac8b6b(%rip), %rcx  # 0x1aaf8c80
movl (%rcx,%rdx,4), %eax
subl (%rcx,%r13,4), %eax
movl %eax, %ecx
negl %ecx
cmovsl %eax, %ecx
movl (%rbx,%rdx,4), %eax
subl (%rbx,%r13,4), %eax
movl %eax, %edx
negl %edx
cmovsl %eax, %edx
imulq $0x4c, %rcx, %rax
addq 0x30e4c(%rip), %rax     # 0x60f88
movslq (%rax,%rdx,4), %rax
movsd 0x13ed8(%rip), %xmm0    # 0x44020
cmpq $0x4, %rax
jg 0x30163
leaq 0x4035bcb(%rip), %rcx   # 0x4065d20
cvtss2sd -0x8(%rcx,%rax,4), %xmm0
mulsd 0x13ebd(%rip), %xmm0    # 0x44020
movsd %xmm0, 0x28(%rsp)
movq 0x50(%rsp), %rdi
movl %r13d, %esi
callq 0x37bd2
movl %eax, %eax
leaq 0x35ba1(%rip), %rcx     # 0x65d20
cvtss2sd (%rcx,%rax,4), %xmm0
mulsd 0x28(%rsp), %xmm0
movsd %xmm0, 0x28(%rsp)
imull $0x6, %r13d, %eax
movslq %eax, %rbx
movq 0x30(%rsp), %r12
leaq (%r12,%rbx), %rdi
callq 0x310ce
mulsd 0x28(%rsp), %xmm0
cvttsd2si %xmm0, %rax
incq %rax
movq 0x20(%rsp), %rcx
movq %rax, (%rcx,%r13,8)
movq 0x18(%rsp), %rdx
addq %rax, (%rdx)
movq (%rcx,%r13,8), %rax
movq %r15, %r8
movslq (%r15,%r13,4), %rcx
movq 0x8(%rsp), %rdx
addq %rax, (%rdx,%rcx,8)
jmp 0x301e8
andq $0x0, (%rsi,%r13,8)
imulq $0x6, %r13, %rbx
movq 0x30(%rsp), %r12
andw $0x0, 0x4(%r12,%rbx)
andl $0x0, (%r12,%rbx)
movb $0x1, 0xc0(%rsp,%r13)
movq 0x58(%rsp), %r12
incq %rbp
jmp 0x3008e
leaq 0x90(%rsp), %r9
movq %r12, %rdi
movl 0x14(%rsp), %ebp
movl %ebp, %esi
movq 0x18(%rsp), %r15
movq %r15, %rdx
movq 0x8(%rsp), %r14
movq %r14, %rcx
movq 0x20(%rsp), %rbx
movq %rbx, %r8
pushq $0x0
leaq 0xc8(%rsp), %r13
pushq %r13
callq 0x30675
popq %rax
popq %rcx
leaq 0x80(%rsp), %r9
movq %r12, %rdi
movl %ebp, %esi
movq %r15, %rdx
movq %r14, %rcx
movq %rbx, %r8
pushq $0x1
pushq %r13
callq 0x30675
popq %rax
popq %rcx
leaq 0x70(%rsp), %r9
movq %r12, %rdi
movl %ebp, %esi
movq %r15, %rdx
movl %ebp, %r15d
movq %r14, %rcx
movq %rbx, %r8
pushq $0x2
pushq %r13
callq 0x30675
popq %rax
popq %rcx
movb 0x7(%rsp), %bpl
movl 0x48(%rsp), %esi
testl %esi, %esi
je 0x302bc
subq $0x8, %rsp
leaq 0x4c(%rsp), %r9
movq %r12, %rdi
movl %r15d, %esi
movq 0x20(%rsp), %rdx
movq 0x10(%rsp), %rcx
movq 0x28(%rsp), %r8
pushq %r13
callq 0x308d2
popq %rax
popq %rcx
movl %r15d, %eax
xorl $0x3, %eax
movl %eax, 0x30(%rsp)
testb %bpl, %bpl
jne 0x302f2
subq $0x8, %rsp
leaq 0x48(%rsp), %r9
movq %r12, %rdi
movl %r15d, %esi
movq 0x20(%rsp), %rdx
movq 0x10(%rsp), %rcx
movq 0x28(%rsp), %r8
pushq %r13
callq 0x308d2
popq %rax
popq %rcx
leaq 0x410(%rsp), %rax
movq %r12, %rdi
movl %r15d, %esi
movq 0x18(%rsp), %rbx
movq %rbx, %rdx
movq %r13, %rbp
movq %r12, %r13
movq 0x8(%rsp), %r12
movq %r12, %rcx
movq 0x20(%rsp), %r14
movq %r14, %r8
movl 0x60(%rsp), %r9d
pushq %rbp
pushq %rax
callq 0x30a42
popq %rax
popq %rcx
movq 0x68(%rsp), %rax
movl 0x99cf8(%r13,%rax,4), %r9d
movq %r13, %rdi
movl %r15d, %esi
movq %rbx, %rdx
movq %r12, %rcx
movq %r14, %r8
pushq %rbp
pushq 0xa8(%rsp)
callq 0x30a42
popq %rax
popq %rcx
movslq 0x30(%rsp), %rax
movl 0x99cf4(%r13,%rax,4), %r9d
decq %rax
movq %rax, 0x48(%rsp)
imulq $0x5a4, %rax, %rax      # imm = 0x5A4
movq 0xa8(%rsp), %r10
addq %rax, %r10
movq %r13, %rdi
movl %r15d, %esi
movq %rbx, %rdx
movq %r12, %rcx
movq %r13, %r15
movq %r14, %r8
pushq %rbp
pushq %r10
callq 0x30a42
popq %rax
popq %rcx
leaq 0x98738(%r13), %rax
movq %rax, 0x38(%rsp)
imulq $0xae0, 0x68(%rsp), %rax # imm = 0xAE0
addq %r13, %rax
addq $0x98738, %rax          # imm = 0x98738
movq %rax, 0x50(%rsp)
movl (%rax), %eax
leaq 0x4748(%r13), %rcx
movq %rcx, 0x30(%rsp)
leaq 0x97372(%r13), %r14
leaq 0x35907(%rip), %rdx     # 0x65ce0
cmpl $0x2b6, %eax            # imm = 0x2B6
jg 0x30512
movslq %eax, %rbp
xorl %ebx, %ebx
cmpq $0x34, %rbx
je 0x30501
movslq (%rbx,%rdx), %r13
addq %rbp, %r13
cmpb $0x0, 0xc0(%rsp,%r13)
jne 0x304f8
cmpb $0x1, 0x96ce0(%r15,%r13)
jne 0x304dd
movq %r15, %rdi
movl 0x14(%rsp), %r12d
movl %r12d, %esi
movl %r13d, %edx
callq 0x3ec62
movq 0x20(%rsp), %rsi
movq (%rsi,%r13,8), %rcx
movq 0x18(%rsp), %r8
subq %rcx, (%r8)
movq (%rsi,%r13,8), %rcx
leaq 0x1aac9569(%rip), %rdx  # 0x1aaf99b0
movslq (%rdx,%r13,4), %rdx
movq 0x8(%rsp), %rdi
subq %rcx, (%rdi,%rdx,8)
testb %al, %al
je 0x304d1
movq %r15, %rdi
movq %rsi, %r15
movl %r12d, %esi
movl %r13d, %edx
movq %r8, %r12
callq 0x3f18e
movq 0x30(%rsp), %rdi
movl %r13d, %esi
callq 0x37bd2
movl %eax, %eax
leaq 0x3589e(%rip), %rcx     # 0x65d20
cvtss2sd (%rcx,%rax,4), %xmm0
movsd %xmm0, 0x28(%rsp)
imull $0x6, %r13d, %eax
movslq %eax, %rdi
addq %r14, %rdi
callq 0x310ce
mulsd 0x28(%rsp), %xmm0
cvttsd2si %xmm0, %rax
incq %rax
movq %rax, (%r15,%r13,8)
addq %rax, (%r12)
movq (%r15,%r13,8), %rax
leaq 0x1aac94f3(%rip), %rcx  # 0x1aaf99b0
movslq (%rcx,%r13,4), %rcx
movq 0x8(%rsp), %rdx
addq %rax, (%rdx,%rcx,8)
movq 0x58(%rsp), %r15
jmp 0x304d6
andq $0x0, (%rsi,%r13,8)
leaq 0x35803(%rip), %rdx     # 0x65ce0
imull $0x6, %r13d, %eax
cltq
andw $0x0, 0x4(%r14,%rax)
andl $0x0, (%r14,%rax)
movb $0x1, 0xc0(%rsp,%r13)
addq $0x4, %rbx
jmp 0x303e9
movq 0x50(%rsp), %rcx
movl (%rcx,%rbp,4), %eax
andl $0x0, (%rcx,%rbp,4)
jmp 0x303d9
imulq $0xae0, 0x48(%rsp), %rax # imm = 0xAE0
movq 0x38(%rsp), %rcx
addq %rax, %rcx
movq %rcx, 0x38(%rsp)
movq %rcx, %rax
movslq (%rax), %rbp
cmpq $0x2b6, %rbp            # imm = 0x2B6
jg 0x30663
xorl %ebx, %ebx
cmpq $0x34, %rbx
je 0x30655
movslq (%rbx,%rdx), %r13
addq %rbp, %r13
cmpb $0x0, 0xc0(%rsp,%r13)
jne 0x3064c
cmpb $0x1, 0x96ce0(%r15,%r13)
jne 0x30631
movq %r15, %rdi
movl 0x14(%rsp), %r12d
movl %r12d, %esi
movl %r13d, %edx
callq 0x3ec62
movq 0x20(%rsp), %rsi
movq (%rsi,%r13,8), %rcx
movq 0x18(%rsp), %r8
subq %rcx, (%r8)
movq (%rsi,%r13,8), %rcx
leaq 0x1aac9415(%rip), %rdx  # 0x1aaf99b0
movslq (%rdx,%r13,4), %rdx
movq 0x8(%rsp), %rdi
subq %rcx, (%rdi,%rdx,8)
testb %al, %al
je 0x30625
movq %r15, %rdi
movq %rsi, %r15
movl %r12d, %esi
movl %r13d, %edx
movq %r8, %r12
callq 0x3f18e
movq 0x30(%rsp), %rdi
movl %r13d, %esi
callq 0x37bd2
movl %eax, %eax
leaq 0x3574a(%rip), %rcx     # 0x65d20
cvtss2sd (%rcx,%rax,4), %xmm0
movsd %xmm0, 0x28(%rsp)
imull $0x6, %r13d, %eax
movslq %eax, %rdi
addq %r14, %rdi
callq 0x310ce
mulsd 0x28(%rsp), %xmm0
cvttsd2si %xmm0, %rax
incq %rax
movq %rax, (%r15,%r13,8)
addq %rax, (%r12)
movq (%r15,%r13,8), %rax
leaq 0x1aac939f(%rip), %rcx  # 0x1aaf99b0
movslq (%rcx,%r13,4), %rcx
movq 0x8(%rsp), %rdx
addq %rax, (%rdx,%rcx,8)
movq 0x58(%rsp), %r15
jmp 0x3062a
andq $0x0, (%rsi,%r13,8)
leaq 0x356af(%rip), %rdx     # 0x65ce0
imull $0x6, %r13d, %eax
cltq
andw $0x0, 0x4(%r14,%rax)
andl $0x0, (%r14,%rax)
movb $0x1, 0xc0(%rsp,%r13)
addq $0x4, %rbx
jmp 0x3053d
movq 0x38(%rsp), %rax
leaq (%rax,%rbp,4), %rax
jmp 0x3052b
addq $0x9b8, %rsp            # imm = 0x9B8
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq