// File: /workspace/github_cpp_makefile_star2_O3/wrighteagle2d[P]wrighteaglebase/Debug/../src/Kicker.cpp
// Function: Kicker::TurnPlan(Agent const&, int, double)
AtomicAction Kicker::TurnPlan(const Agent &agent, int index,
                              double turn_max_speed) {
  UpdateKickData(agent);

  AtomicAction a = GetStopBallAction(agent, true);
  if (a.mSucceed == false) {
    return a;
  }

  // kick之后的各个量
  Vector ball_vel = mInput.mBallVel + a.mKickVel;
  Vector ball_pos = mInput.mBallPos + ball_vel - mInput.mPlayerVel;
  ball_vel = ball_vel * ServerParam::instance().ballDecay();
  Vector target = mKickTarget - mInput.mPlayerVel;
  Vector player_vel =
      mInput.mPlayerVel *
      PlayerParam::instance().HeteroPlayer(mInput.mPlayerType).playerDecay();

  // turn-转坐标轴之前的状态
  ball_pos += ball_vel - player_vel;
  ball_vel *= ServerParam::instance().ballDecay();
  target -= player_vel;
  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) //保证不碰撞
  {
    a.mSucceed = false;
    return a;
  }

  double max_turn_angle = GetMaxTurnAngle(mInput.mPlayerType, player_vel.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);

  Vector kicked_ball_pos =
      mInput.mBallPos + mInput.mBallVel + a.mKickVel - mInput.mPlayerVel;
  index = NearestPoint(kicked_ball_pos); // 这里要用kick后的点算
  turn_max_speed =
      GetOneKickMaxSpeed(ball_vel, (target - ball_pos).Dir(),
                         GetKickRate(ball_pos, mInput.mPlayerType) *
                             ServerParam::instance().maxPower());
  return a;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %r12
pushq %rbx
subq $0xd0, %rsp
movq %rdx, %r15
movq %rsi, %r14
movq %rdi, %rbx
movq %rsi, %rdi
movq %rdx, %rsi
callq 0x2d494
movq %rbx, %rdi
movq %r14, %rsi
movq %r15, %rdx
movl $0x1, %ecx
callq 0x30116
cmpb $0x0, (%rbx)
je 0x3221c
movsd 0x8(%rbx), %xmm0
movsd 0x10(%rbx), %xmm1
movsd 0x2b45c0(%r14), %xmm2
movsd %xmm0, -0xc8(%rbp)
addsd %xmm0, %xmm2
movsd %xmm2, -0x30(%rbp)
movsd 0x2b45c8(%r14), %xmm0
movsd %xmm1, -0xc0(%rbp)
addsd %xmm1, %xmm0
movsd %xmm0, -0x60(%rbp)
movsd %xmm2, -0xe8(%rbp)
movsd 0x2b45b0(%r14), %xmm1
addsd %xmm2, %xmm1
movsd 0x2b45b8(%r14), %xmm2
addsd %xmm0, %xmm2
subsd 0x2b4598(%r14), %xmm1
movsd %xmm1, -0x50(%rbp)
subsd 0x2b45a0(%r14), %xmm2
movsd %xmm2, -0x40(%rbp)
callq 0x49360
movsd 0x30e0(%rax), %xmm0
movsd -0x30(%rbp), %xmm1
mulsd %xmm0, %xmm1
movsd %xmm1, -0x30(%rbp)
movsd -0x60(%rbp), %xmm1
mulsd %xmm0, %xmm1
movsd %xmm1, -0x60(%rbp)
movsd 0x2b45d8(%r14), %xmm1
movsd 0x2b45e0(%r14), %xmm0
subsd 0x2b4598(%r14), %xmm1
movsd %xmm1, -0x80(%rbp)
subsd 0x2b45a0(%r14), %xmm0
movapd %xmm0, -0xa0(%rbp)
callq 0x43dce
movq 0x5c38(%rax), %rax
movslq 0x2b4580(%r14), %rcx
imulq $0x3700, %rcx, %rcx     # imm = 0x3700
movsd 0x3020(%rax,%rcx), %xmm1
movsd 0x2b4598(%r14), %xmm0
mulsd %xmm1, %xmm0
mulsd 0x2b45a0(%r14), %xmm1
movsd -0x30(%rbp), %xmm2
movsd %xmm0, -0x90(%rbp)
subsd %xmm0, %xmm2
movsd -0x60(%rbp), %xmm0
movsd %xmm1, -0xb8(%rbp)
subsd %xmm1, %xmm0
addsd -0x50(%rbp), %xmm2
movapd %xmm2, -0x70(%rbp)
addsd -0x40(%rbp), %xmm0
movapd %xmm0, -0x50(%rbp)
callq 0x49360
movsd 0x30e0(%rax), %xmm0
movsd %xmm0, -0xb0(%rbp)
movapd -0x50(%rbp), %xmm0
mulsd %xmm0, %xmm0
movapd -0x70(%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 0x3825b(%rip), %xmm0    # 0x69f50
movsd -0x40(%rbp), %xmm1
ucomisd %xmm0, %xmm1
ja 0x31d4f
callq 0x43dce
movq 0x5c38(%rax), %rax
movslq 0x2b4580(%r14), %rcx
imulq $0x3700, %rcx, %rcx     # imm = 0x3700
movsd 0x3038(%rax,%rcx), %xmm0
movsd %xmm0, -0xa8(%rbp)
callq 0x49360
movsd -0xa8(%rbp), %xmm0
addsd 0x30d8(%rax), %xmm0
addsd 0x379f8(%rip), %xmm0    # 0x69740
ucomisd -0x40(%rbp), %xmm0
jbe 0x31d57
movb $0x0, (%rbx)
jmp 0x3221c
movsd -0x30(%rbp), %xmm0
movsd -0xb0(%rbp), %xmm1
mulsd %xmm1, %xmm0
movsd %xmm0, -0x30(%rbp)
movsd -0x60(%rbp), %xmm0
mulsd %xmm1, %xmm0
movsd %xmm0, -0x60(%rbp)
movsd -0x80(%rbp), %xmm0
movsd -0x90(%rbp), %xmm1
subsd %xmm1, %xmm0
movsd %xmm0, -0x80(%rbp)
movapd -0xa0(%rbp), %xmm0
movsd -0xb8(%rbp), %xmm2
subsd %xmm2, %xmm0
movapd %xmm0, -0xa0(%rbp)
movslq 0x2b4580(%r14), %r15
mulsd %xmm2, %xmm2
mulsd %xmm1, %xmm1
addsd %xmm2, %xmm1
xorps %xmm0, %xmm0
sqrtsd %xmm1, %xmm0
movsd %xmm0, -0x90(%rbp)
callq 0x49360
movsd 0x3140(%rax), %xmm0
movaps %xmm0, -0x40(%rbp)
callq 0x43dce
movq 0x5c38(%rax), %rax
imulq $0x3700, %r15, %rcx     # imm = 0x3700
movsd -0x90(%rbp), %xmm0
mulsd 0x3028(%rax,%rcx), %xmm0
addsd 0x3724c(%rip), %xmm0    # 0x69058
movapd -0x40(%rbp), %xmm1
divsd %xmm0, %xmm1
movapd %xmm1, -0x40(%rbp)
movapd 0x371ee(%rip), %xmm2    # 0x69010
movapd -0x70(%rbp), %xmm0
andpd %xmm2, %xmm0
movsd 0x3720d(%rip), %xmm3    # 0x69040
ucomisd %xmm0, %xmm3
movapd -0x50(%rbp), %xmm0
jbe 0x31e69
movapd %xmm0, %xmm1
andpd %xmm2, %xmm1
ucomisd %xmm1, %xmm3
jbe 0x31e69
xorpd %xmm0, %xmm0
movapd -0x40(%rbp), %xmm1
ucomisd %xmm0, %xmm1
ja 0x31ed6
xorpd 0x371bd(%rip), %xmm1    # 0x69020
movapd %xmm1, %xmm0
jmp 0x31ed6
movaps -0x70(%rbp), %xmm1
callq 0x90d0
mulsd 0x371ce(%rip), %xmm0    # 0x69048
divsd 0x371ce(%rip), %xmm0    # 0x69050
andpd 0x37186(%rip), %xmm0    # 0x69010
movapd %xmm0, -0x90(%rbp)
movapd -0x50(%rbp), %xmm0
movapd -0x70(%rbp), %xmm1
callq 0x90d0
movapd -0x40(%rbp), %xmm2
ucomisd -0x90(%rbp), %xmm2
mulsd 0x37192(%rip), %xmm0    # 0x69048
divsd 0x37192(%rip), %xmm0    # 0x69050
ja 0x31ed6
xorpd %xmm1, %xmm1
ucomisd %xmm1, %xmm0
ja 0x31ed2
xorpd 0x3714e(%rip), %xmm2    # 0x69020
movapd %xmm2, %xmm0
mulsd 0x371c2(%rip), %xmm0    # 0x690a0
divsd 0x37162(%rip), %xmm0    # 0x69048
movsd %xmm0, -0x40(%rbp)
leaq -0xd8(%rbp), %r15
leaq -0x78(%rbp), %r12
movq %r15, %rdi
movq %r12, %rsi
callq 0x92d0
movsd (%r15), %xmm0
movsd (%r12), %xmm1
movapd -0x70(%rbp), %xmm2
movapd %xmm2, %xmm3
mulsd %xmm0, %xmm2
movapd -0x50(%rbp), %xmm4
mulsd %xmm4, %xmm0
mulsd %xmm1, %xmm3
subsd %xmm0, %xmm3
movapd %xmm3, -0x70(%rbp)
mulsd %xmm1, %xmm4
addsd %xmm2, %xmm4
movapd %xmm4, -0x50(%rbp)
movsd -0x40(%rbp), %xmm0
movq %r15, %rdi
movq %r12, %rsi
callq 0x92d0
movsd (%r15), %xmm0
movsd (%r12), %xmm1
movapd %xmm0, %xmm2
movsd -0x60(%rbp), %xmm4
mulsd %xmm4, %xmm2
movsd -0x30(%rbp), %xmm3
mulsd %xmm3, %xmm0
mulsd %xmm1, %xmm3
subsd %xmm2, %xmm3
mulsd %xmm1, %xmm4
addsd %xmm0, %xmm4
movsd %xmm3, -0xe8(%rbp)
movsd %xmm4, -0xe0(%rbp)
movsd -0x40(%rbp), %xmm0
movq %r15, %rdi
movq %r12, %rsi
callq 0x92d0
movsd (%r15), %xmm0
movsd (%r12), %xmm1
movsd -0x80(%rbp), %xmm2
movapd %xmm2, %xmm3
mulsd %xmm0, %xmm2
movapd -0xa0(%rbp), %xmm4
mulsd %xmm4, %xmm0
mulsd %xmm1, %xmm3
subsd %xmm0, %xmm3
movapd %xmm3, -0x30(%rbp)
mulsd %xmm1, %xmm4
addsd %xmm2, %xmm4
movapd %xmm4, -0xa0(%rbp)
movsd 0x2b45b0(%r14), %xmm0
movsd 0x2b45b8(%r14), %xmm1
addsd 0x2b45c0(%r14), %xmm0
addsd 0x2b45c8(%r14), %xmm1
movsd -0xc8(%rbp), %xmm2
addsd %xmm0, %xmm2
movsd -0xc0(%rbp), %xmm0
addsd %xmm1, %xmm0
subsd 0x2b4598(%r14), %xmm2
subsd 0x2b45a0(%r14), %xmm0
movsd %xmm2, (%r15)
movsd %xmm0, 0x8(%r15)
leaq -0xd8(%rbp), %rsi
movq %r14, %rdi
callq 0x32858
movapd -0x30(%rbp), %xmm1
movapd -0xa0(%rbp), %xmm3
movapd -0x50(%rbp), %xmm2
subsd -0x70(%rbp), %xmm1
subsd %xmm2, %xmm3
movapd %xmm1, %xmm0
movapd 0x36fa3(%rip), %xmm4    # 0x69010
andpd %xmm4, %xmm0
movsd 0x36fc7(%rip), %xmm5    # 0x69040
ucomisd %xmm0, %xmm5
jbe 0x32091
movapd %xmm3, %xmm6
andpd %xmm4, %xmm6
xorpd %xmm0, %xmm0
ucomisd %xmm6, %xmm5
ja 0x320bf
movapd %xmm3, %xmm0
callq 0x90d0
movsd 0x36f9e(%rip), %xmm5    # 0x69040
movapd 0x36f66(%rip), %xmm4    # 0x69010
movapd -0x50(%rbp), %xmm2
mulsd 0x36f91(%rip), %xmm0    # 0x69048
divsd 0x36f91(%rip), %xmm0    # 0x69050
movsd %xmm0, -0x78(%rbp)
movslq 0x2b4580(%r14), %r15
movapd -0x70(%rbp), %xmm1
movapd %xmm1, %xmm0
andpd %xmm4, %xmm0
ucomisd %xmm0, %xmm5
jbe 0x320ec
andpd %xmm2, %xmm4
xorpd %xmm0, %xmm0
ucomisd %xmm4, %xmm5
ja 0x3210f
movapd %xmm2, %xmm0
callq 0x90d0
movapd -0x70(%rbp), %xmm1
movapd -0x50(%rbp), %xmm2
mulsd 0x36f41(%rip), %xmm0    # 0x69048
divsd 0x36f41(%rip), %xmm0    # 0x69050
andpd 0x36ef9(%rip), %xmm0    # 0x69010
movapd %xmm0, -0x60(%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 0x36f25(%rip), %xmm0    # 0x690a8
movapd -0x60(%rbp), %xmm1
mulsd %xmm0, %xmm1
divsd 0x36ecc(%rip), %xmm1    # 0x69060
movsd 0x3068(%rax,%r15), %xmm2
movsd %xmm2, -0x50(%rbp)
addsd 0x36ead(%rip), %xmm1    # 0x69058
movapd %xmm1, -0x60(%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 -0x60(%rbp), %xmm1
subsd %xmm0, %xmm1
mulsd -0x50(%rbp), %xmm1
movapd %xmm1, -0x60(%rbp)
callq 0x49360
movapd -0x60(%rbp), %xmm0
mulsd 0x3130(%rax), %xmm0
leaq -0xf0(%rbp), %rcx
movsd %xmm0, (%rcx)
leaq -0xe8(%rbp), %rsi
leaq -0x78(%rbp), %rdx
movq %r14, %rdi
callq 0x326fe
movq %rbx, %rax
addq $0xd0, %rsp
popq %rbx
popq %r12
popq %r14
popq %r15
popq %rbp
retq
nop