// File: kobanium[P]Ray/src/learn/MinorizationMaximization.cpp
// Function: EvaluateMovePrediction(int)
static void
EvaluateMovePrediction( const int steps )
{
  const std::string accuracy_log_directory = GetWorkingDirectory() + PATH_SEPARATOR +
    LEARNING_RESULT_DIR_NAME + PATH_SEPARATOR +
    ACCURACY_LOG_DIR_NAME + PATH_SEPARATOR;
  const std::string accuracy_filename = accuracy_log_directory + "result" + std::to_string(steps) + ".txt";
  const std::string progress_filename = accuracy_log_directory + ACCURACY_LOG_FILE_NAME;
  std::ofstream accuracy_ofs(accuracy_filename);
  std::ofstream progress_ofs(progress_filename, std::ios::app);
  train_thread_arg_t targ[TRAIN_THREAD_NUM];
  std::thread *handle[TRAIN_THREAD_NUM];
  int count_sum = 0;

  if (!accuracy_ofs) {
    std::cerr << "Cannot open \"" << accuracy_filename << "\"" << std::endl;
    return;
  }

  if (!progress_ofs) {
    std::cerr << "Cannot open \"" << progress_filename << "\"" << std::endl;
    return;
  }

  for (std::atomic<int> &count : counter) {
    count.store(0);
  }

  for (int i = 0; i < TRAIN_THREAD_NUM; i++) {
    targ[i].id = i;
    handle[i] = new std::thread(TestingWorker, &targ[i]);
  }

  for (int i = 0; i < TRAIN_THREAD_NUM; i++) {
    handle[i]->join();
    delete handle[i];
  }

  for (int i = 0; i < pure_board_max; i++) {
    count_sum += counter[i].load();
  }

  for (int i = 0, correct = 0; i < pure_board_max; i++) {
    correct += counter[i];
    accuracy_ofs << static_cast<double>(correct) / count_sum << "\n";
  }
  progress_ofs << steps << " " << static_cast<double>(counter[0].load()) / count_sum << "\n";
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x740, %rsp            # imm = 0x740
movl %edi, -0x48(%rbp)
leaq -0x108(%rbp), %rdi
movq %rdi, -0x690(%rbp)
callq 0x2ccc0
movq -0x690(%rbp), %rsi
leaq 0x75541(%rip), %rdx     # 0xea290
leaq -0xe8(%rbp), %rdi
callq 0x632c0
jmp 0x74d5d
leaq 0x3a00c(%rip), %rdx     # 0xaed70
leaq -0xc8(%rbp), %rdi
leaq -0xe8(%rbp), %rsi
callq 0x63310
jmp 0x74d79
leaq 0x75510(%rip), %rdx     # 0xea290
leaq -0xa8(%rbp), %rdi
leaq -0xc8(%rbp), %rsi
callq 0x632c0
jmp 0x74d95
leaq 0x3a01b(%rip), %rdx     # 0xaedb7
leaq -0x88(%rbp), %rdi
leaq -0xa8(%rbp), %rsi
callq 0x63310
jmp 0x74db1
leaq 0x754d8(%rip), %rdx     # 0xea290
leaq -0x68(%rbp), %rdi
leaq -0x88(%rbp), %rsi
callq 0x632c0
jmp 0x74dca
leaq -0x88(%rbp), %rdi
callq 0x7ae8
leaq -0xa8(%rbp), %rdi
callq 0x7ae8
leaq -0xc8(%rbp), %rdi
callq 0x7ae8
leaq -0xe8(%rbp), %rdi
callq 0x7ae8
leaq -0x108(%rbp), %rdi
callq 0x7ae8
leaq 0x3a0d3(%rip), %rdx     # 0xaeee0
leaq -0x178(%rbp), %rdi
leaq -0x68(%rbp), %rsi
callq 0x63360
jmp 0x74e1f
movl -0x48(%rbp), %esi
leaq -0x198(%rbp), %rdi
callq 0x669f0
jmp 0x74e30
leaq -0x158(%rbp), %rdi
leaq -0x178(%rbp), %rsi
leaq -0x198(%rbp), %rdx
callq 0x66810
jmp 0x74e4c
leaq 0x3950c(%rip), %rdx     # 0xae35f
leaq -0x138(%rbp), %rdi
leaq -0x158(%rbp), %rsi
callq 0x63310
jmp 0x74e68
leaq -0x158(%rbp), %rdi
callq 0x7ae8
leaq -0x198(%rbp), %rdi
callq 0x7ae8
leaq -0x178(%rbp), %rdi
callq 0x7ae8
leaq 0x39f2d(%rip), %rdx     # 0xaedc0
leaq -0x1b8(%rbp), %rdi
leaq -0x68(%rbp), %rsi
callq 0x63360
jmp 0x74ea5
leaq -0x3b8(%rbp), %rdi
leaq -0x138(%rbp), %rsi
movl $0x10, %edx
callq 0x7a90
jmp 0x74ebf
leaq -0x5b8(%rbp), %rdi
leaq -0x1b8(%rbp), %rsi
movl $0x1, %edx
callq 0x7a90
jmp 0x74ed9
movl $0x0, -0x644(%rbp)
movq -0x3b8(%rbp), %rax
movq -0x18(%rax), %rax
leaq -0x3b8(%rbp,%rax), %rdi
callq 0x7220
movb %al, -0x691(%rbp)
jmp 0x74f03
movb -0x691(%rbp), %al
testb $0x1, %al
jne 0x74f12
jmp 0x75103
movq 0x720d7(%rip), %rdi     # 0xe6ff0
leaq 0x39e38(%rip), %rsi     # 0xaed58
callq 0x7530
movq %rax, -0x6a0(%rbp)
jmp 0x74f2e
movq -0x6a0(%rbp), %rdi
leaq -0x138(%rbp), %rsi
callq 0x7480
movq %rax, -0x6a8(%rbp)
jmp 0x74f4a
movq -0x6a8(%rbp), %rdi
leaq 0x37b7b(%rip), %rsi     # 0xacad3
callq 0x7530
movq %rax, -0x6b0(%rbp)
jmp 0x74f66
movq -0x6b0(%rbp), %rdi
movq 0x71ff4(%rip), %rsi     # 0xe6f68
callq 0x75b0
jmp 0x74f7b
movl $0x1, -0x648(%rbp)
jmp 0x75654
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x110(%rbp)
movl %eax, -0x114(%rbp)
jmp 0x7501c
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x110(%rbp)
movl %eax, -0x114(%rbp)
jmp 0x75010
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x110(%rbp)
movl %eax, -0x114(%rbp)
jmp 0x75004
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x110(%rbp)
movl %eax, -0x114(%rbp)
jmp 0x74ff8
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x110(%rbp)
movl %eax, -0x114(%rbp)
leaq -0x88(%rbp), %rdi
callq 0x7ae8
leaq -0xa8(%rbp), %rdi
callq 0x7ae8
leaq -0xc8(%rbp), %rdi
callq 0x7ae8
leaq -0xe8(%rbp), %rdi
callq 0x7ae8
leaq -0x108(%rbp), %rdi
callq 0x7ae8
jmp 0x756cf
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x110(%rbp)
movl %eax, -0x114(%rbp)
jmp 0x756c6
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x110(%rbp)
movl %eax, -0x114(%rbp)
jmp 0x75096
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x110(%rbp)
movl %eax, -0x114(%rbp)
jmp 0x7508a
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x110(%rbp)
movl %eax, -0x114(%rbp)
leaq -0x158(%rbp), %rdi
callq 0x7ae8
leaq -0x198(%rbp), %rdi
callq 0x7ae8
leaq -0x178(%rbp), %rdi
callq 0x7ae8
jmp 0x756c6
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x110(%rbp)
movl %eax, -0x114(%rbp)
jmp 0x756ba
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x110(%rbp)
movl %eax, -0x114(%rbp)
jmp 0x756ae
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x110(%rbp)
movl %eax, -0x114(%rbp)
jmp 0x756a2
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x110(%rbp)
movl %eax, -0x114(%rbp)
jmp 0x75696
movq -0x5b8(%rbp), %rax
movq -0x18(%rax), %rax
leaq -0x5b8(%rbp,%rax), %rdi
callq 0x7220
movb %al, -0x6b1(%rbp)
jmp 0x75123
movb -0x6b1(%rbp), %al
testb $0x1, %al
jne 0x7512f
jmp 0x751a7
movq 0x71eba(%rip), %rdi     # 0xe6ff0
leaq 0x39c1b(%rip), %rsi     # 0xaed58
callq 0x7530
movq %rax, -0x6c0(%rbp)
jmp 0x7514b
movq -0x6c0(%rbp), %rdi
leaq -0x1b8(%rbp), %rsi
callq 0x7480
movq %rax, -0x6c8(%rbp)
jmp 0x75167
movq -0x6c8(%rbp), %rdi
leaq 0x3795e(%rip), %rsi     # 0xacad3
callq 0x7530
movq %rax, -0x6d0(%rbp)
jmp 0x75183
movq -0x6d0(%rbp), %rdi
movq 0x71dd7(%rip), %rsi     # 0xe6f68
callq 0x75b0
jmp 0x75198
movl $0x1, -0x648(%rbp)
jmp 0x75654
leaq 0x7524a(%rip), %rax     # 0xea3f8
movq %rax, -0x650(%rbp)
leaq 0x7523c(%rip), %rdi     # 0xea3f8
callq 0x79480
movq %rax, -0x658(%rbp)
leaq 0x75229(%rip), %rdi     # 0xea3f8
callq 0x794a0
movq %rax, -0x660(%rbp)
movq -0x658(%rbp), %rax
cmpq -0x660(%rbp), %rax
je 0x75295
movq -0x658(%rbp), %rax
movq %rax, -0x668(%rbp)
movq -0x668(%rbp), %rax
movq %rax, -0x8(%rbp)
movl $0x0, -0xc(%rbp)
movl $0x5, -0x10(%rbp)
movq -0x8(%rbp), %rax
movq %rax, -0x6e0(%rbp)
movl -0x10(%rbp), %edi
movl $0xffff, %esi           # imm = 0xFFFF
callq 0x25b00
movl %eax, -0x14(%rbp)
movl -0x10(%rbp), %eax
movl %eax, -0x6d4(%rbp)
movl -0xc(%rbp), %ecx
movl %ecx, -0x18(%rbp)
subl $0x3, %eax
je 0x75262
jmp 0x75247
movl -0x6d4(%rbp), %eax
subl $0x5, %eax
je 0x75270
jmp 0x75254
movq -0x6e0(%rbp), %rax
movl -0x18(%rbp), %ecx
movl %ecx, (%rax)
jmp 0x7527c
movq -0x6e0(%rbp), %rax
movl -0x18(%rbp), %ecx
movl %ecx, (%rax)
jmp 0x7527c
movq -0x6e0(%rbp), %rcx
movl -0x18(%rbp), %eax
xchgl %eax, (%rcx)
jmp 0x7527e
movq -0x658(%rbp), %rax
addq $0x4, %rax
movq %rax, -0x658(%rbp)
jmp 0x751db
movl $0x0, -0x66c(%rbp)
cmpl $0x8, -0x66c(%rbp)
jge 0x75353
movslq -0x66c(%rbp), %rax
movl %eax, %ecx
movl %ecx, -0x600(%rbp,%rax,8)
movl $0x8, %edi
callq 0x7550
movq %rax, -0x6e8(%rbp)
jmp 0x752cf
movq -0x6e8(%rbp), %rdi
movslq -0x66c(%rbp), %rax
leaq -0x600(%rbp,%rax,8), %rax
movq %rax, -0x678(%rbp)
leaq 0x196d(%rip), %rsi      # 0x76c60
leaq -0x678(%rbp), %rdx
callq 0x65fc0
jmp 0x75301
movq -0x6e8(%rbp), %rcx
movslq -0x66c(%rbp), %rax
movq %rcx, -0x640(%rbp,%rax,8)
movl -0x66c(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x66c(%rbp)
jmp 0x7529f
movq -0x6e8(%rbp), %rdi
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x110(%rbp)
movl %eax, -0x114(%rbp)
movl $0x8, %esi
callq 0x7560
jmp 0x75696
movl $0x0, -0x67c(%rbp)
cmpl $0x8, -0x67c(%rbp)
jge 0x753c8
movslq -0x67c(%rbp), %rax
movq -0x640(%rbp,%rax,8), %rdi
callq 0x7940
jmp 0x7537c
movslq -0x67c(%rbp), %rax
movq -0x640(%rbp,%rax,8), %rax
movq %rax, -0x6f0(%rbp)
cmpq $0x0, %rax
je 0x753b5
movq -0x6f0(%rbp), %rdi
callq 0x66080
movq -0x6f0(%rbp), %rdi
movl $0x8, %esi
callq 0x7560
jmp 0x753b7
movl -0x67c(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x67c(%rbp)
jmp 0x7535d
movl $0x0, -0x680(%rbp)
movl -0x680(%rbp), %eax
leaq 0x72661(%rip), %rcx     # 0xe7a40
cmpl (%rcx), %eax
jge 0x754a2
movslq -0x680(%rbp), %rsi
leaq 0x75003(%rip), %rdi     # 0xea3f8
callq 0x794d0
movq %rax, -0x20(%rbp)
movl $0x5, -0x24(%rbp)
movq -0x20(%rbp), %rax
movq %rax, -0x700(%rbp)
movl -0x24(%rbp), %edi
movl $0xffff, %esi           # imm = 0xFFFF
callq 0x25b00
movl %eax, -0x6f4(%rbp)
jmp 0x75425
movl -0x6f4(%rbp), %eax
movl %eax, -0x28(%rbp)
movl -0x24(%rbp), %eax
movl %eax, -0x704(%rbp)
decl %eax
subl $0x2, %eax
jb 0x7545b
jmp 0x75440
movl -0x704(%rbp), %eax
subl $0x5, %eax
je 0x75469
jmp 0x7544d
movq -0x700(%rbp), %rax
movl (%rax), %eax
movl %eax, -0x2c(%rbp)
jmp 0x7547f
movq -0x700(%rbp), %rax
movl (%rax), %eax
movl %eax, -0x2c(%rbp)
jmp 0x7547f
movq -0x700(%rbp), %rax
movl (%rax), %eax
movl %eax, -0x2c(%rbp)
jmp 0x7547f
movq %rax, %rdi
callq 0x25ac0
movl -0x2c(%rbp), %eax
addl -0x644(%rbp), %eax
movl %eax, -0x644(%rbp)
movl -0x680(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x680(%rbp)
jmp 0x753d2
movl $0x0, -0x684(%rbp)
movl $0x0, -0x688(%rbp)
movl -0x684(%rbp), %eax
leaq 0x7257d(%rip), %rcx     # 0xe7a40
cmpl (%rcx), %eax
jge 0x75546
movslq -0x684(%rbp), %rsi
leaq 0x74f23(%rip), %rdi     # 0xea3f8
callq 0x794d0
movq %rax, %rdi
callq 0x25780
movl %eax, %ecx
movl -0x688(%rbp), %eax
addl %ecx, %eax
movl %eax, -0x688(%rbp)
cvtsi2sdl -0x688(%rbp), %xmm0
cvtsi2sdl -0x644(%rbp), %xmm1
divsd %xmm1, %xmm0
leaq -0x3b8(%rbp), %rdi
callq 0x7a60
movq %rax, -0x710(%rbp)
jmp 0x7551b
movq -0x710(%rbp), %rdi
leaq 0x3a1dc(%rip), %rsi     # 0xaf705
callq 0x7530
jmp 0x75530
jmp 0x75532
movl -0x684(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x684(%rbp)
jmp 0x754b6
movl -0x48(%rbp), %esi
leaq -0x5b8(%rbp), %rdi
callq 0x7980
movq %rax, -0x718(%rbp)
jmp 0x7555e
movq -0x718(%rbp), %rdi
leaq 0x36eda(%rip), %rsi     # 0xac446
callq 0x7530
movq %rax, -0x720(%rbp)
jmp 0x7557a
leaq 0x74e77(%rip), %rdi     # 0xea3f8
xorl %eax, %eax
movl %eax, %esi
callq 0x794d0
movq %rax, -0x38(%rbp)
movl $0x5, -0x3c(%rbp)
movq -0x38(%rbp), %rax
movq %rax, -0x730(%rbp)
movl -0x3c(%rbp), %edi
movl $0xffff, %esi           # imm = 0xFFFF
callq 0x25b00
movl %eax, -0x724(%rbp)
jmp 0x755b5
movl -0x724(%rbp), %eax
movl %eax, -0x40(%rbp)
movl -0x3c(%rbp), %eax
movl %eax, -0x734(%rbp)
decl %eax
subl $0x2, %eax
jb 0x755eb
jmp 0x755d0
movl -0x734(%rbp), %eax
subl $0x5, %eax
je 0x755f9
jmp 0x755dd
movq -0x730(%rbp), %rax
movl (%rax), %eax
movl %eax, -0x44(%rbp)
jmp 0x7560f
movq -0x730(%rbp), %rax
movl (%rax), %eax
movl %eax, -0x44(%rbp)
jmp 0x7560f
movq -0x730(%rbp), %rax
movl (%rax), %eax
movl %eax, -0x44(%rbp)
jmp 0x7560f
movq %rax, %rdi
callq 0x25ac0
movq -0x720(%rbp), %rdi
cvtsi2sdl -0x44(%rbp), %xmm0
cvtsi2sdl -0x644(%rbp), %xmm1
divsd %xmm1, %xmm0
callq 0x7a60
movq %rax, -0x740(%rbp)
jmp 0x75635
movq -0x740(%rbp), %rdi
leaq 0x3a0c2(%rip), %rsi     # 0xaf705
callq 0x7530
jmp 0x7564a
movl $0x0, -0x648(%rbp)
leaq -0x5b8(%rbp), %rdi
callq 0x7820
leaq -0x3b8(%rbp), %rdi
callq 0x7820
leaq -0x1b8(%rbp), %rdi
callq 0x7ae8
leaq -0x138(%rbp), %rdi
callq 0x7ae8
leaq -0x68(%rbp), %rdi
callq 0x7ae8
addq $0x740, %rsp            # imm = 0x740
popq %rbp
retq
leaq -0x5b8(%rbp), %rdi
callq 0x7820
leaq -0x3b8(%rbp), %rdi
callq 0x7820
leaq -0x1b8(%rbp), %rdi
callq 0x7ae8
leaq -0x138(%rbp), %rdi
callq 0x7ae8
leaq -0x68(%rbp), %rdi
callq 0x7ae8
movq -0x110(%rbp), %rdi
callq 0x79b0
nopl (%rax,%rax)