// File: /workspace/github_cpp_makefile_star2_O2/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
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0xf8, %rsp
movq 0x20(%rdi), %rax
cmpb $0x1, 0x128(%rax)
jne 0x121f3
movq %rdi, %r14
movq 0x38(%rdi), %rcx
cmpb $0x0, 0xa8(%rcx)
jne 0x121f3
cmpb $0x0, 0x175(%rax)
jne 0x121f3
movq %rsi, -0x110(%rbp)
leaq 0x48(%r14), %rax
movq %rax, -0x48(%rbp)
movsd 0x45355(%rip), %xmm0    # 0x57090
leaq -0x58(%rbp), %r15
leaq -0x60(%rbp), %r12
movsd %xmm0, -0x58(%rbp)
movsd 0x45338(%rip), %xmm1    # 0x57088
ucomisd %xmm0, %xmm1
jbe 0x11f0b
movq 0x8(%r14), %rax
movl $0x5, -0x108(%rbp)
movq %rax, -0x100(%rbp)
andq $0x0, -0xf8(%rbp)
andl $0x0, -0xf0(%rbp)
andl $0x0, -0xb0(%rbp)
andq $0x0, -0xa8(%rbp)
andl $0x0, -0xa0(%rbp)
andq $0x0, -0x98(%rbp)
andl $0x0, -0x90(%rbp)
andq $0x0, -0x88(%rbp)
andl $0x0, -0x80(%rbp)
andq $0x0, -0x78(%rbp)
leaq -0xe0(%rbp), %rax
xorpd %xmm1, %xmm1
movupd %xmm1, 0x19(%rax)
movupd %xmm1, 0x10(%rax)
movupd %xmm1, (%rax)
movl $0x6, -0x70(%rbp)
andq $0x0, -0x68(%rbp)
movsd %xmm0, -0xe8(%rbp)
movq 0x28(%r14), %rdi
callq 0x3c206
movq %rax, %r13
xorl %ebx, %ebx
movsd 0x45951(%rip), %xmm2    # 0x57748
movl %ebx, %ebx
movq (%r13), %rax
movq 0x8(%r13), %rcx
subq %rax, %rcx
sarq $0x2, %rcx
cmpq %rbx, %rcx
jbe 0x11e92
movslq (%rax,%rbx,4), %rax
movq 0x10(%r14), %rcx
movq 0x18(%r14), %rdx
imulq $0x178, %rax, %rax      # imm = 0x178
movsd 0xf60(%rax,%rcx), %xmm0
movsd 0xf68(%rax,%rcx), %xmm1
subsd 0x8(%rdx), %xmm0
subsd 0x10(%rdx), %xmm1
movsd %xmm0, -0x40(%rbp)
movsd %xmm1, -0x38(%rbp)
mulsd %xmm1, %xmm1
mulsd %xmm0, %xmm0
addsd %xmm1, %xmm0
sqrtsd %xmm0, %xmm0
ucomisd 0x458ee(%rip), %xmm0    # 0x57750
ja 0x11e8b
leaq -0x40(%rbp), %rdi
movsd %xmm2, -0x30(%rbp)
callq 0xcd30
movsd %xmm0, -0x60(%rbp)
movq %r15, %rdi
movq %r12, %rsi
callq 0x124e1
minsd -0x30(%rbp), %xmm0
movapd %xmm0, %xmm2
incl %ebx
jmp 0x11df7
movsd 0x4588e(%rip), %xmm0    # 0x57728
ucomisd %xmm2, %xmm0
ja 0x11ef9
movq 0x20(%r14), %rbx
leaq 0x60(%rbx), %rdi
movq %r15, %rsi
callq 0xd15b
addsd 0x8(%rbx), %xmm0
addsd 0x10(%rbx), %xmm1
movsd %xmm0, -0xe0(%rbp)
movsd %xmm1, -0xd8(%rbp)
callq 0x1efde
movq %rax, %rdi
leaq -0xe0(%rbp), %rsi
pushq $0x1
popq %rdx
callq 0x1f058
movsd %xmm0, -0xf8(%rbp)
movq -0x48(%rbp), %rdi
leaq -0x108(%rbp), %rsi
callq 0x10530
movsd -0x58(%rbp), %xmm0
addsd 0x4583a(%rip), %xmm0    # 0x57740
jmp 0x11d43
movq 0x20(%r14), %rax
movsd 0x60(%rax), %xmm0
movsd %xmm0, -0x118(%rbp)
movsd 0x4516c(%rip), %xmm1    # 0x57090
leaq -0x58(%rbp), %rbx
movsd 0x45158(%rip), %xmm0    # 0x57088
ucomisd %xmm1, %xmm0
jbe 0x121cc
movq 0x8(%r14), %rax
pushq $0x5
popq %rcx
movl %ecx, -0x108(%rbp)
movq %rax, -0x100(%rbp)
andq $0x0, -0xf8(%rbp)
andl $0x0, -0xf0(%rbp)
andl $0x0, -0xb0(%rbp)
andq $0x0, -0xa8(%rbp)
andl $0x0, -0xa0(%rbp)
andq $0x0, -0x98(%rbp)
andl $0x0, -0x90(%rbp)
andq $0x0, -0x88(%rbp)
andl $0x0, -0x80(%rbp)
andq $0x0, -0x78(%rbp)
leaq -0xe0(%rbp), %rax
xorpd %xmm0, %xmm0
movupd %xmm0, 0x19(%rax)
movupd %xmm0, 0x10(%rax)
movupd %xmm0, (%rax)
movl %ecx, -0x70(%rbp)
andq $0x0, -0x68(%rbp)
movsd -0x118(%rbp), %xmm0
movsd %xmm0, -0xc0(%rbp)
movsd %xmm1, -0x120(%rbp)
movsd %xmm1, -0xe8(%rbp)
movq 0x28(%r14), %rdi
callq 0x3c206
movq %rax, %r15
movq 0x18(%r14), %r12
movsd -0xc0(%rbp), %xmm0
mulsd 0x45734(%rip), %xmm0    # 0x57728
movsd %xmm0, -0x58(%rbp)
movq %rbx, %rdi
leaq -0xe8(%rbp), %rsi
callq 0xd15b
addsd 0x8(%r12), %xmm0
addsd 0x10(%r12), %xmm1
movsd %xmm0, -0x40(%rbp)
movsd %xmm1, -0x38(%rbp)
callq 0x3db2c
leaq 0x37f0(%rax), %rdi
movabsq $0x3ed92a737110e454, %rax # imm = 0x3ED92A737110E454
movq %rax, -0x58(%rbp)
leaq -0x40(%rbp), %rsi
movq %rbx, %rdx
callq 0x12516
testb %al, %al
je 0x121b7
xorl %r12d, %r12d
movl %r12d, %r12d
movq (%r15), %rcx
movq 0x8(%r15), %rax
subq %rcx, %rax
sarq $0x2, %rax
cmpq %r12, %rax
jbe 0x120f3
movq 0x10(%r14), %rax
movslq (%rcx,%r12,4), %rcx
imulq $0x178, %rcx, %rcx      # imm = 0x178
movsd 0xf60(%rcx,%rax), %xmm0
movsd 0xf68(%rcx,%rax), %xmm1
subsd -0x40(%rbp), %xmm0
subsd -0x38(%rbp), %xmm1
mulsd %xmm1, %xmm1
mulsd %xmm0, %xmm0
addsd %xmm1, %xmm0
sqrtsd %xmm0, %xmm0
movsd -0xc0(%rbp), %xmm1
mulsd 0x45682(%rip), %xmm1    # 0x57738
ucomisd %xmm0, %xmm1
ja 0x121b7
addq %rcx, %rax
addq $0xf60, %rax            # imm = 0xF60
movsd 0x18(%rax), %xmm0
movsd %xmm0, -0x30(%rbp)
callq 0x38d94
movsd 0x31e8(%rax), %xmm0
incl %r12d
ucomisd -0x30(%rbp), %xmm0
jbe 0x12051
jmp 0x121b7
andq $0x0, -0xf8(%rbp)
xorpd %xmm0, %xmm0
pushq $0x8
popq %r12
movsd 0x44f3d(%rip), %xmm1    # 0x57048
movsd %xmm1, -0x30(%rbp)
subl $0x1, %r12d
jb 0x12187
callq 0x1efde
movq %rax, %r15
movq 0x18(%r14), %r13
movsd -0xc0(%rbp), %xmm0
mulsd -0x30(%rbp), %xmm0
movsd %xmm0, -0x60(%rbp)
leaq -0x60(%rbp), %rdi
leaq -0xe8(%rbp), %rsi
callq 0xd15b
addsd 0x8(%r13), %xmm0
addsd 0x10(%r13), %xmm1
movsd %xmm0, -0x58(%rbp)
movsd %xmm1, -0x50(%rbp)
movq %r15, %rdi
movq %rbx, %rsi
pushq $0x1
popq %rdx
callq 0x1f058
addsd -0xf8(%rbp), %xmm0
movsd %xmm0, -0xf8(%rbp)
movsd -0x30(%rbp), %xmm1
addsd 0x44ec3(%rip), %xmm1    # 0x57048
jmp 0x1210b
mulsd 0x455a1(%rip), %xmm0    # 0x57730
movsd %xmm0, -0xf8(%rbp)
movupd -0x40(%rbp), %xmm0
leaq -0xe0(%rbp), %rax
movupd %xmm0, (%rax)
movq -0x48(%rbp), %rdi
leaq -0x108(%rbp), %rsi
callq 0x10530
movsd -0x120(%rbp), %xmm1
addsd 0x45579(%rip), %xmm1    # 0x57740
jmp 0x11f28
movq -0x48(%rbp), %r14
cmpq %r14, (%r14)
movq -0x110(%rbp), %rbx
je 0x121f3
movq %r14, %rdi
callq 0x10370
movq (%r14), %rsi
addq $0x10, %rsi
movq %rbx, %rdi
callq 0x10530
addq $0xf8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
nop