// File: /workspace/github_cpp_makefile_star2_O2/wrighteagle2d[P]wrighteaglebase/Debug/../src/Trainer.cpp
// Function: Trainer::PrepareForTrain()
void Trainer::PrepareForTrain() {
  static uint i = 0;

  if (i == 0) {
    if (mpAgent->World().CurrentTime().T()) {
      std::cerr << "#" << PlayerParam::instance().teamName()
                << " Trainer: episode " << mTrainCount - 1 << " last "
                << mpAgent->World().CurrentTime().T() - mLastStopTime
                << " cycles" << std::endl;
    }

    std::cerr << "#" << PlayerParam::instance().teamName()
              << " Trainer: episode " << mTrainCount << " prepair @ "
              << mpAgent->World().CurrentTime() << std::endl;
  }

  mLastStopTime = mpAgent->World().CurrentTime().T();

  if (!mConverse)
    MoveBall(mBallStateList[i].first, mBallStateList[i].second);
  else
    MoveBall(-mBallStateList[i].first, -mBallStateList[i].second);

  for (std::vector<Trainer::PlayerState>::const_iterator it =
           mPlayerStatesList[i].begin();
       it != mPlayerStatesList[i].end(); it++) {
    if (!mConverse) {
      MovePlayer(it->mUnum, it->mPos, it->mVel, it->mBodyDir);
    } else {
      if (it->mUnum > 0) {
        MovePlayer(-mTm2Opp[it->mUnum], -it->mPos, -it->mVel,
                   GetNormalizeAngleDeg(-180 + it->mBodyDir));
      } else {
        MovePlayer(mOpp2Tm[-it->mUnum], -it->mPos, -it->mVel,
                   GetNormalizeAngleDeg(-180 + it->mBodyDir));
      }
    }
  }
  mpAgent->ChangePlayMode(mServerPlayModeList[i]);
  Recover();
  i++;

  if (i >= mPlayerStatesList.size()) {
    i = 0;
    mPrepared = true;
    std::cerr << "#" << PlayerParam::instance().teamName()
              << " Trainer: episode " << mTrainCount << " start @ "
              << mpAgent->World().CurrentTime() << std::endl;

    mTrainCount++;
  }
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x48, %rsp
movq %rdi, %rbx
cmpl $0x0, 0x316239(%rip)    # 0x35a0f0
jne 0x43fc9
movq 0x18(%rbx), %rax
movq 0x18(%rax), %rax
cmpl $0x0, 0x10(%rax)
je 0x43f57
movq 0x3311a(%rip), %rdi     # 0x76ff0
leaq 0x16fae(%rip), %rsi     # 0x5ae8b
callq 0x94b0
movq %rax, %r14
callq 0x38d94
leaq 0x3138(%rax), %rsi
movq %r14, %rdi
callq 0x9430
leaq 0x172ad(%rip), %rsi     # 0x5b1ad
movq %rax, %rdi
callq 0x94b0
movl 0x9c(%rbx), %esi
decl %esi
movq %rax, %rdi
callq 0x9330
leaq 0x172a1(%rip), %rsi     # 0x5b1c0
movq %rax, %rdi
callq 0x94b0
movq 0x18(%rbx), %rcx
movq 0x18(%rcx), %rcx
movl 0x10(%rcx), %esi
subl 0x194(%rbx), %esi
movq %rax, %rdi
callq 0x9330
leaq 0x17280(%rip), %rsi     # 0x5b1c7
movq %rax, %rdi
callq 0x94b0
movq %rax, %rdi
callq 0x99e8
movq 0x33092(%rip), %rdi     # 0x76ff0
leaq 0x16f26(%rip), %rsi     # 0x5ae8b
callq 0x94b0
movq %rax, %r14
callq 0x38d94
leaq 0x3138(%rax), %rsi
movq %r14, %rdi
callq 0x9430
leaq 0x17225(%rip), %rsi     # 0x5b1ad
movq %rax, %rdi
callq 0x94b0
movl 0x9c(%rbx), %esi
movq %rax, %rdi
callq 0x9330
leaq 0x1722a(%rip), %rsi     # 0x5b1cf
movq %rax, %rdi
callq 0x94b0
movq 0x18(%rbx), %rcx
movq 0x18(%rcx), %rsi
addq $0x10, %rsi
movq %rax, %rdi
callq 0xd465
movq %rax, %rdi
callq 0x99e8
movq 0x18(%rbx), %rax
movq 0x160(%rbx), %rcx
movq 0x18(%rax), %rax
movl 0x10(%rax), %eax
movl %eax, 0x194(%rbx)
movl 0x316109(%rip), %edx    # 0x35a0f0
shlq $0x5, %rdx
leaq (%rcx,%rdx), %rax
movsd (%rcx,%rdx), %xmm0
cmpb $0x0, 0x33(%rbx)
je 0x44023
movapd 0x1301e(%rip), %xmm4    # 0x57020
xorpd %xmm4, %xmm0
movsd 0x8(%rax), %xmm1
movsd 0x10(%rax), %xmm2
movsd 0x18(%rax), %xmm3
xorpd %xmm4, %xmm1
xorpd %xmm4, %xmm2
xorpd %xmm4, %xmm3
jmp 0x44032
movsd 0x8(%rax), %xmm1
movsd 0x10(%rax), %xmm2
movsd 0x18(%rax), %xmm3
movq %rbx, %rdi
callq 0x44546
movl 0x3160b0(%rip), %eax    # 0x35a0f0
movq 0x120(%rbx), %rcx
imulq $0x18, %rax, %rdx
movq (%rcx,%rdx), %r12
movabsq $-0x3f99800000000000, %r13 # imm = 0xC066800000000000
leaq -0x30(%rbp), %r14
movl %eax, %eax
imulq $0x18, %rax, %rdx
cmpq 0x8(%rcx,%rdx), %r12
je 0x44148
movl (%r12), %esi
cmpb $0x0, 0x33(%rbx)
je 0x440d4
movsd 0x8(%r12), %xmm4
movsd 0x10(%r12), %xmm3
movsd 0x18(%r12), %xmm2
movsd 0x20(%r12), %xmm1
movaps 0x12f85(%rip), %xmm0    # 0x57020
xorps %xmm0, %xmm4
movaps %xmm4, -0x40(%rbp)
xorps %xmm0, %xmm3
movaps %xmm3, -0x50(%rbp)
xorps %xmm0, %xmm2
movaps %xmm2, -0x60(%rbp)
xorps %xmm0, %xmm1
movaps %xmm1, -0x70(%rbp)
movsd 0x28(%r12), %xmm0
addsd 0x12fba(%rip), %xmm0    # 0x57080
testl %esi, %esi
jle 0x440fc
xorl %r15d, %r15d
subl 0x34(%rbx,%rsi,4), %r15d
jmp 0x44103
movsd 0x8(%r12), %xmm0
movsd 0x10(%r12), %xmm1
movsd 0x18(%r12), %xmm2
movsd 0x20(%r12), %xmm3
movsd 0x28(%r12), %xmm4
movq %rbx, %rdi
jmp 0x4412d
negl %esi
movl 0x64(%rbx,%rsi,4), %r15d
movq %r13, -0x30(%rbp)
movq %r14, %rdi
callq 0xd305
movapd %xmm0, %xmm4
movq %rbx, %rdi
movl %r15d, %esi
movapd -0x40(%rbp), %xmm0
movapd -0x50(%rbp), %xmm1
movapd -0x60(%rbp), %xmm2
movapd -0x70(%rbp), %xmm3
callq 0x44462
addq $0x38, %r12
movl 0x315fb4(%rip), %eax    # 0x35a0f0
movq 0x120(%rbx), %rcx
jmp 0x4405d
movq 0x18(%rbx), %rdi
movq 0x178(%rbx), %rcx
movl (%rcx,%rax,4), %esi
callq 0x45cc0
movq %rbx, %rdi
callq 0x44570
movl 0x315f87(%rip), %ecx    # 0x35a0f0
incl %ecx
movl %ecx, 0x315f7f(%rip)    # 0x35a0f0
movq 0x128(%rbx), %rax
subq 0x120(%rbx), %rax
pushq $0x18
popq %rsi
cqto
idivq %rsi
cmpq %rcx, %rax
ja 0x44213
andl $0x0, 0x315f59(%rip)    # 0x35a0f0
movb $0x1, 0x31(%rbx)
movq 0x32e4e(%rip), %rdi     # 0x76ff0
leaq 0x16ce2(%rip), %rsi     # 0x5ae8b
callq 0x94b0
movq %rax, %r14
callq 0x38d94
leaq 0x3138(%rax), %rsi
movq %r14, %rdi
callq 0x9430
leaq 0x16fe1(%rip), %rsi     # 0x5b1ad
movq %rax, %rdi
callq 0x94b0
movl 0x9c(%rbx), %esi
movq %rax, %rdi
callq 0x9330
leaq 0x16ff2(%rip), %rsi     # 0x5b1db
movq %rax, %rdi
callq 0x94b0
movq 0x18(%rbx), %rcx
movq 0x18(%rcx), %rsi
addq $0x10, %rsi
movq %rax, %rdi
callq 0xd465
movq %rax, %rdi
callq 0x99e8
incl 0x9c(%rbx)
addq $0x48, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq