// File: /workspace/github_cpp_makefile_star2_O1/wrighteagle2d[P]wrighteaglebase/Debug/../src/BehaviorPenalty.cpp
// Function: BehaviorPenaltyPlanner::Plan(std::__cxx11::list<ActiveBehavior, std::allocator<ActiveBehavior>>&)
void BehaviorPenaltyPlanner::Plan(std::list<ActiveBehavior> &behaviorlist) {
  ActiveBehavior penaltyKO(mAgent, BT_Penalty);

  if (mSelfState.IsGoalie()) {
    switch (mWorldState.GetPlayMode()) {
    case PM_Penalty_On_Our_Field:
    case PM_Penalty_On_Opp_Field:
    case PM_Our_Penalty_Score:
    case PM_Our_Penalty_Miss:
    case PM_Opp_Penalty_Score:
    case PM_Opp_Penalty_Miss: // 对手或队友刚罚完点球，原地休息一会
    case PM_Our_Penalty_Setup:
    case PM_Our_Penalty_Ready:
    case PM_Our_Penalty_Taken: // 队友罚点球，守门员在旁边休息，为了节省体力，不自己dash回去（rcssserver-13.*下不可能是守门员自己罚）
      penaltyKO.mDetailType = BDT_Setplay_Scan;
      break;
    case PM_Opp_Penalty_Setup:
      penaltyKO.mDetailType = BDT_Setplay_Move;
      break;
    case PM_Opp_Penalty_Ready:
    case PM_Opp_Penalty_Taken:
      penaltyKO.mDetailType = BDT_Setplay_GetBall; // 正在罚点球
      break;
    default:
      return;
    }
  } else {
    switch (mWorldState.GetPlayMode()) {
    case PM_Penalty_On_Our_Field:
    case PM_Penalty_On_Opp_Field:
    case PM_Our_Penalty_Score:
    case PM_Our_Penalty_Miss:
    case PM_Opp_Penalty_Score:
    case PM_Opp_Penalty_Miss:
      penaltyKO.mDetailType = BDT_Setplay_Scan; // 原地休息
      break;
    case PM_Our_Penalty_Setup:
    case PM_Opp_Penalty_Setup:
      penaltyKO.mDetailType = BDT_Setplay_Move; // 走向目标位置
      break;
    case PM_Our_Penalty_Ready:
    case PM_Our_Penalty_Taken:
    case PM_Opp_Penalty_Ready:
    case PM_Opp_Penalty_Taken:
      penaltyKO.mDetailType = BDT_Setplay_GetBall; // 正在罚点球
      break;
    default:
      return;
    }
  }

  if (penaltyKO.mDetailType == BDT_Setplay_Scan) {
    penaltyKO.mAngle = 60.0;
    behaviorlist.push_back(penaltyKO);
  } else if (penaltyKO.mDetailType == BDT_Setplay_Move) {
    if (mSelfState.IsGoalie()) {
      penaltyKO.mTarget =
          Vector(-ServerParam::instance().PITCH_LENGTH / 2.0 +
                     ServerParam::instance().penMaxGoalieDistX() - 1.0,
                 0.0);
    } else if (mAgent.GetSelfUnum() == mStrategy.GetPenaltyTaker()) {
      if (mWorldState.CurrentTime() - mWorldState.GetPlayModeTime() < 5 &&
          mStrategy.IsPenaltyFirstStep() != false) {
        mStrategy.SetPenaltyFirstStep(false);
      }

      if (mSelfState.GetPos().Dist(Vector(6.6, 0.0)) < 1.0 &&
          mStrategy.IsPenaltyFirstStep() != true) {
        mStrategy.SetPenaltyFirstStep(true);
      }

      if (mStrategy.IsPenaltyFirstStep() == false) {
        penaltyKO.mTarget = Vector(6.6, 0.0);
      } else {
        const Vector setup_ball_pos =
            Vector(ServerParam::instance().PITCH_LENGTH / 2.0 -
                       ServerParam::instance().penDistX(),
                   0.0);
        penaltyKO.mTarget = (mBallState.GetPos().Dist(setup_ball_pos) < 1.0)
                                ? setup_ball_pos
                                : mBallState.GetPos();
      }
    } else {
      penaltyKO.mAngle = (mAgent.GetSelfUnum() - 2) * 36.0 + 18.0; // 2 ~ 11
      penaltyKO.mTarget = Polar2Vector(8.26, penaltyKO.mAngle);
    }

    penaltyKO.mEvaluation = 1.0;
    behaviorlist.push_back(penaltyKO);
  } else if (penaltyKO.mDetailType == BDT_Setplay_GetBall) {
    if (mSelfState.IsGoalie()) {
      BehaviorInterceptPlanner(mAgent).Plan(behaviorlist);
      if (behaviorlist.empty() || mSelfState.IsBallCatchable())
        BehaviorGoaliePlanner(mAgent).Plan(behaviorlist);
    } else if (mStrategy.IsMyPenaltyTaken() == true) {
      // 先算dribble，shoot中根据dribble的情况来决策
      BehaviorDribblePlanner(mAgent).Plan(behaviorlist);
      BehaviorShootPlanner(mAgent).Plan(behaviorlist);
      BehaviorInterceptPlanner(mAgent).Plan(behaviorlist);
    }

    if (behaviorlist.empty()) {
      penaltyKO.mTarget = mBallState.GetPos();
      penaltyKO.mAngle =
          ((mBallState.GetPos() - mSelfState.GetPos()).Dir() > 0.0) ? 36.0
                                                                    : -36.0;
      penaltyKO.mKickSpeed =
          Min(1.0, Kicker::instance().GetMaxSpeed(mAgent, penaltyKO.mAngle, 1));
      penaltyKO.mEvaluation = 1.0;
      behaviorlist.push_back(penaltyKO);
    }
  }
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %rbx
subq $0x128, %rsp            # imm = 0x128
movq %rsi, %rbx
movq %rdi, %r14
movq 0x8(%rdi), %rax
movl $0x1, -0xc8(%rbp)
movq %rax, -0xc0(%rbp)
xorl %eax, %eax
movq %rax, -0xb8(%rbp)
movl %eax, -0xb0(%rbp)
movl %eax, -0x70(%rbp)
movq %rax, -0x68(%rbp)
movl %eax, -0x60(%rbp)
movq %rax, -0x58(%rbp)
movl %eax, -0x50(%rbp)
movq %rax, -0x48(%rbp)
movl %eax, -0x40(%rbp)
movq %rax, -0x38(%rbp)
xorpd %xmm0, %xmm0
movupd %xmm0, -0xa8(%rbp)
movupd %xmm0, -0x98(%rbp)
movupd %xmm0, -0x88(%rbp)
movb $0x0, -0x78(%rbp)
movl %eax, -0x30(%rbp)
movq %rax, -0x28(%rbp)
movq 0x10(%rdi), %rcx
movq 0x20(%rdi), %rax
movb 0x175(%rax), %al
movl 0x1c(%rcx), %edx
movl %edx, %ecx
cmpb $0x1, %al
jne 0x19c2d
cmpl $0x35, %edx
ja 0x1a0f6
movl $0x10, %edx
movabsq $0x3000000487c000, %rsi # imm = 0x3000000487C000
btq %rcx, %rsi
jb 0x19c7b
movabsq $0xc000000000000, %rdx  # imm = 0xC000000000000
btq %rcx, %rdx
jb 0x19c5b
cmpq $0x31, %rcx
je 0x19c76
jmp 0x1a0f6
cmpl $0x35, %edx
ja 0x1a0f6
movl $0x10, %edx
movabsq $0x30000004860000, %rsi # imm = 0x30000004860000
btq %rcx, %rsi
jb 0x19c7b
movabsq $0xc000000018000, %rdx  # imm = 0xC000000018000
btq %rcx, %rdx
jae 0x19c62
movl $0x11, %edx
jmp 0x19c7b
movabsq $0x2000000004000, %rdx  # imm = 0x2000000004000
btq %rcx, %rdx
jae 0x1a0f6
movl $0xf, %edx
movl %edx, -0x30(%rbp)
cmpl $0xf, %edx
je 0x19d28
cmpl $0x11, %edx
je 0x19cab
cmpl $0x10, %edx
jne 0x1a0f6
movabsq $0x404e000000000000, %rax # imm = 0x404E000000000000
movq %rax, -0xa8(%rbp)
jmp 0x1a0c5
testb %al, %al
je 0x19d7f
movq 0x8(%r14), %rsi
leaq -0x130(%rbp), %r15
movq %r15, %rdi
callq 0x17178
movq %r15, %rdi
movq %rbx, %rsi
callq 0x171d8
leaq -0x130(%rbp), %rdi
callq 0x171ac
cmpq %rbx, (%rbx)
je 0x19d00
movq 0x20(%r14), %rax
cmpb $0x1, 0x175(%rax)
jne 0x19dfc
testb $0x1, 0x138(%rax)
je 0x19dfc
movq 0x8(%r14), %rsi
movq %r15, %rdi
callq 0x15ec6
movq %r15, %rdi
movq %rbx, %rsi
callq 0x15fb2
leaq -0x130(%rbp), %rdi
callq 0x15efa
jmp 0x19dfc
testb %al, %al
je 0x19e6e
callq 0x4a75c
leaq 0x541dc(%rip), %rax     # 0x6df18
movsd (%rax), %xmm0
mulsd 0x51340(%rip), %xmm0    # 0x6b088
movsd %xmm0, -0x20(%rbp)
callq 0x4a75c
movsd -0x20(%rbp), %xmm0
addsd 0x3278(%rax), %xmm0
addsd 0x51331(%rip), %xmm0    # 0x6b098
movsd %xmm0, -0xa0(%rbp)
movq $0x0, -0x98(%rbp)
jmp 0x1a0b4
movq 0x38(%r14), %rdi
callq 0x4de4a
testb %al, %al
je 0x19dfc
movq 0x8(%r14), %rsi
leaq -0x130(%rbp), %r15
movq %r15, %rdi
callq 0x14770
movq %r15, %rdi
movq %rbx, %rsi
callq 0x147d0
leaq -0x130(%rbp), %rdi
callq 0x147a4
movq 0x8(%r14), %rsi
movq %r15, %rdi
callq 0x1b612
movq %r15, %rdi
movq %rbx, %rsi
callq 0x1b672
leaq -0x130(%rbp), %rdi
callq 0x1b646
movq 0x8(%r14), %rsi
movq %r15, %rdi
callq 0x17178
movq %r15, %rdi
movq %rbx, %rsi
callq 0x171d8
leaq -0x130(%rbp), %rdi
callq 0x171ac
cmpq %rbx, (%rbx)
jne 0x1a0f6
leaq -0xa8(%rbp), %r15
movq 0x18(%r14), %rax
movups 0x8(%rax), %xmm0
movups %xmm0, 0x8(%r15)
movq 0x20(%r14), %rcx
movsd 0x8(%rax), %xmm1
movsd 0x10(%rax), %xmm0
subsd 0x8(%rcx), %xmm1
subsd 0x10(%rcx), %xmm0
movapd 0x511d7(%rip), %xmm2    # 0x6b010
movapd %xmm1, %xmm4
andpd %xmm2, %xmm4
movsd 0x511f7(%rip), %xmm3    # 0x6b040
ucomisd %xmm4, %xmm3
jbe 0x19f5a
andpd %xmm0, %xmm2
ucomisd %xmm2, %xmm3
jbe 0x19f5a
movsd 0x51e6f(%rip), %xmm0    # 0x6bcd8
jmp 0x19f88
movq 0x8(%r14), %rax
movq 0x38(%r14), %rcx
movl 0x8(%rax), %eax
cmpl 0x148(%rcx), %eax
jne 0x19ee4
movq 0x10(%r14), %rsi
leaq 0x10(%rsi), %rdi
addq $0x24, %rsi
callq 0x55ef4
cmpl $0x4, %eax
jg 0x19eab
movq 0x38(%r14), %rax
cmpb $0x1, 0x140(%rax)
jne 0x19eab
movb $0x0, 0x140(%rax)
movq 0x20(%r14), %rax
movsd 0x8(%rax), %xmm0
movsd 0x10(%rax), %xmm1
addsd 0x51e37(%rip), %xmm0    # 0x6bcf8
mulsd %xmm1, %xmm1
mulsd %xmm0, %xmm0
addsd %xmm1, %xmm0
xorpd %xmm1, %xmm1
ucomisd %xmm1, %xmm0
jb 0x19fc6
sqrtsd %xmm0, %xmm0
jmp 0x19fcb
addl $-0x2, %eax
xorps %xmm0, %xmm0
cvtsi2sd %eax, %xmm0
mulsd 0x51dea(%rip), %xmm0    # 0x6bce0
addsd 0x51dea(%rip), %xmm0    # 0x6bce8
movsd %xmm0, -0xa8(%rbp)
mulsd 0x51142(%rip), %xmm0    # 0x6b050
divsd 0x51132(%rip), %xmm0    # 0x6b048
leaq -0x130(%rbp), %r14
leaq -0x138(%rbp), %r15
movq %r14, %rdi
movq %r15, %rsi
callq 0x92d0
movsd 0x51db9(%rip), %xmm0    # 0x6bcf0
movsd (%r15), %xmm1
mulsd %xmm0, %xmm1
mulsd (%r14), %xmm0
movsd %xmm1, -0xa0(%rbp)
movsd %xmm0, -0x98(%rbp)
jmp 0x1a0b4
callq 0x90d0
mulsd 0x510e1(%rip), %xmm0    # 0x6b048
divsd 0x510e1(%rip), %xmm0    # 0x6b050
xorpd %xmm1, %xmm1
xorl %eax, %eax
ucomisd %xmm1, %xmm0
seta %al
leaq 0x51d7d(%rip), %rcx     # 0x6bd00
movsd (%rcx,%rax,8), %xmm0
movsd %xmm0, -0xa8(%rbp)
callq 0x2ddfa
movq 0x8(%r14), %rsi
leaq -0x130(%rbp), %rcx
movl $0x1, (%rcx)
movq %rax, %rdi
movq %r15, %rdx
xorl %r8d, %r8d
callq 0x2eaba
minsd 0x5109c(%rip), %xmm0    # 0x6b058
movsd %xmm0, -0x80(%rbp)
jmp 0x1a0b4
callq 0x93c0
movsd 0x51085(%rip), %xmm1    # 0x6b058
ucomisd %xmm0, %xmm1
jbe 0x19fed
movq 0x38(%r14), %rax
cmpb $0x0, 0x140(%rax)
jne 0x19fed
movb $0x1, 0x140(%rax)
movq 0x38(%r14), %rax
cmpb $0x0, 0x140(%rax)
je 0x1a06e
callq 0x4a75c
leaq 0x53f12(%rip), %rax     # 0x6df18
movsd (%rax), %xmm0
mulsd 0x51866(%rip), %xmm0    # 0x6b878
movsd %xmm0, -0x20(%rbp)
callq 0x4a75c
movsd -0x20(%rbp), %xmm0
subsd 0x3268(%rax), %xmm0
movsd %xmm0, -0x130(%rbp)
movapd %xmm0, %xmm2
movq $0x0, -0x128(%rbp)
movq 0x18(%r14), %rax
movsd 0x8(%rax), %xmm0
movsd 0x10(%rax), %xmm1
subsd %xmm2, %xmm0
mulsd %xmm1, %xmm1
mulsd %xmm0, %xmm0
addsd %xmm1, %xmm0
xorpd %xmm1, %xmm1
ucomisd %xmm1, %xmm0
jb 0x1a084
sqrtsd %xmm0, %xmm0
jmp 0x1a089
movabsq $0x401a666666666666, %rax # imm = 0x401A666666666666
movq %rax, -0xa0(%rbp)
jmp 0x19d6f
callq 0x93c0
movsd 0x50fc7(%rip), %xmm1    # 0x6b058
movq 0x18(%r14), %rax
addq $0x8, %rax
ucomisd %xmm0, %xmm1
leaq -0x130(%rbp), %rcx
cmovbeq %rax, %rcx
movupd (%rcx), %xmm0
movupd %xmm0, -0xa0(%rbp)
movabsq $0x3ff0000000000000, %rax # imm = 0x3FF0000000000000
movq %rax, -0xb8(%rbp)
movl $0xb8, %edi
callq 0x94c0
movq %rax, %r14
leaq 0x10(%rax), %rdi
leaq -0xc8(%rbp), %rsi
movl $0xa8, %edx
callq 0x93e0
movq %r14, %rdi
movq %rbx, %rsi
callq 0x90b0
incq 0x10(%rbx)
addq $0x128, %rsp            # imm = 0x128
popq %rbx
popq %r14
popq %r15
popq %rbp
retq
jmp 0x1a139
movq %rax, %rbx
leaq -0x130(%rbp), %rdi
callq 0x1b646
jmp 0x1a148
movq %rax, %rbx
leaq -0x130(%rbp), %rdi
callq 0x147a4
jmp 0x1a148
movq %rax, %rbx
leaq -0x130(%rbp), %rdi
callq 0x15efa
jmp 0x1a148
movq %rax, %rbx
leaq -0x130(%rbp), %rdi
callq 0x171ac
movq %rbx, %rdi
callq 0x98b0