// File: 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
subq $0xe0, %rsp
movl %r8d, -0xb0(%rbp)
movl %ecx, %eax
movl -0xb0(%rbp), %ecx
movl %eax, -0xac(%rbp)
movq %rdx, %rax
movl -0xac(%rbp), %edx
movq %rax, -0xa8(%rbp)
movq %rsi, %rax
movq -0xa8(%rbp), %rsi
movq %rax, -0xa0(%rbp)
movq %rdi, %r8
movq -0xa0(%rbp), %rdi
movb %r9b, %al
movq %r8, -0x8(%rbp)
movq %rdi, -0x10(%rbp)
movq %rsi, -0x18(%rbp)
movl %edx, -0x1c(%rbp)
andb $0x1, %cl
movb %cl, -0x1d(%rbp)
andb $0x1, %al
movb %al, -0x1e(%rbp)
movq -0x8(%rbp), %rax
movq %rax, -0x98(%rbp)
cmpl $-0x1, -0x1c(%rbp)
jne 0x31813
movsd 0x90013(%rip), %xmm0    # 0xc1718
movsd %xmm0, -0x28(%rbp)
movl $0x32, -0x30(%rbp)
movq -0x10(%rbp), %rdi
callq 0x14050
movq %rax, %rdi
callq 0x20a40
subl $0x1, %eax
movl %eax, -0x34(%rbp)
leaq -0x30(%rbp), %rdi
leaq -0x34(%rbp), %rsi
callq 0x13150
movl (%rax), %eax
movl %eax, -0x2c(%rbp)
movl $0x0, -0x38(%rbp)
movl -0x38(%rbp), %eax
cmpl -0x2c(%rbp), %eax
jg 0x31811
movq -0x10(%rbp), %rdi
callq 0x10550
movq %rax, %rdi
callq 0x10570
movq %rax, %rdi
movl -0x38(%rbp), %esi
callq 0x11fc0
movq (%rax), %rcx
movq %rcx, -0x48(%rbp)
movq 0x8(%rax), %rax
movq %rax, -0x40(%rbp)
movq -0x10(%rbp), %rdi
callq 0x10590
movq -0x98(%rbp), %rdi
movq %rax, %rsi
movq -0x48(%rbp), %rax
movq %rax, -0x60(%rbp)
movq -0x40(%rbp), %rax
movq %rax, -0x58(%rbp)
movb -0x1d(%rbp), %al
movsd -0x60(%rbp), %xmm0
movsd -0x58(%rbp), %xmm1
andb $0x1, %al
movzbl %al, %edx
callq 0x329f0
movsd %xmm0, -0x50(%rbp)
movsd -0x50(%rbp), %xmm0
cvtsi2sdl -0x38(%rbp), %xmm1
subsd %xmm1, %xmm0
movsd 0x8f843(%rip), %xmm1    # 0xc1010
addsd %xmm1, %xmm0
movaps 0x8f888(%rip), %xmm1    # 0xc1060
pand %xmm1, %xmm0
movsd %xmm0, -0x68(%rbp)
movsd -0x68(%rbp), %xmm1
movsd -0x28(%rbp), %xmm0
ucomisd %xmm1, %xmm0
jbe 0x31801
movsd -0x68(%rbp), %xmm0
movsd %xmm0, -0x28(%rbp)
movl -0x38(%rbp), %eax
movl %eax, -0x1c(%rbp)
jmp 0x31803
movl -0x38(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x38(%rbp)
jmp 0x31741
jmp 0x31813
cmpl $-0x1, -0x1c(%rbp)
jne 0x31846
movl $0x0, -0x6c(%rbp)
movq -0x10(%rbp), %rdi
callq 0x14050
movq %rax, %rdi
callq 0x1b490
movl %eax, -0x70(%rbp)
leaq -0x6c(%rbp), %rdi
leaq -0x70(%rbp), %rsi
callq 0x329c0
movl (%rax), %eax
movl %eax, -0x1c(%rbp)
movq -0x10(%rbp), %rax
movq %rax, -0xd0(%rbp)
movq -0x18(%rbp), %rax
movq %rax, -0xc8(%rbp)
movq -0x10(%rbp), %rdi
callq 0x10550
movq %rax, %rdi
callq 0x10570
movq %rax, %rdi
movl -0x1c(%rbp), %esi
callq 0x11fc0
movq (%rax), %rcx
movq %rcx, -0x80(%rbp)
movq 0x8(%rax), %rax
movq %rax, -0x78(%rbp)
movq -0x10(%rbp), %rdi
callq 0x10590
movq %rax, %rdi
movq (%rdi), %rax
callq *0x10(%rax)
movsd (%rax), %xmm0
subsd 0xccd93(%rip), %xmm0    # 0xfe638
movsd %xmm0, -0xc0(%rbp)
movq -0x10(%rbp), %rdi
callq 0x10590
movq %rax, -0xd8(%rbp)
callq 0x855e0
movq %rax, %rdi
callq 0x12b60
movq -0xd8(%rbp), %rdi
movsd (%rax), %xmm0
callq 0x7c940
movq -0xd0(%rbp), %rsi
movq -0xc8(%rbp), %rdx
movsd -0xc0(%rbp), %xmm2
movq -0x98(%rbp), %rdi
movaps %xmm0, %xmm3
movb -0x1d(%rbp), %cl
movb -0x1e(%rbp), %al
movsd -0x80(%rbp), %xmm0
movsd -0x78(%rbp), %xmm1
andb $0x1, %cl
andb $0x1, %al
movzbl %cl, %ecx
movzbl %al, %r8d
callq 0x2ed20
movq -0x10(%rbp), %rdi
callq 0x10590
movq %rax, -0xb8(%rbp)
movq -0x10(%rbp), %rdi
callq 0x10550
movq %rax, %rdi
callq 0x10570
movq %rax, %rdi
movl -0x1c(%rbp), %esi
callq 0x11fc0
movq -0x98(%rbp), %rdi
movq -0xb8(%rbp), %rsi
movq (%rax), %rcx
movq %rcx, -0x90(%rbp)
movq 0x8(%rax), %rax
movq %rax, -0x88(%rbp)
movb -0x1d(%rbp), %al
movsd -0x90(%rbp), %xmm0
movsd -0x88(%rbp), %xmm1
andb $0x1, %al
movzbl %al, %edx
callq 0x329f0
addq $0xe0, %rsp
popq %rbp
retq