// File: /workspace/github_cpp_makefile_star2_O1/wrighteagle2d[P]wrighteaglebase/Debug/../src/Strategy.cpp
// Function: Strategy::AdjustTargetForSetplay(Vector)
Vector Strategy::AdjustTargetForSetplay(Vector target) {
  if (mWorldState.GetPlayMode() > PM_Opp_Mode) {
    while (target.Dist(mBallState.GetPos()) <
           ServerParam::instance().offsideKickMargin() + 0.5) {
      target.SetX(target.X() - 0.5);
    }

    if (mWorldState.GetPlayMode() == PM_Opp_Kick_Off) {
      target.SetX(Min(target.X(), -0.1));
    } else if (mWorldState.GetPlayMode() == PM_Opp_Offside_Kick) {
      target.SetX(Min(target.X(), mBallState.GetPos().X() - 0.5));
    } else if (mWorldState.GetPlayMode() == PM_Opp_Goal_Kick) {
      if (ServerParam::instance().oppPenaltyArea().IsWithin(target)) {
        if (mSelfState.GetPos().X() <
            ServerParam::instance().oppPenaltyArea().Left()) {
          if (mSelfState.GetPos().Y() <
              ServerParam::instance().oppPenaltyArea().Top()) {
            target = ServerParam::instance().oppPenaltyArea().TopLeftCorner();
          } else if (mSelfState.GetPos().Y() >
                     ServerParam::instance().oppPenaltyArea().Bottom()) {
            target =
                ServerParam::instance().oppPenaltyArea().BottomLeftCorner();
          } else {
            target.SetX(
                Min(target.X(),
                    ServerParam::instance().oppPenaltyArea().Left() - 0.5));
          }
        } else {
          if (mSelfState.GetPos().Y() <
              ServerParam::instance().oppPenaltyArea().Top()) {
            target.SetY(
                Min(target.Y(),
                    ServerParam::instance().oppPenaltyArea().Top() - 0.5));
          } else if (mSelfState.GetPos().Y() >
                     ServerParam::instance().oppPenaltyArea().Bottom()) {
            target.SetY(
                Max(target.Y(),
                    ServerParam::instance().oppPenaltyArea().Bottom() + 0.5));
          } else {
            target = mSelfState.GetPos(); // do nothing
          }
        }
      }
    }
  }

  return target;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %rbx
subq $0x28, %rsp
movq 0x18(%rdi), %rax
cmpl $0x25, 0x1c(%rax)
jl 0x4dcb0
movq %rdi, %rbx
movq 0x20(%rdi), %rax
movsd %xmm0, -0x18(%rbp)
subsd 0x8(%rax), %xmm0
movapd %xmm1, %xmm2
subsd 0x10(%rax), %xmm2
mulsd %xmm2, %xmm2
mulsd %xmm0, %xmm0
addsd %xmm2, %xmm0
xorpd %xmm2, %xmm2
ucomisd %xmm2, %xmm0
movsd %xmm1, -0x20(%rbp)
jb 0x4dba8
sqrtsd %xmm0, %xmm0
jmp 0x4dbad
callq 0x93c0
movsd %xmm0, -0x10(%rbp)
callq 0x4a75c
movsd 0x32a8(%rax), %xmm0
addsd 0x1dcb1(%rip), %xmm0    # 0x6b878
ucomisd -0x10(%rbp), %xmm0
jbe 0x4dc41
movsd -0x18(%rbp), %xmm0
movsd -0x20(%rbp), %xmm1
addsd 0x1d4a8(%rip), %xmm0    # 0x6b088
movq 0x20(%rbx), %rax
movsd %xmm0, -0x18(%rbp)
subsd 0x8(%rax), %xmm0
subsd 0x10(%rax), %xmm1
mulsd %xmm1, %xmm1
mulsd %xmm0, %xmm0
addsd %xmm1, %xmm0
ucomisd 0x1d489(%rip), %xmm0    # 0x6b090
jb 0x4dc0f
sqrtsd %xmm0, %xmm0
jmp 0x4dc14
callq 0x93c0
movsd %xmm0, -0x10(%rbp)
callq 0x4a75c
movsd 0x32a8(%rax), %xmm0
addsd 0x1dc4a(%rip), %xmm0    # 0x6b878
ucomisd -0x10(%rbp), %xmm0
movsd -0x18(%rbp), %xmm0
movsd -0x20(%rbp), %xmm1
ja 0x4dbd8
jmp 0x4dc4b
movsd -0x18(%rbp), %xmm0
movsd -0x20(%rbp), %xmm1
movq 0x18(%rbx), %rax
movl 0x1c(%rax), %eax
cmpl $0x2c, %eax
je 0x4dc97
cmpl $0x28, %eax
je 0x4dc6b
cmpl $0x25, %eax
jne 0x4dcb0
movsd 0x1e96f(%rip), %xmm2    # 0x6c5d8
jmp 0x4dca8
movsd %xmm0, -0x18(%rbp)
callq 0x4a75c
movsd -0x18(%rbp), %xmm0
movsd 0x3850(%rax), %xmm1
addsd 0x1d3ee(%rip), %xmm1    # 0x6b078
ucomisd %xmm1, %xmm0
jae 0x4dcb7
movsd -0x20(%rbp), %xmm1
jmp 0x4dcb0
movq 0x20(%rbx), %rax
movsd 0x8(%rax), %xmm2
addsd 0x1d3e0(%rip), %xmm2    # 0x6b088
minsd %xmm0, %xmm2
movapd %xmm2, %xmm0
addq $0x28, %rsp
popq %rbx
popq %rbp
retq
movsd 0x3858(%rax), %xmm1
addsd 0x1d379(%rip), %xmm1    # 0x6b040
ucomisd %xmm0, %xmm1
movsd -0x20(%rbp), %xmm1
jb 0x4dcb0
movsd 0x3860(%rax), %xmm2
addsd 0x1d396(%rip), %xmm2    # 0x6b078
ucomisd %xmm2, %xmm1
jb 0x4dcb0
movsd 0x3868(%rax), %xmm2
addsd 0x1d348(%rip), %xmm2    # 0x6b040
ucomisd %xmm1, %xmm2
jb 0x4dcb0
movq 0x28(%rbx), %rax
movsd 0x8(%rax), %xmm0
movsd %xmm0, -0x10(%rbp)
callq 0x4a75c
movsd 0x3850(%rax), %xmm0
movsd %xmm0, -0x30(%rbp)
movq 0x28(%rbx), %rax
movsd 0x10(%rax), %xmm0
movsd %xmm0, -0x28(%rbp)
callq 0x4a75c
movsd -0x30(%rbp), %xmm0
ucomisd -0x10(%rbp), %xmm0
movsd 0x3860(%rax), %xmm0
jbe 0x4dd66
ucomisd -0x28(%rbp), %xmm0
jbe 0x4dd8c
callq 0x4a75c
movsd 0x3850(%rax), %xmm0
movsd 0x3860(%rax), %xmm1
jmp 0x4dcb0
ucomisd -0x28(%rbp), %xmm0
jbe 0x4ddd2
callq 0x4a75c
movsd 0x3860(%rax), %xmm0
addsd 0x1d306(%rip), %xmm0    # 0x6b088
minsd -0x20(%rbp), %xmm0
jmp 0x4de0e
movq 0x28(%rbx), %rax
movsd 0x10(%rax), %xmm0
movsd %xmm0, -0x10(%rbp)
callq 0x4a75c
movsd 0x3868(%rax), %xmm0
movsd %xmm0, -0x28(%rbp)
callq 0x4a75c
movsd -0x10(%rbp), %xmm0
ucomisd -0x28(%rbp), %xmm0
jbe 0x4de1c
movsd 0x3850(%rax), %xmm0
movsd 0x3868(%rax), %xmm1
jmp 0x4dcb0
movq 0x28(%rbx), %rax
movsd 0x10(%rax), %xmm0
movsd %xmm0, -0x10(%rbp)
callq 0x4a75c
movsd -0x10(%rbp), %xmm0
ucomisd 0x3868(%rax), %xmm0
jbe 0x4de36
callq 0x4a75c
movsd 0x3868(%rax), %xmm0
addsd 0x1da6f(%rip), %xmm0    # 0x6b878
maxsd -0x20(%rbp), %xmm0
movapd %xmm0, %xmm1
movsd -0x18(%rbp), %xmm0
jmp 0x4dcb0
movsd 0x3850(%rax), %xmm0
addsd 0x1d25c(%rip), %xmm0    # 0x6b088
minsd -0x18(%rbp), %xmm0
jmp 0x4dc90
movq 0x28(%rbx), %rax
movsd 0x8(%rax), %xmm0
movsd 0x10(%rax), %xmm1
jmp 0x4dcb0
nop