// File: kobanium[P]Ray/src/learn/MovePredictionTest.cpp
// Function: CheckMovePrediction(game_info_t*, char const*)
static void
CheckMovePrediction( game_info_t *game, const char *filename )
{
  int color = S_BLACK;
  SGF_record_t kifu;
  double rate[PURE_BOARD_MAX + 1];

  ExtractKifu(filename, &kifu);

  for (int i = 0; i < kifu.moves; i++) {
    const int expert_move = GetKifuMove(&kifu, i);
    std::vector<std::pair<double, int> > score_data;

    AnalyzeUctRating(game, color, rate);
    //AnalyzePoRating(game, color, rate);

    score_data.push_back({ rate[pure_board_max], PASS });
    for (int j = 0; j < pure_board_max; j++) {
      const int pos = onboard_pos[j];
      score_data.push_back({ rate[j], pos });
    }
    std::sort(score_data.begin(), score_data.end(), std::greater<std::pair<double, int> >());

    int skip = 0;
    bool find = false;
    
    for (int j = 0; j <= pure_board_max; j++) {
      if (j != 0 &&
          score_data[j].first == score_data[j - 1].first) {
        skip++;
      } else {
        skip = 0;
      }
      if (score_data[j].second == expert_move) {
        appearance[j - skip]++;
        find = true;
      }
    }

    if (!find) {
      std::cerr << filename << " " << i << std::endl;
    }
    
    PutStone(game, expert_move, color);
    color = GetOppositeColor(color);
  }
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x4cc0, %rsp           # imm = 0x4CC0
movq %rdi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
movl $0x1, -0x14(%rbp)
movq -0x10(%rbp), %rdi
leaq -0x40b8(%rbp), %rsi
callq 0x818f0
movl $0x0, -0x4c14(%rbp)
movl -0x4c14(%rbp), %eax
cmpl -0x40b4(%rbp), %eax
jge 0x7aa8a
movl -0x4c14(%rbp), %esi
leaq -0x40b8(%rbp), %rdi
callq 0x81830
movl %eax, -0x4c18(%rbp)
leaq -0x4c30(%rbp), %rdi
callq 0x6c210
movq -0x8(%rbp), %rdi
movl -0x14(%rbp), %esi
leaq -0x4c10(%rbp), %rdx
callq 0x86ab0
jmp 0x7a7af
leaq 0x6d28a(%rip), %rax     # 0xe7a40
movslq (%rax), %rax
leaq -0x4c10(%rbp,%rax,8), %rsi
leaq 0x34624(%rip), %rdx     # 0xaedec
leaq -0x4c50(%rbp), %rdi
callq 0x7abb0
jmp 0x7a7d6
leaq -0x4c30(%rbp), %rdi
leaq -0x4c50(%rbp), %rsi
callq 0x6c230
jmp 0x7a7eb
movl $0x0, -0x4c54(%rbp)
movl -0x4c54(%rbp), %eax
leaq 0x6d23e(%rip), %rcx     # 0xe7a40
cmpl (%rcx), %eax
jge 0x7a890
movslq -0x4c54(%rbp), %rcx
leaq 0x1ab58058(%rip), %rax  # 0x1abd2870
movl (%rax,%rcx,4), %eax
movl %eax, -0x4c58(%rbp)
movslq -0x4c54(%rbp), %rax
leaq -0x4c10(%rbp,%rax,8), %rsi
leaq -0x4c68(%rbp), %rdi
leaq -0x4c58(%rbp), %rdx
callq 0x7abb0
jmp 0x7a845
leaq -0x4c30(%rbp), %rdi
leaq -0x4c68(%rbp), %rsi
callq 0x6c230
jmp 0x7a85a
jmp 0x7a85c
movl -0x4c54(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x4c54(%rbp)
jmp 0x7a7f5
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x4c38(%rbp)
movl %eax, -0x4c3c(%rbp)
leaq -0x4c30(%rbp), %rdi
callq 0x6c400
jmp 0x7aa93
leaq -0x4c30(%rbp), %rdi
movq %rdi, -0x4c90(%rbp)
callq 0x6c2d0
movq -0x4c90(%rbp), %rdi
movq %rax, -0x4c70(%rbp)
callq 0x6c300
movq %rax, -0x4c78(%rbp)
movq -0x4c70(%rbp), %rdi
movq -0x4c78(%rbp), %rsi
callq 0x6c290
jmp 0x7a8d2
movl $0x0, -0x4c80(%rbp)
movb $0x0, -0x4c81(%rbp)
movl $0x0, -0x4c88(%rbp)
movl -0x4c88(%rbp), %eax
leaq 0x6d146(%rip), %rcx     # 0xe7a40
cmpl (%rcx), %eax
jg 0x7a9cd
cmpl $0x0, -0x4c88(%rbp)
je 0x7a963
movslq -0x4c88(%rbp), %rsi
leaq -0x4c30(%rbp), %rdi
callq 0x6c330
movsd (%rax), %xmm0
movsd %xmm0, -0x4c98(%rbp)
movl -0x4c88(%rbp), %eax
subl $0x1, %eax
movslq %eax, %rsi
leaq -0x4c30(%rbp), %rdi
callq 0x6c330
movsd -0x4c98(%rbp), %xmm0
ucomisd (%rax), %xmm0
jne 0x7a963
jp 0x7a963
movl -0x4c80(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x4c80(%rbp)
jmp 0x7a96d
movl $0x0, -0x4c80(%rbp)
movslq -0x4c88(%rbp), %rsi
leaq -0x4c30(%rbp), %rdi
callq 0x6c330
movl 0x8(%rax), %eax
cmpl -0x4c18(%rbp), %eax
jne 0x7a9b7
movl -0x4c88(%rbp), %eax
subl -0x4c80(%rbp), %eax
movslq %eax, %rsi
leaq 0x7086f(%rip), %rdi     # 0xeb210
callq 0x7ab60
movq %rax, %rdi
xorl %esi, %esi
callq 0x6c350
movb $0x1, -0x4c81(%rbp)
jmp 0x7a9b9
movl -0x4c88(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x4c88(%rbp)
jmp 0x7a8ed
testb $0x1, -0x4c81(%rbp)
jne 0x7aa3d
movq -0x10(%rbp), %rsi
movq 0x6c60f(%rip), %rdi     # 0xe6ff0
callq 0x7530
movq %rax, -0x4ca0(%rbp)
jmp 0x7a9ef
movq -0x4ca0(%rbp), %rdi
leaq 0x31a49(%rip), %rsi     # 0xac446
callq 0x7530
movq %rax, -0x4ca8(%rbp)
jmp 0x7aa0b
movq -0x4ca8(%rbp), %rdi
movl -0x4c14(%rbp), %esi
callq 0x7980
movq %rax, -0x4cb0(%rbp)
jmp 0x7aa26
movq -0x4cb0(%rbp), %rdi
movq 0x6c534(%rip), %rsi     # 0xe6f68
callq 0x75b0
jmp 0x7aa3b
jmp 0x7aa3d
movq -0x8(%rbp), %rdi
movl -0x4c18(%rbp), %esi
movl -0x14(%rbp), %edx
callq 0x9dbc0
jmp 0x7aa51
movl -0x14(%rbp), %edi
callq 0x25810
movl %eax, -0x4cb4(%rbp)
jmp 0x7aa61
movl -0x4cb4(%rbp), %eax
movl %eax, -0x14(%rbp)
leaq -0x4c30(%rbp), %rdi
callq 0x6c400
movl -0x4c14(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x4c14(%rbp)
jmp 0x7a764
addq $0x4cc0, %rsp           # imm = 0x4CC0
popq %rbp
retq
movq -0x4c38(%rbp), %rdi
callq 0x79b0
nop