// File: /workspace/github_cpp_makefile_star2_O2/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 %xmm0, %xmm0
xorl %eax, %eax
pushq $0x1
popq %rcx
xorl %r15d, %r15d
xorpd %xmm3, %xmm3
xorl %edx, %edx
cmpq $0x1028, %rax           # imm = 0x1028
je 0x3b797
cmpb $0x1, 0x11e2(%r14,%rax)
jne 0x3b774
movsd 0x10d8(%r14,%rax), %xmm1
ucomisd %xmm3, %xmm1
jbe 0x3b774
ucomisd %xmm0, %xmm1
jbe 0x3b78e
movl %edx, %r15d
movapd %xmm1, %xmm2
movapd %xmm0, %xmm1
movl %ecx, %edx
jmp 0x3b77c
movapd %xmm0, %xmm2
movapd %xmm3, %xmm1
addq $0x178, %rax            # imm = 0x178
incl %ecx
movapd %xmm2, %xmm0
movapd %xmm1, %xmm3
jmp 0x3b73c
movl %ecx, %r15d
movapd %xmm0, %xmm2
jmp 0x3b77c
movsd 0x50(%r14), %xmm0
movsd %xmm0, -0x20(%rbp)
movsd %xmm3, -0x28(%rbp)
callq 0x38d94
movsd -0x28(%rbp), %xmm1
movsd -0x20(%rbp), %xmm0
ucomisd 0x31e8(%rax), %xmm0
jbe 0x3b7f1
movsd 0x38(%r14), %xmm0
ucomisd %xmm1, %xmm0
jbe 0x3b7f1
andl $0x0, 0x1798(%rbx)
movsd %xmm0, 0x17a0(%rbx)
movsd 0x50(%r14), %xmm0
movsd %xmm0, 0x17a8(%rbx)
movsd 0x60(%r14), %xmm0
jmp 0x3b830
movsd %xmm1, 0x17a0(%rbx)
testl %r15d, %r15d
je 0x3b83a
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 0x3b84d
andl $0x0, 0x1798(%rbx)
xorpd %xmm0, %xmm0
movupd %xmm0, 0x17a8(%rbx)
movq 0x10(%rbx), %rax
xorpd %xmm0, %xmm0
xorl %r15d, %r15d
movl $0x1ba, %ecx            # imm = 0x1BA
pushq $0x1
popq %rdx
xorpd %xmm3, %xmm3
xorl %esi, %esi
cmpq $0x11e2, %rcx           # imm = 0x11E2
je 0x3b8bd
cmpb $0x1, (%rax,%rcx)
jne 0x3b899
movsd -0x10a(%rax,%rcx), %xmm1
ucomisd %xmm1, %xmm3
jbe 0x3b899
ucomisd %xmm1, %xmm0
jbe 0x3b8b4
movl %esi, %r15d
movapd %xmm1, %xmm2
movapd %xmm0, %xmm1
movl %edx, %esi
jmp 0x3b8a1
movapd %xmm0, %xmm2
movapd %xmm3, %xmm1
addq $0x178, %rcx            # imm = 0x178
incl %edx
movapd %xmm2, %xmm0
movapd %xmm1, %xmm3
jmp 0x3b866
movl %edx, %r15d
movapd %xmm0, %xmm2
jmp 0x3b8a1
movsd 0x50(%r14), %xmm0
movsd %xmm0, -0x20(%rbp)
movsd %xmm3, -0x28(%rbp)
callq 0x38d94
movsd -0x28(%rbp), %xmm1
movsd -0x20(%rbp), %xmm0
ucomisd 0x31e8(%rax), %xmm0
jbe 0x3b917
movsd 0x38(%r14), %xmm0
ucomisd %xmm0, %xmm1
jbe 0x3b917
andl $0x0, 0x17b8(%rbx)
movsd %xmm0, 0x17c0(%rbx)
movsd 0x50(%r14), %xmm0
movsd %xmm0, 0x17c8(%rbx)
movsd 0x60(%r14), %xmm0
jmp 0x3b956
movsd %xmm1, 0x17c0(%rbx)
testl %r15d, %r15d
je 0x3b960
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 0x3b973
andl $0x0, 0x17b8(%rbx)
xorpd %xmm0, %xmm0
movupd %xmm0, 0x17c8(%rbx)
addq $0x18, %rsp
popq %rbx
popq %r14
popq %r15
popq %rbp
retq