// File: /workspace/github_cpp_makefile_star2_O3/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, %al
cmpb $0x0, 0x1b1(%rsi)
jne 0x659ea
cmpb $0x0, 0x1b2(%rsi)
jne 0x659ea
movb 0x1b0(%rsi), %al
movq 0x5660(%rsi), %rcx
movq %rcx, %rdx
shrq $0x20, %rdx
cmpl %edx, 0x10(%rsi)
jne 0x65a3c
cmpl %ecx, 0xc(%rsi)
jne 0x65a3c
testb %al, %al
je 0x65b18
movslq 0x14(%rbx), %rcx
movq 0x8(%rbx), %r15
imulq $0x178, %rcx, %rdx      # imm = 0x178
decq %rcx
movabsq $0x40c3880000000000, %rdi # imm = 0x40C3880000000000
movq %rdi, -0xa8(%r15,%rdx)
testb %r14b, %r14b
jne 0x65b2c
jmp 0x65d9a
movslq 0x14(%rbx), %rcx
movq 0x8(%rbx), %rdx
leaq 0xa8(%rdx), %r15
decq %rcx
testb %al, %al
je 0x65a6a
imulq $0x178, %rcx, %rax      # imm = 0x178
movabsq $0x40c3880000000000, %rsi # imm = 0x40C3880000000000
movq %rsi, 0x28(%r15,%rax)
jmp 0x65ac9
imulq $0x178, %rcx, %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 0x49360
movsd -0x38(%rbp), %xmm0
mulsd 0x3028(%rax), %xmm0
addsd -0x30(%rbp), %xmm0
movsd %xmm0, 0x28(%r15,%r12)
movslq 0x14(%rbx), %rcx
movq 0x8(%rbx), %rdx
decq %rcx
imulq $0x178, %rcx, %rax      # imm = 0x178
leaq (%rdx,%rax), %r15
addq $0xa8, %r15
callq 0x43dce
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 0x66690
jmp 0x65def
testb %r14b, %r14b
je 0x65d19
movq 0x8(%rbx), %r15
movslq 0x14(%rbx), %rcx
decq %rcx
movq 0x8(%r15), %rdx
movl 0x14b90(%rdx), %edi
movl %edi, %r8d
addl $0x9, %r8d
movslq %r8d, %r8
imulq $0x66666667, %r8, %r8   # imm = 0x66666667
movq %r8, %r9
shrq $0x3f, %r9
sarq $0x22, %r8
addl %r9d, %r8d
addl %r8d, %r8d
leal (%r8,%r8,4), %r8d
negl %r8d
addl %r8d, %edi
addl $0x9, %edi
movslq %edi, %rdi
imulq $0x2128, %rdi, %rdi     # imm = 0x2128
addq %rdx, %rdi
imulq $0x178, %rcx, %rcx      # imm = 0x178
movsd 0x5668(%rsi), %xmm1
movsd 0x5670(%rsi), %xmm2
subsd 0xb0(%rcx,%rdi), %xmm1
subsd 0xb8(%rcx,%rdi), %xmm2
subsd 0xd8(%rcx,%rdi), %xmm1
subsd 0xe0(%rcx,%rdi), %xmm2
addsd 0xd8(%r15,%rcx), %xmm1
addsd 0xe0(%r15,%rcx), %xmm2
movsd %xmm1, -0x50(%rbp)
movsd %xmm2, -0x48(%rbp)
testb %al, %al
movsd %xmm2, -0x38(%rbp)
movsd %xmm1, -0x30(%rbp)
jne 0x65c39
movapd %xmm2, %xmm0
mulsd %xmm2, %xmm0
movsd -0x30(%rbp), %xmm1
mulsd %xmm1, %xmm1
addsd %xmm0, %xmm1
xorps %xmm0, %xmm0
sqrtsd %xmm1, %xmm0
movsd %xmm0, -0x40(%rbp)
callq 0x49360
movsd -0x30(%rbp), %xmm1
movsd -0x38(%rbp), %xmm2
movsd -0x40(%rbp), %xmm0
mulsd 0x3028(%rax), %xmm0
movslq 0x14(%rbx), %rax
movq 0x8(%rbx), %r15
imulq $0x178, %rax, %rax      # imm = 0x178
addsd -0xa8(%r15,%rax), %xmm0
movsd %xmm0, -0xa8(%r15,%rax)
movslq 0x14(%rbx), %rax
imulq $0x178, %rax, %r13      # imm = 0x178
movsd -0xc8(%r13,%r15), %xmm0
addsd %xmm1, %xmm0
movsd -0xc0(%r13,%r15), %xmm1
addsd %xmm2, %xmm1
leaq -0x60(%rbp), %r12
movsd %xmm0, (%r12)
movsd %xmm1, 0x8(%r12)
callq 0x43dce
movq 0x5c38(%rax), %rax
movslq 0x44(%r13,%r15), %rcx
imulq $0x3700, %rcx, %rcx     # imm = 0x3700
movsd -0x30(%rbp), %xmm0
mulsd 0x3020(%rax,%rcx), %xmm0
leaq -0x50(%rbp), %r15
movsd %xmm0, (%r15)
movsd -0x38(%rbp), %xmm0
mulsd 0x3020(%rax,%rcx), %xmm0
movsd %xmm0, 0x8(%r15)
movslq 0x14(%rbx), %rax
movq 0x8(%rbx), %rcx
imulq $0x178, %rax, %rax      # imm = 0x178
movq $-0xd0, %r13
leaq (%rcx,%r13), %rdi
addq %rax, %rdi
movl -0xb8(%rax,%rcx), %edx
movsd -0xb0(%rax,%rcx), %xmm0
movq %r12, %rsi
callq 0xf572
movslq 0x14(%rbx), %rax
movq 0x8(%rbx), %rcx
imulq $0x178, %rax, %rax      # imm = 0x178
addq %rcx, %r13
addq %rax, %r13
movl -0x90(%rax,%rcx), %edx
movsd -0x88(%rax,%rcx), %xmm0
movq %r13, %rdi
movq %r15, %rsi
jmp 0x65dea
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 0x49360
movsd -0x30(%rbp), %xmm0
mulsd 0x3028(%rax), %xmm0
movslq 0x14(%rbx), %rcx
movq 0x8(%rbx), %r15
imulq $0x178, %rcx, %rax      # imm = 0x178
decq %rcx
addsd -0xa8(%r15,%rax), %xmm0
movsd %xmm0, -0xa8(%r15,%rax)
movq (%rbx), %rsi
imulq $0x178, %rcx, %rax      # imm = 0x178
leaq (%r15,%rax), %rdi
addq $0xa8, %rdi
addq $0x5668, %rsi           # imm = 0x5668
movl 0x18(%rdi), %edx
movsd 0x20(%rdi), %xmm0
callq 0xf572
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 0xf53c
movq (%rbx), %rsi
movq 0x5688(%rsi), %rdx
movq %rdx, %rdi
shrq $0x20, %rdi
movl 0xc(%rsi), %ecx
movl 0x10(%rsi), %eax
xorl %eax, %edi
xorl %ecx, %edx
orl %edi, %edx
jne 0x65e85
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 0xf572
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 0xf53c
movq (%rbx), %rsi
movl 0xc(%rsi), %ecx
movl 0x10(%rsi), %eax
movq 0x56b0(%rsi), %rdx
movq %rdx, %rdi
shrq $0x20, %rdi
cmpl %edi, %eax
jne 0x6600a
cmpl %edx, %ecx
jne 0x6600a
testb %r14b, %r14b
je 0x65f2d
movq 0x8(%rbx), %rcx
movq 0x8(%rcx), %rdx
movl 0x14b90(%rdx), %edi
addl $0x9, %edi
movslq %edi, %rdi
imulq $0x66666667, %rdi, %r8  # imm = 0x66666667
movq %r8, %r9
shrq $0x3f, %r9
sarq $0x22, %r8
addl %r9d, %r8d
addl %r8d, %r8d
leal (%r8,%r8,4), %r8d
subl %r8d, %edi
movslq %edi, %rdi
imulq $0x2128, %rdi, %rdi     # imm = 0x2128
addq %rdx, %rdi
movslq 0x14(%rbx), %rdx
imulq $0x178, %rdx, %rdx      # imm = 0x178
movsd 0x56b8(%rsi), %xmm0
subsd -0x20(%rdx,%rdi), %xmm0
addsd -0x20(%rcx,%rdx), %xmm0
movsd 0x314d(%rip), %xmm1     # 0x69060
ucomisd %xmm0, %xmm1
jbe 0x65f67
movsd 0x314f(%rip), %xmm2     # 0x69070
addsd %xmm2, %xmm0
ucomisd %xmm0, %xmm1
ja 0x65f21
jmp 0x65f8b
movslq 0x14(%rbx), %rdx
movl $0xa8, %ecx
decq %rdx
movsd 0x56b8(%rsi), %xmm0
movsd 0x3117(%rip), %xmm1     # 0x69060
addq 0x8(%rbx), %rcx
ucomisd %xmm0, %xmm1
jbe 0x65fac
movsd 0x3115(%rip), %xmm2     # 0x69070
addsd %xmm2, %xmm0
ucomisd %xmm0, %xmm1
ja 0x65f5b
jmp 0x65fd0
ucomisd 0x30d9(%rip), %xmm0     # 0x69048
jb 0x65f8b
movsd 0x30ef(%rip), %xmm2     # 0x69068
movsd 0x30c7(%rip), %xmm3     # 0x69048
addsd %xmm2, %xmm0
ucomisd %xmm3, %xmm0
jae 0x65f81
addq %rdx, %rcx
addq $-0x20, %rcx
ucomisd %xmm0, %xmm1
jbe 0x65fe2
movsd 0x30d0(%rip), %xmm2     # 0x69070
addsd %xmm2, %xmm0
ucomisd %xmm0, %xmm1
ja 0x65fa0
jmp 0x66006
ucomisd 0x3094(%rip), %xmm0     # 0x69048
jb 0x65fd0
movsd 0x30aa(%rip), %xmm1     # 0x69068
movsd 0x3082(%rip), %xmm2     # 0x69048
addsd %xmm1, %xmm0
ucomisd %xmm2, %xmm0
jae 0x65fc6
imulq $0x178, %rdx, %rdx      # imm = 0x178
movsd %xmm0, 0xb0(%rcx,%rdx)
jmp 0x6600a
ucomisd 0x305e(%rip), %xmm0     # 0x69048
jb 0x66006
movsd 0x3074(%rip), %xmm1     # 0x69068
movsd 0x304c(%rip), %xmm2     # 0x69048
addsd %xmm1, %xmm0
ucomisd %xmm2, %xmm0
jae 0x65ffc
movsd %xmm0, (%rcx)
testb %r14b, %r14b
jne 0x66098
movq 0x56c0(%rsi), %rcx
movq %rcx, %rdx
shrq $0x20, %rdx
cmpl %edx, %eax
jne 0x66098
cmpl %ecx, 0xc(%rsi)
jne 0x66098
movslq 0x14(%rbx), %rcx
movl $0xa8, %eax
decq %rcx
movsd 0x56c8(%rsi), %xmm0
movsd 0x301a(%rip), %xmm1     # 0x69060
addq 0x8(%rbx), %rax
ucomisd %xmm0, %xmm1
jbe 0x66064
movsd 0x3018(%rip), %xmm2     # 0x69070
addsd %xmm2, %xmm0
ucomisd %xmm0, %xmm1
ja 0x66058
jmp 0x66088
ucomisd 0x2fdc(%rip), %xmm0     # 0x69048
jb 0x66088
movsd 0x2ff2(%rip), %xmm1     # 0x69068
movsd 0x2fca(%rip), %xmm2     # 0x69048
addsd %xmm1, %xmm0
ucomisd %xmm2, %xmm0
jae 0x6607e
imulq $0x178, %rcx, %rcx      # imm = 0x178
movsd %xmm0, 0x98(%rax,%rcx)
addq $0x38, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
nop