// File: /workspace/github_cpp_makefile_star2_O2/wrighteagle2d[P]wrighteaglebase/Debug/../src/BehaviorIntercept.cpp
// Function: BehaviorInterceptPlanner::Plan(std::__cxx11::list<ActiveBehavior, std::allocator<ActiveBehavior>>&)
void BehaviorInterceptPlanner::Plan(std::list<ActiveBehavior> &behavior_list) {
  if (mSelfState.IsKickable())
    return;
  PlayMode play_mode = mWorldState.GetPlayMode();
  if (play_mode != PM_Play_On && play_mode != PM_Our_Penalty_Ready &&
      play_mode != PM_Our_Penalty_Taken && play_mode != PM_Opp_Penalty_Taken) {
    return;
  }
  if (!mInterceptInfo.IsPlayerBallInterceptable(mSelfState.GetUnum())) {
    if (mSelfState.IsGoalie()) {
      ActiveBehavior intercept(mAgent, BT_Intercept, BDT_Intercept_Normal);
      Ray a(mBallState.GetPos(), mBallState.GetVel().Dir());
      Line c(ServerParam::instance().ourLeftGoalPost(),
             ServerParam::instance().ourRightGoalPost());
      c.Intersection(a, intercept.mTarget);
      if (intercept.mTarget.Y() <
              ServerParam::instance().ourLeftGoalPost().Y() ||
          intercept.mTarget.Y() >
              ServerParam::instance().ourRightGoalPost().Y()) {
        return;
      } else {
        intercept.mEvaluation =
            Evaluation::instance().EvaluatePosition(intercept.mTarget, true);
        behavior_list.push_back(intercept);
      }
    } else {
      return;
    }
  }

  Rectangular GoalieInterRec = ServerParam::instance().ourGoalArea();
  GoalieInterRec.SetRight(ServerParam::instance().ourPenaltyArea().Right());

  if (mStrategy.GetMyInterCycle() <= mStrategy.GetMinTmInterCycle() &&
      mStrategy.GetMyInterCycle() <= mStrategy.GetSureOppInterCycle() + 1 &&
      (!mSelfState.IsGoalie())) {
    ActiveBehavior intercept(mAgent, BT_Intercept, BDT_Intercept_Normal);

    intercept.mTarget = mStrategy.GetMyInterPos();
    intercept.mEvaluation =
        Evaluation::instance().EvaluatePosition(intercept.mTarget, true);

    behavior_list.push_back(intercept);
  } else if (mPositionInfo.GetClosestOpponentToBall() == 0 ||
             ((mWorldState.GetTeammate(mPositionInfo.GetClosestTeammateToBall())
                   .GetPos() -
               mWorldState.GetOpponent(mPositionInfo.GetClosestOpponentToBall())
                   .GetPos())
                      .Mod() <= 1 &&
              mSelfState.GetUnum() ==
                  mPositionInfo.GetCloseTeammateToBall().at(
                      1))) // 0.4受PlayerSize影响，这里直接使用0.3
  {
    ActiveBehavior intercept(mAgent, BT_Intercept, BDT_Intercept_Normal);
    intercept.mTarget = mStrategy.GetMyInterPos();
    intercept.mEvaluation =
        Evaluation::instance().EvaluatePosition(intercept.mTarget, true);
    behavior_list.push_back(intercept);

  } else if (mSelfState.IsGoalie() &&
             GoalieInterRec.IsWithin(mStrategy.GetMyInterPos())) {
    ActiveBehavior intercept(mAgent, BT_Intercept, BDT_Intercept_Normal);
    intercept.mTarget = mStrategy.GetMyInterPos();
    intercept.mEvaluation =
        Evaluation::instance().EvaluatePosition(intercept.mTarget, true);
    if (mWorldState.GetPlayMode() == PM_Opp_Penalty_Taken) {
      intercept.mEvaluation =
          Evaluation::instance().EvaluatePosition(intercept.mTarget, false);
    }
    behavior_list.push_back(intercept);
  } else if (mSelfState.GetUnum() == mPositionInfo.GetClosestTeammateToBall() &&
             !mSelfState.IsGoalie()) {
    ActiveBehavior intercept(mAgent, BT_Intercept, BDT_Intercept_Normal);
    intercept.mTarget = mStrategy.GetMyInterPos();
    intercept.mEvaluation =
        Evaluation::instance().EvaluatePosition(intercept.mTarget, true);
    behavior_list.push_back(intercept);
  } else if (mPositionInfo.GetClosestTeammateToBall() ==
                 mWorldState.GetTeammateGoalieUnum() &&
             mSelfState.GetUnum() ==
                 mPositionInfo.GetCloseTeammateToBall()[1]) {

    ActiveBehavior intercept(mAgent, BT_Intercept, BDT_Intercept_Normal);
    intercept.mTarget = mStrategy.GetMyInterPos();
    intercept.mEvaluation =
        Evaluation::instance().EvaluatePosition(intercept.mTarget, true);
    behavior_list.push_back(intercept);
  }
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0xf8, %rsp
movq 0x20(%rdi), %rax
cmpb $0x0, 0x128(%rax)
jne 0x143f1
movq %rdi, %r14
movq 0x10(%rdi), %rcx
movl 0x1c(%rcx), %ecx
cmpq $0x33, %rcx
ja 0x143f1
movabsq $0x8000000018002, %rdx  # imm = 0x8000000018002
btq %rcx, %rdx
jae 0x143f1
movq %rsi, %r13
movq 0x30(%r14), %rdi
movl 0x11c(%rax), %esi
callq 0x1450c
testb %al, %al
je 0x140f4
callq 0x3db2c
movups 0x3870(%rax), %xmm0
movupd 0x3880(%rax), %xmm1
movaps %xmm0, -0x60(%rbp)
movapd %xmm1, -0x50(%rbp)
callq 0x3db2c
movsd 0x3838(%rax), %xmm0
movsd %xmm0, -0x58(%rbp)
movq 0x38(%r14), %rdi
movl 0x64(%rdi), %eax
cmpl 0x68(%rdi), %eax
jg 0x13f2d
movl 0x80(%rdi), %ecx
incl %ecx
cmpl %ecx, %eax
jg 0x13f2d
movq 0x20(%r14), %rax
cmpb $0x0, 0x175(%rax)
je 0x14249
movq 0x28(%r14), %rdi
callq 0x12338
testl %eax, %eax
je 0x14344
movq 0x10(%r14), %rbx
movq 0x28(%r14), %rdi
callq 0x114f0
decl %eax
cltq
imulq $0x178, %rax, %r15      # imm = 0x178
movq 0x10(%r14), %r12
movq 0x28(%r14), %rdi
callq 0x12338
decl %eax
cltq
imulq $0x178, %rax, %rax      # imm = 0x178
movsd 0xb0(%rbx,%r15), %xmm0
movsd 0xb8(%rbx,%r15), %xmm1
subsd 0x10d8(%r12,%rax), %xmm0
subsd 0x10e0(%r12,%rax), %xmm1
mulsd %xmm1, %xmm1
mulsd %xmm0, %xmm0
addsd %xmm1, %xmm0
sqrtsd %xmm0, %xmm0
movsd 0x4309a(%rip), %xmm1    # 0x57048
ucomisd %xmm0, %xmm1
jb 0x13fda
movq 0x20(%r14), %rax
movq 0x28(%r14), %rdi
movl 0x11c(%rax), %ebx
callq 0x3c1ae
pushq $0x1
popq %rsi
movq %rax, %rdi
callq 0x14540
cmpl (%rax), %ebx
je 0x14344
movq 0x20(%r14), %rax
cmpb $0x1, 0x175(%rax)
jne 0x142ec
movq 0x38(%r14), %rdi
callq 0x40a6a
leaq -0x108(%rbp), %rsi
movsd %xmm0, (%rsi)
movsd %xmm1, 0x8(%rsi)
movabsq $0x3ed92a737110e454, %rax # imm = 0x3ED92A737110E454
leaq -0x120(%rbp), %rdx
movq %rax, (%rdx)
leaq -0x60(%rbp), %rdi
callq 0x12516
testb %al, %al
je 0x142e8
movq 0x8(%r14), %rax
leaq -0xe0(%rbp), %r15
movl $0x9, -0x28(%r15)
movq %rax, -0x20(%r15)
andq $0x0, -0x18(%r15)
andl $0x0, -0x10(%r15)
andl $0x0, 0x30(%r15)
andq $0x0, 0x38(%r15)
andl $0x0, 0x40(%r15)
andq $0x0, 0x48(%r15)
andl $0x0, 0x50(%r15)
andq $0x0, 0x58(%r15)
andl $0x0, 0x60(%r15)
andq $0x0, 0x68(%r15)
xorpd %xmm0, %xmm0
movupd %xmm0, -0x8(%r15)
movupd %xmm0, 0x8(%r15)
movupd %xmm0, 0x18(%r15)
movb $0x0, 0x28(%r15)
movl $0x1, 0x70(%r15)
andq $0x0, 0x78(%r15)
movq 0x38(%r14), %rdi
callq 0x40a6a
movsd %xmm0, (%r15)
movsd %xmm1, 0x8(%r15)
callq 0x1efde
pushq $0x1
popq %rdx
movq %rax, %rdi
movq %r15, %rsi
callq 0x1f058
movsd %xmm0, -0x18(%r15)
movq 0x10(%r14), %rax
cmpl $0x33, 0x1c(%rax)
jne 0x143e2
callq 0x1efde
movq %rax, %rdi
movq %r15, %rsi
xorl %edx, %edx
callq 0x1f058
movsd %xmm0, -0xf8(%rbp)
jmp 0x143e2
movq 0x20(%r14), %rax
cmpb $0x1, 0x175(%rax)
jne 0x143f1
movq %r13, -0x38(%rbp)
movq 0x8(%r14), %rax
leaq -0xe0(%rbp), %r15
movl $0x9, -0x28(%r15)
movq %rax, -0x20(%r15)
andq $0x0, -0x18(%r15)
andl $0x0, -0x10(%r15)
andl $0x0, 0x30(%r15)
andq $0x0, 0x38(%r15)
andl $0x0, 0x40(%r15)
andq $0x0, 0x48(%r15)
andl $0x0, 0x50(%r15)
andq $0x0, 0x58(%r15)
andl $0x0, 0x60(%r15)
andq $0x0, 0x68(%r15)
xorps %xmm0, %xmm0
movups %xmm0, -0x8(%r15)
movups %xmm0, 0x8(%r15)
movups %xmm0, 0x18(%r15)
movb $0x0, 0x28(%r15)
movl $0x1, 0x70(%r15)
andq $0x0, 0x78(%r15)
movq 0x18(%r14), %rbx
leaq 0x30(%rbx), %rdi
callq 0xcd30
movupd 0x8(%rbx), %xmm1
leaq -0x60(%rbp), %r12
movapd %xmm1, (%r12)
movsd %xmm0, 0x10(%r12)
callq 0x3db2c
leaq 0x3910(%rax), %r13
callq 0x3db2c
leaq 0x3920(%rax), %rdx
leaq -0x120(%rbp), %rbx
movq %rbx, %rdi
movq %r13, %rsi
callq 0x12e9a
movq %rbx, %rdi
movq %r12, %rsi
movq %r15, %rdx
callq 0x23916
movsd 0x8(%r15), %xmm0
movsd %xmm0, -0x30(%rbp)
callq 0x3db2c
movsd 0x3918(%rax), %xmm0
ucomisd -0x30(%rbp), %xmm0
ja 0x143f1
movsd -0xd8(%rbp), %xmm0
movsd %xmm0, -0x30(%rbp)
callq 0x3db2c
movsd -0x30(%rbp), %xmm0
ucomisd 0x3928(%rax), %xmm0
ja 0x143f1
callq 0x1efde
pushq $0x1
popq %rdx
movq %rax, %rdi
movq %r15, %rsi
callq 0x1f058
leaq -0x108(%rbp), %rsi
movsd %xmm0, 0x10(%rsi)
movq -0x38(%rbp), %r13
movq %r13, %rdi
callq 0x10530
jmp 0x13ed5
movq 0x8(%r14), %rax
leaq -0xe0(%rbp), %r14
movl $0x9, -0x28(%r14)
movq %rax, -0x20(%r14)
andq $0x0, -0x18(%r14)
andl $0x0, -0x10(%r14)
andl $0x0, 0x30(%r14)
andq $0x0, 0x38(%r14)
andl $0x0, 0x40(%r14)
andq $0x0, 0x48(%r14)
andl $0x0, 0x50(%r14)
andq $0x0, 0x58(%r14)
andl $0x0, 0x60(%r14)
andq $0x0, 0x68(%r14)
xorpd %xmm0, %xmm0
movupd %xmm0, -0x8(%r14)
movupd %xmm0, 0x8(%r14)
movupd %xmm0, 0x18(%r14)
movb $0x0, 0x28(%r14)
movl $0x1, 0x70(%r14)
andq $0x0, 0x78(%r14)
callq 0x40a6a
movsd %xmm0, (%r14)
movsd %xmm1, 0x8(%r14)
callq 0x1efde
pushq $0x1
popq %rdx
movq %rax, %rdi
movq %r14, %rsi
callq 0x1f058
movsd %xmm0, -0x18(%r14)
jmp 0x143e2
movq 0x20(%r14), %rax
movl 0x11c(%rax), %ebx
movq 0x28(%r14), %rdi
callq 0x114f0
cmpl %eax, %ebx
jne 0x1430c
movq 0x20(%r14), %rax
cmpb $0x0, 0x175(%rax)
je 0x14344
movq 0x28(%r14), %rdi
callq 0x114f0
movq 0x10(%r14), %rcx
cmpl 0x2110(%rcx), %eax
jne 0x143f1
movq 0x20(%r14), %rax
movq 0x28(%r14), %rdi
movl 0x11c(%rax), %ebx
callq 0x3c1ae
movq (%rax), %rax
cmpl 0x4(%rax), %ebx
jne 0x143f1
movq 0x8(%r14), %rax
leaq -0xe0(%rbp), %r15
movl $0x9, -0x28(%r15)
movq %rax, -0x20(%r15)
andq $0x0, -0x18(%r15)
andl $0x0, -0x10(%r15)
andl $0x0, 0x30(%r15)
andq $0x0, 0x38(%r15)
andl $0x0, 0x40(%r15)
andq $0x0, 0x48(%r15)
andl $0x0, 0x50(%r15)
andq $0x0, 0x58(%r15)
andl $0x0, 0x60(%r15)
andq $0x0, 0x68(%r15)
xorpd %xmm0, %xmm0
movupd %xmm0, -0x8(%r15)
movupd %xmm0, 0x8(%r15)
movupd %xmm0, 0x18(%r15)
movb $0x0, 0x28(%r15)
movl $0x1, 0x70(%r15)
andq $0x0, 0x78(%r15)
movq 0x38(%r14), %rdi
callq 0x40a6a
movsd %xmm0, (%r15)
movsd %xmm1, 0x8(%r15)
callq 0x1efde
pushq $0x1
popq %rdx
movq %rax, %rdi
movq %r15, %rsi
callq 0x1f058
movsd %xmm0, -0x18(%r15)
leaq -0x108(%rbp), %rsi
movq %r13, %rdi
callq 0x10530
addq $0xf8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
nop