// File: kobanium[P]Ray/src/learn/FactorizationMachines.cpp
// Function: EvaluateMovePrediction(game_info_t*, int, int)
static void
EvaluateMovePrediction( game_info_t *game, const int expert_move, const int color )
{
  const int moves = game->moves;
  std::vector<std::pair<double, int> > score_list;
  unsigned int tactical_features[BOARD_MAX * UCT_INDEX_MAX] = {0};
  const int distance_index = CheckFeaturesForTree(game, color, tactical_features);
  CheckRemove2StonesForTree(game, color, tactical_features);

  if (moves > 2 && game->ko_move == moves - 2) {
    CheckCaptureAfterKoForTree(game, color, tactical_features);
    CheckKoConnectionForTree(game, tactical_features);
  } else if (moves > 3 && game->ko_move == moves - 3) {
    CheckKoRecaptureForTree(game, color, tactical_features);
  }


  score_list.push_back({ CalculateMoveScore(game, PASS, tactical_features, distance_index), PASS });

  for (int i = 0; i < pure_board_max; i++) {
    const int pos = onboard_pos[i];
    if (IsLegal(game, pos, color)) {
      CheckSelfAtariForTree(game, color, pos, tactical_features);
      CheckCaptureForTree(game, color, pos, tactical_features);
      CheckAtariForTree(game, color, pos, tactical_features);

      score_list.push_back({ CalculateMoveScore(game, pos, tactical_features, distance_index), pos });
    } else {
      score_list.push_back({ 0.0, pos });
    }
  }

  std::sort(score_list.begin(), score_list.end(), std::greater<std::pair<double, int> >());

  int skip = 0;

  for (int j = 0; j < pure_board_max + 1; j++) {
    if (j != 0 &&
        score_list[j].first == score_list[j - 1].first) {
      skip++;
    } else {
      skip = 0;
    }
    if (score_list[j].second == expert_move) {
      prediction[j]++;
    }
  }
  counter++;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x5cf0, %rsp           # imm = 0x5CF0
movq %rdi, -0x8(%rbp)
movl %esi, -0xc(%rbp)
movl %edx, -0x10(%rbp)
movq -0x8(%rbp), %rax
movl 0x43b0(%rax), %eax
movl %eax, -0x14(%rbp)
leaq -0x30(%rbp), %rdi
callq 0x6c210
leaq -0x5c30(%rbp), %rdi
movq %rdi, -0x5cc0(%rbp)
xorl %esi, %esi
movl $0x5bfc, %edx           # imm = 0x5BFC
callq 0x72b0
movq -0x5cc0(%rbp), %rdx
movq -0x8(%rbp), %rdi
movl -0x10(%rbp), %esi
callq 0xa5cf0
movl %eax, -0x5cb8(%rbp)
jmp 0x5fa70
movl -0x5cb8(%rbp), %eax
movl %eax, -0x5c34(%rbp)
movq -0x8(%rbp), %rdi
movl -0x10(%rbp), %esi
leaq -0x5c30(%rbp), %rdx
callq 0xa7be0
jmp 0x5fa91
cmpl $0x2, -0x14(%rbp)
jle 0x5faf4
movq -0x8(%rbp), %rax
movl 0x43c8(%rax), %eax
movl -0x14(%rbp), %ecx
subl $0x2, %ecx
cmpl %ecx, %eax
jne 0x5faf4
movq -0x8(%rbp), %rdi
movl -0x10(%rbp), %esi
leaq -0x5c30(%rbp), %rdx
callq 0xa7320
jmp 0x5fac0
movq -0x8(%rbp), %rdi
leaq -0x5c30(%rbp), %rsi
callq 0xa7ab0
jmp 0x5fad2
jmp 0x5fb27
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x5c40(%rbp)
movl %eax, -0x5c44(%rbp)
leaq -0x30(%rbp), %rdi
callq 0x6c400
jmp 0x5fe2a
cmpl $0x3, -0x14(%rbp)
jle 0x5fb25
movq -0x8(%rbp), %rax
movl 0x43c8(%rax), %eax
movl -0x14(%rbp), %ecx
subl $0x3, %ecx
cmpl %ecx, %eax
jne 0x5fb25
movq -0x8(%rbp), %rdi
movl -0x10(%rbp), %esi
leaq -0x5c30(%rbp), %rdx
callq 0xa7b00
jmp 0x5fb23
jmp 0x5fb25
jmp 0x5fb27
movq -0x8(%rbp), %rdi
movl -0x5c34(%rbp), %ecx
xorl %esi, %esi
leaq -0x5c30(%rbp), %rdx
callq 0x5fe40
movsd %xmm0, -0x5cc8(%rbp)
jmp 0x5fb49
movsd -0x5cc8(%rbp), %xmm0
movsd %xmm0, -0x5c60(%rbp)
leaq 0x4e4fc(%rip), %rdx     # 0xae05c
leaq -0x5c58(%rbp), %rdi
leaq -0x5c60(%rbp), %rsi
callq 0x6c260
jmp 0x5fb75
leaq -0x30(%rbp), %rdi
leaq -0x5c58(%rbp), %rsi
callq 0x6c230
jmp 0x5fb87
movl $0x0, -0x5c64(%rbp)
movl -0x5c64(%rbp), %eax
leaq 0x87ea2(%rip), %rcx     # 0xe7a40
cmpl (%rcx), %eax
jge 0x5fcee
movslq -0x5c64(%rbp), %rcx
leaq 0x1ab72cbc(%rip), %rax  # 0x1abd2870
movl (%rax,%rcx,4), %eax
movl %eax, -0x5c68(%rbp)
movq -0x8(%rbp), %rdi
movl -0x5c68(%rbp), %esi
movl -0x10(%rbp), %edx
callq 0x9d0b0
movb %al, -0x5cc9(%rbp)
jmp 0x5fbd7
movb -0x5cc9(%rbp), %al
testb $0x1, %al
jne 0x5fbe6
jmp 0x5fc9d
movq -0x8(%rbp), %rdi
movl -0x10(%rbp), %esi
movl -0x5c68(%rbp), %edx
leaq -0x5c30(%rbp), %rcx
callq 0xa7480
jmp 0x5fc01
movq -0x8(%rbp), %rdi
movl -0x10(%rbp), %esi
movl -0x5c68(%rbp), %edx
leaq -0x5c30(%rbp), %rcx
callq 0xa7870
jmp 0x5fc1c
movq -0x8(%rbp), %rdi
movl -0x10(%rbp), %esi
movl -0x5c68(%rbp), %edx
leaq -0x5c30(%rbp), %rcx
callq 0xa79e0
jmp 0x5fc37
movq -0x8(%rbp), %rdi
movl -0x5c68(%rbp), %esi
movl -0x5c34(%rbp), %ecx
leaq -0x5c30(%rbp), %rdx
callq 0x5fe40
movsd %xmm0, -0x5cd8(%rbp)
jmp 0x5fc5d
movsd -0x5cd8(%rbp), %xmm0
movsd %xmm0, -0x5c80(%rbp)
leaq -0x5c78(%rbp), %rdi
leaq -0x5c80(%rbp), %rsi
leaq -0x5c68(%rbp), %rdx
callq 0x6c260
jmp 0x5fc89
leaq -0x30(%rbp), %rdi
leaq -0x5c78(%rbp), %rsi
callq 0x6c230
jmp 0x5fc9b
jmp 0x5fcd8
movq $0x0, -0x5c98(%rbp)
leaq -0x5c90(%rbp), %rdi
leaq -0x5c98(%rbp), %rsi
leaq -0x5c68(%rbp), %rdx
callq 0x6c260
jmp 0x5fcc4
leaq -0x30(%rbp), %rdi
leaq -0x5c90(%rbp), %rsi
callq 0x6c230
jmp 0x5fcd6
jmp 0x5fcd8
jmp 0x5fcda
movl -0x5c64(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x5c64(%rbp)
jmp 0x5fb91
leaq -0x30(%rbp), %rdi
movq %rdi, -0x5ce0(%rbp)
callq 0x6c2d0
movq -0x5ce0(%rbp), %rdi
movq %rax, -0x5ca0(%rbp)
callq 0x6c300
movq %rax, -0x5ca8(%rbp)
movq -0x5ca0(%rbp), %rdi
movq -0x5ca8(%rbp), %rsi
callq 0x6c290
jmp 0x5fd2d
movl $0x0, -0x5cb0(%rbp)
movl $0x0, -0x5cb4(%rbp)
movl -0x5cb4(%rbp), %eax
leaq 0x87cf2(%rip), %rcx     # 0xe7a40
movl (%rcx), %ecx
addl $0x1, %ecx
cmpl %ecx, %eax
jge 0x5fe0a
cmpl $0x0, -0x5cb4(%rbp)
je 0x5fdb6
movslq -0x5cb4(%rbp), %rsi
leaq -0x30(%rbp), %rdi
callq 0x6c330
movsd (%rax), %xmm0
movsd %xmm0, -0x5ce8(%rbp)
movl -0x5cb4(%rbp), %eax
subl $0x1, %eax
movslq %eax, %rsi
leaq -0x30(%rbp), %rdi
callq 0x6c330
movsd -0x5ce8(%rbp), %xmm0
ucomisd (%rax), %xmm0
jne 0x5fdb6
jp 0x5fdb6
movl -0x5cb0(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x5cb0(%rbp)
jmp 0x5fdc0
movl $0x0, -0x5cb0(%rbp)
movslq -0x5cb4(%rbp), %rsi
leaq -0x30(%rbp), %rdi
callq 0x6c330
movl 0x8(%rax), %eax
cmpl -0xc(%rbp), %eax
jne 0x5fdf4
movslq -0x5cb4(%rbp), %rax
leaq 0x898da(%rip), %rdi     # 0xe96c0
shlq $0x2, %rax
addq %rax, %rdi
xorl %esi, %esi
callq 0x6c350
jmp 0x5fdf6
movl -0x5cb4(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x5cb4(%rbp)
jmp 0x5fd41
leaq 0x8989b(%rip), %rdi     # 0xe96ac
xorl %esi, %esi
callq 0x6c350
leaq -0x30(%rbp), %rdi
callq 0x6c400
addq $0x5cf0, %rsp           # imm = 0x5CF0
popq %rbp
retq
movq -0x5c40(%rbp), %rdi
callq 0x79b0
nopw %cs:(%rax,%rax)