// File: wrighteagle2d[P]wrighteaglebase/Debug/../src/Kicker.cpp
// Function: Kicker::KickBall(Agent&, Vector const&, double, int, bool)
bool Kicker::KickBall(Agent &agent, const Vector &target, double speed_out,
                      int cycle, bool is_shoot) {
  UpdateKickData(agent);

  mKickSpeed = speed_out;
  mKickTarget = (target - mInput.mPlayerPos).Rotate(-mInput.mPlayerBodyDir);

  ActionPlan p;
  switch (cycle) {
  case 1:
    p = OneCycleKick(agent, is_shoot);
    break;
  case 2:
  case 3:
  case 4:
    p = MultiCycleKick(agent, cycle);
    break;
  default:
    p.mSucceed = false;
    break;
  }

  if (p.mSucceed == false) // 后备处理
  {
    p.mActionQueue.clear();
    AtomicAction a;
    a.mSucceed = false;
    if ((mInput.mBallPos + mInput.mBallVel)
            .Dist(mInput.mPlayerPos + mInput.mPlayerVel) <
        PlayerParam::instance()
                .HeteroPlayer(mInput.mPlayerType)
                .kickableArea() -
            0.05) {
      // a.mTurnAngle = mKickTarget.Dir();
      a.mTurnAngle = GetNormalizeAngleDeg(mKickTarget.Dir());
      if (fabs(a.mTurnAngle) > 10) {
        a.mType = CT_Turn;
        a.mSucceed = true;
      } else // try kick to body
      {
        mKickTarget = Vector(0, 0);
        mKickSpeed = mInput.mBallPos.Mod();
        a = GetKickOutAction(agent, mInput.mBallPos, mInput.mBallVel);
      }
    }
    if (a.mSucceed == false) // 实在不行先停球
    {
      a = GetStopBallAction(agent);
    }
    p.mSucceed = a.mSucceed;
    p.mActionQueue.push_back(a);
  }

  if (p.mActionQueue.size() > 0) {
    Execute(agent, p); // 执行动作
  }
  return p.mSucceed;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x2b0, %rsp            # imm = 0x2B0
movb %r8b, %al
movq %rdi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
movq %rdx, -0x18(%rbp)
movsd %xmm0, -0x20(%rbp)
movl %ecx, -0x24(%rbp)
andb $0x1, %al
movb %al, -0x25(%rbp)
movq -0x8(%rbp), %rdi
movq %rdi, -0x250(%rbp)
movq -0x10(%rbp), %rsi
callq 0x50020
movq -0x250(%rbp), %rsi
movsd -0x20(%rbp), %xmm0
movsd %xmm0, 0x2b45d0(%rsi)
movq -0x18(%rbp), %rdi
addq $0x2b4588, %rsi         # imm = 0x2B4588
callq 0x110a0
movq -0x250(%rbp), %rax
movsd %xmm0, -0x48(%rbp)
movsd %xmm1, -0x40(%rbp)
movsd 0x2b45a8(%rax), %xmm0
movaps 0x6f651(%rip), %xmm1    # 0xc1730
pxor %xmm1, %xmm0
movlpd %xmm0, -0x50(%rbp)
leaq -0x48(%rbp), %rdi
leaq -0x50(%rbp), %rsi
callq 0x11110
movq -0x250(%rbp), %rax
movsd %xmm0, -0x38(%rbp)
movsd %xmm1, -0x30(%rbp)
movups -0x38(%rbp), %xmm0
movups %xmm0, 0x2b45d8(%rax)
leaq -0xa8(%rbp), %rdi
callq 0x56b60
movl -0x24(%rbp), %eax
movl %eax, -0x244(%rbp)
subl $0x1, %eax
je 0x52140
jmp 0x5212d
movl -0x244(%rbp), %eax
addl $-0x2, %eax
subl $0x3, %eax
jb 0x521a4
jmp 0x521e1
movq -0x250(%rbp), %rsi
movq -0x10(%rbp), %rdx
movzbl -0x25(%rbp), %ecx
andl $0x1, %ecx
leaq -0x100(%rbp), %rdi
callq 0x52570
jmp 0x52160
leaq -0xa8(%rbp), %rdi
leaq -0x100(%rbp), %rsi
callq 0x56b90
leaq -0x100(%rbp), %rdi
callq 0x56bd0
jmp 0x521e8
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x108(%rbp)
movl %eax, -0x10c(%rbp)
leaq -0xa8(%rbp), %rdi
callq 0x56bd0
jmp 0x5255b
movq -0x250(%rbp), %rsi
movq -0x10(%rbp), %rdx
movl -0x24(%rbp), %ecx
leaq -0x168(%rbp), %rdi
callq 0x52750
jmp 0x521c0
leaq -0xa8(%rbp), %rdi
leaq -0x168(%rbp), %rsi
callq 0x56b90
leaq -0x168(%rbp), %rdi
callq 0x56bd0
jmp 0x521e8
movb $0x0, -0xa8(%rbp)
movb -0xa8(%rbp), %al
andb $0x1, %al
movzbl %al, %eax
cmpl $0x0, %eax
jne 0x52501
leaq -0xa0(%rbp), %rdi
callq 0x56bf0
leaq -0x198(%rbp), %rdi
xorl %esi, %esi
callq 0x1d620
jmp 0x52218
movq -0x250(%rbp), %rsi
movb $0x0, -0x198(%rbp)
movq %rsi, %rdi
addq $0x2b45b0, %rdi         # imm = 0x2B45B0
addq $0x2b45c0, %rsi         # imm = 0x2B45C0
callq 0x11360
movsd %xmm1, -0x260(%rbp)
movsd %xmm0, -0x258(%rbp)
jmp 0x5224e
movq -0x250(%rbp), %rsi
movsd -0x260(%rbp), %xmm0
movsd -0x258(%rbp), %xmm1
movsd %xmm1, -0x1a8(%rbp)
movsd %xmm0, -0x1a0(%rbp)
movq %rsi, %rdi
addq $0x2b4588, %rdi         # imm = 0x2B4588
addq $0x2b4598, %rsi         # imm = 0x2B4598
callq 0x11360
movsd %xmm1, -0x270(%rbp)
movsd %xmm0, -0x268(%rbp)
jmp 0x5229d
movsd -0x270(%rbp), %xmm0
movsd -0x268(%rbp), %xmm1
movsd %xmm1, -0x1b8(%rbp)
movsd %xmm0, -0x1b0(%rbp)
leaq -0x1a8(%rbp), %rdi
leaq -0x1b8(%rbp), %rsi
callq 0x1d6d0
movsd %xmm0, -0x278(%rbp)
jmp 0x522da
callq 0x798a0
movq %rax, -0x280(%rbp)
jmp 0x522e8
movq -0x280(%rbp), %rdi
movq -0x250(%rbp), %rsi
addq $0x2b4580, %rsi         # imm = 0x2B4580
callq 0x129d0
movq %rax, -0x288(%rbp)
jmp 0x5230b
movq -0x288(%rbp), %rdi
callq 0x1deb0
movq %rax, -0x290(%rbp)
jmp 0x52320
movsd -0x278(%rbp), %xmm1
movq -0x290(%rbp), %rax
movsd (%rax), %xmm0
movsd 0x6fb9d(%rip), %xmm2    # 0xc1ed8
subsd %xmm2, %xmm0
ucomisd %xmm1, %xmm0
jbe 0x52496
movq -0x250(%rbp), %rdi
addq $0x2b45d8, %rdi         # imm = 0x2B45D8
callq 0x10520
movsd %xmm0, -0x298(%rbp)
jmp 0x52366
movsd -0x298(%rbp), %xmm0
movabsq $-0x3f99800000000000, %rax # imm = 0xC066800000000000
movq %rax, -0x1c0(%rbp)
leaq -0x1c0(%rbp), %rdi
callq 0x116b0
movsd %xmm0, -0x2a0(%rbp)
jmp 0x52395
movsd -0x2a0(%rbp), %xmm0
movsd %xmm0, -0x180(%rbp)
movsd -0x180(%rbp), %xmm0
movaps 0x6ecac(%rip), %xmm1    # 0xc1060
pand %xmm1, %xmm0
movsd 0x6f338(%rip), %xmm1    # 0xc16f8
ucomisd %xmm1, %xmm0
jbe 0x523dc
movl $0x1, -0x194(%rbp)
movb $0x1, -0x198(%rbp)
jmp 0x52494
movq $0x0, -0x1d8(%rbp)
movq $0x0, -0x1e0(%rbp)
leaq -0x1d0(%rbp), %rdi
leaq -0x1d8(%rbp), %rsi
leaq -0x1e0(%rbp), %rdx
callq 0x11a10
jmp 0x5240e
movq -0x250(%rbp), %rdi
movups -0x1d0(%rbp), %xmm0
movups %xmm0, 0x2b45d8(%rdi)
addq $0x2b45b0, %rdi         # imm = 0x2B45B0
callq 0x104e0
movsd %xmm0, -0x2a8(%rbp)
jmp 0x52439
movq -0x250(%rbp), %rsi
movsd -0x2a8(%rbp), %xmm0
movsd %xmm0, 0x2b45d0(%rsi)
movq -0x10(%rbp), %rdx
movq %rsi, %rcx
addq $0x2b45b0, %rcx         # imm = 0x2B45B0
movq %rsi, %r8
addq $0x2b45c0, %r8          # imm = 0x2B45C0
leaq -0x210(%rbp), %rdi
movl $0x1, %r9d
callq 0x53bd0
jmp 0x5247c
leaq -0x198(%rbp), %rdi
leaq -0x210(%rbp), %rsi
movl $0x30, %edx
callq 0xa4b0
jmp 0x52496
movb -0x198(%rbp), %al
andb $0x1, %al
movzbl %al, %eax
cmpl $0x0, %eax
jne 0x524dc
movq -0x250(%rbp), %rsi
movq -0x10(%rbp), %rdx
leaq -0x240(%rbp), %rdi
movl $0x1, %ecx
callq 0x53d50
jmp 0x524c4
leaq -0x198(%rbp), %rdi
leaq -0x240(%rbp), %rsi
movl $0x30, %edx
callq 0xa4b0
movb -0x198(%rbp), %al
andb $0x1, %al
movb %al, -0xa8(%rbp)
leaq -0xa0(%rbp), %rdi
leaq -0x198(%rbp), %rsi
callq 0x56c30
jmp 0x524ff
jmp 0x52501
leaq -0xa8(%rbp), %rdi
addq $0x8, %rdi
callq 0x56c90
cmpq $0x0, %rax
jbe 0x52532
movq -0x250(%rbp), %rdi
movq -0x10(%rbp), %rsi
leaq -0xa8(%rbp), %rdx
callq 0x540e0
jmp 0x52530
jmp 0x52532
movb -0xa8(%rbp), %al
movb %al, -0x2a9(%rbp)
leaq -0xa8(%rbp), %rdi
callq 0x56bd0
movb -0x2a9(%rbp), %al
andb $0x1, %al
addq $0x2b0, %rsp            # imm = 0x2B0
popq %rbp
retq
movq -0x108(%rbp), %rdi
callq 0xaa60
nopw (%rax,%rax)