// File: /workspace/github_cpp_makefile_star2_O3/wrighteagle2d[P]wrighteaglebase/Debug/../src/Dasher.cpp
// Function: Dasher::GetBall(Agent&, AtomicAction&, int, bool, bool)
double Dasher::GetBall(Agent &agent, AtomicAction &act, int int_cycle,
                       bool can_inverse, bool turn_first) {
  Assert(int_cycle == -1 || int_cycle >= 0);

  if (int_cycle == -1) {
    double min_diff = HUGE_VALUE;

    const int max_consider_cycle =
        Min(int(MobileState::Predictor::MAX_STEP),
            agent.GetStrategy().GetSureOppInterCycle() - 1);
    for (int i = 0; i <= max_consider_cycle; ++i) {
      Vector target = agent.GetWorldState().GetBall().GetPredictedPos(i);
      double my_cycle =
          RealCycleNeedToPoint(agent.GetSelf(), target, can_inverse);
      double diff = fabs(my_cycle - i + 1.0);

      if (diff < min_diff) {
        min_diff = diff;
        int_cycle = i;
      }
    }
  }

  if (int_cycle == -1) {
    int_cycle = Max(0, agent.GetStrategy().GetMyInterCycle());
  }

  GoToPoint(agent, act,
            agent.GetWorldState().GetBall().GetPredictedPos(int_cycle),
            agent.GetSelf().GetKickableArea() - GETBALL_BUFFER,
            agent.GetSelf().CorrectDashPowerForStamina(
                ServerParam::instance().maxDashPower()),
            can_inverse, turn_first);

  return RealCycleNeedToPoint(
      agent.GetSelf(),
      agent.GetWorldState().GetBall().GetPredictedPos(int_cycle), can_inverse);
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x48, %rsp
movl %r9d, -0x44(%rbp)
movl %ecx, %r15d
movq %rdx, -0x68(%rbp)
movq %rsi, %r14
movq %rdi, -0x60(%rbp)
movzbl %r8b, %ebx
cmpl $-0x1, %ecx
jne 0x21617
leaq 0x38(%r14), %r12
movq %r14, %rdi
movq %r12, %rsi
callq 0xf4b0
movl 0x80(%rax), %eax
cmpl $0x33, %eax
movl $0x33, %r13d
cmovll %eax, %r13d
testl %eax, %eax
jle 0x21600
movq %r12, -0x58(%rbp)
xorl %r12d, %r12d
xorpd %xmm1, %xmm1
movsd 0x481f7(%rip), %xmm0    # 0x69750
movl $0xffffffff, %r15d      # imm = 0xFFFFFFFF
movsd %xmm0, -0x38(%rbp)
movsd %xmm1, -0x40(%rbp)
movq 0x18(%r14), %rdi
addq $0x30, %rdi
movl %r12d, %esi
callq 0x220a4
movsd (%rax), %xmm0
movsd %xmm0, -0x30(%rbp)
movsd 0x8(%rax), %xmm0
movsd %xmm0, -0x70(%rbp)
movq %r14, %rdi
callq 0xe75a
movq %rax, %rsi
movsd -0x30(%rbp), %xmm0
movsd -0x70(%rbp), %xmm1
movl %ebx, %edx
leaq -0x50(%rbp), %rcx
callq 0x2100c
movsd -0x40(%rbp), %xmm1
xorps %xmm0, %xmm0
cvtsi2sd %eax, %xmm0
subsd -0x50(%rbp), %xmm0
subsd %xmm1, %xmm0
movsd 0x47a8f(%rip), %xmm2    # 0x69058
addsd %xmm2, %xmm0
andpd 0x47a3b(%rip), %xmm0    # 0x69010
movsd -0x38(%rbp), %xmm3
ucomisd %xmm0, %xmm3
minsd %xmm3, %xmm0
cmoval %r12d, %r15d
addsd %xmm2, %xmm1
incl %r12d
cmpl %r12d, %r13d
jne 0x2155f
cmpl $-0x1, %r15d
movq -0x58(%rbp), %r12
jne 0x21617
movq %r14, %rdi
movq %r12, %rsi
callq 0xf4b0
movl 0x64(%rax), %eax
xorl %r15d, %r15d
testl %eax, %eax
cmovgl %eax, %r15d
movq 0x18(%r14), %rdi
addq $0x30, %rdi
movl %r15d, %esi
callq 0x220a4
movsd (%rax), %xmm0
movsd %xmm0, -0x40(%rbp)
movsd 0x8(%rax), %xmm0
movsd %xmm0, -0x38(%rbp)
movq %r14, %rdi
callq 0xe75a
movq (%rax), %rcx
movq %rax, %rdi
callq *0x10(%rcx)
movsd (%rax), %xmm0
subsd 0x62ec1(%rip), %xmm0    # 0x84518
movsd %xmm0, -0x30(%rbp)
movq %r14, %rdi
callq 0xe75a
movq %rax, %r12
callq 0x49360
movsd 0x33c0(%rax), %xmm0
movq %r12, %rdi
callq 0x45d84
movaps %xmm0, %xmm3
movzbl -0x44(%rbp), %r8d
movq -0x60(%rbp), %rdi
movq %r14, %rsi
movq -0x68(%rbp), %rdx
movsd -0x40(%rbp), %xmm0
movsd -0x38(%rbp), %xmm1
movsd -0x30(%rbp), %xmm2
movl %ebx, %ecx
callq 0x1f1a0
movq %r14, %rdi
callq 0xe75a
movq %rax, %r12
movq 0x18(%r14), %rdi
addq $0x30, %rdi
movl %r15d, %esi
callq 0x220a4
movsd (%rax), %xmm0
movsd 0x8(%rax), %xmm1
leaq -0x50(%rbp), %r14
movq %r12, %rsi
movl %ebx, %edx
movq %r14, %rcx
callq 0x2100c
xorps %xmm0, %xmm0
cvtsi2sd %eax, %xmm0
subsd (%r14), %xmm0
addq $0x48, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
nop