// File: /workspace/github_cpp_makefile_star2_O2/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
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x38, %rsp
movl %esi, %r14d
movq %rdi, %rbx
movq (%rdi), %rsi
movb $0x1, %cl
cmpb $0x0, 0x1b1(%rsi)
jne 0x54088
cmpb $0x0, 0x1b2(%rsi)
jne 0x54088
movb 0x1b0(%rsi), %cl
movq 0x5660(%rsi), %rax
movq %rax, %rdx
shrq $0x20, %rdx
pushq $0xa
popq %r13
cmpl %edx, 0x10(%rsi)
jne 0x540de
cmpl %eax, 0xc(%rsi)
jne 0x540de
testb %cl, %cl
je 0x541ba
movslq 0x14(%rbx), %rdi
movq 0x8(%rbx), %r8
imulq $0x178, %rdi, %rax      # imm = 0x178
decq %rdi
movabsq $0x40c3880000000000, %rdx # imm = 0x40C3880000000000
movq %rdx, -0xa8(%r8,%rax)
testb %r14b, %r14b
jne 0x541ce
jmp 0x54406
movslq 0x14(%rbx), %rax
movq 0x8(%rbx), %rdx
leaq 0xa8(%rdx), %r15
decq %rax
testb %cl, %cl
je 0x5410c
imulq $0x178, %rax, %rcx      # imm = 0x178
movabsq $0x40c3880000000000, %rsi # imm = 0x40C3880000000000
movq %rsi, 0x28(%r15,%rcx)
jmp 0x5416b
imulq $0x178, %rax, %r12      # imm = 0x178
movsd 0x28(%r15,%r12), %xmm0
movsd %xmm0, -0x30(%rbp)
movsd 0x30(%r15,%r12), %xmm0
movsd 0x38(%r15,%r12), %xmm1
mulsd %xmm1, %xmm1
mulsd %xmm0, %xmm0
addsd %xmm1, %xmm0
sqrtsd %xmm0, %xmm0
movsd %xmm0, -0x38(%rbp)
callq 0x3db2c
movsd -0x38(%rbp), %xmm0
mulsd 0x3028(%rax), %xmm0
addsd -0x30(%rbp), %xmm0
movsd %xmm0, 0x28(%r15,%r12)
movslq 0x14(%rbx), %rax
movq 0x8(%rbx), %rdx
decq %rax
imulq $0x178, %rax, %rax      # imm = 0x178
leaq (%rdx,%rax), %r15
addq $0xa8, %r15
callq 0x38d94
movslq 0x14(%rbx), %rcx
movq 0x8(%rbx), %rdx
imulq $0x178, %rcx, %rcx      # imm = 0x178
movslq 0x44(%rdx,%rcx), %rcx
movq 0x5c38(%rax), %rax
imulq $0x3700, %rcx, %rcx     # imm = 0x3700
movsd 0x3020(%rax,%rcx), %xmm0
movq %r15, %rsi
callq 0x54b58
jmp 0x5445b
testb %r14b, %r14b
je 0x54385
movq 0x8(%rbx), %r8
movslq 0x14(%rbx), %rdi
decq %rdi
movq 0x8(%r8), %r9
movl 0x14b90(%r9), %eax
addl $0x9, %eax
cltd
idivl %r13d
movslq %edx, %rax
imulq $0x2128, %rax, %rax     # imm = 0x2128
addq %r9, %rax
imulq $0x178, %rdi, %rdx      # imm = 0x178
movsd 0x5668(%rsi), %xmm1
movsd 0x5670(%rsi), %xmm2
subsd 0xb0(%rdx,%rax), %xmm1
subsd 0xb8(%rdx,%rax), %xmm2
subsd 0xd8(%rdx,%rax), %xmm1
subsd 0xe0(%rdx,%rax), %xmm2
addsd 0xd8(%r8,%rdx), %xmm1
addsd 0xe0(%r8,%rdx), %xmm2
movsd %xmm1, -0x50(%rbp)
movsd %xmm2, -0x48(%rbp)
testb %cl, %cl
movsd %xmm2, -0x38(%rbp)
movsd %xmm1, -0x30(%rbp)
jne 0x542b1
movapd %xmm2, %xmm0
mulsd %xmm2, %xmm0
movsd -0x30(%rbp), %xmm1
mulsd %xmm1, %xmm1
addsd %xmm0, %xmm1
sqrtsd %xmm1, %xmm0
movsd %xmm0, -0x40(%rbp)
callq 0x3db2c
movsd -0x30(%rbp), %xmm1
movsd -0x38(%rbp), %xmm2
movsd -0x40(%rbp), %xmm0
mulsd 0x3028(%rax), %xmm0
movslq 0x14(%rbx), %rax
movq 0x8(%rbx), %r8
imulq $0x178, %rax, %rax      # imm = 0x178
addsd -0xa8(%r8,%rax), %xmm0
movsd %xmm0, -0xa8(%r8,%rax)
movslq 0x14(%rbx), %rax
imulq $0x178, %rax, %rax      # imm = 0x178
movq $-0xd0, %r15
leaq (%r8,%r15), %rdi
addq %rax, %rdi
movsd -0xc8(%rax,%r8), %xmm0
addsd %xmm1, %xmm0
movsd -0xc0(%rax,%r8), %xmm1
addsd %xmm2, %xmm1
leaq -0x60(%rbp), %r13
movsd %xmm0, (%r13)
movsd %xmm1, 0x8(%r13)
callq 0xd344
movsd (%rax), %xmm0
movsd -0x30(%rbp), %xmm1
mulsd %xmm0, %xmm1
leaq -0x50(%rbp), %r12
movsd %xmm1, (%r12)
mulsd -0x38(%rbp), %xmm0
movsd %xmm0, 0x8(%r12)
movslq 0x14(%rbx), %rax
movq 0x8(%rbx), %rcx
imulq $0x178, %rax, %rax      # imm = 0x178
leaq (%rcx,%r15), %rdi
addq %rax, %rdi
movl -0xb8(%rax,%rcx), %edx
movsd -0xb0(%rax,%rcx), %xmm0
movq %r13, %rsi
callq 0xde1c
movslq 0x14(%rbx), %rax
movq 0x8(%rbx), %rcx
imulq $0x178, %rax, %rax      # imm = 0x178
addq %rcx, %r15
addq %rax, %r15
movl -0x90(%rax,%rcx), %edx
movsd -0x88(%rax,%rcx), %xmm0
movq %r15, %rdi
movq %r12, %rsi
callq 0xdde8
pushq $0xa
popq %r13
jmp 0x5445b
movslq 0x14(%rbx), %rax
movq 0x8(%rbx), %rcx
imulq $0x178, %rax, %rax      # imm = 0x178
movsd -0xc8(%rax,%rcx), %xmm0
movsd -0xc0(%rax,%rcx), %xmm1
subsd 0x5668(%rsi), %xmm0
subsd 0x5670(%rsi), %xmm1
mulsd %xmm1, %xmm1
mulsd %xmm0, %xmm0
addsd %xmm1, %xmm0
sqrtsd %xmm0, %xmm0
movsd %xmm0, -0x30(%rbp)
callq 0x3db2c
movsd -0x30(%rbp), %xmm0
mulsd 0x3028(%rax), %xmm0
movslq 0x14(%rbx), %rdi
movq 0x8(%rbx), %r8
imulq $0x178, %rdi, %rax      # imm = 0x178
decq %rdi
addsd -0xa8(%r8,%rax), %xmm0
movsd %xmm0, -0xa8(%r8,%rax)
movq (%rbx), %rsi
imulq $0x178, %rdi, %rax      # imm = 0x178
leaq (%r8,%rax), %rdi
addq $0xa8, %rdi
addq $0x5668, %rsi           # imm = 0x5668
movl 0x18(%rdi), %edx
movsd 0x20(%rdi), %xmm0
callq 0xde1c
movslq 0x14(%rbx), %rax
movq 0x8(%rbx), %rcx
imulq $0x178, %rax, %rax      # imm = 0x178
leaq (%rax,%rcx), %rdi
addq $-0xd0, %rdi
movl $0x5678, %esi           # imm = 0x5678
addq (%rbx), %rsi
movl 0x40(%rdi), %edx
movsd 0x48(%rdi), %xmm0
callq 0xdde8
movq (%rbx), %rsi
movq 0x5688(%rsi), %rdx
movq %rdx, %rdi
shrq $0x20, %rdi
movl 0xc(%rsi), %eax
movl 0x10(%rsi), %ecx
xorl %ecx, %edi
xorl %eax, %edx
orl %edi, %edx
jne 0x544f1
movslq 0x14(%rbx), %rax
movq 0x8(%rbx), %rcx
imulq $0x178, %rax, %rax      # imm = 0x178
movq $-0xd0, %r15
leaq (%rcx,%r15), %rdi
addq %rax, %rdi
addq $0x5690, %rsi           # imm = 0x5690
movl -0xb8(%rax,%rcx), %edx
movsd -0xb0(%rax,%rcx), %xmm0
callq 0xde1c
movslq 0x14(%rbx), %rax
movq 0x8(%rbx), %rcx
imulq $0x178, %rax, %rax      # imm = 0x178
addq %rcx, %r15
addq %rax, %r15
movl $0x56a0, %esi           # imm = 0x56A0
addq (%rbx), %rsi
movl -0x90(%rax,%rcx), %edx
movsd -0x88(%rax,%rcx), %xmm0
movq %r15, %rdi
callq 0xdde8
movq (%rbx), %rsi
movl 0xc(%rsi), %eax
movl 0x10(%rsi), %ecx
movq 0x56b0(%rsi), %rdx
movq %rdx, %rdi
shrq $0x20, %rdi
xorl %ecx, %edi
xorl %eax, %edx
orl %edi, %edx
jne 0x5459d
testb %r14b, %r14b
je 0x545a7
movq 0x8(%rbx), %rcx
movq 0x8(%rcx), %rdi
movl 0x14b90(%rdi), %eax
addl $0x9, %eax
cltd
idivl %r13d
movslq %edx, %rax
imulq $0x2128, %rax, %rax     # imm = 0x2128
addq %rdi, %rax
movslq 0x14(%rbx), %rdx
imulq $0x178, %rdx, %rdx      # imm = 0x178
movsd 0x56b8(%rsi), %xmm0
subsd -0x20(%rdx,%rax), %xmm0
addsd -0x20(%rcx,%rdx), %xmm0
movabsq $-0x3f99800000000000, %rax # imm = 0xC066800000000000
leaq -0x50(%rbp), %rdi
movq %rax, (%rdi)
callq 0xd305
movslq 0x14(%rbx), %rax
movq 0x8(%rbx), %rcx
imulq $0x178, %rax, %rax      # imm = 0x178
leaq (%rax,%rcx), %rdi
addq $-0xd0, %rdi
movl 0xb8(%rdi), %esi
movsd 0xc0(%rdi), %xmm1
callq 0x382a6
jmp 0x54630
testb %r14b, %r14b
je 0x545e5
jmp 0x54630
movslq 0x14(%rbx), %rax
movq 0x8(%rbx), %rcx
imulq $0x178, %rax, %rax      # imm = 0x178
leaq (%rax,%rcx), %rdi
addq $-0xd0, %rdi
movsd 0x56b8(%rsi), %xmm0
movl 0xb8(%rdi), %esi
movsd 0xc0(%rdi), %xmm1
callq 0x382a6
movq (%rbx), %rsi
movl 0xc(%rsi), %eax
movl 0x10(%rsi), %ecx
movq 0x56c0(%rsi), %rdx
movq %rdx, %rdi
shrq $0x20, %rdi
cmpl %edi, %ecx
jne 0x54630
cmpl %edx, %eax
jne 0x54630
movslq 0x14(%rbx), %rax
movq 0x8(%rbx), %rcx
imulq $0x178, %rax, %rax      # imm = 0x178
leaq (%rax,%rcx), %rdi
addq $-0xd0, %rdi
movsd 0x56c8(%rsi), %xmm0
movl 0xa0(%rdi), %esi
movsd 0xa8(%rdi), %xmm1
callq 0x382f8
addq $0x38, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
nop