// File: /workspace/github_cpp_makefile_star2_O1/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, -0x60(%rbp)
movq %rsi, %r14
movq %rdi, -0x58(%rbp)
movzbl %r8b, %ebx
cmpl $-0x1, %ecx
jne 0x21c24
leaq 0x38(%r14), %rsi
movq %r14, %rdi
callq 0xf5c4
movl 0x80(%rax), %eax
cmpl $0x33, %eax
movl $0x33, %r13d
cmovll %eax, %r13d
testl %eax, %eax
jle 0x21c1e
xorl %r12d, %r12d
xorpd %xmm1, %xmm1
movsd 0x49bd4(%rip), %xmm0    # 0x6b750
movl $0xffffffff, %r15d      # imm = 0xFFFFFFFF
movsd %xmm0, -0x38(%rbp)
movsd %xmm1, -0x40(%rbp)
movq 0x18(%r14), %rax
movq 0x98(%rax), %rdi
movl %r12d, %esi
callq 0x22890
movsd (%rax), %xmm0
movsd %xmm0, -0x30(%rbp)
movsd 0x8(%rax), %xmm0
movsd %xmm0, -0x68(%rbp)
movq %r14, %rdi
callq 0xe85a
movq %rax, %rsi
movsd -0x30(%rbp), %xmm0
movsd -0x68(%rbp), %xmm1
movl %ebx, %edx
leaq -0x50(%rbp), %rcx
callq 0x21622
movsd -0x40(%rbp), %xmm1
xorps %xmm0, %xmm0
cvtsi2sd %eax, %xmm0
subsd -0x50(%rbp), %xmm0
subsd %xmm1, %xmm0
movsd 0x49469(%rip), %xmm2    # 0x6b058
addsd %xmm2, %xmm0
andpd 0x49415(%rip), %xmm0    # 0x6b010
movsd -0x38(%rbp), %xmm3
ucomisd %xmm0, %xmm3
minsd %xmm3, %xmm0
cmoval %r12d, %r15d
addsd %xmm2, %xmm1
incl %r12d
cmpl %r12d, %r13d
jne 0x21b82
jmp 0x21c24
movl $0xffffffff, %r15d      # imm = 0xFFFFFFFF
cmpl $-0x1, %r15d
jne 0x21c42
leaq 0x38(%r14), %rsi
movq %r14, %rdi
callq 0xf5c4
movl 0x64(%rax), %eax
xorl %r15d, %r15d
testl %eax, %eax
cmovgl %eax, %r15d
movq 0x18(%r14), %rax
movq 0x98(%rax), %rdi
movl %r15d, %esi
callq 0x22890
movsd (%rax), %xmm0
movsd %xmm0, -0x40(%rbp)
movsd 0x8(%rax), %xmm0
movsd %xmm0, -0x38(%rbp)
movq %r14, %rdi
callq 0xe85a
movq (%rax), %rcx
movq %rax, %rdi
callq *0x10(%rcx)
movsd (%rax), %xmm0
subsd 0x65893(%rip), %xmm0    # 0x87518
movsd %xmm0, -0x30(%rbp)
movq %r14, %rdi
callq 0xe85a
movq %rax, %r12
callq 0x4a75c
movsd 0x33c0(%rax), %xmm0
movq %r12, %rdi
callq 0x470e2
movaps %xmm0, %xmm3
movzbl -0x44(%rbp), %r8d
movq -0x58(%rbp), %rdi
movq %r14, %rsi
movq -0x60(%rbp), %rdx
movsd -0x40(%rbp), %xmm0
movsd -0x38(%rbp), %xmm1
movsd -0x30(%rbp), %xmm2
movl %ebx, %ecx
callq 0x1f640
movq %r14, %rdi
callq 0xe85a
movq %rax, %r12
movq 0x18(%r14), %rax
movq 0x98(%rax), %rdi
movl %r15d, %esi
callq 0x22890
movsd (%rax), %xmm0
movsd 0x8(%rax), %xmm1
leaq -0x50(%rbp), %r14
movq %r12, %rsi
movl %ebx, %edx
movq %r14, %rcx
callq 0x21622
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