// File: /workspace/github_cpp_makefile_star2_O2/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 $0x20, %rsp
movl %ecx, %r15d
movq %rdx, %r12
movq %rsi, %r14
movq %rdi, %rbx
movq %rsi, %rdi
movq %rdx, %rsi
callq 0x2703e
callq 0x3db2c
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
pushq $-0x1
popq %rdx
pushq $0x28
popq %rsi
xorl %edi, %edi
movsd 0x2dfc6(%rip), %xmm5    # 0x57040
cmpq $0x51, %rdi
je 0x290d2
movsd 0x2b4d80(%r14,%rdi,8), %xmm6
ucomisd %xmm5, %xmm6
jbe 0x290c9
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 0x290c9
movapd %xmm6, %xmm2
movl %edi, %edx
incq %rdi
addq $0x8, %rsi
jmp 0x2907a
movb $0x0, (%rbx)
xorpd %xmm2, %xmm2
movupd %xmm2, 0x4(%rbx)
movupd %xmm2, 0x14(%rbx)
movupd %xmm2, 0x20(%rbx)
testl %edx, %edx
js 0x29130
movl %edx, %edx
shlq $0x4, %rdx
addsd (%rax,%rdx), %xmm0
addsd 0x8(%rax,%rdx), %xmm1
leaq 0x2b45c0(%r14), %r8
leaq -0x38(%rbp), %r9
movsd %xmm0, (%r9)
movsd %xmm1, 0x8(%r9)
movl $0x1, (%rsp)
movq %rbx, %rdi
movq %r14, %rsi
movq %r12, %rdx
callq 0x2972c
cmpb $0x0, (%rbx)
sete %al
jmp 0x29132
movb $0x1, %al
andb %r15b, %al
cmpb $0x1, %al
jne 0x291d1
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 0x2decf(%rip), %xmm0    # 0x57040
jbe 0x291c5
addq $0x2b45c0, %r14         # imm = 0x2B45C0
movabsq $0x4066800000000000, %rax # imm = 0x4066800000000000
leaq -0x28(%rbp), %rsi
movq %rax, (%rsi)
movq %r14, %rdi
callq 0xd02c
leaq -0x38(%rbp), %r14
movsd %xmm0, (%r14)
movsd %xmm1, 0x8(%r14)
callq 0x3db2c
leaq 0x3130(%rax), %rsi
movq %r14, %rdi
callq 0x219b2
movsd %xmm0, 0x8(%rbx)
movsd %xmm1, 0x10(%rbx)
movb $0x1, (%rbx)
jmp 0x291d1
movb $0x0, (%rbx)
xorpd %xmm0, %xmm0
movupd %xmm0, 0x8(%rbx)
movq %rbx, %rax
addq $0x20, %rsp
popq %rbx
popq %r12
popq %r14
popq %r15
popq %rbp
retq
nop