// File: /workspace/github_cpp_makefile_star2_O1/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 %r13
pushq %r12
pushq %rbx
subq $0x38, %rsp
movl %ecx, -0x38(%rbp)
movq %rsi, %r14
movq %rdi, %rbx
movq %rsi, %rdi
movq %rdx, -0x30(%rbp)
movq %rdx, %rsi
callq 0x2de9c
callq 0x4a75c
movsd 0x30f8(%rax), %xmm2
movl $0xffffffff, %r13d      # imm = 0xFFFFFFFF
movl $0x28, %r12d
xorl %r15d, %r15d
movsd 0x3a42b(%rip), %xmm3    # 0x6b040
xorpd %xmm4, %xmm4
movsd 0x2b4d80(%r14,%r15,8), %xmm0
ucomisd %xmm3, %xmm0
jbe 0x30c9a
movsd 0x2b4598(%r14), %xmm0
movsd 0x2b45a0(%r14), %xmm1
addsd -0x8(%r14,%r12,2), %xmm0
addsd (%r14,%r12,2), %xmm1
subsd 0x2b45b0(%r14), %xmm0
subsd 0x2b45b8(%r14), %xmm1
mulsd %xmm1, %xmm1
mulsd %xmm0, %xmm0
addsd %xmm1, %xmm0
ucomisd %xmm4, %xmm0
jb 0x30c72
sqrtsd %xmm0, %xmm0
jmp 0x30c8d
movsd %xmm2, -0x40(%rbp)
callq 0x93c0
xorpd %xmm4, %xmm4
movsd 0x3a3b8(%rip), %xmm3    # 0x6b040
movsd -0x40(%rbp), %xmm2
ucomisd %xmm0, %xmm2
jbe 0x30c9a
movapd %xmm0, %xmm2
movl %r15d, %r13d
incq %r15
addq $0x8, %r12
cmpq $0x51, %r15
jne 0x30c19
movb $0x0, (%rbx)
xorpd %xmm0, %xmm0
movupd %xmm0, 0x4(%rbx)
movupd %xmm0, 0x14(%rbx)
movupd %xmm0, 0x20(%rbx)
testl %r13d, %r13d
js 0x30d20
leaq 0x2b45b0(%r14), %rcx
movl %r13d, %eax
shlq $0x4, %rax
movsd 0x2b4598(%r14), %xmm0
movsd 0x2b45a0(%r14), %xmm1
addsd 0x48(%r14,%rax), %xmm0
addsd 0x50(%r14,%rax), %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 -0x30(%rbp), %rdx
callq 0x315de
movl -0x38(%rbp), %eax
xorb $0x1, %al
orb (%rbx), %al
jne 0x30e54
leaq 0x4(%rbx), %rax
movl $0x6, (%rax)
movsd 0x2b45c0(%r14), %xmm0
movsd 0x2b45c8(%r14), %xmm1
mulsd %xmm1, %xmm1
mulsd %xmm0, %xmm0
addsd %xmm1, %xmm0
xorpd %xmm1, %xmm1
ucomisd %xmm1, %xmm0
jb 0x30d65
sqrtsd %xmm0, %xmm0
jmp 0x30d6a
callq 0x93c0
ucomisd 0x3a2ce(%rip), %xmm0    # 0x6b040
jbe 0x30dcf
addq $0x2b45c0, %r14         # imm = 0x2B45C0
movabsq $0x4066800000000000, %rax # imm = 0x4066800000000000
leaq -0x50(%rbp), %rsi
movq %rax, (%rsi)
movq %r14, %rdi
callq 0x33428
movsd %xmm0, -0x40(%rbp)
movsd %xmm1, -0x38(%rbp)
callq 0x4a75c
movq %rax, %r14
movsd -0x38(%rbp), %xmm0
mulsd %xmm0, %xmm0
movsd -0x40(%rbp), %xmm1
mulsd %xmm1, %xmm1
addsd %xmm0, %xmm1
xorpd %xmm2, %xmm2
ucomisd %xmm2, %xmm1
jb 0x30ddd
xorps %xmm0, %xmm0
sqrtsd %xmm1, %xmm0
jmp 0x30df4
movb $0x0, (%rbx)
xorpd %xmm0, %xmm0
movupd %xmm0, 0x8(%rbx)
jmp 0x30e54
movapd %xmm1, %xmm0
movsd %xmm1, -0x30(%rbp)
callq 0x93c0
xorpd %xmm2, %xmm2
movsd -0x30(%rbp), %xmm1
ucomisd %xmm2, %xmm0
xorpd %xmm0, %xmm0
jbe 0x30e47
movsd 0x3130(%r14), %xmm2
ucomisd %xmm0, %xmm1
jb 0x30e16
xorps %xmm0, %xmm0
sqrtsd %xmm1, %xmm0
jmp 0x30e29
movapd %xmm1, %xmm0
movsd %xmm2, -0x30(%rbp)
callq 0x93c0
movsd -0x30(%rbp), %xmm2
divsd %xmm0, %xmm2
movsd -0x40(%rbp), %xmm0
mulsd %xmm2, %xmm0
movsd -0x38(%rbp), %xmm1
mulsd %xmm2, %xmm1
movapd %xmm0, %xmm2
movapd %xmm1, %xmm0
movsd %xmm2, 0x8(%rbx)
movsd %xmm0, 0x10(%rbx)
movb $0x1, (%rbx)
movq %rbx, %rax
addq $0x38, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq