// File: /workspace/github_cpp_makefile_star2_O3/wrighteagle2d[P]wrighteaglebase/Debug/../src/Kicker.cpp
// Function: Kicker::GetTurnAction(Agent const&)
AtomicAction Kicker::GetTurnAction(const Agent &agent) {
  UpdateKickData(agent);

  AtomicAction a;
  a.mSucceed = false;

  Vector ball_pos = mInput.mBallPos + mInput.mBallVel - mInput.mPlayerVel;
  Vector ball_vel = mInput.mBallVel * ServerParam::instance().ballDecay();
  Vector target = mKickTarget - mInput.mPlayerVel;
  if (ball_pos.Mod() < PlayerParam::instance()
                               .HeteroPlayer(mInput.mPlayerType)
                               .kickableArea() -
                           0.05 &&
      ball_pos.Mod() > PlayerParam::instance()
                               .HeteroPlayer(mInput.mPlayerType)
                               .playerSize() +
                           ServerParam::instance().ballSize() + 0.01) {
    double max_turn_angle =
        GetMaxTurnAngle(mInput.mPlayerType, mInput.mPlayerVel.Mod());
    if (max_turn_angle > fabs(ball_pos.Dir())) {
      max_turn_angle = ball_pos.Dir();
    } else {
      max_turn_angle = (ball_pos.Dir() > 0) ? max_turn_angle : -max_turn_angle;
    }

    /** turn之后的状态 */
    ball_pos = ball_pos.Rotate(-max_turn_angle);
    ball_vel = ball_vel.Rotate(-max_turn_angle);
    target = target.Rotate(-max_turn_angle);

    double kick_angle = (target - ball_pos).Dir();
    if (fabs(kick_angle) < 90.0) // 尽量转身以后要面对要踢的方向
    {
      double max_speed =
          GetOneKickMaxSpeed(ball_vel, kick_angle,
                             GetKickRate(ball_pos, mInput.mPlayerType) *
                                 ServerParam::instance().maxPower());
      if (max_speed >
          mKickSpeed +
              0.16) /** 这里要苛刻一点，否则可能由于误差导致转身过后达不到所需速度 */
      {
        a.mType = CT_Turn;
        a.mSucceed = true;
        a.mTurnAngle = max_turn_angle;
      }
    }
  }
  return a;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %r12
pushq %rbx
subq $0x90, %rsp
movq %rsi, %r14
movq %rdi, %rbx
movq %rsi, %rdi
movq %rdx, %rsi
callq 0x2d494
xorps %xmm0, %xmm0
movups %xmm0, 0x20(%rbx)
movups %xmm0, 0x14(%rbx)
movups %xmm0, 0x4(%rbx)
movb $0x0, (%rbx)
movsd 0x2b45b0(%r14), %xmm0
movsd 0x2b45b8(%r14), %xmm1
addsd 0x2b45c0(%r14), %xmm0
addsd 0x2b45c8(%r14), %xmm1
subsd 0x2b4598(%r14), %xmm0
movapd %xmm0, -0x50(%rbp)
subsd 0x2b45a0(%r14), %xmm1
movapd %xmm1, -0x30(%rbp)
callq 0x49360
movsd 0x30e0(%rax), %xmm0
movsd 0x2b45c0(%r14), %xmm1
mulsd %xmm0, %xmm1
movsd %xmm1, -0x78(%rbp)
mulsd 0x2b45c8(%r14), %xmm0
movsd %xmm0, -0x80(%rbp)
movsd 0x2b45d8(%r14), %xmm1
movsd 0x2b45e0(%r14), %xmm0
subsd 0x2b4598(%r14), %xmm1
movsd %xmm1, -0x88(%rbp)
subsd 0x2b45a0(%r14), %xmm0
movapd %xmm0, -0xb0(%rbp)
movapd -0x30(%rbp), %xmm0
mulsd %xmm0, %xmm0
movapd -0x50(%rbp), %xmm1
mulsd %xmm1, %xmm1
addsd %xmm0, %xmm1
xorps %xmm0, %xmm0
sqrtsd %xmm1, %xmm0
movsd %xmm0, -0x40(%rbp)
callq 0x43dce
movq 0x5c38(%rax), %rax
movslq 0x2b4580(%r14), %rcx
imulq $0x3700, %rcx, %rcx     # imm = 0x3700
movsd 0x3080(%rax,%rcx), %xmm0
addsd 0x388fb(%rip), %xmm0    # 0x69f50
ucomisd -0x40(%rbp), %xmm0
jbe 0x31af8
callq 0x43dce
movq 0x5c38(%rax), %rax
movslq 0x2b4580(%r14), %rcx
imulq $0x3700, %rcx, %rcx     # imm = 0x3700
movsd 0x3038(%rax,%rcx), %xmm0
movsd %xmm0, -0x60(%rbp)
callq 0x49360
movsd -0x60(%rbp), %xmm1
addsd 0x30d8(%rax), %xmm1
addsd 0x3809e(%rip), %xmm1    # 0x69740
movsd -0x40(%rbp), %xmm0
ucomisd %xmm1, %xmm0
jbe 0x31af8
movslq 0x2b4580(%r14), %r15
movsd 0x2b4598(%r14), %xmm0
movsd 0x2b45a0(%r14), %xmm1
mulsd %xmm1, %xmm1
mulsd %xmm0, %xmm0
addsd %xmm1, %xmm0
sqrtsd %xmm0, %xmm0
movsd %xmm0, -0x60(%rbp)
callq 0x49360
movsd 0x3140(%rax), %xmm0
movaps %xmm0, -0x40(%rbp)
callq 0x43dce
movq 0x5c38(%rax), %rax
imulq $0x3700, %r15, %rcx     # imm = 0x3700
movsd -0x60(%rbp), %xmm0
mulsd 0x3028(%rax,%rcx), %xmm0
addsd 0x3793f(%rip), %xmm0    # 0x69058
movapd -0x40(%rbp), %xmm1
divsd %xmm0, %xmm1
movapd %xmm1, -0x40(%rbp)
movapd 0x378e1(%rip), %xmm2    # 0x69010
movapd -0x50(%rbp), %xmm0
andpd %xmm2, %xmm0
movsd 0x37900(%rip), %xmm3    # 0x69040
ucomisd %xmm0, %xmm3
movapd -0x30(%rbp), %xmm0
jbe 0x31776
movapd %xmm0, %xmm1
andpd %xmm2, %xmm1
ucomisd %xmm1, %xmm3
jbe 0x31776
xorpd %xmm0, %xmm0
movapd -0x40(%rbp), %xmm1
ucomisd %xmm0, %xmm1
ja 0x317dd
xorpd 0x378b0(%rip), %xmm1    # 0x69020
movapd %xmm1, %xmm0
jmp 0x317dd
movaps -0x50(%rbp), %xmm1
callq 0x90d0
mulsd 0x378c1(%rip), %xmm0    # 0x69048
divsd 0x378c1(%rip), %xmm0    # 0x69050
andpd 0x37879(%rip), %xmm0    # 0x69010
movapd %xmm0, -0x60(%rbp)
movapd -0x30(%rbp), %xmm0
movapd -0x50(%rbp), %xmm1
callq 0x90d0
movapd -0x40(%rbp), %xmm2
ucomisd -0x60(%rbp), %xmm2
mulsd 0x3788b(%rip), %xmm0    # 0x69048
divsd 0x3788b(%rip), %xmm0    # 0x69050
ja 0x317dd
xorpd %xmm1, %xmm1
ucomisd %xmm1, %xmm0
ja 0x317d9
xorpd 0x37847(%rip), %xmm2    # 0x69020
movapd %xmm2, %xmm0
movsd 0x378bb(%rip), %xmm1    # 0x690a0
movsd %xmm0, -0x70(%rbp)
mulsd %xmm0, %xmm1
divsd 0x37852(%rip), %xmm1    # 0x69048
movsd %xmm1, -0x40(%rbp)
leaq -0xa0(%rbp), %r15
leaq -0x68(%rbp), %r12
movapd %xmm1, %xmm0
movq %r15, %rdi
movq %r12, %rsi
callq 0x92d0
movsd (%r15), %xmm0
movsd (%r12), %xmm1
movapd -0x50(%rbp), %xmm2
movapd %xmm2, %xmm3
mulsd %xmm0, %xmm2
movapd -0x30(%rbp), %xmm4
mulsd %xmm4, %xmm0
mulsd %xmm1, %xmm3
subsd %xmm0, %xmm3
movapd %xmm3, -0x60(%rbp)
mulsd %xmm1, %xmm4
addsd %xmm2, %xmm4
movapd %xmm4, -0x30(%rbp)
movsd -0x40(%rbp), %xmm0
movq %r15, %rdi
movq %r12, %rsi
callq 0x92d0
movsd (%r15), %xmm0
movsd (%r12), %xmm1
movapd %xmm0, %xmm2
movsd -0x80(%rbp), %xmm3
mulsd %xmm3, %xmm2
movsd -0x78(%rbp), %xmm4
mulsd %xmm4, %xmm0
mulsd %xmm1, %xmm4
subsd %xmm2, %xmm4
mulsd %xmm1, %xmm3
addsd %xmm0, %xmm3
movsd %xmm4, (%r15)
movsd %xmm3, 0x8(%r15)
leaq -0x68(%rbp), %r15
leaq -0x90(%rbp), %r12
movsd -0x40(%rbp), %xmm0
movq %r15, %rdi
movq %r12, %rsi
callq 0x92d0
movsd (%r15), %xmm0
movsd (%r12), %xmm2
movsd -0x88(%rbp), %xmm4
movapd %xmm4, %xmm1
mulsd %xmm0, %xmm4
movapd -0xb0(%rbp), %xmm3
mulsd %xmm3, %xmm0
mulsd %xmm2, %xmm1
subsd %xmm0, %xmm1
mulsd %xmm2, %xmm3
addsd %xmm4, %xmm3
subsd -0x60(%rbp), %xmm1
subsd -0x30(%rbp), %xmm3
movapd %xmm1, %xmm0
movapd 0x3770c(%rip), %xmm4    # 0x69010
andpd %xmm4, %xmm0
movsd 0x37730(%rip), %xmm5    # 0x69040
ucomisd %xmm0, %xmm5
jbe 0x31928
movapd %xmm3, %xmm2
andpd %xmm4, %xmm2
xorpd %xmm0, %xmm0
ucomisd %xmm2, %xmm5
ja 0x31951
movapd %xmm3, %xmm0
callq 0x90d0
movsd 0x37707(%rip), %xmm5    # 0x69040
movapd 0x376cf(%rip), %xmm4    # 0x69010
mulsd 0x376ff(%rip), %xmm0    # 0x69048
divsd 0x376ff(%rip), %xmm0    # 0x69050
movsd %xmm0, -0x68(%rbp)
andpd 0x376b2(%rip), %xmm0    # 0x69010
movsd 0x3774a(%rip), %xmm1    # 0x690b0
ucomisd %xmm0, %xmm1
jbe 0x31af8
movslq 0x2b4580(%r14), %r15
movapd -0x60(%rbp), %xmm1
movapd %xmm1, %xmm0
andpd %xmm4, %xmm0
ucomisd %xmm0, %xmm5
movapd -0x30(%rbp), %xmm2
jbe 0x3199d
andpd %xmm2, %xmm4
xorpd %xmm0, %xmm0
ucomisd %xmm4, %xmm5
ja 0x319c0
movapd %xmm2, %xmm0
callq 0x90d0
movapd -0x60(%rbp), %xmm1
movapd -0x30(%rbp), %xmm2
mulsd 0x37690(%rip), %xmm0    # 0x69048
divsd 0x37690(%rip), %xmm0    # 0x69050
andpd 0x37648(%rip), %xmm0    # 0x69010
movapd %xmm0, -0x50(%rbp)
mulsd %xmm2, %xmm2
mulsd %xmm1, %xmm1
addsd %xmm2, %xmm1
sqrtsd %xmm1, %xmm1
movsd %xmm1, -0x30(%rbp)
callq 0x43dce
movq 0x5c38(%rax), %rax
imulq $0x3700, %r15, %r15     # imm = 0x3700
movsd -0x30(%rbp), %xmm0
subsd 0x3038(%rax,%r15), %xmm0
movsd %xmm0, -0x30(%rbp)
callq 0x49360
movsd -0x30(%rbp), %xmm0
subsd 0x30d8(%rax), %xmm0
movsd %xmm0, -0x30(%rbp)
callq 0x43dce
movq 0x5c38(%rax), %rax
movsd 0x37674(%rip), %xmm0    # 0x690a8
movapd -0x50(%rbp), %xmm1
mulsd %xmm0, %xmm1
divsd 0x3761b(%rip), %xmm1    # 0x69060
movsd 0x3068(%rax,%r15), %xmm2
movsd %xmm2, -0x40(%rbp)
addsd 0x375fc(%rip), %xmm1    # 0x69058
movapd %xmm1, -0x50(%rbp)
movsd -0x30(%rbp), %xmm1
mulsd %xmm0, %xmm1
movsd %xmm1, -0x30(%rbp)
callq 0x43dce
movq 0x5c38(%rax), %rax
movsd -0x30(%rbp), %xmm0
divsd 0x3040(%rax,%r15), %xmm0
movapd -0x50(%rbp), %xmm1
subsd %xmm0, %xmm1
mulsd -0x40(%rbp), %xmm1
movapd %xmm1, -0x50(%rbp)
callq 0x49360
movapd -0x50(%rbp), %xmm0
mulsd 0x3130(%rax), %xmm0
leaq -0x90(%rbp), %rcx
movsd %xmm0, (%rcx)
leaq -0xa0(%rbp), %rsi
leaq -0x68(%rbp), %rdx
movq %r14, %rdi
callq 0x326fe
movsd 0x2b45d0(%r14), %xmm1
addsd 0x38e2a(%rip), %xmm1    # 0x6a908
ucomisd %xmm1, %xmm0
jbe 0x31af8
movl $0x1, 0x4(%rbx)
movb $0x1, (%rbx)
movsd -0x70(%rbp), %xmm0
movsd %xmm0, 0x18(%rbx)
movq %rbx, %rax
addq $0x90, %rsp
popq %rbx
popq %r12
popq %r14
popq %r15
popq %rbp
retq
nop