// File: /workspace/github_cpp_makefile_star2_O2/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 $0x38, %rsp
movsd %xmm0, -0x20(%rbp)
movsd %xmm1, -0x38(%rbp)
movsd %xmm1, -0x18(%rbp)
movq 0x18(%rdi), %rax
cmpl $0x25, 0x1c(%rax)
jl 0x40bf2
movq %rdi, %rbx
movsd %xmm0, -0x28(%rbp)
movq 0x20(%rbx), %rax
movapd %xmm0, %xmm2
subsd 0x8(%rax), %xmm2
movsd -0x38(%rbp), %xmm1
subsd 0x10(%rax), %xmm1
mulsd %xmm1, %xmm1
mulsd %xmm2, %xmm2
addsd %xmm1, %xmm2
sqrtsd %xmm2, %xmm0
movsd %xmm0, -0x30(%rbp)
callq 0x3db2c
movsd 0x32a8(%rax), %xmm0
addsd 0x16d51(%rip), %xmm0    # 0x57848
ucomisd -0x30(%rbp), %xmm0
jbe 0x40b0d
movsd -0x28(%rbp), %xmm0
addsd 0x16555(%rip), %xmm0    # 0x57060
jmp 0x40ab1
movsd -0x28(%rbp), %xmm1
movsd %xmm1, -0x20(%rbp)
movq 0x18(%rbx), %rax
movl 0x1c(%rax), %eax
cmpl $0x2c, %eax
je 0x40bd8
cmpl $0x28, %eax
je 0x40b42
cmpl $0x25, %eax
jne 0x40bf2
movsd 0x17a5b(%rip), %xmm0    # 0x58598
jmp 0x40be9
callq 0x3db2c
leaq 0x3850(%rax), %rdi
movabsq $0x3ed92a737110e454, %rax # imm = 0x3ED92A737110E454
leaq -0x40(%rbp), %rdx
movq %rax, (%rdx)
leaq -0x20(%rbp), %rsi
callq 0x12516
testb %al, %al
je 0x40bf2
movq 0x28(%rbx), %rax
movsd 0x8(%rax), %xmm0
movsd %xmm0, -0x28(%rbp)
callq 0x3db2c
movsd 0x3850(%rax), %xmm0
movsd %xmm0, -0x38(%rbp)
movq 0x28(%rbx), %rax
movsd 0x10(%rax), %xmm0
movsd %xmm0, -0x30(%rbp)
callq 0x3db2c
movsd -0x38(%rbp), %xmm0
ucomisd -0x28(%rbp), %xmm0
movsd 0x3860(%rax), %xmm0
jbe 0x40c03
ucomisd -0x30(%rbp), %xmm0
jbe 0x40c29
callq 0x3db2c
movsd 0x3850(%rax), %xmm0
movsd 0x3860(%rax), %xmm1
jmp 0x40c6a
movq 0x20(%rbx), %rax
movsd 0x8(%rax), %xmm0
addsd 0x16477(%rip), %xmm0    # 0x57060
minsd %xmm1, %xmm0
movsd %xmm0, -0x20(%rbp)
movsd -0x20(%rbp), %xmm0
movsd -0x18(%rbp), %xmm1
addq $0x38, %rsp
popq %rbx
popq %rbp
retq
ucomisd -0x30(%rbp), %xmm0
jbe 0x40c79
callq 0x3db2c
movsd 0x3860(%rax), %xmm0
addsd 0x16441(%rip), %xmm0    # 0x57060
minsd -0x18(%rbp), %xmm0
jmp 0x40cb5
movq 0x28(%rbx), %rax
movsd 0x10(%rax), %xmm0
movsd %xmm0, -0x28(%rbp)
callq 0x3db2c
movsd 0x3868(%rax), %xmm0
movsd %xmm0, -0x30(%rbp)
callq 0x3db2c
movsd -0x28(%rbp), %xmm0
ucomisd -0x30(%rbp), %xmm0
jbe 0x40cbf
movsd 0x3850(%rax), %xmm0
movsd 0x3868(%rax), %xmm1
movsd %xmm0, -0x20(%rbp)
movsd %xmm1, -0x18(%rbp)
jmp 0x40bf2
movq 0x28(%rbx), %rax
movsd 0x10(%rax), %xmm0
movsd %xmm0, -0x28(%rbp)
callq 0x3db2c
movsd -0x28(%rbp), %xmm0
ucomisd 0x3868(%rax), %xmm0
jbe 0x40cd9
callq 0x3db2c
movsd 0x3868(%rax), %xmm0
addsd 0x16b98(%rip), %xmm0    # 0x57848
maxsd -0x18(%rbp), %xmm0
movsd %xmm0, -0x18(%rbp)
jmp 0x40bf2
movsd 0x3850(%rax), %xmm0
addsd 0x16391(%rip), %xmm0    # 0x57060
minsd -0x20(%rbp), %xmm0
jmp 0x40bed
movq 0x28(%rbx), %rax
movupd 0x8(%rax), %xmm0
movapd %xmm0, -0x20(%rbp)
jmp 0x40bf2