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

  int best = -1;
  double speed = 0.0;
  double min_speed = ServerParam::instance().ballSpeedMax();

  for (int i = 0; i < POINTS_NUM; i++) {
    if (mPointEva[i] > FLOAT_EPS) {
      speed = (mInput.mPlayerVel + mPoint[i] - mInput.mBallPos).Mod();
      if (speed < min_speed) /** 找出踢完后球速最小的点 */
      {
        best = i;
        min_speed = speed;
      }
    }
  }

  AtomicAction b;
  if (best >= 0) {
    b = GetOneKickAction(agent, mInput.mBallPos, mInput.mBallVel,
                         mInput.mPlayerVel + mPoint[best]);
  }

  if (b.mSucceed == false && forceStop) {
    b.mType = CT_Kick;
    if (mInput.mBallVel.Mod() > FLOAT_EPS) {
      b.mKickVel = mInput.mBallVel.Rotate(180.0).SetLength(
          ServerParam::instance().maxPower());
      b.mSucceed = true;
    } else {
      b.mKickVel = Vector(0.0, 0.0);
      b.mSucceed = false;
    }
  }
  return b;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %r12
pushq %rbx
subq $0x40, %rsp
movl %ecx, %r15d
movq %rdx, %r12
movq %rsi, %r14
movq %rdi, %rbx
movq %rsi, %rdi
movq %rdx, %rsi
callq 0x2d494
callq 0x49360
movsd 0x30f8(%rax), %xmm2
leaq 0x48(%r14), %rax
movsd 0x2b4598(%r14), %xmm0
movsd 0x2b45a0(%r14), %xmm1
leaq 0x2b45b0(%r14), %rcx
movsd 0x2b45b0(%r14), %xmm3
movsd 0x2b45b8(%r14), %xmm4
movl $0xffffffff, %edx       # imm = 0xFFFFFFFF
movl $0x28, %esi
xorl %edi, %edi
movsd 0x38eb4(%rip), %xmm5    # 0x69040
movsd 0x2b4d80(%r14,%rdi,8), %xmm6
ucomisd %xmm5, %xmm6
jbe 0x301d5
movsd -0x8(%r14,%rsi,2), %xmm6
addsd %xmm0, %xmm6
subsd %xmm3, %xmm6
movsd (%r14,%rsi,2), %xmm7
addsd %xmm1, %xmm7
subsd %xmm4, %xmm7
mulsd %xmm7, %xmm7
mulsd %xmm6, %xmm6
addsd %xmm7, %xmm6
sqrtsd %xmm6, %xmm6
ucomisd %xmm6, %xmm2
jbe 0x301d5
movapd %xmm6, %xmm2
movl %edi, %edx
incq %rdi
addq $0x8, %rsi
cmpq $0x51, %rdi
jne 0x3018c
movb $0x0, (%rbx)
xorpd %xmm2, %xmm2
movupd %xmm2, 0x4(%rbx)
movupd %xmm2, 0x14(%rbx)
movupd %xmm2, 0x20(%rbx)
testl %edx, %edx
js 0x30240
movl %edx, %edx
shlq $0x4, %rdx
addsd (%rax,%rdx), %xmm0
addsd 0x8(%rax,%rdx), %xmm1
leaq 0x2b45c0(%r14), %r8
leaq -0x50(%rbp), %r9
movsd %xmm0, (%r9)
movsd %xmm1, 0x8(%r9)
movl $0x1, (%rsp)
movq %rbx, %rdi
movq %r14, %rsi
movq %r12, %rdx
callq 0x30a2c
cmpb $0x0, (%rbx)
sete %al
jmp 0x30242
movb $0x1, %al
andb %r15b, %al
cmpb $0x1, %al
jne 0x3031c
leaq 0x4(%rbx), %rax
movl $0x6, (%rax)
movsd 0x2b45c0(%r14), %xmm0
movsd 0x2b45c8(%r14), %xmm1
mulsd %xmm1, %xmm1
mulsd %xmm0, %xmm0
addsd %xmm1, %xmm0
sqrtsd %xmm0, %xmm0
ucomisd 0x38dbf(%rip), %xmm0    # 0x69040
jbe 0x302f4
addq $0x2b45c0, %r14         # imm = 0x2B45C0
movabsq $0x4066800000000000, %rax # imm = 0x4066800000000000
leaq -0x50(%rbp), %rsi
movq %rax, (%rsi)
movq %r14, %rdi
callq 0x3268c
movsd %xmm0, -0x28(%rbp)
movapd %xmm1, -0x40(%rbp)
callq 0x49360
movapd -0x40(%rbp), %xmm4
movsd -0x28(%rbp), %xmm3
movapd %xmm4, %xmm0
mulsd %xmm4, %xmm0
movapd %xmm3, %xmm1
mulsd %xmm3, %xmm1
addsd %xmm0, %xmm1
sqrtsd %xmm1, %xmm1
xorpd %xmm0, %xmm0
ucomisd %xmm0, %xmm1
movsd 0x3130(%rax), %xmm2
divsd %xmm1, %xmm2
mulsd %xmm2, %xmm4
ja 0x30302
xorpd %xmm3, %xmm3
jmp 0x30306
movb $0x0, (%rbx)
xorpd %xmm0, %xmm0
movupd %xmm0, 0x8(%rbx)
jmp 0x3031c
mulsd %xmm2, %xmm3
cmpltsd %xmm1, %xmm0
andpd %xmm4, %xmm0
movsd %xmm3, 0x8(%rbx)
movlpd %xmm0, 0x10(%rbx)
movb $0x1, (%rbx)
movq %rbx, %rax
addq $0x40, %rsp
popq %rbx
popq %r12
popq %r14
popq %r15
popq %rbp
retq