// File: /workspace/github_cpp_makefile_star2_O1/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 $0xe0, %rsp
movq %rdx, %r15
movq %rsi, %r14
movq %rdi, %rbx
movq %rsi, %rdi
movq %rdx, %rsi
callq 0x2de9c
movq %rbx, %rdi
movq %r14, %rsi
movq %r15, %rdx
movl $0x1, %ecx
callq 0x30bc8
cmpb $0x0, (%rbx)
je 0x32fe2
movsd 0x8(%rbx), %xmm0
movsd 0x10(%rbx), %xmm1
movsd 0x2b45c0(%r14), %xmm2
movsd %xmm0, -0xc8(%rbp)
addsd %xmm0, %xmm2
movsd 0x2b45c8(%r14), %xmm0
movsd %xmm1, -0xc0(%rbp)
addsd %xmm1, %xmm0
movsd %xmm2, -0x40(%rbp)
movsd %xmm0, -0x38(%rbp)
addsd 0x2b45b0(%r14), %xmm2
addsd 0x2b45b8(%r14), %xmm0
subsd 0x2b4598(%r14), %xmm2
movsd %xmm2, -0x30(%rbp)
subsd 0x2b45a0(%r14), %xmm0
movsd %xmm0, -0x50(%rbp)
callq 0x4a75c
movsd 0x30e0(%rax), %xmm0
movsd -0x40(%rbp), %xmm1
mulsd %xmm0, %xmm1
mulsd -0x38(%rbp), %xmm0
movsd %xmm1, -0x40(%rbp)
movsd %xmm0, -0x38(%rbp)
movsd 0x2b45d8(%r14), %xmm1
movsd 0x2b45e0(%r14), %xmm0
subsd 0x2b4598(%r14), %xmm1
movsd %xmm1, -0x98(%rbp)
subsd 0x2b45a0(%r14), %xmm0
movapd %xmm0, -0x90(%rbp)
callq 0x450ba
movq 0x5c38(%rax), %rax
movslq 0x2b4580(%r14), %rcx
imulq $0x3700, %rcx, %rcx     # imm = 0x3700
movsd 0x3020(%rax,%rcx), %xmm0
movsd 0x2b4598(%r14), %xmm1
mulsd %xmm0, %xmm1
mulsd 0x2b45a0(%r14), %xmm0
movsd -0x40(%rbp), %xmm2
movsd -0x38(%rbp), %xmm3
movsd %xmm1, -0xb8(%rbp)
subsd %xmm1, %xmm2
movsd %xmm0, -0xb0(%rbp)
subsd %xmm0, %xmm3
addsd -0x30(%rbp), %xmm2
movapd %xmm2, -0x60(%rbp)
addsd -0x50(%rbp), %xmm3
movapd %xmm3, -0x30(%rbp)
callq 0x4a75c
movsd 0x30e0(%rax), %xmm0
movsd -0x40(%rbp), %xmm1
mulsd %xmm0, %xmm1
movsd %xmm1, -0x40(%rbp)
mulsd -0x38(%rbp), %xmm0
movsd %xmm0, -0x38(%rbp)
movapd -0x30(%rbp), %xmm1
mulsd %xmm1, %xmm1
movapd -0x60(%rbp), %xmm0
mulsd %xmm0, %xmm0
addsd %xmm1, %xmm0
xorpd %xmm1, %xmm1
ucomisd %xmm1, %xmm0
movapd %xmm0, -0x80(%rbp)
jb 0x32a04
sqrtsd %xmm0, %xmm0
jmp 0x32a09
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 0x39517(%rip), %xmm0    # 0x6bf50
movsd -0x50(%rbp), %xmm1
ucomisd %xmm0, %xmm1
ja 0x32aac
xorpd %xmm1, %xmm1
movapd -0x80(%rbp), %xmm0
ucomisd %xmm1, %xmm0
jb 0x32a59
sqrtsd %xmm0, %xmm0
jmp 0x32a5e
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, -0x80(%rbp)
callq 0x4a75c
movsd -0x80(%rbp), %xmm0
addsd 0x30d8(%rax), %xmm0
addsd 0x38c9b(%rip), %xmm0    # 0x6b740
ucomisd -0x50(%rbp), %xmm0
jbe 0x32ab4
movb $0x0, (%rbx)
jmp 0x32fe2
movslq 0x2b4580(%r14), %r15
movsd -0xb0(%rbp), %xmm1
mulsd %xmm1, %xmm1
movsd -0xb8(%rbp), %xmm0
mulsd %xmm0, %xmm0
addsd %xmm1, %xmm0
xorpd %xmm1, %xmm1
ucomisd %xmm1, %xmm0
jb 0x32ae7
sqrtsd %xmm0, %xmm0
jmp 0x32aec
callq 0x93c0
movsd %xmm0, -0x80(%rbp)
callq 0x4a75c
movsd 0x3140(%rax), %xmm0
movaps %xmm0, -0x50(%rbp)
callq 0x450ba
movq 0x5c38(%rax), %rax
imulq $0x3700, %r15, %rcx     # imm = 0x3700
movsd -0x80(%rbp), %xmm0
mulsd 0x3028(%rax,%rcx), %xmm0
addsd 0x3852d(%rip), %xmm0    # 0x6b058
movapd -0x50(%rbp), %xmm1
divsd %xmm0, %xmm1
movapd %xmm1, -0x50(%rbp)
movapd 0x384cf(%rip), %xmm2    # 0x6b010
movapd -0x60(%rbp), %xmm4
andpd %xmm2, %xmm4
movsd 0x384ee(%rip), %xmm0    # 0x6b040
ucomisd %xmm4, %xmm0
movapd -0x30(%rbp), %xmm5
andpd %xmm2, %xmm5
xorpd %xmm3, %xmm3
jbe 0x32b6b
ucomisd %xmm5, %xmm0
ja 0x32bb0
movapd -0x30(%rbp), %xmm0
movapd -0x60(%rbp), %xmm1
movapd %xmm4, -0x80(%rbp)
movapd %xmm5, -0xf0(%rbp)
callq 0x90d0
movapd -0xf0(%rbp), %xmm5
movapd -0x80(%rbp), %xmm4
movapd 0x38474(%rip), %xmm2    # 0x6b010
movapd %xmm0, %xmm3
mulsd 0x384a0(%rip), %xmm3    # 0x6b048
divsd 0x384a0(%rip), %xmm3    # 0x6b050
movsd -0x98(%rbp), %xmm0
subsd -0xb8(%rbp), %xmm0
movsd %xmm0, -0x98(%rbp)
movapd -0x90(%rbp), %xmm1
subsd -0xb0(%rbp), %xmm1
andpd %xmm2, %xmm3
movapd -0x50(%rbp), %xmm2
ucomisd %xmm3, %xmm2
movsd 0x38453(%rip), %xmm0    # 0x6b040
cmpltpd %xmm0, %xmm4
cmpltpd %xmm0, %xmm5
andpd %xmm4, %xmm5
movd %xmm5, %eax
movapd %xmm1, -0x90(%rbp)
jbe 0x32c36
xorpd %xmm2, %xmm2
testb $0x1, %al
jne 0x32c79
movapd -0x30(%rbp), %xmm0
movapd -0x60(%rbp), %xmm1
callq 0x90d0
movapd %xmm0, %xmm2
mulsd 0x3841c(%rip), %xmm2    # 0x6b048
divsd 0x3841c(%rip), %xmm2    # 0x6b050
jmp 0x32c79
testb $0x1, %al
je 0x32c3e
xorl %eax, %eax
jmp 0x32c6d
movapd -0x30(%rbp), %xmm0
movapd -0x60(%rbp), %xmm1
callq 0x90d0
movapd -0x50(%rbp), %xmm2
mulsd 0x383ee(%rip), %xmm0    # 0x6b048
divsd 0x383ee(%rip), %xmm0    # 0x6b050
xorpd %xmm1, %xmm1
ucomisd %xmm1, %xmm0
seta %al
testb %al, %al
jne 0x32c79
xorpd 0x383a7(%rip), %xmm2    # 0x6b020
mulsd 0x3841f(%rip), %xmm2    # 0x6b0a0
divsd 0x383bf(%rip), %xmm2    # 0x6b048
movapd %xmm2, -0x50(%rbp)
leaq -0xd8(%rbp), %r15
leaq -0x68(%rbp), %r12
movapd %xmm2, %xmm0
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, -0xb0(%rbp)
mulsd %xmm1, %xmm4
addsd %xmm2, %xmm4
movapd %xmm4, -0x30(%rbp)
movaps -0x50(%rbp), %xmm0
movq %r15, %rdi
movq %r12, %rsi
callq 0x92d0
movsd (%r15), %xmm0
movsd (%r12), %xmm1
movsd -0x40(%rbp), %xmm2
movsd -0x38(%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, -0x40(%rbp)
movsd %xmm3, -0x38(%rbp)
movaps -0x50(%rbp), %xmm0
movq %r15, %rdi
movq %r12, %rsi
callq 0x92d0
movsd (%r15), %xmm0
movsd (%r12), %xmm1
movsd -0x98(%rbp), %xmm2
movapd %xmm2, %xmm3
mulsd %xmm0, %xmm2
movapd -0x90(%rbp), %xmm4
mulsd %xmm4, %xmm0
mulsd %xmm1, %xmm3
subsd %xmm0, %xmm3
movapd %xmm3, -0x60(%rbp)
mulsd %xmm1, %xmm4
addsd %xmm2, %xmm4
movapd %xmm4, -0x90(%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 0x33702
movapd -0x60(%rbp), %xmm1
movapd -0x90(%rbp), %xmm2
subsd -0xb0(%rbp), %xmm1
subsd -0x30(%rbp), %xmm2
movapd %xmm1, %xmm0
movapd 0x381ff(%rip), %xmm3    # 0x6b010
andpd %xmm3, %xmm0
movsd 0x38223(%rip), %xmm4    # 0x6b040
ucomisd %xmm0, %xmm4
jbe 0x32e35
movapd %xmm2, %xmm5
andpd %xmm3, %xmm5
xorpd %xmm0, %xmm0
ucomisd %xmm5, %xmm4
ja 0x32e5e
movapd %xmm2, %xmm0
callq 0x90d0
movsd 0x381fa(%rip), %xmm4    # 0x6b040
movapd 0x381c2(%rip), %xmm3    # 0x6b010
mulsd 0x381f2(%rip), %xmm0    # 0x6b048
divsd 0x381f2(%rip), %xmm0    # 0x6b050
movsd %xmm0, -0x68(%rbp)
movslq 0x2b4580(%r14), %r15
movapd -0xb0(%rbp), %xmm1
movapd %xmm1, %xmm0
andpd %xmm3, %xmm0
ucomisd %xmm0, %xmm4
movapd -0x30(%rbp), %xmm2
jbe 0x32e93
andpd %xmm2, %xmm3
xorpd %xmm0, %xmm0
ucomisd %xmm3, %xmm4
ja 0x32eba
movapd -0x30(%rbp), %xmm0
callq 0x90d0
movapd -0xb0(%rbp), %xmm1
movapd -0x30(%rbp), %xmm2
mulsd 0x38196(%rip), %xmm0    # 0x6b048
divsd 0x38196(%rip), %xmm0    # 0x6b050
andpd 0x3814e(%rip), %xmm0    # 0x6b010
movapd %xmm0, -0x60(%rbp)
mulsd %xmm2, %xmm2
mulsd %xmm1, %xmm1
addsd %xmm2, %xmm1
xorpd %xmm0, %xmm0
ucomisd %xmm0, %xmm1
jb 0x32ee6
xorps %xmm0, %xmm0
sqrtsd %xmm1, %xmm0
jmp 0x32eef
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 0x38162(%rip), %xmm0    # 0x6b0a8
movapd -0x60(%rbp), %xmm1
mulsd %xmm0, %xmm1
divsd 0x38109(%rip), %xmm1    # 0x6b060
movsd 0x3068(%rax,%r15), %xmm2
movsd %xmm2, -0x90(%rbp)
addsd 0x380e7(%rip), %xmm1    # 0x6b058
movapd %xmm1, -0x60(%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 -0x60(%rbp), %xmm1
subsd %xmm0, %xmm1
mulsd -0x90(%rbp), %xmm1
movapd %xmm1, -0x60(%rbp)
callq 0x4a75c
movapd -0x60(%rbp), %xmm0
mulsd 0x3130(%rax), %xmm0
leaq -0xf8(%rbp), %rcx
movsd %xmm0, (%rcx)
leaq -0x40(%rbp), %rsi
leaq -0x68(%rbp), %rdx
movq %r14, %rdi
callq 0x3349a
movq %rbx, %rax
addq $0xe0, %rsp
popq %rbx
popq %r12
popq %r14
popq %r15
popq %rbp
retq
nop