// File: 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
subq $0x180, %rsp            # imm = 0x180
movb %dl, %al
movq %rdi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
andb $0x1, %al
movb %al, -0x11(%rbp)
movq -0x8(%rbp), %rax
movq %rax, -0x128(%rbp)
movq -0x10(%rbp), %rax
movq %rax, -0x120(%rbp)
movq -0x10(%rbp), %rax
movq 0x60(%rax), %rdi
movq (%rdi), %rax
callq *0x10(%rax)
movq -0x128(%rbp), %rdi
movq -0x120(%rbp), %rsi
movq %rax, %rdx
callq 0x4a320
movq -0x10(%rbp), %rax
movq 0x60(%rax), %rdi
callq 0x10f70
movl %eax, -0x18(%rbp)
movq -0x10(%rbp), %rax
cmpl $0x1, 0x4(%rax)
jne 0x49dd9
movq -0x10(%rbp), %rdi
addq $0x68, %rdi
movq $0x0, -0x28(%rbp)
leaq -0x28(%rbp), %rsi
callq 0x4aaa0
movl (%rax), %eax
movl %eax, -0x1c(%rbp)
movl $0x32, -0x2c(%rbp)
movl -0x1c(%rbp), %eax
movl %eax, -0x30(%rbp)
movl -0x30(%rbp), %eax
cmpl -0x2c(%rbp), %eax
jg 0x49dd4
callq 0x2ec90
movq %rax, -0x138(%rbp)
movq -0x10(%rbp), %rax
movq 0x60(%rax), %rax
movq %rax, -0x130(%rbp)
movq -0x8(%rbp), %rdi
movl -0x30(%rbp), %esi
callq 0x11fc0
movq -0x138(%rbp), %rdi
movq -0x130(%rbp), %rsi
movq (%rax), %rcx
movq %rcx, -0x48(%rbp)
movq 0x8(%rax), %rax
movq %rax, -0x40(%rbp)
movb -0x11(%rbp), %al
movsd -0x48(%rbp), %xmm0
movsd -0x40(%rbp), %xmm1
xorl %ecx, %ecx
andb $0x1, %al
movzbl %al, %edx
callq 0x31070
addl -0x18(%rbp), %eax
movl %eax, -0x34(%rbp)
movl -0x34(%rbp), %eax
cmpl -0x30(%rbp), %eax
jg 0x49da6
jmp 0x49dd4
movq -0x10(%rbp), %rdi
addq $0x68, %rdi
movq $0x0, -0x50(%rbp)
leaq -0x50(%rbp), %rsi
callq 0x4aaa0
movl (%rax), %ecx
addl $0x1, %ecx
movl %ecx, (%rax)
movl -0x30(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x30(%rbp)
jmp 0x49d2d
jmp 0x4a20b
movq -0x10(%rbp), %rdi
addq $0x68, %rdi
movq $0x0, -0x60(%rbp)
leaq -0x60(%rbp), %rsi
callq 0x4aaa0
movl (%rax), %eax
movl %eax, -0x54(%rbp)
movq -0x10(%rbp), %rdi
addq $0x68, %rdi
movq $0x1, -0x70(%rbp)
leaq -0x70(%rbp), %rsi
callq 0x4aaa0
movl (%rax), %eax
movl %eax, -0x64(%rbp)
movl -0x54(%rbp), %eax
movl %eax, -0x74(%rbp)
movl -0x74(%rbp), %eax
cmpl -0x64(%rbp), %eax
jg 0x49ece
callq 0x2ec90
movq %rax, -0x148(%rbp)
movq -0x10(%rbp), %rax
movq 0x60(%rax), %rax
movq %rax, -0x140(%rbp)
movq -0x8(%rbp), %rdi
movl -0x74(%rbp), %esi
callq 0x11fc0
movq -0x148(%rbp), %rdi
movq -0x140(%rbp), %rsi
movq (%rax), %rcx
movq %rcx, -0x88(%rbp)
movq 0x8(%rax), %rax
movq %rax, -0x80(%rbp)
movb -0x11(%rbp), %al
movsd -0x88(%rbp), %xmm0
movsd -0x80(%rbp), %xmm1
xorl %ecx, %ecx
andb $0x1, %al
movzbl %al, %edx
callq 0x31070
addl -0x18(%rbp), %eax
movl %eax, -0x78(%rbp)
movl -0x78(%rbp), %eax
cmpl -0x74(%rbp), %eax
jg 0x49e9a
jmp 0x49ece
movq -0x10(%rbp), %rdi
addq $0x68, %rdi
movq $0x0, -0x90(%rbp)
leaq -0x90(%rbp), %rsi
callq 0x4aaa0
movl (%rax), %ecx
addl $0x1, %ecx
movl %ecx, (%rax)
movl -0x74(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x74(%rbp)
jmp 0x49e1b
movq -0x10(%rbp), %rdi
addq $0x68, %rdi
movq $0x0, -0x98(%rbp)
leaq -0x98(%rbp), %rsi
callq 0x4aaa0
movl (%rax), %eax
movl %eax, -0x14c(%rbp)
movq -0x10(%rbp), %rdi
addq $0x68, %rdi
movq $0x1, -0xa0(%rbp)
leaq -0xa0(%rbp), %rsi
callq 0x4aaa0
movq %rax, %rcx
movl -0x14c(%rbp), %eax
cmpl (%rcx), %eax
jg 0x4a0a4
movq -0x10(%rbp), %rdi
addq $0x68, %rdi
movq $0x0, -0xa8(%rbp)
leaq -0xa8(%rbp), %rsi
callq 0x4aaa0
movl (%rax), %eax
movl %eax, -0x54(%rbp)
movq -0x10(%rbp), %rdi
addq $0x68, %rdi
movq $0x1, -0xb0(%rbp)
leaq -0xb0(%rbp), %rsi
callq 0x4aaa0
movl (%rax), %eax
movl %eax, -0x64(%rbp)
movl -0x64(%rbp), %eax
movl %eax, -0xb4(%rbp)
movl -0xb4(%rbp), %eax
cmpl -0x54(%rbp), %eax
jl 0x4a044
callq 0x2ec90
movq %rax, -0x160(%rbp)
movq -0x10(%rbp), %rax
movq 0x60(%rax), %rax
movq %rax, -0x158(%rbp)
movq -0x8(%rbp), %rdi
movl -0xb4(%rbp), %esi
callq 0x11fc0
movq -0x160(%rbp), %rdi
movq -0x158(%rbp), %rsi
movq (%rax), %rcx
movq %rcx, -0xc8(%rbp)
movq 0x8(%rax), %rax
movq %rax, -0xc0(%rbp)
movb -0x11(%rbp), %al
movsd -0xc8(%rbp), %xmm0
movsd -0xc0(%rbp), %xmm1
xorl %ecx, %ecx
andb $0x1, %al
movzbl %al, %edx
callq 0x31070
addl -0x18(%rbp), %eax
movl %eax, -0xb8(%rbp)
movl -0xb8(%rbp), %eax
cmpl -0xb4(%rbp), %eax
jg 0x4a00a
jmp 0x4a044
movq -0x10(%rbp), %rdi
addq $0x68, %rdi
movq $0x1, -0xd0(%rbp)
leaq -0xd0(%rbp), %rsi
callq 0x4aaa0
movl (%rax), %ecx
addl $-0x1, %ecx
movl %ecx, (%rax)
movl -0xb4(%rbp), %eax
addl $-0x1, %eax
movl %eax, -0xb4(%rbp)
jmp 0x49f76
movq -0x10(%rbp), %rdi
addq $0x68, %rdi
movq $0x0, -0xd8(%rbp)
leaq -0xd8(%rbp), %rsi
callq 0x4aaa0
movl (%rax), %eax
movl %eax, -0x164(%rbp)
movq -0x10(%rbp), %rdi
addq $0x68, %rdi
movq $0x1, -0xe0(%rbp)
leaq -0xe0(%rbp), %rsi
callq 0x4aaa0
movq %rax, %rcx
movl -0x164(%rbp), %eax
cmpl (%rcx), %eax
jle 0x4a0a2
movq -0x10(%rbp), %rax
movl $0x1, 0x4(%rax)
jmp 0x4a0af
movq -0x10(%rbp), %rax
movl $0x1, 0x4(%rax)
movq -0x10(%rbp), %rdi
addq $0x68, %rdi
movq $0x2, -0xe8(%rbp)
leaq -0xe8(%rbp), %rsi
callq 0x4aaa0
movl (%rax), %eax
movl %eax, -0x54(%rbp)
movl $0x32, -0x64(%rbp)
movl -0x54(%rbp), %eax
movl %eax, -0xec(%rbp)
movl -0xec(%rbp), %eax
cmpl -0x64(%rbp), %eax
jg 0x4a1b1
callq 0x2ec90
movq %rax, -0x178(%rbp)
movq -0x10(%rbp), %rax
movq 0x60(%rax), %rax
movq %rax, -0x170(%rbp)
movq -0x8(%rbp), %rdi
movl -0xec(%rbp), %esi
callq 0x11fc0
movq -0x178(%rbp), %rdi
movq -0x170(%rbp), %rsi
movq (%rax), %rcx
movq %rcx, -0x100(%rbp)
movq 0x8(%rax), %rax
movq %rax, -0xf8(%rbp)
movb -0x11(%rbp), %al
movsd -0x100(%rbp), %xmm0
movsd -0xf8(%rbp), %xmm1
xorl %ecx, %ecx
andb $0x1, %al
movzbl %al, %edx
callq 0x31070
addl -0x18(%rbp), %eax
movl %eax, -0xf0(%rbp)
movl -0xf0(%rbp), %eax
cmpl -0xec(%rbp), %eax
jg 0x4a177
jmp 0x4a1b1
movq -0x10(%rbp), %rdi
addq $0x68, %rdi
movq $0x2, -0x108(%rbp)
leaq -0x108(%rbp), %rsi
callq 0x4aaa0
movl (%rax), %ecx
addl $0x1, %ecx
movl %ecx, (%rax)
movl -0xec(%rbp), %eax
addl $0x1, %eax
movl %eax, -0xec(%rbp)
jmp 0x4a0e3
movq -0x10(%rbp), %rax
cmpl $0x1, 0x4(%rax)
jne 0x4a209
movq -0x10(%rbp), %rdi
addq $0x68, %rdi
movq $0x2, -0x110(%rbp)
leaq -0x110(%rbp), %rsi
callq 0x4aaa0
movl (%rax), %eax
movl %eax, -0x17c(%rbp)
movq -0x10(%rbp), %rdi
addq $0x68, %rdi
movq $0x0, -0x118(%rbp)
leaq -0x118(%rbp), %rsi
callq 0x4aaa0
movl -0x17c(%rbp), %ecx
movl %ecx, (%rax)
jmp 0x4a20b
movq -0x8(%rbp), %rdi
movq -0x10(%rbp), %rsi
callq 0x4a230
addq $0x180, %rsp            # imm = 0x180
popq %rbp
retq
nopw %cs:(%rax,%rax)