// File: /workspace/github_cpp_makefile_star2_O3/wrighteagle2d[P]wrighteaglebase/Debug/../src/PositionInfo.cpp
// Function: PositionInfo::UpdateOffsideLine()
void PositionInfo::UpdateOffsideLine() {
  const BallState &ball_state = mpWorldState->GetBall();
  const PlayerState *pPlayer = 0;

  double first = 0.0;
  double second = 0.0;
  Unum f_unum = 0;
  Unum s_unum = 0;

  // teammate offside line
  for (int i = 1; i <= TEAMSIZE; ++i) {
    pPlayer = &(mpWorldState->GetOpponent(i));
    if (pPlayer->IsAlive() == false) {
      continue;
    }

    if (pPlayer->GetPos().X() > second) {
      if (pPlayer->GetPos().X() > first) {
        second = first;
        s_unum = f_unum;
        first = pPlayer->GetPos().X();
        f_unum = i;
      } else {
        second = pPlayer->GetPos().X();
        s_unum = i;
      }
    }
  }

  if (ball_state.GetPosConf() > PlayerParam::instance().minValidConf() &&
      ball_state.GetPos().X() > second) {
    mTeammateOffsideLineOpp = 0;
    mTeammateOffsideLine = ball_state.GetPos().X();
    mTeammateOffsideLineConf = ball_state.GetPosConf();
    mTeammateOffsideLineSpeed = ball_state.GetVel().X();
  } else {
    mTeammateOffsideLine = second;
    if (s_unum == 0) {
      mTeammateOffsideLineOpp = 0;
      mTeammateOffsideLineConf = 0.0;
      mTeammateOffsideLineSpeed = 0.0;
    } else {
      mTeammateOffsideLineOpp = s_unum;
      mTeammateOffsideLineConf = mpWorldState->GetOpponent(s_unum).GetPosConf();
      mTeammateOffsideLineSpeed =
          mpWorldState->GetOpponent(s_unum).GetVel().X();
    }
  }

  // opponent offside line
  first = 0.0;
  second = 0.0;
  f_unum = 0;
  s_unum = 0;
  for (int i = 1; i <= TEAMSIZE; ++i) {
    pPlayer = &(mpWorldState->GetTeammate(i));
    if (pPlayer->IsAlive() == false) {
      continue;
    }

    if (pPlayer->GetPos().X() < second) {
      if (pPlayer->GetPos().X() < first) {
        second = first;
        s_unum = f_unum;
        first = pPlayer->GetPos().X();
        f_unum = i;
      } else {
        second = pPlayer->GetPos().X();
        s_unum = i;
      }
    }
  }
  if (ball_state.GetPosConf() > PlayerParam::instance().minValidConf() &&
      ball_state.GetPos().X() < second) {
    mOpponentOffsideLineTm = 0;
    mOpponentOffsideLine = ball_state.GetPos().X();
    mOpponentOffsideLineConf = ball_state.GetPosConf();
    mOpponentOffsideLineSpeed = ball_state.GetVel().X();
  } else {
    mOpponentOffsideLine = second;
    if (s_unum == 0) {
      mOpponentOffsideLineTm = 0;
      mOpponentOffsideLineConf = 0.0;
      mOpponentOffsideLineSpeed = 0.0;
    } else {
      mOpponentOffsideLineTm = s_unum;
      mOpponentOffsideLineConf = mpWorldState->GetTeammate(s_unum).GetPosConf();
      mOpponentOffsideLineSpeed =
          mpWorldState->GetTeammate(s_unum).GetVel().X();
    }
  }
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %rbx
subq $0x18, %rsp
movq %rdi, %rbx
movq 0x10(%rdi), %r14
xorpd %xmm3, %xmm3
xorl %eax, %eax
movl $0x1, %ecx
xorl %edx, %edx
xorpd %xmm0, %xmm0
xorl %r15d, %r15d
cmpb $0x1, 0x11e2(%r14,%rax)
jne 0x46d56
movsd 0x10d8(%r14,%rax), %xmm2
ucomisd %xmm3, %xmm2
jbe 0x46d56
ucomisd %xmm0, %xmm2
jbe 0x46d70
movl %edx, %r15d
movapd %xmm2, %xmm1
movapd %xmm0, %xmm3
movl %ecx, %edx
jmp 0x46d5a
movapd %xmm0, %xmm1
addq $0x178, %rax            # imm = 0x178
incl %ecx
movapd %xmm1, %xmm0
cmpq $0x1028, %rax           # imm = 0x1028
jne 0x46d26
jmp 0x46d7d
movl %ecx, %r15d
movapd %xmm0, %xmm1
movapd %xmm2, %xmm3
jmp 0x46d5a
movsd 0x50(%r14), %xmm0
movsd %xmm0, -0x20(%rbp)
movsd %xmm3, -0x28(%rbp)
callq 0x43dce
movsd -0x28(%rbp), %xmm1
movsd -0x20(%rbp), %xmm0
ucomisd 0x31e8(%rax), %xmm0
jbe 0x46dda
movsd 0x38(%r14), %xmm0
ucomisd %xmm1, %xmm0
jbe 0x46dda
movl $0x0, 0x1798(%rbx)
movsd %xmm0, 0x17a0(%rbx)
movsd 0x50(%r14), %xmm0
movsd %xmm0, 0x17a8(%rbx)
movsd 0x60(%r14), %xmm0
jmp 0x46e19
movsd %xmm1, 0x17a0(%rbx)
testl %r15d, %r15d
je 0x46e23
movl %r15d, 0x1798(%rbx)
movq 0x10(%rbx), %rax
decl %r15d
movslq %r15d, %rcx
imulq $0x178, %rcx, %rcx      # imm = 0x178
movsd 0x10f0(%rax,%rcx), %xmm0
movsd %xmm0, 0x17a8(%rbx)
movsd 0x1100(%rax,%rcx), %xmm0
movsd %xmm0, 0x17b0(%rbx)
jmp 0x46e39
movl $0x0, 0x1798(%rbx)
xorpd %xmm0, %xmm0
movupd %xmm0, 0x17a8(%rbx)
movq 0x10(%rbx), %rax
xorpd %xmm3, %xmm3
xorl %esi, %esi
movl $0x1ba, %ecx            # imm = 0x1BA
movl $0x1, %edx
xorpd %xmm0, %xmm0
xorl %r15d, %r15d
cmpb $0x1, (%rax,%rcx)
jne 0x46e7e
movsd -0x10a(%rax,%rcx), %xmm2
ucomisd %xmm2, %xmm3
jbe 0x46e7e
ucomisd %xmm2, %xmm0
jbe 0x46e9a
movl %esi, %r15d
movapd %xmm2, %xmm1
movapd %xmm0, %xmm3
movl %edx, %esi
jmp 0x46e82
movapd %xmm0, %xmm1
addq $0x178, %rcx            # imm = 0x178
incl %edx
movapd %xmm1, %xmm0
cmpq $0x11e2, %rcx           # imm = 0x11E2
jne 0x46e54
jmp 0x46ea7
movl %edx, %r15d
movapd %xmm0, %xmm1
movapd %xmm2, %xmm3
jmp 0x46e82
movsd 0x50(%r14), %xmm0
movsd %xmm0, -0x20(%rbp)
movsd %xmm3, -0x28(%rbp)
callq 0x43dce
movsd -0x28(%rbp), %xmm1
movsd -0x20(%rbp), %xmm0
ucomisd 0x31e8(%rax), %xmm0
jbe 0x46f04
movsd 0x38(%r14), %xmm0
ucomisd %xmm0, %xmm1
jbe 0x46f04
movl $0x0, 0x17b8(%rbx)
movsd %xmm0, 0x17c0(%rbx)
movsd 0x50(%r14), %xmm0
movsd %xmm0, 0x17c8(%rbx)
movsd 0x60(%r14), %xmm0
jmp 0x46f43
movsd %xmm1, 0x17c0(%rbx)
testl %r15d, %r15d
je 0x46f4d
movl %r15d, 0x17b8(%rbx)
movq 0x10(%rbx), %rax
decl %r15d
movslq %r15d, %rcx
imulq $0x178, %rcx, %rcx      # imm = 0x178
movsd 0xc8(%rax,%rcx), %xmm0
movsd %xmm0, 0x17c8(%rbx)
movsd 0xd8(%rax,%rcx), %xmm0
movsd %xmm0, 0x17d0(%rbx)
jmp 0x46f63
movl $0x0, 0x17b8(%rbx)
xorpd %xmm0, %xmm0
movupd %xmm0, 0x17c8(%rbx)
addq $0x18, %rsp
popq %rbx
popq %r14
popq %r15
popq %rbp
retq