// File: /workspace/github_cpp_makefile_star2_O3/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 0x2d494
movsd 0x2b45d8(%r12), %xmm1
movsd 0x2b45e0(%r12), %xmm0
subsd (%r14), %xmm1
subsd 0x8(%r14), %xmm0
movapd 0x3834c(%rip), %xmm2    # 0x69010
movapd %xmm1, %xmm4
andpd %xmm2, %xmm4
movsd 0x3836c(%rip), %xmm3    # 0x69040
ucomisd %xmm4, %xmm3
jbe 0x30ce8
andpd %xmm0, %xmm2
xorpd %xmm4, %xmm4
ucomisd %xmm2, %xmm3
ja 0x30d01
callq 0x90d0
movapd %xmm0, %xmm4
mulsd 0x3834f(%rip), %xmm4    # 0x69048
divsd 0x3834f(%rip), %xmm4    # 0x69050
movsd %xmm4, -0x48(%rbp)
xorpd %xmm0, %xmm0
movupd %xmm0, 0x18(%rbx)
movq $0x0, 0x28(%rbx)
movl $0x6, 0x4(%rbx)
movq %r13, %rdi
callq 0xe702
subsd -0x48(%rbp), %xmm0
mulsd 0x3831d(%rip), %xmm0    # 0x69050
divsd 0x3830d(%rip), %xmm0    # 0x69048
callq 0x9130
movapd %xmm0, -0x60(%rbp)
movsd (%r13), %xmm0
movsd 0x8(%r13), %xmm1
mulsd %xmm1, %xmm1
mulsd %xmm0, %xmm0
addsd %xmm1, %xmm0
sqrtsd %xmm0, %xmm0
movsd %xmm0, -0x70(%rbp)
cmpb $0x0, -0x40(%rbp)
je 0x30d86
movq %r15, %rdi
callq 0xe75a
movsd 0x130(%rax), %xmm0
movapd %xmm0, -0x40(%rbp)
jmp 0x30e7e
movslq 0x2b4580(%r12), %r15
movq %r14, %rdi
callq 0xe702
andpd 0x38272(%rip), %xmm0    # 0x69010
movapd %xmm0, -0x40(%rbp)
movsd (%r14), %xmm0
movsd 0x8(%r14), %xmm1
mulsd %xmm1, %xmm1
mulsd %xmm0, %xmm0
addsd %xmm1, %xmm0
sqrtsd %xmm0, %xmm0
movsd %xmm0, -0x30(%rbp)
callq 0x43dce
movq 0x5c38(%rax), %rax
imulq $0x3700, %r15, %r14     # imm = 0x3700
movsd -0x30(%rbp), %xmm0
subsd 0x3038(%rax,%r14), %xmm0
movsd %xmm0, -0x30(%rbp)
callq 0x49360
movsd -0x30(%rbp), %xmm0
subsd 0x30d8(%rax), %xmm0
movsd %xmm0, -0x30(%rbp)
callq 0x43dce
movq 0x5c38(%rax), %rax
movsd 0x38293(%rip), %xmm0    # 0x690a8
movapd -0x40(%rbp), %xmm1
mulsd %xmm0, %xmm1
divsd 0x3823a(%rip), %xmm1    # 0x69060
movsd 0x3068(%rax,%r14), %xmm2
movsd %xmm2, -0x68(%rbp)
addsd 0x3821b(%rip), %xmm1    # 0x69058
movapd %xmm1, -0x40(%rbp)
movsd -0x30(%rbp), %xmm1
mulsd %xmm0, %xmm1
movsd %xmm1, -0x30(%rbp)
callq 0x43dce
movq 0x5c38(%rax), %rax
movsd -0x30(%rbp), %xmm0
divsd 0x3040(%rax,%r14), %xmm0
movapd -0x40(%rbp), %xmm1
subsd %xmm0, %xmm1
mulsd -0x68(%rbp), %xmm1
movapd %xmm1, -0x40(%rbp)
movapd -0x60(%rbp), %xmm0
mulsd -0x70(%rbp), %xmm0
movapd %xmm0, -0x60(%rbp)
callq 0x49360
movapd -0x60(%rbp), %xmm0
movsd 0x3130(%rax), %xmm2
movapd -0x40(%rbp), %xmm1
mulsd %xmm1, %xmm2
movapd 0x38160(%rip), %xmm1    # 0x69010
andpd %xmm0, %xmm1
ucomisd %xmm1, %xmm2
seta (%rbx)
xorpd 0x3815d(%rip), %xmm0    # 0x69020
movsd %xmm2, -0x60(%rbp)
divsd %xmm2, %xmm0
ucomisd 0x393ec(%rip), %xmm0    # 0x6a2c0
jae 0x30efb
movsd 0x393ea(%rip), %xmm1    # 0x6a2c8
ucomisd %xmm0, %xmm1
jae 0x30f05
callq 0x9840
mulsd 0x38157(%rip), %xmm0    # 0x69048
divsd 0x38157(%rip), %xmm0    # 0x69050
jmp 0x30f0d
movsd 0x381ad(%rip), %xmm0    # 0x690b0
jmp 0x30f0d
movsd 0x381ab(%rip), %xmm0    # 0x690b8
movsd -0x48(%rbp), %xmm1
addsd %xmm0, %xmm1
mulsd 0x38132(%rip), %xmm1    # 0x69050
divsd 0x38122(%rip), %xmm1    # 0x69048
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 0x380a6(%rip), %xmm1    # 0x69010
andpd %xmm3, %xmm1
leaq 0x3963b(%rip), %rcx     # 0x6a5b0
movsd (%rcx,%rax,8), %xmm2
cmpltsd 0x380bd(%rip), %xmm1    # 0x69040
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
nop