// File: /workspace/github_cpp_makefile_star2_O3/wrighteagle2d[P]wrighteaglebase/Debug/../src/InterceptInfo.cpp
// Function: InterceptInfo::CalcTightInterception(BallState const&, PlayerInterceptInfo*, bool)
void InterceptInfo::CalcTightInterception(const BallState &ball,
                                          PlayerInterceptInfo *pInfo,
                                          bool can_inverse) {
  CalcIdealInterception(
      ball, pInfo,
      pInfo->mpPlayer->GetKickableArea()); // TODO: 改成从外面传进来 buffer

  const int idle_cycle = pInfo->mpPlayer->GetIdleCycle();

  //根据go_to_point模型修正
  if (pInfo->solution.interc == 1) {
    int cycle_sup = pInfo->mInterCycle[0];
    int cycle_inf = MobileState::Predictor::MAX_STEP;
    for (int i = cycle_sup; i <= cycle_inf; ++i) {
      int n = Dasher::instance().CycleNeedToPoint(
                  *(pInfo->mpPlayer), ball.GetPredictedPos(i), can_inverse) +
              idle_cycle;
      if (n <= i) { // n以后完全可截
        break;
      }
      pInfo->mInterCycle[0]++;
    }
  } else { // 3
    int cycle_sup = pInfo->mInterCycle[0];
    int cycle_inf = pInfo->mInterCycle[1];
    for (int i = cycle_sup; i <= cycle_inf; ++i) {
      int n = Dasher::instance().CycleNeedToPoint(
                  *(pInfo->mpPlayer), ball.GetPredictedPos(i), can_inverse) +
              idle_cycle;
      if (n <= i) {
        break;
      }
      pInfo->mInterCycle[0]++;
    }
    if (pInfo->mInterCycle[0] <= pInfo->mInterCycle[1]) {
      cycle_sup = pInfo->mInterCycle[0];
      cycle_inf = pInfo->mInterCycle[1];
      for (int i = cycle_inf; i >= cycle_sup; --i) {
        int n = Dasher::instance().CycleNeedToPoint(
                    *(pInfo->mpPlayer), ball.GetPredictedPos(i), can_inverse) +
                idle_cycle;
        if (n <= i) {
          break;
        }
        pInfo->mInterCycle[1]--;
      }
      if (pInfo->mInterCycle[0] > pInfo->mInterCycle[1]) { //窗口收缩成点
        pInfo->solution.interc = 1;
      }
    } else {
      pInfo->solution.interc = 1;
    }

    cycle_sup = pInfo->mInterCycle[2];
    cycle_inf = MobileState::Predictor::MAX_STEP;
    for (int i = cycle_sup; i <= cycle_inf; ++i) {
      int n = Dasher::instance().CycleNeedToPoint(
                  *(pInfo->mpPlayer), ball.GetPredictedPos(i), can_inverse) +
              idle_cycle;
      if (n <= i) { // n以后完全可截
        break;
      }
      pInfo->mInterCycle[2]++;
    }

    if (pInfo->solution.interc == 1) {
      pInfo->mInterCycle[0] = pInfo->mInterCycle[2];
    }
  }

  AnalyseInterceptSolution(ball, pInfo);
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x18, %rsp
movl %edx, %r15d
movq %rsi, %rbx
movq %rdi, %r14
movq 0x60(%rsi), %rdi
movq (%rdi), %rax
callq *0x10(%rax)
movq %r14, -0x38(%rbp)
movq %r14, %rdi
movq %rbx, %rsi
movq %rax, %rdx
callq 0x2aee0
movq 0x60(%rbx), %rax
movl 0x124(%rax), %ecx
movl 0x68(%rbx), %r12d
addl 0xc8(%rax), %ecx
movl %ecx, -0x2c(%rbp)
cmpl $0x1, 0x4(%rbx)
jne 0x2aced
cmpl $0x32, %r12d
jg 0x2ae09
movzbl %r15b, %r14d
callq 0x1f148
movq %rax, %r13
movq 0x60(%rbx), %r15
movq -0x38(%rbp), %rdi
movl %r12d, %esi
callq 0x220a4
movsd (%rax), %xmm0
movsd 0x8(%rax), %xmm1
movq %r13, %rdi
movq %r15, %rsi
movl %r14d, %edx
xorl %ecx, %ecx
callq 0x2100c
addl -0x2c(%rbp), %eax
cmpl %r12d, %eax
jle 0x2ae09
incl 0x68(%rbx)
incl %r12d
cmpl $0x33, %r12d
jne 0x2ac9f
jmp 0x2ae09
movl 0x6c(%rbx), %r13d
movzbl %r15b, %eax
movl %eax, -0x30(%rbp)
cmpl %r13d, %r12d
jg 0x2ad50
incl %r13d
callq 0x1f148
movq %rax, %r15
movq 0x60(%rbx), %r14
movq -0x38(%rbp), %rdi
movl %r12d, %esi
callq 0x220a4
movsd (%rax), %xmm0
movsd 0x8(%rax), %xmm1
movq %r15, %rdi
movq %r14, %rsi
movl -0x30(%rbp), %edx
xorl %ecx, %ecx
callq 0x2100c
addl -0x2c(%rbp), %eax
movl 0x68(%rbx), %ecx
cmpl %r12d, %eax
jle 0x2ad49
incl %ecx
movl %ecx, 0x68(%rbx)
incl %r12d
cmpl %r12d, %r13d
jne 0x2ad00
movl 0x6c(%rbx), %r13d
movl %ecx, %r12d
cmpl %r13d, %r12d
jg 0x2ada7
callq 0x1f148
movq %rax, %r14
movq 0x60(%rbx), %r15
movq -0x38(%rbp), %rdi
movl %r13d, %esi
callq 0x220a4
movsd (%rax), %xmm0
movsd 0x8(%rax), %xmm1
movq %r14, %rdi
movq %r15, %rsi
movl -0x30(%rbp), %edx
xorl %ecx, %ecx
callq 0x2100c
addl -0x2c(%rbp), %eax
movl 0x6c(%rbx), %ecx
cmpl %r13d, %eax
jle 0x2ada2
decl %ecx
movl %ecx, 0x6c(%rbx)
leal -0x1(%r13), %eax
cmpl %r12d, %r13d
movl %eax, %r13d
jg 0x2ad55
cmpl %ecx, 0x68(%rbx)
jle 0x2adae
movl $0x1, 0x4(%rbx)
movl 0x70(%rbx), %r12d
cmpl $0x32, %r12d
jg 0x2adfd
callq 0x1f148
movq %rax, %r14
movq 0x60(%rbx), %r15
movq -0x38(%rbp), %rdi
movl %r12d, %esi
callq 0x220a4
movsd (%rax), %xmm0
movsd 0x8(%rax), %xmm1
movq %r14, %rdi
movq %r15, %rsi
movl -0x30(%rbp), %edx
xorl %ecx, %ecx
callq 0x2100c
addl -0x2c(%rbp), %eax
cmpl %r12d, %eax
jle 0x2adfd
incl 0x70(%rbx)
incl %r12d
cmpl $0x33, %r12d
jne 0x2adb8
cmpl $0x1, 0x4(%rbx)
jne 0x2ae09
movl 0x70(%rbx), %eax
movl %eax, 0x68(%rbx)
movq -0x38(%rbp), %rdi
movq %rbx, %rsi
addq $0x18, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
jmp 0x2ae24
nop