// File: 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
subq $0x120, %rsp            # imm = 0x120
movq %rdi, -0xe8(%rbp)
movq %rdi, -0xf0(%rbp)
movq %rsi, -0x8(%rbp)
movq %rdx, -0x10(%rbp)
movq -0x8(%rbp), %rdi
movq %rdi, -0xd8(%rbp)
movq -0x10(%rbp), %rsi
callq 0x50020
movq -0xe8(%rbp), %rdi
xorl %esi, %esi
callq 0x1d620
movq -0xe8(%rbp), %rdi
movq -0xd8(%rbp), %rsi
movb $0x0, (%rdi)
movq %rsi, %rdi
addq $0x2b4580, %rdi         # imm = 0x2B4580
addq $0x30, %rdi
addq $0x2b4580, %rsi         # imm = 0x2B4580
addq $0x40, %rsi
callq 0x11360
movq -0xd8(%rbp), %rsi
movsd %xmm0, -0x30(%rbp)
movsd %xmm1, -0x28(%rbp)
addq $0x2b4580, %rsi         # imm = 0x2B4580
addq $0x18, %rsi
leaq -0x30(%rbp), %rdi
callq 0x110a0
movq -0xd8(%rbp), %rax
movsd %xmm0, -0x20(%rbp)
movsd %xmm1, -0x18(%rbp)
addq $0x2b4580, %rax         # imm = 0x2B4580
addq $0x40, %rax
movq %rax, -0xe0(%rbp)
callq 0x855e0
movq %rax, %rdi
callq 0x113d0
movq -0xe0(%rbp), %rdi
movq %rax, %rsi
callq 0x13320
movq -0xd8(%rbp), %rsi
movsd %xmm0, -0x40(%rbp)
movsd %xmm1, -0x38(%rbp)
movq %rsi, %rdi
addq $0x2b45d8, %rdi         # imm = 0x2B45D8
addq $0x2b4580, %rsi         # imm = 0x2B4580
addq $0x18, %rsi
callq 0x110a0
movsd %xmm0, -0x50(%rbp)
movsd %xmm1, -0x48(%rbp)
leaq -0x20(%rbp), %rdi
callq 0x104e0
movsd %xmm0, -0xd0(%rbp)
callq 0x798a0
movq -0xd8(%rbp), %rsi
movq %rax, %rdi
addq $0x2b4580, %rsi         # imm = 0x2B4580
callq 0x129d0
movq %rax, %rdi
callq 0x1deb0
movsd -0xd0(%rbp), %xmm1
movsd (%rax), %xmm0
movsd 0x6c7d6(%rip), %xmm2    # 0xc1ed8
subsd %xmm2, %xmm0
ucomisd %xmm1, %xmm0
jbe 0x55a3d
leaq -0x20(%rbp), %rdi
callq 0x104e0
movsd %xmm0, -0xf8(%rbp)
callq 0x798a0
movq -0xd8(%rbp), %rsi
movq %rax, %rdi
addq $0x2b4580, %rsi         # imm = 0x2B4580
callq 0x129d0
movq %rax, %rdi
callq 0x12ef0
movsd (%rax), %xmm0
movsd %xmm0, -0x100(%rbp)
callq 0x855e0
movq %rax, %rdi
callq 0x12f10
movsd -0x100(%rbp), %xmm1
movsd -0xf8(%rbp), %xmm0
addsd (%rax), %xmm1
movsd 0x6bf57(%rip), %xmm2    # 0xc16d0
addsd %xmm2, %xmm1
ucomisd %xmm1, %xmm0
jbe 0x55a3d
movq -0xd8(%rbp), %rdi
movl 0x2b4580(%rdi), %eax
movl %eax, -0x10c(%rbp)
addq $0x2b4580, %rdi         # imm = 0x2B4580
addq $0x18, %rdi
callq 0x104e0
movl -0x10c(%rbp), %edi
callq 0x570a0
movsd %xmm0, -0x58(%rbp)
movsd -0x58(%rbp), %xmm0
movsd %xmm0, -0x108(%rbp)
leaq -0x20(%rbp), %rdi
callq 0x10520
movaps %xmm0, %xmm1
movsd -0x108(%rbp), %xmm0
movaps 0x6b87e(%rip), %xmm2    # 0xc1060
pand %xmm2, %xmm1
ucomisd %xmm1, %xmm0
jbe 0x557fc
leaq -0x20(%rbp), %rdi
callq 0x10520
movsd %xmm0, -0x58(%rbp)
jmp 0x5584e
leaq -0x20(%rbp), %rdi
callq 0x10520
xorps %xmm1, %xmm1
ucomisd %xmm1, %xmm0
jbe 0x5581d
movsd -0x58(%rbp), %xmm0
movsd %xmm0, -0x118(%rbp)
jmp 0x55841
movsd -0x58(%rbp), %xmm0
movq %xmm0, %rax
movabsq $-0x8000000000000000, %rcx # imm = 0x8000000000000000
xorq %rcx, %rax
movq %rax, %xmm0
movsd %xmm0, -0x118(%rbp)
movsd -0x118(%rbp), %xmm0
movsd %xmm0, -0x58(%rbp)
movsd -0x58(%rbp), %xmm0
movq %xmm0, %rax
movabsq $-0x8000000000000000, %rcx # imm = 0x8000000000000000
xorq %rcx, %rax
movq %rax, %xmm0
movsd %xmm0, -0x70(%rbp)
leaq -0x20(%rbp), %rdi
leaq -0x70(%rbp), %rsi
callq 0x11110
movsd %xmm0, -0x68(%rbp)
movsd %xmm1, -0x60(%rbp)
movq -0x68(%rbp), %rax
movq %rax, -0x20(%rbp)
movq -0x60(%rbp), %rax
movq %rax, -0x18(%rbp)
movsd -0x58(%rbp), %xmm0
movq %xmm0, %rax
movabsq $-0x8000000000000000, %rcx # imm = 0x8000000000000000
xorq %rcx, %rax
movq %rax, %xmm0
movsd %xmm0, -0x88(%rbp)
leaq -0x40(%rbp), %rdi
leaq -0x88(%rbp), %rsi
callq 0x11110
movsd %xmm0, -0x80(%rbp)
movsd %xmm1, -0x78(%rbp)
movq -0x80(%rbp), %rax
movq %rax, -0x40(%rbp)
movq -0x78(%rbp), %rax
movq %rax, -0x38(%rbp)
movsd -0x58(%rbp), %xmm0
movq %xmm0, %rax
movabsq $-0x8000000000000000, %rcx # imm = 0x8000000000000000
xorq %rcx, %rax
movq %rax, %xmm0
movsd %xmm0, -0xa0(%rbp)
leaq -0x50(%rbp), %rdi
leaq -0xa0(%rbp), %rsi
callq 0x11110
movsd %xmm0, -0x98(%rbp)
movsd %xmm1, -0x90(%rbp)
movq -0x98(%rbp), %rax
movq %rax, -0x50(%rbp)
movq -0x90(%rbp), %rax
movq %rax, -0x48(%rbp)
leaq -0x50(%rbp), %rdi
leaq -0x20(%rbp), %rsi
callq 0x110a0
movsd %xmm0, -0xb8(%rbp)
movsd %xmm1, -0xb0(%rbp)
leaq -0xb8(%rbp), %rdi
callq 0x10520
movsd %xmm0, -0xa8(%rbp)
movsd -0xa8(%rbp), %xmm1
movaps 0x6b6e2(%rip), %xmm0    # 0xc1060
pand %xmm0, %xmm1
movsd 0x6b6b6(%rip), %xmm0    # 0xc1040
ucomisd %xmm1, %xmm0
jbe 0x55a3b
movq -0xd8(%rbp), %rax
movl 0x2b4580(%rax), %esi
leaq -0x20(%rbp), %rdi
callq 0x111b0
movsd %xmm0, -0x120(%rbp)
callq 0x855e0
movq %rax, %rdi
callq 0x10f10
movsd -0x120(%rbp), %xmm0
movq -0xd8(%rbp), %rdi
mulsd (%rax), %xmm0
movsd %xmm0, -0xc8(%rbp)
leaq -0x40(%rbp), %rsi
leaq -0xa8(%rbp), %rdx
leaq -0xc8(%rbp), %rcx
callq 0x569c0
movq -0xd8(%rbp), %rax
movsd %xmm0, -0xc0(%rbp)
movsd -0xc0(%rbp), %xmm0
movsd 0x6ce68(%rip), %xmm1    # 0xc2878
addsd 0x2b45d0(%rax), %xmm1
ucomisd %xmm1, %xmm0
jbe 0x55a39
movq -0xe8(%rbp), %rax
movl $0x1, 0x4(%rax)
movb $0x1, (%rax)
movsd -0x58(%rbp), %xmm0
movsd %xmm0, 0x18(%rax)
jmp 0x55a3b
jmp 0x55a3d
movq -0xf0(%rbp), %rax
addq $0x120, %rsp            # imm = 0x120
popq %rbp
retq
nopl (%rax)