// File: /workspace/github_cpp_makefile_star2_O3/wrighteagle2d[P]wrighteaglebase/Debug/../src/PlayerState.cpp
// Function: PlayerState::GetRandAngle(double const&, double const&, BallState const&) const
AngleDeg PlayerState::GetRandAngle(const double &power, const double &vel,
                                   const BallState &bs) const {

  double dir_diff = fabs((bs.GetPos() - GetPos()).Dir() - GetBodyDir());
  Vector tmp = bs.GetPos() - GetPos();
  double dist_ball =
      (tmp.Mod() - GetPlayerSize() - -ServerParam::instance().ballSize());

  double pos_rate =
      0.5 + 0.25 * (dir_diff / 180 + dist_ball / GetKickableMargin());
  // [0.5, 1.0]
  double speed_rate =
      0.5 + 0.5 * (bs.GetVel().Mod() / (ServerParam::instance().ballSpeedMax() *
                                        ServerParam::instance().ballDecay()));
  // [0, 2*kick_rand]
  double max_rand = GetKickRand() *
                    (power / ServerParam::instance().maxPower()) *
                    (pos_rate + speed_rate);

  return Rad2Deg(max_rand / vel);
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %r12
pushq %rbx
subq $0x30, %rsp
movq %rcx, %r12
movq %rdx, %rbx
movq %rsi, %r14
movq %rdi, %r15
movsd 0x8(%rcx), %xmm1
movsd 0x10(%rcx), %xmm0
subsd 0x8(%rdi), %xmm1
subsd 0x10(%rdi), %xmm0
movapd 0x230ed(%rip), %xmm2    # 0x69010
movapd %xmm1, %xmm4
andpd %xmm2, %xmm4
movsd 0x2310d(%rip), %xmm3    # 0x69040
ucomisd %xmm4, %xmm3
jbe 0x45f47
andpd %xmm0, %xmm2
xorpd %xmm4, %xmm4
ucomisd %xmm2, %xmm3
ja 0x45f7a
callq 0x90d0
movapd %xmm0, %xmm4
mulsd 0x230f0(%rip), %xmm4    # 0x69048
divsd 0x230f0(%rip), %xmm4    # 0x69050
movsd 0x8(%r12), %xmm1
movsd 0x10(%r12), %xmm0
subsd 0x8(%r15), %xmm1
subsd 0x10(%r15), %xmm0
subsd 0xb0(%r15), %xmm4
andpd 0x23085(%rip), %xmm4    # 0x69010
movapd %xmm4, -0x40(%rbp)
mulsd %xmm0, %xmm0
mulsd %xmm1, %xmm1
addsd %xmm0, %xmm1
xorps %xmm0, %xmm0
sqrtsd %xmm1, %xmm0
movsd %xmm0, -0x28(%rbp)
callq 0x43dce
movq 0x5c38(%rax), %rax
movslq 0x114(%r15), %rcx
imulq $0x3700, %rcx, %rcx     # imm = 0x3700
movsd -0x28(%rbp), %xmm0
subsd 0x3038(%rax,%rcx), %xmm0
movsd %xmm0, -0x28(%rbp)
callq 0x49360
movsd -0x28(%rbp), %xmm0
addsd 0x30d8(%rax), %xmm0
movsd %xmm0, -0x28(%rbp)
movapd -0x40(%rbp), %xmm0
divsd 0x2304f(%rip), %xmm0    # 0x69048
movapd %xmm0, -0x40(%rbp)
callq 0x43dce
movq 0x5c38(%rax), %rax
movslq 0x114(%r15), %rcx
imulq $0x3700, %rcx, %rcx     # imm = 0x3700
movsd -0x28(%rbp), %xmm0
divsd 0x3040(%rax,%rcx), %xmm0
addsd -0x40(%rbp), %xmm0
mulsd 0x23075(%rip), %xmm0    # 0x690a8
addsd 0x2383d(%rip), %xmm0    # 0x69878
movsd %xmm0, -0x28(%rbp)
movsd 0x30(%r12), %xmm0
movsd 0x38(%r12), %xmm1
mulsd %xmm1, %xmm1
mulsd %xmm0, %xmm0
addsd %xmm1, %xmm0
sqrtsd %xmm0, %xmm0
movsd %xmm0, -0x40(%rbp)
callq 0x49360
movsd 0x30f8(%rax), %xmm0
movsd %xmm0, -0x48(%rbp)
callq 0x49360
movsd -0x48(%rbp), %xmm1
mulsd 0x30e0(%rax), %xmm1
movsd -0x40(%rbp), %xmm0
divsd %xmm1, %xmm0
movsd 0x237e0(%rip), %xmm1    # 0x69878
mulsd %xmm1, %xmm0
addsd %xmm1, %xmm0
addsd -0x28(%rbp), %xmm0
movsd %xmm0, -0x40(%rbp)
callq 0x43dce
movq 0x5c38(%rax), %rax
movslq 0x114(%r15), %rcx
imulq $0x3700, %rcx, %rcx     # imm = 0x3700
movsd 0x3048(%rax,%rcx), %xmm0
movsd %xmm0, -0x28(%rbp)
movsd (%r14), %xmm0
movsd %xmm0, -0x48(%rbp)
callq 0x49360
movsd -0x48(%rbp), %xmm0
divsd 0x3130(%rax), %xmm0
mulsd -0x28(%rbp), %xmm0
mulsd -0x40(%rbp), %xmm0
divsd (%rbx), %xmm0
mulsd 0x22f44(%rip), %xmm0    # 0x69048
divsd 0x22f44(%rip), %xmm0    # 0x69050
addq $0x30, %rsp
popq %rbx
popq %r12
popq %r14
popq %r15
popq %rbp
retq
nop