// File: /workspace/github_cpp_makefile_star2_O1/wrighteagle2d[P]wrighteaglebase/Debug/../src/Kicker.cpp
// Function: Kicker::GetMaxKickOutAction(Agent const&, Vector&, Vector&, bool)
AtomicAction Kicker::GetMaxKickOutAction(const Agent &agent, Vector &ball_pos,
                                         Vector &ball_vel, bool is_self) {
  UpdateKickData(agent);

  AngleDeg kick_angle = (mKickTarget - ball_pos).Dir();
  AtomicAction a;
  a.mType = CT_Kick;
  double y = (Sin(ball_vel.Dir() - kick_angle)) * ball_vel.Mod();
  double kick_rate = (is_self ? agent.GetSelf().GetKickRate()
                              : GetKickRate(ball_pos, mInput.mPlayerType));
  double max_speed = ServerParam::instance().maxPower() * kick_rate;
  a.mSucceed = (fabs(y) < max_speed);
  a.mKickVel = Polar2Vector(max_speed, ASin(-y / max_speed) + kick_angle);
  a.mKickVel = a.mKickVel / kick_rate;
  return a;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x58, %rsp
movl %r9d, -0x40(%rbp)
movq %r8, %r13
movq %rcx, %r14
movq %rdx, %r15
movq %rsi, %r12
movq %rdi, %rbx
movq %rsi, %rdi
movq %rdx, %rsi
callq 0x2de9c
movsd 0x2b45d8(%r12), %xmm1
movsd 0x2b45e0(%r12), %xmm0
subsd (%r14), %xmm1
subsd 0x8(%r14), %xmm0
movapd 0x397a4(%rip), %xmm2    # 0x6b010
movapd %xmm1, %xmm4
andpd %xmm2, %xmm4
movsd 0x397c4(%rip), %xmm3    # 0x6b040
ucomisd %xmm4, %xmm3
jbe 0x31890
andpd %xmm0, %xmm2
xorpd %xmm4, %xmm4
ucomisd %xmm2, %xmm3
ja 0x318a9
callq 0x90d0
movapd %xmm0, %xmm4
mulsd 0x397a7(%rip), %xmm4    # 0x6b048
divsd 0x397a7(%rip), %xmm4    # 0x6b050
movsd %xmm4, -0x48(%rbp)
movb $0x0, (%rbx)
xorpd %xmm0, %xmm0
movupd %xmm0, 0x4(%rbx)
movupd %xmm0, 0x14(%rbx)
movupd %xmm0, 0x20(%rbx)
movl $0x6, 0x4(%rbx)
movq %r13, %rdi
callq 0xe804
subsd -0x48(%rbp), %xmm0
mulsd 0x39770(%rip), %xmm0    # 0x6b050
divsd 0x39760(%rip), %xmm0    # 0x6b048
callq 0x9130
movapd %xmm0, -0x60(%rbp)
movsd (%r13), %xmm0
movsd 0x8(%r13), %xmm1
mulsd %xmm1, %xmm1
mulsd %xmm0, %xmm0
addsd %xmm1, %xmm0
xorpd %xmm1, %xmm1
ucomisd %xmm1, %xmm0
jb 0x3191a
sqrtsd %xmm0, %xmm0
jmp 0x3191f
callq 0x93c0
movsd %xmm0, -0x68(%rbp)
cmpb $0x0, -0x40(%rbp)
je 0x31944
movq %r15, %rdi
callq 0xe85a
movsd 0x130(%rax), %xmm0
movapd %xmm0, -0x40(%rbp)
jmp 0x31a4d
movslq 0x2b4580(%r12), %r15
movq %r14, %rdi
callq 0xe804
andpd 0x396b4(%rip), %xmm0    # 0x6b010
movapd %xmm0, -0x40(%rbp)
movsd (%r14), %xmm0
movsd 0x8(%r14), %xmm1
mulsd %xmm1, %xmm1
mulsd %xmm0, %xmm0
addsd %xmm1, %xmm0
xorpd %xmm1, %xmm1
ucomisd %xmm1, %xmm0
jb 0x31988
sqrtsd %xmm0, %xmm0
jmp 0x3198d
callq 0x93c0
movsd %xmm0, -0x30(%rbp)
callq 0x450ba
movq 0x5c38(%rax), %rax
imulq $0x3700, %r15, %r14     # imm = 0x3700
movsd -0x30(%rbp), %xmm0
subsd 0x3038(%rax,%r14), %xmm0
movsd %xmm0, -0x30(%rbp)
callq 0x4a75c
movsd -0x30(%rbp), %xmm0
subsd 0x30d8(%rax), %xmm0
movsd %xmm0, -0x30(%rbp)
callq 0x450ba
movq 0x5c38(%rax), %rax
movsd 0x396c4(%rip), %xmm0    # 0x6b0a8
movapd -0x40(%rbp), %xmm1
mulsd %xmm0, %xmm1
divsd 0x3966b(%rip), %xmm1    # 0x6b060
movsd 0x3068(%rax,%r14), %xmm2
movsd %xmm2, -0x70(%rbp)
addsd 0x3964c(%rip), %xmm1    # 0x6b058
movapd %xmm1, -0x40(%rbp)
movsd -0x30(%rbp), %xmm1
mulsd %xmm0, %xmm1
movsd %xmm1, -0x30(%rbp)
callq 0x450ba
movq 0x5c38(%rax), %rax
movsd -0x30(%rbp), %xmm0
divsd 0x3040(%rax,%r14), %xmm0
movapd -0x40(%rbp), %xmm1
subsd %xmm0, %xmm1
mulsd -0x70(%rbp), %xmm1
movapd %xmm1, -0x40(%rbp)
movapd -0x60(%rbp), %xmm0
mulsd -0x68(%rbp), %xmm0
movapd %xmm0, -0x60(%rbp)
callq 0x4a75c
movapd -0x60(%rbp), %xmm0
movsd 0x3130(%rax), %xmm2
movapd -0x40(%rbp), %xmm1
mulsd %xmm1, %xmm2
movapd 0x39591(%rip), %xmm1    # 0x6b010
andpd %xmm0, %xmm1
ucomisd %xmm1, %xmm2
seta (%rbx)
xorpd 0x3958e(%rip), %xmm0    # 0x6b020
movsd %xmm2, -0x60(%rbp)
divsd %xmm2, %xmm0
ucomisd 0x3a82d(%rip), %xmm0    # 0x6c2d0
jae 0x31aca
movsd 0x3a82b(%rip), %xmm1    # 0x6c2d8
ucomisd %xmm0, %xmm1
jae 0x31ad4
callq 0x9840
mulsd 0x39588(%rip), %xmm0    # 0x6b048
divsd 0x39588(%rip), %xmm0    # 0x6b050
jmp 0x31adc
movsd 0x395de(%rip), %xmm0    # 0x6b0b0
jmp 0x31adc
movsd 0x395dc(%rip), %xmm0    # 0x6b0b8
movsd -0x48(%rbp), %xmm1
addsd %xmm0, %xmm1
mulsd 0x39563(%rip), %xmm1    # 0x6b050
divsd 0x39553(%rip), %xmm1    # 0x6b048
leaq -0x80(%rbp), %r14
leaq -0x78(%rbp), %r15
movapd %xmm1, %xmm0
movq %r14, %rdi
movq %r15, %rsi
callq 0x92d0
movsd (%r15), %xmm0
movsd -0x60(%rbp), %xmm4
mulsd %xmm4, %xmm0
mulsd (%r14), %xmm4
xorpd %xmm1, %xmm1
xorl %eax, %eax
movapd -0x40(%rbp), %xmm3
ucomisd %xmm1, %xmm3
setae %al
movapd 0x394d7(%rip), %xmm1    # 0x6b010
andpd %xmm3, %xmm1
leaq 0x3aa7c(%rip), %rcx     # 0x6c5c0
movsd (%rcx,%rax,8), %xmm2
cmpltsd 0x394ee(%rip), %xmm1    # 0x6b040
andpd %xmm1, %xmm2
andnpd %xmm3, %xmm1
orpd %xmm2, %xmm1
divsd %xmm1, %xmm0
divsd %xmm1, %xmm4
movsd %xmm0, 0x8(%rbx)
movsd %xmm4, 0x10(%rbx)
movq %rbx, %rax
addq $0x58, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq