// File: wrighteagle2d[P]wrighteaglebase/Debug/../src/WorldState.cpp
// Function: WorldStateUpdater::EstimateSelf(bool, int)
void WorldStateUpdater::EstimateSelf(bool is_estimate_to_now, int cycle) {
  (void)cycle;
  bool is_collided = mpObserver->Sense().IsCollideWithPlayer() ||
                     mpObserver->Sense().IsCollideWithBall() ||
                     mpObserver->Sense().IsCollideWithPost();
  if (mpObserver->GetPlayerDashTime() == mpObserver->CurrentTime()) {
    if (is_collided) {
      //碰撞由于内部处理太复杂,直接认为不准.
      SelfState().UpdatePosEps(10000);
    }

    if (!is_estimate_to_now) {
      if (!is_collided) {
        // server内部最大的randp为Vel.Mod()*playerRand()
        double eps =
            (SelfState().GetPos() - mpObserver->GetPlayerPosByDash()).Mod() *
            ServerParam::instance().playerRand();
        SelfState().UpdatePosEps(SelfState().GetPosEps() + eps);
      }
      SelfState().UpdatePos(mpObserver->GetPlayerPosByDash(),
                            SelfState().GetPosDelay(),
                            SelfState().GetPosConf());
      SelfState().UpdateVel(mpObserver->GetPlayerVelByDash(),
                            SelfState().GetVelDelay(),
                            SelfState().GetVelConf());
    } else {
      const PlayerState &player =
          mpWorldState->GetHistory(1)->GetTeammate(mSelfUnum);
      Vector accel =
          mpObserver->GetPlayerPosByDash() - player.GetPos() - player.GetVel();
      Vector vel = SelfState().GetVel() + accel;

      if (!is_collided) {
        double eps = vel.Mod() * ServerParam::instance().playerRand();
        SelfState().UpdatePosEps(SelfState().GetPosEps() + eps);
      }

      Vector pos = SelfState().GetPos() + vel;
      vel *= SelfState().GetPlayerDecay();
      SelfState().UpdatePos(pos, SelfState().GetPosDelay(),
                            SelfState().GetPosConf());
      SelfState().UpdateVel(vel, SelfState().GetVelDelay(),
                            SelfState().GetVelConf());
    }
  } else {
    if (is_collided) {
      //碰撞由于内部处理太复杂,直接认为不准.
      SelfState().UpdatePosEps(10000);
    } else {
      SelfState().UpdatePosEps(SelfState().GetPosEps() +
                               SelfState().GetVel().Mod() *
                                   ServerParam::instance().playerRand());
    }
    ComputeNextCycle(SelfState(), PlayerParam::instance()
                                      .HeteroPlayer(GetSelf().GetPlayerType())
                                      .playerDecay());
  }

  if (mpObserver->GetPlayerMoveTime() == mpObserver->CurrentTime()) {
    SelfState().UpdatePos(mpObserver->GetPlayerPosByMove(),
                          GetSelf().GetPosDelay(), GetSelf().GetPosConf());
    SelfState().UpdateVel(mpObserver->GetPlayerVelByMove(),
                          GetSelf().GetVelDelay(), GetSelf().GetVelConf());
  }

  //预测身体角度
  if (mpObserver->GetPlayerTurnTime() == mpObserver->CurrentTime()) {
    if (!is_estimate_to_now) {
      SelfState().UpdateBodyDir(mpObserver->GetPlayerBodyDirByTurn(),
                                GetSelf().GetBodyDirDelay(),
                                GetSelf().GetBodyDirConf());
    } else {
      const PlayerState &player =
          mpWorldState->GetHistory(1)->GetTeammate(mSelfUnum);
      double eff_moment =
          mpObserver->GetPlayerBodyDirByTurn() - player.GetBodyDir();
      double body_dir =
          GetNormalizeAngleDeg(eff_moment + SelfState().GetBodyDir());
      SelfState().UpdateBodyDir(body_dir, GetSelf().GetBodyDirDelay(),
                                GetSelf().GetBodyDirConf());
    }
  }

  //预测头部角度
  if (!is_estimate_to_now &&
      mpObserver->GetPlayerTurnNeckTime() == mpObserver->CurrentTime()) {
    SelfState().UpdateNeckDir(mpObserver->GetPlayerNeckDirByTurnNeck(),
                              GetSelf().GetNeckDirDelay(),
                              GetSelf().GetNeckDirConf());
  }
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x210, %rsp            # imm = 0x210
movb %sil, %al
movq %rdi, -0x8(%rbp)
andb $0x1, %al
movb %al, -0x9(%rbp)
movl %edx, -0x10(%rbp)
movq -0x8(%rbp), %rax
movq %rax, -0xd8(%rbp)
movq (%rax), %rdi
callq 0x119d0
movq %rax, %rdi
callq 0xbcee0
movb %al, %cl
movb $0x1, %al
testb $0x1, %cl
movb %al, -0xc9(%rbp)
jne 0xb9f77
movq -0xd8(%rbp), %rax
movq (%rax), %rdi
callq 0x119d0
movq %rax, %rdi
callq 0xbcec0
movb %al, %cl
movb $0x1, %al
testb $0x1, %cl
movb %al, -0xc9(%rbp)
jne 0xb9f77
movq -0xd8(%rbp), %rax
movq (%rax), %rdi
callq 0x119d0
movq %rax, %rdi
callq 0xbd600
movb %al, -0xc9(%rbp)
movq -0xd8(%rbp), %rax
movb -0xc9(%rbp), %cl
andb $0x1, %cl
movb %cl, -0x11(%rbp)
movq (%rax), %rdi
callq 0xbe310
movq %rax, %rcx
movq -0xd8(%rbp), %rax
movq %rcx, -0x1c(%rbp)
movq (%rax), %rdi
callq 0x11a70
movq %rax, %rsi
leaq -0x1c(%rbp), %rdi
callq 0x120a0
testb $0x1, %al
jne 0xb9fbd
jmp 0xba3f3
testb $0x1, -0x11(%rbp)
je 0xb9fe3
movq -0xd8(%rbp), %rdi
callq 0xbc740
movq %rax, %rdi
addq $0x8, %rdi
movsd 0x8f02(%rip), %xmm0     # 0xc2ee0
callq 0xbc830
testb $0x1, -0x9(%rbp)
jne 0xba1af
testb $0x1, -0x11(%rbp)
jne 0xba0b4
movq -0xd8(%rbp), %rdi
callq 0xbc740
movq %rax, %rdi
addq $0x8, %rdi
callq 0x11090
movq %rax, %rcx
movq -0xd8(%rbp), %rax
movq %rcx, -0xf0(%rbp)
movq (%rax), %rdi
callq 0xbe330
movq -0xf0(%rbp), %rdi
movq %rax, %rsi
callq 0x110a0
movsd %xmm0, -0x38(%rbp)
movsd %xmm1, -0x30(%rbp)
leaq -0x38(%rbp), %rdi
callq 0x104e0
movsd %xmm0, -0xe8(%rbp)
callq 0x855e0
movq %rax, %rdi
callq 0x325f0
movsd -0xe8(%rbp), %xmm0
movq -0xd8(%rbp), %rdi
mulsd (%rax), %xmm0
movsd %xmm0, -0x28(%rbp)
callq 0xbc740
movq -0xd8(%rbp), %rdi
addq $0x8, %rax
movq %rax, -0xe0(%rbp)
callq 0xbc740
movq %rax, %rdi
addq $0x8, %rdi
callq 0xbcf40
movq -0xe0(%rbp), %rdi
movsd (%rax), %xmm0
addsd -0x28(%rbp), %xmm0
callq 0xbc830
movq -0xd8(%rbp), %rdi
callq 0xbc740
movq %rax, %rcx
movq -0xd8(%rbp), %rax
movq %rcx, -0x120(%rbp)
movq (%rax), %rdi
callq 0xbe330
movq -0xd8(%rbp), %rdi
movq %rax, -0x118(%rbp)
callq 0xbc740
movq %rax, %rdi
addq $0x8, %rdi
callq 0x1ddd0
movq -0xd8(%rbp), %rdi
movl %eax, -0x10c(%rbp)
callq 0xbc740
movq %rax, %rdi
addq $0x8, %rdi
callq 0x1d930
movq -0x120(%rbp), %rdi
movq -0x118(%rbp), %rsi
movl -0x10c(%rbp), %edx
movsd (%rax), %xmm0
callq 0x142f0
movq -0xd8(%rbp), %rdi
callq 0xbc740
movq %rax, %rcx
movq -0xd8(%rbp), %rax
movq %rcx, -0x108(%rbp)
movq (%rax), %rdi
callq 0xbe350
movq -0xd8(%rbp), %rdi
movq %rax, -0x100(%rbp)
callq 0xbc740
movq %rax, %rdi
callq 0x28a30
movq -0xd8(%rbp), %rdi
movl %eax, -0xf4(%rbp)
callq 0xbc740
movq %rax, %rdi
callq 0x32aa0
movq -0x108(%rbp), %rdi
movq -0x100(%rbp), %rsi
movl -0xf4(%rbp), %edx
movsd (%rax), %xmm0
callq 0x142a0
jmp 0xba3ee
movq -0xd8(%rbp), %rax
movq 0x8(%rax), %rdi
movl $0x1, %esi
callq 0xab550
movq -0xd8(%rbp), %rsi
movq %rax, %rdi
addq $0x14, %rsi
callq 0x12520
movq %rax, %rcx
movq -0xd8(%rbp), %rax
movq %rcx, -0x40(%rbp)
movq (%rax), %rdi
callq 0xbe330
movq %rax, -0x128(%rbp)
movq -0x40(%rbp), %rdi
addq $0x8, %rdi
callq 0x11090
movq -0x128(%rbp), %rdi
movq %rax, %rsi
callq 0x110a0
movsd %xmm0, -0x60(%rbp)
movsd %xmm1, -0x58(%rbp)
movq -0x40(%rbp), %rdi
callq 0x10a80
movq %rax, %rsi
leaq -0x60(%rbp), %rdi
callq 0x110a0
movq -0xd8(%rbp), %rdi
movsd %xmm0, -0x50(%rbp)
movsd %xmm1, -0x48(%rbp)
callq 0xbc740
movq %rax, %rdi
callq 0x10a80
movq %rax, %rdi
leaq -0x50(%rbp), %rsi
callq 0x11360
movsd %xmm0, -0x70(%rbp)
movsd %xmm1, -0x68(%rbp)
testb $0x1, -0x11(%rbp)
jne 0xba2dc
leaq -0x70(%rbp), %rdi
callq 0x104e0
movsd %xmm0, -0x138(%rbp)
callq 0x855e0
movq %rax, %rdi
callq 0x325f0
movsd -0x138(%rbp), %xmm0
movq -0xd8(%rbp), %rdi
mulsd (%rax), %xmm0
movsd %xmm0, -0x78(%rbp)
callq 0xbc740
movq -0xd8(%rbp), %rdi
addq $0x8, %rax
movq %rax, -0x130(%rbp)
callq 0xbc740
movq %rax, %rdi
addq $0x8, %rdi
callq 0xbcf40
movq -0x130(%rbp), %rdi
movsd (%rax), %xmm0
addsd -0x78(%rbp), %xmm0
callq 0xbc830
movq -0xd8(%rbp), %rdi
callq 0xbc740
movq %rax, %rdi
addq $0x8, %rdi
callq 0x11090
movq %rax, %rdi
leaq -0x70(%rbp), %rsi
callq 0x11360
movq -0xd8(%rbp), %rdi
movsd %xmm0, -0x88(%rbp)
movsd %xmm1, -0x80(%rbp)
callq 0xbc740
movq %rax, %rdi
callq 0x11740
movq %rax, %rsi
leaq -0x70(%rbp), %rdi
callq 0x113f0
movq -0xd8(%rbp), %rdi
callq 0xbc740
movq -0xd8(%rbp), %rdi
movq %rax, -0x158(%rbp)
callq 0xbc740
movq %rax, %rdi
addq $0x8, %rdi
callq 0x1ddd0
movq -0xd8(%rbp), %rdi
movl %eax, -0x14c(%rbp)
callq 0xbc740
movq %rax, %rdi
addq $0x8, %rdi
callq 0x1d930
movq -0x158(%rbp), %rdi
movl -0x14c(%rbp), %edx
movsd (%rax), %xmm0
leaq -0x88(%rbp), %rsi
callq 0x142f0
movq -0xd8(%rbp), %rdi
callq 0xbc740
movq -0xd8(%rbp), %rdi
movq %rax, -0x148(%rbp)
callq 0xbc740
movq %rax, %rdi
callq 0x28a30
movq -0xd8(%rbp), %rdi
movl %eax, -0x13c(%rbp)
callq 0xbc740
movq %rax, %rdi
callq 0x32aa0
movq -0x148(%rbp), %rdi
movl -0x13c(%rbp), %edx
movsd (%rax), %xmm0
leaq -0x70(%rbp), %rsi
callq 0x142a0
jmp 0xba51d
testb $0x1, -0x11(%rbp)
je 0xba41e
movq -0xd8(%rbp), %rdi
callq 0xbc740
movq %rax, %rdi
addq $0x8, %rdi
movsd 0x8acc(%rip), %xmm0     # 0xc2ee0
callq 0xbc830
jmp 0xba4b2
movq -0xd8(%rbp), %rdi
callq 0xbc740
movq -0xd8(%rbp), %rdi
addq $0x8, %rax
movq %rax, -0x160(%rbp)
callq 0xbc740
movq %rax, %rdi
addq $0x8, %rdi
callq 0xbcf40
movq -0xd8(%rbp), %rdi
movsd (%rax), %xmm0
movsd %xmm0, -0x168(%rbp)
callq 0xbc740
movq %rax, %rdi
callq 0x10a80
movq %rax, %rdi
callq 0x104e0
movsd %xmm0, -0x170(%rbp)
callq 0x855e0
movq %rax, %rdi
callq 0x325f0
movsd -0x170(%rbp), %xmm0
movsd -0x168(%rbp), %xmm1
movq -0x160(%rbp), %rdi
movsd (%rax), %xmm2
mulsd %xmm2, %xmm0
addsd %xmm1, %xmm0
callq 0xbc830
movq -0xd8(%rbp), %rdi
callq 0xbc740
movq %rax, -0x178(%rbp)
callq 0x798a0
movq -0xd8(%rbp), %rdi
movq %rax, -0x180(%rbp)
callq 0xbcea0
movq %rax, %rdi
callq 0x10a60
movq -0x180(%rbp), %rdi
movl %eax, -0x8c(%rbp)
leaq -0x8c(%rbp), %rsi
callq 0x129d0
movq %rax, %rdi
callq 0x12fe0
movq -0xd8(%rbp), %rdi
movq -0x178(%rbp), %rsi
movsd (%rax), %xmm0
callq 0xbb2b0
movq -0xd8(%rbp), %rax
movq (%rax), %rdi
callq 0xbcf00
movq %rax, %rcx
movq -0xd8(%rbp), %rax
movq %rcx, -0x94(%rbp)
movq (%rax), %rdi
callq 0x11a70
movq %rax, %rsi
leaq -0x94(%rbp), %rdi
callq 0x120a0
testb $0x1, %al
jne 0xba55d
jmp 0xba653
movq -0xd8(%rbp), %rdi
callq 0xbc740
movq %rax, %rcx
movq -0xd8(%rbp), %rax
movq %rcx, -0x1b0(%rbp)
movq (%rax), %rdi
callq 0xbe370
movq -0xd8(%rbp), %rdi
movq %rax, -0x1a8(%rbp)
callq 0xbcea0
movq %rax, %rdi
addq $0x8, %rdi
callq 0x1ddd0
movq -0xd8(%rbp), %rdi
movl %eax, -0x19c(%rbp)
callq 0xbcea0
movq %rax, %rdi
addq $0x8, %rdi
callq 0x1d930
movq -0x1b0(%rbp), %rdi
movq -0x1a8(%rbp), %rsi
movl -0x19c(%rbp), %edx
movsd (%rax), %xmm0
callq 0x142f0
movq -0xd8(%rbp), %rdi
callq 0xbc740
movq %rax, %rcx
movq -0xd8(%rbp), %rax
movq %rcx, -0x198(%rbp)
movq (%rax), %rdi
callq 0xbe390
movq -0xd8(%rbp), %rdi
movq %rax, -0x190(%rbp)
callq 0xbcea0
movq %rax, %rdi
callq 0x28a30
movq -0xd8(%rbp), %rdi
movl %eax, -0x184(%rbp)
callq 0xbcea0
movq %rax, %rdi
callq 0x32aa0
movq -0x198(%rbp), %rdi
movq -0x190(%rbp), %rsi
movl -0x184(%rbp), %edx
movsd (%rax), %xmm0
callq 0x142a0
movq -0xd8(%rbp), %rax
movq (%rax), %rdi
callq 0xbe3b0
movq %rax, %rcx
movq -0xd8(%rbp), %rax
movq %rcx, -0x9c(%rbp)
movq (%rax), %rdi
callq 0x11a70
movq %rax, %rsi
leaq -0x9c(%rbp), %rdi
callq 0x120a0
testb $0x1, %al
jne 0xba693
jmp 0xba843
testb $0x1, -0x9(%rbp)
jne 0xba716
movq -0xd8(%rbp), %rdi
callq 0xbc740
movq %rax, %rcx
movq -0xd8(%rbp), %rax
movq %rcx, -0x1c8(%rbp)
movq (%rax), %rdi
callq 0xbe3d0
movq -0xd8(%rbp), %rdi
movsd %xmm0, -0x1b8(%rbp)
callq 0xbcea0
movq %rax, %rdi
callq 0x5c650
movq -0xd8(%rbp), %rdi
movl %eax, -0x1bc(%rbp)
callq 0xbcea0
movq %rax, %rdi
callq 0x32a60
movq -0x1c8(%rbp), %rdi
movl -0x1bc(%rbp), %esi
movaps %xmm0, %xmm1
movsd -0x1b8(%rbp), %xmm0
callq 0x77ef0
jmp 0xba841
movq -0xd8(%rbp), %rax
movq 0x8(%rax), %rdi
movl $0x1, %esi
callq 0xab550
movq -0xd8(%rbp), %rsi
movq %rax, %rdi
addq $0x14, %rsi
callq 0x12520
movq %rax, %rcx
movq -0xd8(%rbp), %rax
movq %rcx, -0xa8(%rbp)
movq (%rax), %rdi
callq 0xbe3d0
movsd %xmm0, -0x1f0(%rbp)
movq -0xa8(%rbp), %rdi
callq 0x11170
movsd -0x1f0(%rbp), %xmm0
movq -0xd8(%rbp), %rdi
subsd (%rax), %xmm0
movsd %xmm0, -0xb0(%rbp)
movsd -0xb0(%rbp), %xmm0
movsd %xmm0, -0x1e8(%rbp)
callq 0xbc740
movq %rax, %rdi
callq 0x11170
movsd -0x1e8(%rbp), %xmm0
addsd (%rax), %xmm0
movsd 0x6879(%rip), %xmm1     # 0xc1030
movsd %xmm1, -0xc0(%rbp)
leaq -0xc0(%rbp), %rdi
callq 0x116b0
movq -0xd8(%rbp), %rdi
movsd %xmm0, -0xb8(%rbp)
callq 0xbc740
movq -0xd8(%rbp), %rdi
movq %rax, -0x1e0(%rbp)
movsd -0xb8(%rbp), %xmm0
movsd %xmm0, -0x1d0(%rbp)
callq 0xbcea0
movq %rax, %rdi
callq 0x5c650
movq -0xd8(%rbp), %rdi
movl %eax, -0x1d4(%rbp)
callq 0xbcea0
movq %rax, %rdi
callq 0x32a60
movq -0x1e0(%rbp), %rdi
movl -0x1d4(%rbp), %esi
movaps %xmm0, %xmm1
movsd -0x1d0(%rbp), %xmm0
callq 0x77ef0
jmp 0xba843
xorl %eax, %eax
testb $0x1, -0x9(%rbp)
movb %al, -0x1f1(%rbp)
jne 0xba88e
movq -0xd8(%rbp), %rax
movq (%rax), %rdi
callq 0xbe3f0
movq %rax, %rcx
movq -0xd8(%rbp), %rax
movq %rcx, -0xc8(%rbp)
movq (%rax), %rdi
callq 0x11a70
movq %rax, %rsi
leaq -0xc8(%rbp), %rdi
callq 0x120a0
movb %al, -0x1f1(%rbp)
movb -0x1f1(%rbp), %al
testb $0x1, %al
jne 0xba89a
jmp 0xba912
movq -0xd8(%rbp), %rdi
callq 0xbc740
movq %rax, %rcx
movq -0xd8(%rbp), %rax
movq %rcx, -0x210(%rbp)
movq (%rax), %rdi
callq 0xbe410
movq -0xd8(%rbp), %rdi
movsd %xmm0, -0x200(%rbp)
callq 0xbcea0
movq %rax, %rdi
callq 0x5c670
movq -0xd8(%rbp), %rdi
movl %eax, -0x204(%rbp)
callq 0xbcea0
movq %rax, %rdi
callq 0x5c690
movq -0x210(%rbp), %rdi
movl -0x204(%rbp), %esi
movaps %xmm0, %xmm1
movsd -0x200(%rbp), %xmm0
callq 0x77f60
addq $0x210, %rsp            # imm = 0x210
popq %rbp
retq
nopl (%rax,%rax)