// File: /workspace/github_cpp_makefile_star2_O2/wrighteagle2d[P]wrighteaglebase/Debug/../src/Kicker.cpp
// Function: Kicker::KickBallCloseToBody(Agent&, double, double)
bool Kicker::KickBallCloseToBody(Agent &agent, AngleDeg ang, double KickRatio) {
  BallState bs = agent.GetWorldState().GetBall();
  PlayerState ms = agent.GetSelf();
  AngleDeg angBody = ms.GetBodyDir();
  Vector posAgent = ms.GetPredictedPos(1);
  double dist = ms.GetKickableMargin() * KickRatio +
                ServerParam::instance().ballSize() + ms.GetPlayerSize();
  AngleDeg angGlobal = GetNormalizeAngleDeg(angBody + ang);
  Vector posDesBall = posAgent + Polar2Vector(dist, angGlobal);
  if (fabs(posDesBall.Y()) > ServerParam::PITCH_WIDTH / 2.0 ||
      fabs(posDesBall.X()) > ServerParam::PITCH_LENGTH / 2.0) {
    Ray lineBody(posAgent, angGlobal);
    Ray lineSide;
    if (fabs(posDesBall.Y()) > ServerParam::PITCH_WIDTH / 2.0) {
      lineSide = Ray(Vector(0, (posDesBall.Y() > 0 ? 1 : -1) *
                                   ServerParam::PITCH_WIDTH / 2.0),
                     0);
    }

    else {
      lineSide = Ray(Vector(0, (posDesBall.Y() > 0 ? 1 : -1) *
                                   ServerParam::PITCH_WIDTH / 2.0),
                     90);
    }
    Vector posIntersect;
    lineSide.Intersection(Line(lineBody), posIntersect);
    posDesBall =
        posAgent + Polar2Vector(posIntersect.Dist(posAgent) - 0.2, angGlobal);
  }

  Vector vecDesired = posDesBall - bs.GetPos();
  return Kicker::KickBall(agent, posDesBall, vecDesired.Mod(), 1, false);
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %rbx
subq $0x2a8, %rsp            # imm = 0x2A8
movsd %xmm1, -0x90(%rbp)
movsd %xmm0, -0x98(%rbp)
movq %rsi, %rbx
movq %rdi, %r14
movq 0x18(%rsi), %rsi
addq $0x30, %rsi
leaq -0x148(%rbp), %rdi
callq 0x15972
movq %rbx, %rdi
callq 0xcd42
leaq -0x2c0(%rbp), %rdi
movq %rax, %rsi
callq 0x12368
movsd -0x210(%rbp), %xmm0
movsd %xmm0, -0x88(%rbp)
movq -0x258(%rbp), %rdi
pushq $0x1
popq %rsi
callq 0xd82c
movsd (%rax), %xmm0
movsd %xmm0, -0x28(%rbp)
movsd 0x8(%rax), %xmm0
movsd %xmm0, -0x20(%rbp)
leaq -0x2c0(%rbp), %rdi
callq 0x2abc0
movsd (%rax), %xmm0
movsd %xmm0, -0x80(%rbp)
callq 0x3db2c
movsd 0x30d8(%rax), %xmm0
movsd %xmm0, -0x78(%rbp)
leaq -0x2c0(%rbp), %rdi
callq 0x2abf4
movsd -0x80(%rbp), %xmm0
mulsd -0x90(%rbp), %xmm0
addsd -0x78(%rbp), %xmm0
addsd (%rax), %xmm0
leaq -0xd0(%rbp), %r15
movsd %xmm0, (%r15)
movsd -0x88(%rbp), %xmm0
addsd -0x98(%rbp), %xmm0
movabsq $-0x3f99800000000000, %rax # imm = 0xC066800000000000
leaq -0x48(%rbp), %rdi
movq %rax, (%rdi)
callq 0xd305
leaq -0x30(%rbp), %rsi
movsd %xmm0, (%rsi)
movq %r15, %rdi
callq 0xd15b
movsd -0x28(%rbp), %xmm5
addsd %xmm5, %xmm0
movsd -0x20(%rbp), %xmm6
addsd %xmm6, %xmm1
movsd %xmm0, -0x58(%rbp)
movsd %xmm1, -0x50(%rbp)
movapd 0x2d522(%rip), %xmm3    # 0x57010
andpd %xmm1, %xmm3
leaq 0x303d7(%rip), %rax     # 0x59ed0
movsd (%rax), %xmm2
movsd 0x2dd43(%rip), %xmm4    # 0x57848
mulsd %xmm2, %xmm4
ucomisd %xmm4, %xmm3
jbe 0x29b29
movsd %xmm5, -0x48(%rbp)
movsd %xmm6, -0x40(%rbp)
movsd -0x30(%rbp), %xmm0
movsd %xmm0, -0x38(%rbp)
xorpd %xmm0, %xmm0
jmp 0x29b78
movapd 0x2d4df(%rip), %xmm3    # 0x57010
andpd %xmm0, %xmm3
leaq 0x3038c(%rip), %rax     # 0x59ec8
movsd (%rax), %xmm4
mulsd 0x2dd00(%rip), %xmm4    # 0x57848
ucomisd %xmm4, %xmm3
jbe 0x29c4d
movsd -0x28(%rbp), %xmm0
movsd %xmm0, -0x48(%rbp)
movsd -0x20(%rbp), %xmm0
movsd %xmm0, -0x40(%rbp)
movsd -0x30(%rbp), %xmm0
movsd %xmm0, -0x38(%rbp)
movsd 0x2d510(%rip), %xmm0    # 0x57088
movapd 0x2d4a0(%rip), %xmm3    # 0x57020
xorpd %xmm2, %xmm3
xorpd %xmm4, %xmm4
cmpltsd %xmm1, %xmm4
andpd %xmm4, %xmm2
andnpd %xmm3, %xmm4
orpd %xmm2, %xmm4
mulsd 0x2dca7(%rip), %xmm4    # 0x57848
andq $0x0, -0xb0(%rbp)
movsd %xmm4, -0xa8(%rbp)
movsd %xmm0, -0xa0(%rbp)
xorpd %xmm0, %xmm0
movapd %xmm0, -0x70(%rbp)
leaq -0xc8(%rbp), %rdi
leaq -0x48(%rbp), %rsi
callq 0x1cc46
leaq -0xb0(%rbp), %rdi
leaq -0xc8(%rbp), %rsi
leaq -0x70(%rbp), %rdx
callq 0x23566
movsd -0x70(%rbp), %xmm0
movsd -0x68(%rbp), %xmm1
subsd -0x28(%rbp), %xmm0
subsd -0x20(%rbp), %xmm1
mulsd %xmm1, %xmm1
mulsd %xmm0, %xmm0
addsd %xmm1, %xmm0
sqrtsd %xmm0, %xmm0
addsd 0x2ecb3(%rip), %xmm0    # 0x588c8
leaq -0xc8(%rbp), %rdi
movsd %xmm0, (%rdi)
leaq -0x30(%rbp), %rsi
callq 0xd15b
movsd -0x28(%rbp), %xmm2
addsd %xmm0, %xmm2
movsd -0x20(%rbp), %xmm0
addsd %xmm1, %xmm0
movsd %xmm2, -0x58(%rbp)
movsd %xmm0, -0x50(%rbp)
movapd %xmm0, %xmm1
movapd %xmm2, %xmm0
subsd -0x140(%rbp), %xmm0
subsd -0x138(%rbp), %xmm1
mulsd %xmm1, %xmm1
mulsd %xmm0, %xmm0
addsd %xmm1, %xmm0
sqrtsd %xmm0, %xmm0
leaq -0x58(%rbp), %rdx
pushq $0x1
popq %rcx
movq %r14, %rdi
movq %rbx, %rsi
xorl %r8d, %r8d
callq 0x2807c
movl %eax, %ebx
leaq -0x2c0(%rbp), %rdi
callq 0xd716
leaq -0x148(%rbp), %rdi
callq 0xd716
movl %ebx, %eax
addq $0x2a8, %rsp            # imm = 0x2A8
popq %rbx
popq %r14
popq %r15
popq %rbp
retq
jmp 0x29cbb
jmp 0x29cbb
jmp 0x29cbb
jmp 0x29cbb
jmp 0x29cbb
movq %rax, %rbx
jmp 0x29cca
movq %rax, %rbx
leaq -0x2c0(%rbp), %rdi
callq 0xd716
leaq -0x148(%rbp), %rdi
callq 0xd716
movq %rbx, %rdi
callq 0x98b0