// File: wrighteagle2d[P]wrighteaglebase/Debug/../src/BehaviorDribble.cpp
// Function: BehaviorDribblePlanner::Plan(std::__cxx11::list<ActiveBehavior, std::allocator<ActiveBehavior>>&)
void BehaviorDribblePlanner::Plan(std::list<ActiveBehavior> &behavior_list) {
  if (!mSelfState.IsKickable())
    return;
  if (mStrategy.IsForbidenDribble())
    return;
  if (mSelfState.IsGoalie())
    return;

  for (AngleDeg dir = -90.0; dir < 90.0; dir += 2.5) {
    ActiveBehavior dribble(mAgent, BT_Dribble, BDT_Dribble_Normal);

    dribble.mAngle = dir;

    const std::vector<Unum> &opp2ball = mPositionInfo.GetCloseOpponentToBall();
    AngleDeg min_differ = HUGE_VALUE;

    for (uint j = 0; j < opp2ball.size(); ++j) {
      Vector rel_pos =
          mWorldState.GetOpponent(opp2ball[j]).GetPos() - mBallState.GetPos();
      if (rel_pos.Mod() > 15.0)
        continue;

      AngleDeg differ = GetAngleDegDiffer(dir, rel_pos.Dir());
      if (differ < min_differ) {
        min_differ = differ;
      }
    }

    if (min_differ < 10.0)
      continue;

    dribble.mTarget = mSelfState.GetPos() +
                      Polar2Vector(mSelfState.GetEffectiveSpeedMax(), dir);

    dribble.mEvaluation =
        Evaluation::instance().EvaluatePosition(dribble.mTarget, true);

    mActiveBehaviorList.push_back(dribble);
  }
  double speed = mSelfState.GetEffectiveSpeedMax();

  for (AngleDeg dir = -90.0; dir < 90.0; dir += 2.5) {
    ActiveBehavior dribble(mAgent, BT_Dribble, BDT_Dribble_Fast);
    dribble.mKickSpeed = speed;
    dribble.mAngle = dir;

    const std::vector<Unum> &opp2ball = mPositionInfo.GetCloseOpponentToBall();
    Vector target = mBallState.GetPos() +
                    Polar2Vector(dribble.mKickSpeed * 10, dribble.mAngle);
    if (!ServerParam::instance().pitchRectanglar().IsWithin(target)) {
      continue;
    }
    bool ok = true;
    for (uint j = 0; j < opp2ball.size(); ++j) {
      Vector rel_pos = mWorldState.GetOpponent(opp2ball[j]).GetPos() - target;
      if (rel_pos.Mod() < dribble.mKickSpeed * 12 ||
          mWorldState.GetOpponent(opp2ball[j]).GetPosConf() <
              PlayerParam::instance().minValidConf()) {
        ok = false;
        break;
      }
    }
    if (!ok) {
      continue;
    }
    dribble.mEvaluation = 0;
    for (int i = 1; i <= 8; ++i) {
      dribble.mEvaluation += Evaluation::instance().EvaluatePosition(
          mBallState.GetPos() +
              Polar2Vector(dribble.mKickSpeed * i, dribble.mAngle),
          true);
    }
    dribble.mEvaluation /= 8;
    dribble.mTarget = target;

    mActiveBehaviorList.push_back(dribble);
  }

  if (!mActiveBehaviorList.empty()) {
    mActiveBehaviorList.sort(std::greater<ActiveBehavior>());
    behavior_list.push_back(mActiveBehaviorList.front());
  }
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x2c0, %rsp            # imm = 0x2C0
movq %rdi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
movq -0x8(%rbp), %rax
movq %rax, -0x260(%rbp)
movq 0x20(%rax), %rdi
callq 0x10ef0
testb $0x1, %al
jne 0x1cb00
jmp 0x1d230
movq -0x260(%rbp), %rax
movq 0x38(%rax), %rdi
callq 0x1d760
testb $0x1, %al
jne 0x1cb16
jmp 0x1cb1b
jmp 0x1d230
movq -0x260(%rbp), %rax
movq 0x20(%rax), %rdi
callq 0x1d780
testb $0x1, %al
jne 0x1cb31
jmp 0x1cb36
jmp 0x1d230
movsd 0xa4bb2(%rip), %xmm0    # 0xc16f0
movsd %xmm0, -0x18(%rbp)
movsd 0xa44f5(%rip), %xmm0    # 0xc1040
ucomisd -0x18(%rbp), %xmm0
jbe 0x1cdd6
movq -0x260(%rbp), %rax
movq 0x8(%rax), %rsi
leaq -0xc0(%rbp), %rdi
movl $0x5, %edx
movl $0x6, %ecx
callq 0x1b4d0
movq -0x260(%rbp), %rax
movsd -0x18(%rbp), %xmm0
movsd %xmm0, -0xa0(%rbp)
movq 0x28(%rax), %rdi
callq 0x80370
movq %rax, -0xc8(%rbp)
movsd 0xa4b75(%rip), %xmm0    # 0xc1718
movsd %xmm0, -0xd0(%rbp)
movl $0x0, -0xd4(%rbp)
movl -0xd4(%rbp), %eax
movq %rax, -0x268(%rbp)
movq -0xc8(%rbp), %rdi
callq 0x1d7a0
movq %rax, %rcx
movq -0x268(%rbp), %rax
cmpq %rcx, %rax
jae 0x1cce3
movq -0x260(%rbp), %rax
movq 0x10(%rax), %rax
movq %rax, -0x278(%rbp)
movq -0xc8(%rbp), %rdi
movl -0xd4(%rbp), %eax
movl %eax, %esi
callq 0x1b610
movq -0x278(%rbp), %rdi
movq %rax, %rsi
callq 0x1d480
movq %rax, %rdi
addq $0x8, %rdi
callq 0x11090
movq %rax, %rcx
movq -0x260(%rbp), %rax
movq %rcx, -0x270(%rbp)
movq 0x18(%rax), %rdi
addq $0x8, %rdi
callq 0x11090
movq -0x270(%rbp), %rdi
movq %rax, %rsi
callq 0x110a0
movsd %xmm0, -0xe8(%rbp)
movsd %xmm1, -0xe0(%rbp)
leaq -0xe8(%rbp), %rdi
callq 0x104e0
movsd 0xa4aad(%rip), %xmm1    # 0xc1720
ucomisd %xmm1, %xmm0
jbe 0x1cc7b
jmp 0x1cccf
leaq -0xe8(%rbp), %rdi
callq 0x10520
movsd %xmm0, -0xf8(%rbp)
leaq -0x18(%rbp), %rdi
leaq -0xf8(%rbp), %rsi
callq 0x1d7c0
movsd %xmm0, -0xf0(%rbp)
movsd -0xf0(%rbp), %xmm1
movsd -0xd0(%rbp), %xmm0
ucomisd %xmm1, %xmm0
jbe 0x1cccd
movsd -0xf0(%rbp), %xmm0
movsd %xmm0, -0xd0(%rbp)
jmp 0x1cccf
movl -0xd4(%rbp), %eax
addl $0x1, %eax
movl %eax, -0xd4(%rbp)
jmp 0x1cbb5
movsd 0xa4a0d(%rip), %xmm0    # 0xc16f8
ucomisd -0xd0(%rbp), %xmm0
jbe 0x1ccfa
jmp 0x1cdbf
movq -0x260(%rbp), %rax
movq 0x20(%rax), %rdi
addq $0x8, %rdi
callq 0x11090
movq %rax, %rcx
movq -0x260(%rbp), %rax
movq %rcx, -0x280(%rbp)
movq 0x20(%rax), %rdi
callq 0x1d810
movq %rax, %rdi
leaq -0x18(%rbp), %rsi
callq 0x112c0
movq -0x280(%rbp), %rdi
movsd %xmm0, -0x118(%rbp)
movsd %xmm1, -0x110(%rbp)
leaq -0x118(%rbp), %rsi
callq 0x11360
movsd %xmm0, -0x108(%rbp)
movsd %xmm1, -0x100(%rbp)
movq -0x108(%rbp), %rax
movq %rax, -0x98(%rbp)
movq -0x100(%rbp), %rax
movq %rax, -0x90(%rbp)
callq 0x38230
movq %rax, %rdi
leaq -0xc0(%rbp), %rsi
addq $0x28, %rsi
movl $0x1, %edx
callq 0x382c0
movq -0x260(%rbp), %rdi
movsd %xmm0, -0xb0(%rbp)
addq $0x48, %rdi
leaq -0xc0(%rbp), %rsi
callq 0x189a0
movsd 0xa4949(%rip), %xmm0    # 0xc1710
addsd -0x18(%rbp), %xmm0
movsd %xmm0, -0x18(%rbp)
jmp 0x1cb43
movq -0x260(%rbp), %rax
movq 0x20(%rax), %rdi
callq 0x1d810
movsd (%rax), %xmm0
movsd %xmm0, -0x120(%rbp)
movsd 0xa48f6(%rip), %xmm0    # 0xc16f0
movsd %xmm0, -0x128(%rbp)
movsd 0xa4236(%rip), %xmm0    # 0xc1040
ucomisd -0x128(%rbp), %xmm0
jbe 0x1d1e2
movq -0x260(%rbp), %rax
movq 0x8(%rax), %rsi
leaq -0x1d0(%rbp), %rdi
movl $0x5, %ecx
movl %ecx, %edx
callq 0x1b4d0
movq -0x260(%rbp), %rax
movsd -0x120(%rbp), %xmm0
movsd %xmm0, -0x188(%rbp)
movsd -0x128(%rbp), %xmm0
movsd %xmm0, -0x1b0(%rbp)
movq 0x28(%rax), %rdi
callq 0x80370
movq %rax, %rcx
movq -0x260(%rbp), %rax
movq %rcx, -0x1d8(%rbp)
movq 0x18(%rax), %rdi
addq $0x8, %rdi
callq 0x11090
movq %rax, -0x288(%rbp)
movsd 0xa4865(%rip), %xmm0    # 0xc16f8
mulsd -0x188(%rbp), %xmm0
movsd %xmm0, -0x200(%rbp)
leaq -0x1d0(%rbp), %rsi
addq $0x20, %rsi
leaq -0x200(%rbp), %rdi
callq 0x112c0
movq -0x288(%rbp), %rdi
movsd %xmm0, -0x1f8(%rbp)
movsd %xmm1, -0x1f0(%rbp)
leaq -0x1f8(%rbp), %rsi
callq 0x11360
movsd %xmm0, -0x1e8(%rbp)
movsd %xmm1, -0x1e0(%rbp)
callq 0x855e0
movq %rax, %rdi
callq 0x1d830
movq %rax, %rdi
movsd 0xa4103(%rip), %xmm0    # 0xc1008
movsd %xmm0, -0x208(%rbp)
leaq -0x1e8(%rbp), %rsi
leaq -0x208(%rbp), %rdx
callq 0x1d850
xorb $-0x1, %al
testb $0x1, %al
jne 0x1cf28
jmp 0x1cf2d
jmp 0x1d1c5
movb $0x1, -0x209(%rbp)
movl $0x0, -0x210(%rbp)
movl -0x210(%rbp), %eax
movq %rax, -0x290(%rbp)
movq -0x1d8(%rbp), %rdi
callq 0x1d7a0
movq %rax, %rcx
movq -0x290(%rbp), %rax
cmpq %rcx, %rax
jae 0x1d07a
movq -0x260(%rbp), %rax
movq 0x10(%rax), %rax
movq %rax, -0x298(%rbp)
movq -0x1d8(%rbp), %rdi
movl -0x210(%rbp), %eax
movl %eax, %esi
callq 0x1b610
movq -0x298(%rbp), %rdi
movq %rax, %rsi
callq 0x1d480
movq %rax, %rdi
addq $0x8, %rdi
callq 0x11090
movq %rax, %rdi
leaq -0x1e8(%rbp), %rsi
callq 0x110a0
movsd %xmm0, -0x220(%rbp)
movsd %xmm1, -0x218(%rbp)
leaq -0x220(%rbp), %rdi
callq 0x104e0
movaps %xmm0, %xmm1
movsd 0xa471f(%rip), %xmm0    # 0xc1700
mulsd -0x188(%rbp), %xmm0
ucomisd %xmm1, %xmm0
ja 0x1d05b
movq -0x260(%rbp), %rax
movq 0x10(%rax), %rax
movq %rax, -0x2a8(%rbp)
movq -0x1d8(%rbp), %rdi
movl -0x210(%rbp), %eax
movl %eax, %esi
callq 0x1b610
movq -0x2a8(%rbp), %rdi
movq %rax, %rsi
callq 0x1d480
movq %rax, %rdi
addq $0x8, %rdi
callq 0x1d930
movsd (%rax), %xmm0
movsd %xmm0, -0x2a0(%rbp)
callq 0x798a0
movq %rax, %rdi
callq 0x1d950
movsd -0x2a0(%rbp), %xmm1
movsd (%rax), %xmm0
ucomisd %xmm1, %xmm0
jbe 0x1d064
movb $0x0, -0x209(%rbp)
jmp 0x1d07a
jmp 0x1d066
movl -0x210(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x210(%rbp)
jmp 0x1cf3e
testb $0x1, -0x209(%rbp)
jne 0x1d088
jmp 0x1d1c5
xorps %xmm0, %xmm0
movsd %xmm0, -0x1c0(%rbp)
movl $0x1, -0x224(%rbp)
cmpl $0x8, -0x224(%rbp)
jg 0x1d176
callq 0x38230
movq %rax, %rcx
movq -0x260(%rbp), %rax
movq %rcx, -0x2b0(%rbp)
movq 0x18(%rax), %rdi
addq $0x8, %rdi
callq 0x11090
movq %rax, -0x2b8(%rbp)
movsd -0x188(%rbp), %xmm0
cvtsi2sdl -0x224(%rbp), %xmm1
mulsd %xmm1, %xmm0
movsd %xmm0, -0x250(%rbp)
leaq -0x1d0(%rbp), %rsi
addq $0x20, %rsi
leaq -0x250(%rbp), %rdi
callq 0x112c0
movq -0x2b8(%rbp), %rdi
movsd %xmm0, -0x248(%rbp)
movsd %xmm1, -0x240(%rbp)
leaq -0x248(%rbp), %rsi
callq 0x11360
movq -0x2b0(%rbp), %rdi
movsd %xmm0, -0x238(%rbp)
movsd %xmm1, -0x230(%rbp)
leaq -0x238(%rbp), %rsi
movl $0x1, %edx
callq 0x382c0
addsd -0x1c0(%rbp), %xmm0
movsd %xmm0, -0x1c0(%rbp)
movl -0x224(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x224(%rbp)
jmp 0x1d09d
movq -0x260(%rbp), %rdi
movsd -0x1c0(%rbp), %xmm0
movsd 0xa457b(%rip), %xmm1    # 0xc1708
divsd %xmm1, %xmm0
movsd %xmm0, -0x1c0(%rbp)
movq -0x1e8(%rbp), %rax
movq %rax, -0x1a8(%rbp)
movq -0x1e0(%rbp), %rax
movq %rax, -0x1a0(%rbp)
addq $0x48, %rdi
leaq -0x1d0(%rbp), %rsi
callq 0x189a0
movsd 0xa4543(%rip), %xmm0    # 0xc1710
addsd -0x128(%rbp), %xmm0
movsd %xmm0, -0x128(%rbp)
jmp 0x1ce02
movq -0x260(%rbp), %rdi
addq $0x48, %rdi
callq 0x18580
testb $0x1, %al
jne 0x1d230
movq -0x260(%rbp), %rdi
addq $0x48, %rdi
callq 0x185a0
movq -0x260(%rbp), %rdi
movq -0x10(%rbp), %rax
movq %rax, -0x2c0(%rbp)
addq $0x48, %rdi
callq 0x189e0
movq -0x2c0(%rbp), %rdi
movq %rax, %rsi
callq 0x189a0
addq $0x2c0, %rsp            # imm = 0x2C0
popq %rbp
retq
nopl (%rax)