// File: /workspace/github_cpp_makefile_star2_O1/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, %r12d
movq %rdi, %rbx
movq (%rdi), %rcx
movb $0x1, %al
cmpb $0x0, 0x1b1(%rcx)
jne 0x68100
cmpb $0x0, 0x1b2(%rcx)
jne 0x68100
movb 0x1b0(%rcx), %al
movq 0x5660(%rcx), %rdx
movq %rdx, %rsi
shrq $0x20, %rsi
cmpl %esi, 0x10(%rcx)
jne 0x6821e
cmpl %edx, 0xc(%rcx)
jne 0x6821e
testb %al, %al
je 0x68145
movslq 0x14(%rbx), %rdx
movq 0x8(%rbx), %rsi
imulq $0x178, %rdx, %rdx      # imm = 0x178
movabsq $0x40c3880000000000, %rdi # imm = 0x40C3880000000000
movq %rdi, -0xa8(%rsi,%rdx)
testb %r12b, %r12b
je 0x6828b
movq 0x8(%rbx), %rdx
movq 0x8(%rdx), %rsi
movl 0x14b90(%rsi), %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 %rsi, %rdi
movslq 0x14(%rbx), %rsi
imulq $0x178, %rsi, %rsi      # imm = 0x178
movsd 0x5668(%rcx), %xmm0
movsd 0x5670(%rcx), %xmm1
subsd -0xc8(%rsi,%rdi), %xmm0
subsd -0xc0(%rsi,%rdi), %xmm1
subsd -0xa0(%rsi,%rdi), %xmm0
subsd -0x98(%rsi,%rdi), %xmm1
addsd -0xa0(%rdx,%rsi), %xmm0
addsd -0x98(%rdx,%rsi), %xmm1
movsd %xmm0, -0x48(%rbp)
movsd %xmm1, -0x40(%rbp)
testb %al, %al
jne 0x683a2
mulsd %xmm1, %xmm1
mulsd %xmm0, %xmm0
addsd %xmm1, %xmm0
xorpd %xmm1, %xmm1
ucomisd %xmm1, %xmm0
jb 0x68365
sqrtsd %xmm0, %xmm0
jmp 0x6836a
movslq 0x14(%rbx), %rdx
movl $0xa8, %ecx
addq 0x8(%rbx), %rcx
decq %rdx
testb %al, %al
je 0x6824d
imulq $0x178, %rdx, %rax      # imm = 0x178
movabsq $0x40c3880000000000, %rdx # imm = 0x40C3880000000000
movq %rdx, 0x28(%rcx,%rax)
jmp 0x6830e
imulq $0x178, %rdx, %rax      # imm = 0x178
leaq (%rcx,%rax), %r15
movsd 0x28(%rcx,%rax), %xmm0
movsd %xmm0, -0x30(%rbp)
movsd 0x30(%rcx,%rax), %xmm0
movsd 0x38(%rcx,%rax), %xmm1
mulsd %xmm1, %xmm1
mulsd %xmm0, %xmm0
addsd %xmm1, %xmm0
xorpd %xmm1, %xmm1
ucomisd %xmm1, %xmm0
jb 0x682e7
sqrtsd %xmm0, %xmm0
jmp 0x682ec
testb %al, %al
jne 0x684c4
movslq 0x14(%rbx), %rax
movq 0x8(%rbx), %rdx
imulq $0x178, %rax, %rax      # imm = 0x178
movsd -0xc8(%rax,%rdx), %xmm0
movsd -0xc0(%rax,%rdx), %xmm1
subsd 0x5668(%rcx), %xmm0
subsd 0x5670(%rcx), %xmm1
mulsd %xmm1, %xmm1
mulsd %xmm0, %xmm0
addsd %xmm1, %xmm0
xorpd %xmm1, %xmm1
ucomisd %xmm1, %xmm0
jb 0x68487
sqrtsd %xmm0, %xmm0
jmp 0x6848c
callq 0x93c0
movsd %xmm0, -0x38(%rbp)
callq 0x4a75c
movsd -0x38(%rbp), %xmm0
mulsd 0x3028(%rax), %xmm0
addsd -0x30(%rbp), %xmm0
movsd %xmm0, 0x28(%r15)
movslq 0x14(%rbx), %rax
movq 0x8(%rbx), %rcx
imulq $0x178, %rax, %rax      # imm = 0x178
leaq (%rax,%rcx), %r15
addq $-0xd0, %r15
callq 0x450ba
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 0x68e00
jmp 0x68533
callq 0x93c0
movsd %xmm0, -0x30(%rbp)
callq 0x4a75c
movsd -0x30(%rbp), %xmm0
mulsd 0x3028(%rax), %xmm0
movslq 0x14(%rbx), %rax
movq 0x8(%rbx), %rcx
imulq $0x178, %rax, %rax      # imm = 0x178
addsd -0xa8(%rcx,%rax), %xmm0
movsd %xmm0, -0xa8(%rcx,%rax)
movslq 0x14(%rbx), %rax
movq 0x8(%rbx), %r13
imulq $0x178, %rax, %r14      # imm = 0x178
movsd -0xc8(%r14,%r13), %xmm0
movsd -0xc0(%r14,%r13), %xmm1
leaq -0x48(%rbp), %r15
addsd (%r15), %xmm0
addsd 0x8(%r15), %xmm1
leaq -0x58(%rbp), %rax
movsd %xmm0, (%rax)
movsd %xmm1, 0x8(%rax)
callq 0x450ba
movq 0x5c38(%rax), %rax
movslq 0x44(%r14,%r13), %rcx
imulq $0x3700, %rcx, %rcx     # imm = 0x3700
movsd 0x3020(%rax,%rcx), %xmm0
mulsd (%r15), %xmm0
movsd %xmm0, (%r15)
movsd 0x3020(%rax,%rcx), %xmm0
mulsd 0x8(%r15), %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
leaq -0x58(%rbp), %rsi
callq 0xf682
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 0x6852e
callq 0x93c0
movsd %xmm0, -0x30(%rbp)
callq 0x4a75c
movsd -0x30(%rbp), %xmm0
mulsd 0x3028(%rax), %xmm0
movslq 0x14(%rbx), %rax
movq 0x8(%rbx), %rcx
imulq $0x178, %rax, %rax      # imm = 0x178
addsd -0xa8(%rcx,%rax), %xmm0
movsd %xmm0, -0xa8(%rcx,%rax)
movslq 0x14(%rbx), %rax
movq 0x8(%rbx), %rcx
imulq $0x178, %rax, %rax      # imm = 0x178
movq $-0xd0, %r15
leaq (%rcx,%r15), %rdi
addq %rax, %rdi
movl $0x5668, %esi           # imm = 0x5668
addq (%rbx), %rsi
movl -0xb8(%rax,%rcx), %edx
movsd -0xb0(%rax,%rcx), %xmm0
callq 0xf682
movslq 0x14(%rbx), %rax
movq 0x8(%rbx), %rcx
imulq $0x178, %rax, %rax      # imm = 0x178
addq %rcx, %r15
addq %rax, %r15
movl $0x5678, %esi           # imm = 0x5678
addq (%rbx), %rsi
movl -0x90(%rax,%rcx), %edx
movsd -0x88(%rax,%rcx), %xmm0
movq %r15, %rdi
callq 0xf64c
movq (%rbx), %rsi
movq 0x5688(%rsi), %rax
movq %rax, %rcx
shrq $0x20, %rcx
cmpl %ecx, 0x10(%rsi)
jne 0x685bc
cmpl %eax, 0xc(%rsi)
jne 0x685bc
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 0xf682
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 0xf64c
movq (%rbx), %rax
movq 0x56b0(%rax), %rdx
movq %rdx, %rsi
shrq $0x20, %rsi
movl 0x10(%rax), %ecx
cmpl %esi, %ecx
jne 0x68748
cmpl %edx, 0xc(%rax)
jne 0x68748
testb %r12b, %r12b
je 0x6866b
movq 0x8(%rbx), %rdx
movq 0x8(%rdx), %rsi
movl 0x14b90(%rsi), %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 %rsi, %rdi
movslq 0x14(%rbx), %rsi
imulq $0x178, %rsi, %rsi      # imm = 0x178
movsd 0x56b8(%rax), %xmm0
subsd -0x20(%rsi,%rdi), %xmm0
addsd -0x20(%rdx,%rsi), %xmm0
movsd 0x2a0f(%rip), %xmm1     # 0x6b060
ucomisd %xmm0, %xmm1
jbe 0x686a5
movsd 0x2a11(%rip), %xmm2     # 0x6b070
addsd %xmm2, %xmm0
ucomisd %xmm0, %xmm1
ja 0x6865f
jmp 0x686c9
movslq 0x14(%rbx), %rsi
movl $0xa8, %edx
decq %rsi
movsd 0x56b8(%rax), %xmm0
movsd 0x29d9(%rip), %xmm1     # 0x6b060
addq 0x8(%rbx), %rdx
ucomisd %xmm0, %xmm1
jbe 0x686ea
movsd 0x29d7(%rip), %xmm2     # 0x6b070
addsd %xmm2, %xmm0
ucomisd %xmm0, %xmm1
ja 0x68699
jmp 0x6870e
ucomisd 0x299b(%rip), %xmm0     # 0x6b048
jb 0x686c9
movsd 0x29b1(%rip), %xmm2     # 0x6b068
movsd 0x2989(%rip), %xmm3     # 0x6b048
addsd %xmm2, %xmm0
ucomisd %xmm3, %xmm0
jae 0x686bf
addq %rsi, %rdx
addq $-0x20, %rdx
ucomisd %xmm0, %xmm1
jbe 0x68720
movsd 0x2992(%rip), %xmm2     # 0x6b070
addsd %xmm2, %xmm0
ucomisd %xmm0, %xmm1
ja 0x686de
jmp 0x68744
ucomisd 0x2956(%rip), %xmm0     # 0x6b048
jb 0x6870e
movsd 0x296c(%rip), %xmm1     # 0x6b068
movsd 0x2944(%rip), %xmm2     # 0x6b048
addsd %xmm1, %xmm0
ucomisd %xmm2, %xmm0
jae 0x68704
imulq $0x178, %rsi, %rsi      # imm = 0x178
movsd %xmm0, 0xb0(%rdx,%rsi)
jmp 0x68748
ucomisd 0x2920(%rip), %xmm0     # 0x6b048
jb 0x68744
movsd 0x2936(%rip), %xmm1     # 0x6b068
movsd 0x290e(%rip), %xmm2     # 0x6b048
addsd %xmm1, %xmm0
ucomisd %xmm2, %xmm0
jae 0x6873a
movsd %xmm0, (%rdx)
testb %r12b, %r12b
jne 0x687d6
movq 0x56c0(%rax), %rdx
movq %rdx, %rsi
shrq $0x20, %rsi
cmpl %esi, %ecx
jne 0x687d6
cmpl %edx, 0xc(%rax)
jne 0x687d6
movslq 0x14(%rbx), %rdx
movl $0xa8, %ecx
decq %rdx
movsd 0x56c8(%rax), %xmm0
movsd 0x28dc(%rip), %xmm1     # 0x6b060
addq 0x8(%rbx), %rcx
ucomisd %xmm0, %xmm1
jbe 0x687a2
movsd 0x28da(%rip), %xmm2     # 0x6b070
addsd %xmm2, %xmm0
ucomisd %xmm0, %xmm1
ja 0x68796
jmp 0x687c6
ucomisd 0x289e(%rip), %xmm0     # 0x6b048
jb 0x687c6
movsd 0x28b4(%rip), %xmm1     # 0x6b068
movsd 0x288c(%rip), %xmm2     # 0x6b048
addsd %xmm1, %xmm0
ucomisd %xmm2, %xmm0
jae 0x687bc
imulq $0x178, %rdx, %rax      # imm = 0x178
movsd %xmm0, 0x98(%rcx,%rax)
addq $0x38, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
nop