// File: /workspace/github_cpp_makefile_star2_O1/wrighteagle2d[P]wrighteaglebase/Debug/../src/Trainer.cpp
// Function: Trainer::ReadRcgFile()
bool Trainer::ReadRcgFile() {
  // TODO 读取之前的PlayMode
  string line;
  const char *buf = 0;
  ifstream fin(mTrainRcg);
  int time = 0, n_read = 0;

  const int begin_time = mTrainTime - mInitialTime;
  const int end_time = mTrainTime;

  ServerPlayMode server_playmode = SPM_PlayOn;

  while (1) {
    vector<PlayerState> ps;
    pair<Vector, Vector> bs;

    bool read = false;

    while (getline(fin, line)) {
      read = true;
      if (!line.compare(0, 5, "(show")) {
        if (sscanf(line.c_str(), "(show %d %n", &time, &n_read) != 1) {
          PRINT_ERROR("error time info:" << line);
          return false;
        }

        if (time >= begin_time) {
          buf = line.c_str();
          buf += n_read;
          break;
        }
      } else if (line.compare(0, 10, "(playmode ") == 0) {
        int time = 0;
        char pm_string[32];

        if (std::sscanf(line.c_str(), " (playmode %d %31[^)] ) ", &time,
                        pm_string) != 2) {
          std::cerr << "error: "
                    << "Illegal playmode line. \"" << line << "\"" << std::endl;
          return false;
        }

        server_playmode =
            ServerPlayModeMap::instance().GetServerPlayMode(pm_string);
      }
    }

    if (!read) {
      break;
    }

    mServerPlayModeList.push_back(server_playmode);

    float bx, by, bvx, bvy;

    if (buf == 0) //没有找到对应周期
    {
      return false;
    }

    {
      if (sscanf(buf, " ((b) %f %f %f %f) %n", &bx, &by, &bvx, &bvy, &n_read) !=
          4) {
        PRINT_ERROR("error ball info:" << line);
        return false;
      }
      buf += n_read;
      bs.first = Vector(bx, by);
      bs.second = Vector(bvx, bvy);
      bs.second /= 0.94;
      bs.first -= bs.second; //这是因为Server接到后会模拟一周期
    }

    // players
    char side;
    short unum;
    short type;
    int state;
    float x, y, vx, vy, body, neck;
    for (int i = 0; i < ServerParam::TEAM_SIZE * 2; ++i) {
      if (*buf == '\0' || *buf == ')')
        break;

      if (sscanf(buf, " ((%c %hd) %hd %x %f %f %f %f %f %f %n", &side, &unum,
                 &type, &state, &x, &y, &vx, &vy, &body, &neck,
                 &n_read) != 10) {
        PRINT_ERROR("error player info:" << buf);
        return false;
      }
      buf += n_read;

      int idx = unum - 1;
      if (side == 'r')
        idx += ServerParam::TEAM_SIZE;
      if (idx < 0 || ServerParam::TEAM_SIZE * 2 <= idx) {
        PRINT_ERROR("error player info:" << buf);
        return false;
      }

      if (side == 'r')
        unum = -unum;

      //对球员的微调安排在开场前，而不是建立前，因为牵涉到Server发来的异构
      ps.push_back(
          Trainer::PlayerState(unum, Vector(x, y), Vector(vx, vy), body, type));

      while (strncmp(buf, "((", 2)) {
        buf++;
        if (*buf == '\0')
          break;
      }
    }

    if (ps.size() == 22) {
      mPlayerStatesList.push_back(ps);
      mBallStateList.push_back(bs);
    }

    if (time >= end_time) {
      break;
    }
  }

  Assert(mPlayerStatesList.size() == mBallStateList.size());
  Assert(mPlayerStatesList.size() == mServerPlayModeList.size());

  return !mPlayerStatesList.empty();
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x348, %rsp            # imm = 0x348
movq %rdi, %rbx
leaq -0x58(%rbp), %rax
movq %rax, -0x10(%rax)
movq $0x0, -0x8(%rax)
movb $0x0, (%rax)
leaq 0xa0(%rdi), %rsi
leaq -0x368(%rbp), %rdi
movl $0x8, %edx
callq 0x9920
xorl %eax, %eax
leaq -0x40(%rbp), %rcx
movl %eax, (%rcx)
leaq -0x30(%rbp), %rcx
movl %eax, (%rcx)
movl 0x98(%rbx), %eax
movl %eax, -0x94(%rbp)
subl 0x138(%rbx), %eax
movl %eax, -0x9c(%rbp)
leaq -0x3c(%rbp), %rax
movl $0x3, (%rax)
leaq 0x178(%rbx), %rax
movq %rax, -0x158(%rbp)
leaq 0x1b293(%rip), %rax     # 0x6df88
movl (%rax), %eax
movq %rax, -0xc0(%rbp)
addl %eax, %eax
leaq 0x120(%rbx), %rcx
movq %rcx, -0x150(%rbp)
movq %rbx, -0x88(%rbp)
leaq 0x160(%rbx), %rcx
movq %rcx, -0x148(%rbp)
cmpl $0x2, %eax
movl $0x1, %ecx
movl %eax, -0x48(%rbp)
cmovgel %eax, %ecx
movl %ecx, -0x98(%rbp)
leaq -0xe0(%rbp), %r15
xorl %r12d, %r12d
xorpd %xmm0, %xmm0
movapd %xmm0, -0x80(%rbp)
movq $0x0, -0x70(%rbp)
movapd %xmm0, -0x130(%rbp)
movapd %xmm0, -0x140(%rbp)
xorl %r14d, %r14d
movq %r12, -0x90(%rbp)
movq -0x368(%rbp), %rax
movq -0x18(%rax), %rdi
leaq -0x368(%rbp), %rax
addq %rax, %rdi
movl $0xa, %esi
callq 0x9480
movsbl %al, %edx
leaq -0x368(%rbp), %rdi
leaq -0x68(%rbp), %rsi
callq 0x9940
movq (%rax), %rcx
movq -0x18(%rcx), %rcx
testb $0x5, 0x20(%rax,%rcx)
jne 0x5302f
movl $0x5, %edx
leaq -0x68(%rbp), %rdi
xorl %esi, %esi
leaq 0x1c196(%rip), %rcx     # 0x6ef58
callq 0x9650
testl %eax, %eax
je 0x52e9b
movl $0xa, %edx
leaq -0x68(%rbp), %rdi
xorl %esi, %esi
leaq 0x19c49(%rip), %rcx     # 0x6ca2a
callq 0x9650
movb $0x1, %r14b
testl %eax, %eax
jne 0x52d6c
movl $0x0, -0x38(%rbp)
movq -0x68(%rbp), %rdi
leaq 0x1c178(%rip), %rsi     # 0x6ef7b
leaq -0x38(%rbp), %rdx
leaq -0x120(%rbp), %rcx
xorl %eax, %eax
callq 0x9490
movl %eax, %r12d
cmpl $0x2, %eax
jne 0x52ed5
callq 0x55f0c
movq %rax, %rbx
leaq -0xd0(%rbp), %rax
movq %rax, -0xe0(%rbp)
movq %r15, %r13
leaq -0x120(%rbp), %r15
movq %r15, %rdi
callq 0x9200
leaq (%rax,%rbp), %rdx
addq $-0x120, %rdx           # imm = 0xFEE0
movq %r13, %rdi
movq %r15, %rsi
callq 0x13766
movq %rbx, %rdi
movq %r13, %rsi
callq 0x57198
movq %r13, %r15
movl %eax, -0x3c(%rbp)
movq -0xe0(%rbp), %rdi
leaq -0xd0(%rbp), %rax
cmpq %rax, %rdi
je 0x52f57
movq -0xd0(%rbp), %rsi
incq %rsi
callq 0x94e0
jmp 0x52f57
movq -0x68(%rbp), %rdi
leaq 0x1c0b8(%rip), %rsi     # 0x6ef5e
leaq -0x40(%rbp), %rdx
leaq -0x30(%rbp), %rcx
xorl %eax, %eax
callq 0x9490
cmpl $0x1, %eax
jne 0x52f73
movb $0x1, %r14b
movl -0x9c(%rbp), %eax
cmpl %eax, -0x40(%rbp)
jl 0x52d6c
jmp 0x53024
movl $0x7, %edx
movq 0x3410f(%rip), %rdi     # 0x86ff0
leaq 0x1c0ac(%rip), %rsi     # 0x6ef94
callq 0x9560
movl $0x18, %edx
movq 0x340f7(%rip), %rdi     # 0x86ff0
leaq 0x1c09c(%rip), %rsi     # 0x6ef9c
callq 0x9560
movq -0x68(%rbp), %rsi
movq -0x60(%rbp), %rdx
movq 0x340dc(%rip), %rdi     # 0x86ff0
callq 0x9560
movq %rax, %rbx
movl $0x1, %edx
movq %rax, %rdi
leaq 0x1c088(%rip), %rsi     # 0x6efb3
callq 0x9560
movq (%rbx), %rax
movq -0x18(%rax), %rdi
addq %rbx, %rdi
movl $0xa, %esi
callq 0x9480
movsbl %al, %esi
movq %rbx, %rdi
callq 0x9070
movq %rax, %rdi
callq 0x9330
cmpl $0x2, %r12d
movq -0x90(%rbp), %r12
je 0x52d6c
movl $0x1, %r14d
jmp 0x535f4
movl $0x12, %edx
movq 0x34071(%rip), %rdi     # 0x86ff0
leaq 0x1be84(%rip), %rsi     # 0x6ee0a
callq 0x9560
movl $0x1, %edx
movq 0x34059(%rip), %rdi     # 0x86ff0
leaq 0x1c224(%rip), %rsi     # 0x6f1c2
callq 0x9560
movq 0x34046(%rip), %rdi     # 0x86ff0
movl $0x204, %esi            # imm = 0x204
callq 0x9880
movq %rax, %rbx
movl $0x3, %edx
movq %rax, %rdi
leaq 0x1a4b9(%rip), %rsi     # 0x6d47f
callq 0x9560
movl $0x10, %edx
movq %rbx, %rdi
leaq 0x1bf90(%rip), %rsi     # 0x6ef6a
callq 0x9560
movq -0x68(%rbp), %rsi
movq -0x60(%rbp), %rdx
movq %rbx, %rdi
callq 0x9560
movq %rax, %rbx
movq (%rax), %rax
movq -0x18(%rax), %rdi
addq %rbx, %rdi
movl $0xa, %esi
callq 0x9480
movsbl %al, %esi
movq %rbx, %rdi
callq 0x9070
movl $0x1, %r14d
movq %rax, %rdi
callq 0x9330
jmp 0x535f4
movslq -0x30(%rbp), %r12
addq -0x68(%rbp), %r12
movb $0x1, %r14b
testb $0x1, %r14b
je 0x5305e
movq -0x88(%rbp), %rcx
movq 0x180(%rcx), %rsi
cmpq 0x188(%rcx), %rsi
je 0x53069
movl -0x3c(%rbp), %eax
movl %eax, (%rsi)
addq $0x4, %rsi
movq %rsi, 0x180(%rcx)
jmp 0x53079
movl $0x3, %r14d
jmp 0x535f4
movq -0x158(%rbp), %rdi
leaq -0x3c(%rbp), %rdx
callq 0x54d9c
movl $0x1, %r14d
testq %r12, %r12
je 0x533ed
subq $0x8, %rsp
movq %r12, %rdi
leaq 0x1bf1f(%rip), %rsi     # 0x6efb5
movq %r15, %rdx
leaq -0x38(%rbp), %rcx
leaq -0xb8(%rbp), %r8
leaq -0xb4(%rbp), %r9
xorl %eax, %eax
leaq -0x30(%rbp), %r10
pushq %r10
callq 0x9490
addq $0x10, %rsp
cmpl $0x4, %eax
jne 0x533f5
movslq -0x30(%rbp), %rax
xorps %xmm0, %xmm0
cvtss2sd -0xe0(%rbp), %xmm0
cvtss2sd -0x38(%rbp), %xmm1
cvtss2sd -0xb8(%rbp), %xmm2
cvtss2sd -0xb4(%rbp), %xmm3
addq %rax, %r12
movsd 0x1ada4(%rip), %xmm4    # 0x6de98
divsd %xmm4, %xmm2
movsd %xmm2, -0x130(%rbp)
divsd %xmm4, %xmm3
movsd %xmm3, -0x128(%rbp)
subsd %xmm2, %xmm0
movsd %xmm0, -0x140(%rbp)
subsd %xmm3, %xmm1
movsd %xmm1, -0x138(%rbp)
movl $0xa, %r14d
movb $0x1, %al
movl %eax, -0x34(%rbp)
cmpl $0x0, -0xc0(%rbp)
jle 0x5356f
xorl %ebx, %ebx
movzbl (%r12), %eax
testl %eax, %eax
je 0x5356f
cmpl $0x29, %eax
je 0x5356f
subq $0x8, %rsp
movq %r12, %rdi
leaq 0x1be7a(%rip), %rsi     # 0x6efdc
leaq -0x2b(%rbp), %rdx
leaq -0x2a(%rbp), %rcx
leaq -0x42(%rbp), %r8
leaq -0x160(%rbp), %r9
xorl %eax, %eax
leaq -0x30(%rbp), %r10
pushq %r10
leaq -0x15c(%rbp), %r10
pushq %r10
leaq -0xa0(%rbp), %r10
pushq %r10
leaq -0xa4(%rbp), %r10
pushq %r10
leaq -0xa8(%rbp), %r10
pushq %r10
leaq -0xac(%rbp), %r10
pushq %r10
leaq -0xb0(%rbp), %r10
pushq %r10
callq 0x9490
addq $0x40, %rsp
cmpl $0xa, %eax
jne 0x534a0
movslq -0x30(%rbp), %rax
addq %rax, %r12
movswl -0x2a(%rbp), %eax
movb -0x2b(%rbp), %cl
cmpb $0x72, %cl
movl $0x0, %edx
cmovel -0xc0(%rbp), %edx
addl %eax, %edx
decl %edx
movl %edx, -0x90(%rbp)
cmpl -0x48(%rbp), %edx
jae 0x532ca
cmpb $0x72, %cl
jne 0x53200
negl %eax
movw %ax, -0x2a(%rbp)
xorps %xmm0, %xmm0
cvtss2sd -0xb0(%rbp), %xmm0
xorps %xmm1, %xmm1
cvtss2sd -0xac(%rbp), %xmm1
xorps %xmm2, %xmm2
cvtss2sd -0xa8(%rbp), %xmm2
xorps %xmm3, %xmm3
cvtss2sd -0xa4(%rbp), %xmm3
movswl -0x2a(%rbp), %eax
cvtss2sd -0xa0(%rbp), %xmm4
movswl -0x42(%rbp), %ecx
leaq -0x118(%rbp), %rdx
xorps %xmm5, %xmm5
movups %xmm5, 0x10(%rdx)
movups %xmm5, (%rdx)
movl %eax, -0x120(%rbp)
movsd %xmm0, -0x118(%rbp)
movsd %xmm1, -0x110(%rbp)
movsd %xmm2, -0x108(%rbp)
movsd %xmm3, -0x100(%rbp)
movsd %xmm4, -0xf8(%rbp)
movl %ecx, -0xf0(%rbp)
movq -0x78(%rbp), %rsi
cmpq -0x70(%rbp), %rsi
je 0x5337c
movl %ebx, %r14d
movq -0xf0(%rbp), %rax
movq %rax, 0x30(%rsi)
movups -0x120(%rbp), %xmm0
movups -0x110(%rbp), %xmm1
movups -0x100(%rbp), %xmm2
movups %xmm2, 0x20(%rsi)
movups %xmm1, 0x10(%rsi)
movups %xmm0, (%rsi)
addq $0x38, %rsi
movq %rsi, -0x78(%rbp)
jmp 0x5338f
movl %ebx, %r14d
movq %r12, %r13
movl $0x12, %edx
movq 0x33d14(%rip), %rdi     # 0x86ff0
leaq 0x1bb27(%rip), %rsi     # 0x6ee0a
callq 0x9560
movl $0x1, %edx
movq 0x33cfc(%rip), %rdi     # 0x86ff0
leaq 0x1bec7(%rip), %rsi     # 0x6f1c2
callq 0x9560
movq 0x33ce9(%rip), %rdi     # 0x86ff0
movl $0x24d, %esi            # imm = 0x24D
callq 0x9880
movq %rax, %r12
movl $0x3, %edx
movq %rax, %rdi
leaq 0x1a15c(%rip), %rsi     # 0x6d47f
callq 0x9560
movl $0x12, %edx
movq %r12, %rdi
leaq 0x1bccc(%rip), %rsi     # 0x6f003
callq 0x9560
movq %r13, %rdi
callq 0x9200
movq %r12, %rdi
movq %r13, %rsi
movq %rax, %rdx
callq 0x9560
movq (%r12), %rax
movq -0x18(%rax), %rdi
addq %r12, %rdi
movl $0xa, %esi
callq 0x9480
movsbl %al, %esi
movq %r12, %rdi
callq 0x9070
movq %rax, %rdi
callq 0x9330
jmp 0x533bf
movl %ebx, %r14d
leaq -0x80(%rbp), %rdi
leaq -0x120(%rbp), %rdx
callq 0x54edc
movl $0x2, %edx
movq %r12, %rdi
leaq 0x1965d(%rip), %rsi     # 0x6c9fb
callq 0x9230
testl %eax, %eax
je 0x533bc
leaq 0x1(%r12), %rax
cmpb $0x0, 0x1(%r12)
movq %rax, %r13
movq %rax, %r12
jne 0x5338f
jmp 0x533bf
movq %r12, %r13
movl -0x90(%rbp), %eax
cmpl -0x48(%rbp), %eax
jae 0x5355f
movl %r14d, %ebx
incl %ebx
cmpl -0x98(%rbp), %ebx
movq %r13, %r12
movl $0xa, %r14d
jne 0x5313e
jmp 0x5356f
xorl %r12d, %r12d
jmp 0x535f4
movl $0x12, %edx
movq 0x33bef(%rip), %rdi     # 0x86ff0
leaq 0x1ba02(%rip), %rsi     # 0x6ee0a
callq 0x9560
movl $0x1, %edx
movq 0x33bd7(%rip), %rdi     # 0x86ff0
leaq 0x1bda2(%rip), %rsi     # 0x6f1c2
callq 0x9560
movq 0x33bc4(%rip), %rdi     # 0x86ff0
movl $0x22d, %esi            # imm = 0x22D
callq 0x9880
movq %rax, %rbx
movl $0x3, %edx
movq %rax, %rdi
leaq 0x1a037(%rip), %rsi     # 0x6d47f
callq 0x9560
movl $0x10, %edx
movq %rbx, %rdi
leaq 0x1bb6f(%rip), %rsi     # 0x6efcb
callq 0x9560
movq -0x68(%rbp), %rsi
movq -0x60(%rbp), %rdx
movq %rbx, %rdi
callq 0x9560
movq %rax, %rbx
movq (%rax), %rax
movq -0x18(%rax), %rdi
addq %rbx, %rdi
movl $0xa, %esi
callq 0x9480
movsbl %al, %esi
movq %rbx, %rdi
callq 0x9070
movq %rax, %rdi
callq 0x9330
jmp 0x535f4
movq %r12, %r14
movl $0x12, %edx
movq 0x33b41(%rip), %rdi     # 0x86ff0
leaq 0x1b954(%rip), %rsi     # 0x6ee0a
callq 0x9560
movl $0x1, %edx
movq 0x33b29(%rip), %rdi     # 0x86ff0
leaq 0x1bcf4(%rip), %rsi     # 0x6f1c2
callq 0x9560
movq 0x33b16(%rip), %rdi     # 0x86ff0
movl $0x244, %esi            # imm = 0x244
callq 0x9880
movq %rax, %r12
movl $0x3, %edx
movq %rax, %rdi
leaq 0x19f89(%rip), %rsi     # 0x6d47f
callq 0x9560
movl $0x12, %edx
movq %r12, %rdi
leaq 0x1baf9(%rip), %rsi     # 0x6f003
callq 0x9560
movq %r14, %rdi
callq 0x9200
movq %r12, %rdi
movq %r14, %rsi
movq %rax, %rdx
callq 0x9560
movq (%r12), %rax
movq -0x18(%rax), %rdi
addq %r12, %rdi
movl $0xa, %esi
callq 0x9480
movsbl %al, %esi
movq %r12, %rdi
callq 0x9070
movq %rax, %rdi
callq 0x9330
movl $0x0, -0x34(%rbp)
movq %r14, %r12
movl $0x1, %r14d
jmp 0x5356f
movl $0x1, %r14d
movl $0x0, -0x34(%rbp)
movq %r13, %r12
cmpb $0x0, -0x34(%rbp)
je 0x535f4
movq -0x78(%rbp), %rax
subq -0x80(%rbp), %rax
cmpq $0x4d0, %rax            # imm = 0x4D0
jne 0x535e2
movq -0x150(%rbp), %rdi
leaq -0x80(%rbp), %rsi
callq 0x545f0
movq -0x88(%rbp), %rax
movq 0x168(%rax), %rsi
cmpq 0x170(%rax), %rsi
je 0x535cf
movapd -0x140(%rbp), %xmm0
movapd -0x130(%rbp), %xmm1
movupd %xmm1, 0x10(%rsi)
movupd %xmm0, (%rsi)
addq $0x20, 0x168(%rax)
jmp 0x535e2
movq -0x148(%rbp), %rdi
leaq -0x140(%rbp), %rdx
callq 0x5535e
xorl %eax, %eax
movl -0x94(%rbp), %ecx
cmpl %ecx, -0x40(%rbp)
setge %al
leal (%rax,%rax,2), %r14d
movq -0x80(%rbp), %rdi
testq %rdi, %rdi
je 0x53609
movq -0x70(%rbp), %rsi
subq %rdi, %rsi
callq 0x94e0
testl %r14d, %r14d
je 0x52d41
cmpl $0x3, %r14d
jne 0x53632
movq -0x88(%rbp), %rcx
movq 0x120(%rcx), %rax
cmpq 0x128(%rcx), %rax
setne %bl
jmp 0x53634
xorl %ebx, %ebx
leaq -0x368(%rbp), %rdi
callq 0x9170
movq -0x68(%rbp), %rdi
leaq -0x58(%rbp), %rax
cmpq %rax, %rdi
je 0x53659
movq -0x58(%rbp), %rsi
incq %rsi
callq 0x94e0
movl %ebx, %eax
addq $0x348, %rsp            # imm = 0x348
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
jmp 0x536a9
movq %rax, %rbx
jmp 0x536cd
jmp 0x536a9
jmp 0x536a9
jmp 0x536a9
jmp 0x536a9
jmp 0x536a9
movq %rax, %rbx
movq -0xe0(%rbp), %rdi
leaq -0xd0(%rbp), %rax
cmpq %rax, %rdi
je 0x536ac
movq -0xd0(%rbp), %rsi
incq %rsi
callq 0x94e0
jmp 0x536ac
jmp 0x536a9
jmp 0x536a9
movq %rax, %rbx
movq -0x80(%rbp), %rdi
testq %rdi, %rdi
je 0x536c1
movq -0x70(%rbp), %rsi
subq %rdi, %rsi
callq 0x94e0
leaq -0x368(%rbp), %rdi
callq 0x9170
movq -0x68(%rbp), %rdi
leaq -0x58(%rbp), %rax
cmpq %rax, %rdi
je 0x536e6
movq -0x58(%rbp), %rsi
incq %rsi
callq 0x94e0
movq %rbx, %rdi
callq 0x98b0