// File: kobanium[P]Ray/src/learn/MinorizationMaximization.cpp
// Function: LearningWorker(train_thread_arg_t*)
static void
LearningWorker( train_thread_arg_t *targ )
{
  game_info_t *game = AllocateGame();
  game_info_t *init_game = AllocateGame();

  InitializeBoard(init_game);

  for (int i = TRAIN_KIFU_START_INDEX; i <= TRAIN_KIFU_LAST_INDEX; i++) {
    if (i % TRAIN_THREAD_NUM == targ->id) {
      std::ostringstream oss;

      oss << TRAIN_KIFU_PATH << PATH_SEPARATOR << i << ".sgf";
      if (targ->id == 0) {
        std::cerr << "Step " << targ->step << " : " << oss.str() << std::endl;
      }
      CopyGame(game, init_game);
      ReplayMatch(game, oss.str(), targ->id);
    }
  }

  FreeGame(game);
  FreeGame(init_game);
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x230, %rsp            # imm = 0x230
movq %rdi, -0x8(%rbp)
callq 0x9bce0
movq %rax, -0x10(%rbp)
callq 0x9bce0
movq %rax, -0x18(%rbp)
movq -0x18(%rbp), %rdi
callq 0x9bd70
movl $0x1, -0x1c(%rbp)
cmpl $0x7530, -0x1c(%rbp)    # imm = 0x7530
jg 0x732ec
movl -0x1c(%rbp), %eax
movl $0x8, %ecx
cltd
idivl %ecx
movq -0x8(%rbp), %rax
cmpl (%rax), %edx
jne 0x732dc
leaq -0x198(%rbp), %rdi
movq %rdi, -0x1f8(%rbp)
callq 0x7750
movq -0x1f8(%rbp), %rdi
leaq 0x3bc97(%rip), %rsi     # 0xaed9d
callq 0x7530
movq %rax, -0x1f0(%rbp)
jmp 0x73114
movq -0x1f0(%rbp), %rdi
leaq 0x7716e(%rip), %rsi     # 0xea290
callq 0x7480
movq %rax, -0x200(%rbp)
jmp 0x73130
movq -0x200(%rbp), %rdi
movl -0x1c(%rbp), %esi
callq 0x7980
movq %rax, -0x208(%rbp)
jmp 0x73148
movq -0x208(%rbp), %rdi
leaq 0x3af6d(%rip), %rsi     # 0xae0c3
callq 0x7530
jmp 0x7315d
movq -0x8(%rbp), %rax
cmpl $0x0, (%rax)
jne 0x7324c
movq 0x73e7f(%rip), %rdi     # 0xe6ff0
leaq 0x3bbb3(%rip), %rsi     # 0xaed2b
callq 0x7530
movq %rax, -0x210(%rbp)
jmp 0x73186
movq -0x210(%rbp), %rdi
movq -0x8(%rbp), %rax
movl 0x4(%rax), %esi
callq 0x7980
movq %rax, -0x218(%rbp)
jmp 0x731a2
movq -0x218(%rbp), %rdi
leaq 0x39061(%rip), %rsi     # 0xac211
callq 0x7530
movq %rax, -0x220(%rbp)
jmp 0x731be
leaq -0x1c8(%rbp), %rdi
leaq -0x198(%rbp), %rsi
callq 0x7580
jmp 0x731d3
movq -0x220(%rbp), %rdi
leaq -0x1c8(%rbp), %rsi
callq 0x7480
movq %rax, -0x228(%rbp)
jmp 0x731ef
movq -0x228(%rbp), %rdi
movq 0x73d6b(%rip), %rsi     # 0xe6f68
callq 0x75b0
jmp 0x73204
leaq -0x1c8(%rbp), %rdi
callq 0x7ae8
jmp 0x7324c
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x1a0(%rbp)
movl %eax, -0x1a4(%rbp)
jmp 0x732ce
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x1a0(%rbp)
movl %eax, -0x1a4(%rbp)
leaq -0x1c8(%rbp), %rdi
callq 0x7ae8
jmp 0x732ce
movq -0x10(%rbp), %rdi
movq -0x18(%rbp), %rsi
callq 0x9c660
jmp 0x7325b
movq -0x10(%rbp), %rax
movq %rax, -0x230(%rbp)
leaq -0x1e8(%rbp), %rdi
leaq -0x198(%rbp), %rsi
callq 0x7580
jmp 0x7327b
movq -0x230(%rbp), %rdi
movq -0x8(%rbp), %rax
movl (%rax), %edx
leaq -0x1e8(%rbp), %rsi
callq 0x757a0
jmp 0x73296
leaq -0x1e8(%rbp), %rdi
callq 0x7ae8
leaq -0x198(%rbp), %rdi
callq 0x7110
jmp 0x732dc
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x1a0(%rbp)
movl %eax, -0x1a4(%rbp)
leaq -0x1e8(%rbp), %rdi
callq 0x7ae8
leaq -0x198(%rbp), %rdi
callq 0x7110
jmp 0x73307
jmp 0x732de
movl -0x1c(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x1c(%rbp)
jmp 0x730c1
movq -0x10(%rbp), %rdi
callq 0x9bd30
movq -0x18(%rbp), %rdi
callq 0x9bd30
addq $0x230, %rsp            # imm = 0x230
popq %rbp
retq
movq -0x1a0(%rbp), %rdi
callq 0x79b0
nopw %cs:(%rax,%rax)