// File: /workspace/github_cpp_makefile_star2_O1/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 0x2de9c
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, -0x60(%rbp)
subsd 0x2b45a0(%r14), %xmm1
movapd %xmm1, -0x30(%rbp)
callq 0x4a75c
movsd 0x30e0(%rax), %xmm0
movsd 0x2b45c0(%r14), %xmm1
mulsd %xmm0, %xmm1
mulsd 0x2b45c8(%r14), %xmm0
movsd %xmm1, -0x80(%rbp)
movsd %xmm0, -0x78(%rbp)
movsd 0x2b45d8(%r14), %xmm0
movsd 0x2b45e0(%r14), %xmm1
subsd 0x2b4598(%r14), %xmm0
movsd %xmm0, -0x88(%rbp)
subsd 0x2b45a0(%r14), %xmm1
movapd -0x30(%rbp), %xmm2
mulsd %xmm2, %xmm2
movapd -0x60(%rbp), %xmm0
mulsd %xmm0, %xmm0
addsd %xmm2, %xmm0
xorpd %xmm2, %xmm2
ucomisd %xmm2, %xmm0
movapd %xmm1, -0xb0(%rbp)
movapd %xmm0, -0x40(%rbp)
jb 0x322c5
sqrtsd %xmm0, %xmm0
jmp 0x322ca
callq 0x93c0
movsd %xmm0, -0x50(%rbp)
callq 0x450ba
movq 0x5c38(%rax), %rax
movslq 0x2b4580(%r14), %rcx
imulq $0x3700, %rcx, %rcx     # imm = 0x3700
movsd 0x3080(%rax,%rcx), %xmm0
addsd 0x39c56(%rip), %xmm0    # 0x6bf50
ucomisd -0x50(%rbp), %xmm0
jbe 0x3282a
xorpd %xmm1, %xmm1
movapd -0x40(%rbp), %xmm0
ucomisd %xmm1, %xmm0
jb 0x3231a
sqrtsd %xmm0, %xmm0
jmp 0x3231f
callq 0x93c0
movsd %xmm0, -0x50(%rbp)
callq 0x450ba
movq 0x5c38(%rax), %rax
movslq 0x2b4580(%r14), %rcx
imulq $0x3700, %rcx, %rcx     # imm = 0x3700
movsd 0x3038(%rax,%rcx), %xmm0
movsd %xmm0, -0x40(%rbp)
callq 0x4a75c
movsd -0x40(%rbp), %xmm1
addsd 0x30d8(%rax), %xmm1
addsd 0x393da(%rip), %xmm1    # 0x6b740
movsd -0x50(%rbp), %xmm0
ucomisd %xmm1, %xmm0
jbe 0x3282a
movslq 0x2b4580(%r14), %r15
movsd 0x2b4598(%r14), %xmm0
movsd 0x2b45a0(%r14), %xmm1
mulsd %xmm1, %xmm1
mulsd %xmm0, %xmm0
addsd %xmm1, %xmm0
xorpd %xmm1, %xmm1
ucomisd %xmm1, %xmm0
jb 0x323aa
sqrtsd %xmm0, %xmm0
jmp 0x323af
callq 0x93c0
movsd %xmm0, -0x40(%rbp)
callq 0x4a75c
movsd 0x3140(%rax), %xmm0
movaps %xmm0, -0x50(%rbp)
callq 0x450ba
movapd -0x50(%rbp), %xmm1
movq 0x5c38(%rax), %rax
imulq $0x3700, %r15, %rcx     # imm = 0x3700
movsd -0x40(%rbp), %xmm0
mulsd 0x3028(%rax,%rcx), %xmm0
addsd 0x38c65(%rip), %xmm0    # 0x6b058
divsd %xmm0, %xmm1
movapd 0x38c11(%rip), %xmm2    # 0x6b010
movapd -0x60(%rbp), %xmm4
andpd %xmm2, %xmm4
movsd 0x38c30(%rip), %xmm3    # 0x6b040
ucomisd %xmm4, %xmm3
movapd -0x30(%rbp), %xmm5
andpd %xmm2, %xmm5
xorpd %xmm0, %xmm0
jbe 0x32429
ucomisd %xmm5, %xmm3
ja 0x32473
movapd -0x30(%rbp), %xmm0
movapd %xmm1, -0x50(%rbp)
movaps -0x60(%rbp), %xmm1
movapd %xmm4, -0x40(%rbp)
movapd %xmm5, -0xa0(%rbp)
callq 0x90d0
movapd -0xa0(%rbp), %xmm5
movapd -0x40(%rbp), %xmm4
movapd 0x38bb2(%rip), %xmm2    # 0x6b010
movapd -0x50(%rbp), %xmm1
mulsd 0x38bdd(%rip), %xmm0    # 0x6b048
divsd 0x38bdd(%rip), %xmm0    # 0x6b050
andpd %xmm2, %xmm0
ucomisd %xmm0, %xmm1
movsd 0x38bbd(%rip), %xmm0    # 0x6b040
cmpltpd %xmm0, %xmm4
cmpltpd %xmm0, %xmm5
andpd %xmm4, %xmm5
movd %xmm5, %eax
jbe 0x324c3
xorpd %xmm1, %xmm1
testb $0x1, %al
jne 0x3250b
movapd -0x30(%rbp), %xmm0
movaps -0x60(%rbp), %xmm1
callq 0x90d0
movapd %xmm0, %xmm1
mulsd 0x38b8f(%rip), %xmm1    # 0x6b048
divsd 0x38b8f(%rip), %xmm1    # 0x6b050
jmp 0x3250b
testb $0x1, %al
je 0x324cb
xorl %eax, %eax
jmp 0x324ff
movapd -0x30(%rbp), %xmm0
movapd %xmm1, -0x50(%rbp)
movapd -0x60(%rbp), %xmm1
callq 0x90d0
mulsd 0x38b61(%rip), %xmm0    # 0x6b048
divsd 0x38b61(%rip), %xmm0    # 0x6b050
xorpd %xmm1, %xmm1
ucomisd %xmm1, %xmm0
movapd -0x50(%rbp), %xmm1
seta %al
testb %al, %al
jne 0x3250b
xorpd 0x38b15(%rip), %xmm1    # 0x6b020
movsd 0x38b8d(%rip), %xmm0    # 0x6b0a0
movapd %xmm1, -0x50(%rbp)
mulsd %xmm1, %xmm0
divsd 0x38b24(%rip), %xmm0    # 0x6b048
movsd %xmm0, -0x40(%rbp)
leaq -0x68(%rbp), %r15
leaq -0x70(%rbp), %r12
movq %r15, %rdi
movq %r12, %rsi
callq 0x92d0
movsd (%r15), %xmm0
movsd (%r12), %xmm1
movapd -0x60(%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
movsd -0x80(%rbp), %xmm2
movsd -0x78(%rbp), %xmm3
movapd %xmm0, %xmm4
mulsd %xmm3, %xmm4
mulsd %xmm2, %xmm0
mulsd %xmm1, %xmm2
subsd %xmm4, %xmm2
mulsd %xmm1, %xmm3
addsd %xmm0, %xmm3
movsd %xmm2, -0x80(%rbp)
movsd %xmm3, -0x78(%rbp)
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 0x389f1(%rip), %xmm4    # 0x6b010
andpd %xmm4, %xmm0
movsd 0x38a15(%rip), %xmm5    # 0x6b040
ucomisd %xmm0, %xmm5
jbe 0x32643
movapd %xmm3, %xmm2
andpd %xmm4, %xmm2
xorpd %xmm0, %xmm0
ucomisd %xmm2, %xmm5
ja 0x3266c
movapd %xmm3, %xmm0
callq 0x90d0
movsd 0x389ec(%rip), %xmm5    # 0x6b040
movapd 0x389b4(%rip), %xmm4    # 0x6b010
mulsd 0x389e4(%rip), %xmm0    # 0x6b048
divsd 0x389e4(%rip), %xmm0    # 0x6b050
movsd %xmm0, -0x68(%rbp)
andpd 0x38997(%rip), %xmm0    # 0x6b010
movsd 0x38a2f(%rip), %xmm1    # 0x6b0b0
ucomisd %xmm0, %xmm1
jbe 0x3282a
movslq 0x2b4580(%r14), %r15
movapd -0x60(%rbp), %xmm1
movapd %xmm1, %xmm0
andpd %xmm4, %xmm0
ucomisd %xmm0, %xmm5
movapd -0x30(%rbp), %xmm2
jbe 0x326b8
andpd %xmm2, %xmm4
xorpd %xmm0, %xmm0
ucomisd %xmm4, %xmm5
ja 0x326e0
movapd -0x30(%rbp), %xmm0
movaps -0x60(%rbp), %xmm1
callq 0x90d0
movapd -0x60(%rbp), %xmm1
movapd -0x30(%rbp), %xmm2
mulsd 0x38970(%rip), %xmm0    # 0x6b048
divsd 0x38970(%rip), %xmm0    # 0x6b050
andpd 0x38928(%rip), %xmm0    # 0x6b010
movapd %xmm0, -0x40(%rbp)
mulsd %xmm2, %xmm2
mulsd %xmm1, %xmm1
addsd %xmm2, %xmm1
xorpd %xmm0, %xmm0
ucomisd %xmm0, %xmm1
jb 0x3270c
xorps %xmm0, %xmm0
sqrtsd %xmm1, %xmm0
jmp 0x32715
movapd %xmm1, %xmm0
callq 0x93c0
movsd %xmm0, -0x30(%rbp)
callq 0x450ba
movq 0x5c38(%rax), %rax
imulq $0x3700, %r15, %r15     # imm = 0x3700
movsd -0x30(%rbp), %xmm0
subsd 0x3038(%rax,%r15), %xmm0
movsd %xmm0, -0x30(%rbp)
callq 0x4a75c
movsd -0x30(%rbp), %xmm0
subsd 0x30d8(%rax), %xmm0
movsd %xmm0, -0x30(%rbp)
callq 0x450ba
movq 0x5c38(%rax), %rax
movsd 0x3893c(%rip), %xmm0    # 0x6b0a8
movapd -0x40(%rbp), %xmm1
mulsd %xmm0, %xmm1
divsd 0x388e3(%rip), %xmm1    # 0x6b060
movsd 0x3068(%rax,%r15), %xmm2
movsd %xmm2, -0x60(%rbp)
addsd 0x388c4(%rip), %xmm1    # 0x6b058
movapd %xmm1, -0x40(%rbp)
movsd -0x30(%rbp), %xmm1
mulsd %xmm0, %xmm1
movsd %xmm1, -0x30(%rbp)
callq 0x450ba
movq 0x5c38(%rax), %rax
movsd -0x30(%rbp), %xmm0
divsd 0x3040(%rax,%r15), %xmm0
movapd -0x40(%rbp), %xmm1
subsd %xmm0, %xmm1
mulsd -0x60(%rbp), %xmm1
movapd %xmm1, -0x40(%rbp)
callq 0x4a75c
movapd -0x40(%rbp), %xmm0
mulsd 0x3130(%rax), %xmm0
leaq -0x70(%rbp), %rcx
movsd %xmm0, (%rcx)
leaq -0x80(%rbp), %rsi
leaq -0x68(%rbp), %rdx
movq %r14, %rdi
callq 0x3349a
movsd 0x2b45d0(%r14), %xmm1
addsd 0x3a108(%rip), %xmm1    # 0x6c918
ucomisd %xmm1, %xmm0
jbe 0x3282a
movl $0x1, 0x4(%rbx)
movb $0x1, (%rbx)
movapd -0x50(%rbp), %xmm0
movsd %xmm0, 0x18(%rbx)
movq %rbx, %rax
addq $0x90, %rsp
popq %rbx
popq %r12
popq %r14
popq %r15
popq %rbp
retq
nop