// File: 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
subq $0x4a0, %rsp            # imm = 0x4A0
movq %rdi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
movsd %xmm0, -0x18(%rbp)
movsd %xmm1, -0x20(%rbp)
movq -0x8(%rbp), %rax
movq %rax, -0x3a8(%rbp)
movq -0x10(%rbp), %rdi
callq 0x10550
movq %rax, %rdi
callq 0x10570
movq %rax, %rsi
leaq -0x98(%rbp), %rdi
callq 0x23e70
movq -0x10(%rbp), %rdi
callq 0x10590
movq %rax, -0x3a0(%rbp)
jmp 0x54e9a
movq -0x3a0(%rbp), %rsi
leaq -0x210(%rbp), %rdi
callq 0x1d510
jmp 0x54eaf
leaq -0x210(%rbp), %rdi
callq 0x11170
movq %rax, -0x3b0(%rbp)
jmp 0x54ec4
movq -0x3b0(%rbp), %rax
movsd (%rax), %xmm0
movsd %xmm0, -0x228(%rbp)
leaq -0x210(%rbp), %rdi
movl $0x1, %esi
callq 0x11fc0
movq %rax, -0x3b8(%rbp)
jmp 0x54ef1
movq -0x3b8(%rbp), %rax
movups (%rax), %xmm0
movaps %xmm0, -0x240(%rbp)
leaq -0x210(%rbp), %rdi
callq 0x56fe0
movq %rax, -0x3c0(%rbp)
jmp 0x54f17
movq -0x3c0(%rbp), %rax
movsd (%rax), %xmm0
movsd %xmm0, -0x3d8(%rbp)
movsd -0x20(%rbp), %xmm0
movsd %xmm0, -0x3d0(%rbp)
callq 0x855e0
movq %rax, -0x3c8(%rbp)
jmp 0x54f45
movq -0x3c8(%rbp), %rdi
callq 0x12f10
movq %rax, -0x3e0(%rbp)
jmp 0x54f5a
movsd -0x3d0(%rbp), %xmm2
movsd -0x3d8(%rbp), %xmm0
movq -0x3e0(%rbp), %rax
movsd (%rax), %xmm1
mulsd %xmm2, %xmm0
addsd %xmm1, %xmm0
movsd %xmm0, -0x3f0(%rbp)
leaq -0x210(%rbp), %rdi
callq 0x57020
movq %rax, -0x3e8(%rbp)
jmp 0x54f9a
movsd -0x3f0(%rbp), %xmm0
movq -0x3e8(%rbp), %rax
movsd (%rax), %xmm1
addsd %xmm1, %xmm0
movsd %xmm0, -0x248(%rbp)
movsd -0x228(%rbp), %xmm0
movsd -0x18(%rbp), %xmm1
addsd %xmm1, %xmm0
movabsq $-0x3f99800000000000, %rax # imm = 0xC066800000000000
movq %rax, -0x258(%rbp)
leaq -0x258(%rbp), %rdi
callq 0x116b0
movsd %xmm0, -0x3f8(%rbp)
jmp 0x54ff1
movsd -0x3f8(%rbp), %xmm0
movsd %xmm0, -0x250(%rbp)
leaq -0x248(%rbp), %rdi
leaq -0x250(%rbp), %rsi
callq 0x112c0
movsd %xmm1, -0x408(%rbp)
movsd %xmm0, -0x400(%rbp)
jmp 0x55026
movsd -0x408(%rbp), %xmm0
movsd -0x400(%rbp), %xmm1
movsd %xmm1, -0x278(%rbp)
movsd %xmm0, -0x270(%rbp)
leaq -0x240(%rbp), %rdi
leaq -0x278(%rbp), %rsi
callq 0x11360
movsd %xmm1, -0x418(%rbp)
movsd %xmm0, -0x410(%rbp)
jmp 0x5506b
movsd -0x418(%rbp), %xmm0
movsd -0x410(%rbp), %xmm1
movsd %xmm1, -0x268(%rbp)
movsd %xmm0, -0x260(%rbp)
leaq -0x268(%rbp), %rdi
callq 0x17700
movq %rax, -0x420(%rbp)
jmp 0x550a0
movq -0x420(%rbp), %rax
movsd (%rax), %xmm0
movaps 0x6bfae(%rip), %xmm1    # 0xc1060
pand %xmm1, %xmm0
leaq 0x6ef83(%rip), %rax     # 0xc4040
movsd (%rax), %xmm1
movsd 0x6c3e7(%rip), %xmm2    # 0xc14b0
divsd %xmm2, %xmm1
ucomisd %xmm1, %xmm0
ja 0x5511f
leaq -0x268(%rbp), %rdi
callq 0x176f0
movq %rax, -0x428(%rbp)
jmp 0x550e8
movq -0x428(%rbp), %rax
movsd (%rax), %xmm0
movaps 0x6bf66(%rip), %xmm1    # 0xc1060
pand %xmm1, %xmm0
leaq 0x6ef33(%rip), %rax     # 0xc4038
movsd (%rax), %xmm1
movsd 0x6c39f(%rip), %xmm2    # 0xc14b0
divsd %xmm2, %xmm1
ucomisd %xmm1, %xmm0
jbe 0x554c0
leaq -0x290(%rbp), %rdi
leaq -0x240(%rbp), %rsi
leaq -0x250(%rbp), %rdx
callq 0x1fde0
jmp 0x5513b
leaq -0x2a8(%rbp), %rdi
callq 0x57060
jmp 0x55149
leaq -0x268(%rbp), %rdi
callq 0x17700
movq %rax, -0x430(%rbp)
jmp 0x5515e
movq -0x430(%rbp), %rax
movsd (%rax), %xmm0
movaps 0x6bef0(%rip), %xmm1    # 0xc1060
pand %xmm1, %xmm0
leaq 0x6eec5(%rip), %rax     # 0xc4040
movsd (%rax), %xmm1
movsd 0x6c329(%rip), %xmm2    # 0xc14b0
divsd %xmm2, %xmm1
ucomisd %xmm1, %xmm0
jbe 0x552a6
movq $0x0, -0x2d8(%rbp)
leaq -0x268(%rbp), %rdi
callq 0x17700
movq %rax, -0x438(%rbp)
jmp 0x551b5
movq -0x438(%rbp), %rax
movsd (%rax), %xmm0
xorps %xmm1, %xmm1
ucomisd %xmm1, %xmm0
seta %al
movzbl %al, %ecx
movl %ecx, %eax
leal -0x1(%rax,%rax), %eax
cvtsi2sd %eax, %xmm0
leaq 0x6ee62(%rip), %rax     # 0xc4040
movsd (%rax), %xmm1
mulsd %xmm1, %xmm0
movsd 0x6be32(%rip), %xmm1    # 0xc1020
mulsd %xmm1, %xmm0
movsd %xmm0, -0x2e0(%rbp)
leaq -0x2d0(%rbp), %rdi
leaq -0x2d8(%rbp), %rsi
leaq -0x2e0(%rbp), %rdx
callq 0x11a10
jmp 0x55216
movq $0x0, -0x2e8(%rbp)
leaq -0x2c0(%rbp), %rdi
leaq -0x2d0(%rbp), %rsi
leaq -0x2e8(%rbp), %rdx
callq 0x1fde0
jmp 0x5523d
movq -0x2c0(%rbp), %rax
movq %rax, -0x2a8(%rbp)
movq -0x2b8(%rbp), %rax
movq %rax, -0x2a0(%rbp)
movq -0x2b0(%rbp), %rax
movq %rax, -0x298(%rbp)
jmp 0x5537e
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x218(%rbp)
movl %eax, -0x21c(%rbp)
jmp 0x55596
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x218(%rbp)
movl %eax, -0x21c(%rbp)
leaq -0x210(%rbp), %rdi
callq 0x12500
jmp 0x55596
movq $0x0, -0x318(%rbp)
leaq -0x268(%rbp), %rdi
callq 0x17700
movq %rax, -0x440(%rbp)
jmp 0x552c6
movq -0x440(%rbp), %rax
movsd (%rax), %xmm0
xorps %xmm1, %xmm1
ucomisd %xmm1, %xmm0
seta %al
movzbl %al, %ecx
movl %ecx, %eax
leal -0x1(%rax,%rax), %eax
cvtsi2sd %eax, %xmm0
leaq 0x6ed51(%rip), %rax     # 0xc4040
movsd (%rax), %xmm1
mulsd %xmm1, %xmm0
movsd 0x6bd21(%rip), %xmm1    # 0xc1020
mulsd %xmm1, %xmm0
movsd %xmm0, -0x320(%rbp)
leaq -0x310(%rbp), %rdi
leaq -0x318(%rbp), %rsi
leaq -0x320(%rbp), %rdx
callq 0x11a10
jmp 0x55327
movabsq $0x4056800000000000, %rax # imm = 0x4056800000000000
movq %rax, -0x328(%rbp)
leaq -0x300(%rbp), %rdi
leaq -0x310(%rbp), %rsi
leaq -0x328(%rbp), %rdx
callq 0x1fde0
jmp 0x55354
movq -0x300(%rbp), %rax
movq %rax, -0x2a8(%rbp)
movq -0x2f8(%rbp), %rax
movq %rax, -0x2a0(%rbp)
movq -0x2f0(%rbp), %rax
movq %rax, -0x298(%rbp)
movq $0x0, -0x340(%rbp)
movq $0x0, -0x348(%rbp)
leaq -0x338(%rbp), %rdi
leaq -0x340(%rbp), %rsi
leaq -0x348(%rbp), %rdx
callq 0x11a10
jmp 0x553b0
leaq -0x360(%rbp), %rdi
leaq -0x290(%rbp), %rsi
callq 0x32670
jmp 0x553c5
leaq -0x2a8(%rbp), %rdi
leaq -0x360(%rbp), %rsi
leaq -0x338(%rbp), %rdx
callq 0x473c0
jmp 0x553e1
leaq -0x338(%rbp), %rdi
leaq -0x240(%rbp), %rsi
callq 0x1d6d0
movsd %xmm0, -0x448(%rbp)
jmp 0x553fe
movsd -0x448(%rbp), %xmm0
movsd 0x6d462(%rip), %xmm1    # 0xc2870
addsd %xmm1, %xmm0
movsd %xmm0, -0x388(%rbp)
leaq -0x388(%rbp), %rdi
leaq -0x250(%rbp), %rsi
callq 0x112c0
movsd %xmm1, -0x458(%rbp)
movsd %xmm0, -0x450(%rbp)
jmp 0x5543f
movsd -0x458(%rbp), %xmm0
movsd -0x450(%rbp), %xmm1
movsd %xmm1, -0x380(%rbp)
movsd %xmm0, -0x378(%rbp)
leaq -0x240(%rbp), %rdi
leaq -0x380(%rbp), %rsi
callq 0x11360
movsd %xmm1, -0x468(%rbp)
movsd %xmm0, -0x460(%rbp)
jmp 0x55484
movsd -0x468(%rbp), %xmm0
movsd -0x460(%rbp), %xmm1
movsd %xmm1, -0x370(%rbp)
movsd %xmm0, -0x368(%rbp)
movq -0x370(%rbp), %rax
movq %rax, -0x268(%rbp)
movq -0x368(%rbp), %rax
movq %rax, -0x260(%rbp)
leaq -0x90(%rbp), %rdi
callq 0x11090
movq %rax, -0x470(%rbp)
jmp 0x554d5
movq -0x470(%rbp), %rsi
leaq -0x268(%rbp), %rdi
callq 0x110a0
movsd %xmm1, -0x480(%rbp)
movsd %xmm0, -0x478(%rbp)
jmp 0x554fa
movsd -0x480(%rbp), %xmm0
movsd -0x478(%rbp), %xmm1
movsd %xmm1, -0x398(%rbp)
movsd %xmm0, -0x390(%rbp)
movq -0x10(%rbp), %rax
movq %rax, -0x490(%rbp)
leaq -0x398(%rbp), %rdi
callq 0x104e0
movsd %xmm0, -0x488(%rbp)
jmp 0x5553b
movsd -0x488(%rbp), %xmm0
movq -0x490(%rbp), %rsi
movq -0x3a8(%rbp), %rdi
leaq -0x268(%rbp), %rdx
movl $0x1, %ecx
xorl %r8d, %r8d
callq 0x52060
movb %al, -0x491(%rbp)
jmp 0x5556d
leaq -0x210(%rbp), %rdi
callq 0x12500
leaq -0x98(%rbp), %rdi
callq 0x23f80
movb -0x491(%rbp), %al
andb $0x1, %al
addq $0x4a0, %rsp            # imm = 0x4A0
popq %rbp
retq
leaq -0x98(%rbp), %rdi
callq 0x23f80
movq -0x218(%rbp), %rdi
callq 0xaa60
nop