// File: /workspace/github_cpp_makefile_star2_O2/wrighteagle2d[P]wrighteaglebase/Debug/../src/WorldState.cpp
// Function: WorldStateUpdater::UpdateMostSimilarPlayer(Vector const&, int)
bool WorldStateUpdater::UpdateMostSimilarPlayer(const Vector &pos, int index) {
  bool is_known_side = mpObserver->UnknownPlayer(index).IsKnownSide();
  int least_num = mpObserver->UnknownPlayerBugInfo(index).mLeastNum;

  int min_index = 0;
  double min = 100000;

  if (is_known_side) {
    if (mpObserver->UnknownPlayer(index).Side() !=
        mpObserver->UnknownPlayerBugInfo(index).mSide) {
      least_num = 1;
    }
    for (int i = least_num; i <= TEAMSIZE; i++) {
      const PlayerState &player =
          mpObserver->UnknownPlayer(index).Side() == mSelfSide
              ? mpWorldState->GetTeammate(i)
              : mpWorldState->GetOpponent(i);
      if (player.GetPosDelay() != 0 && (player.GetPos() - pos).Mod() < min) {
        min = (player.GetPos() - pos).Mod();
        min_index = player.GetUnum();
      }
    }
  } else {
    for (int i = 1; i <= TEAMSIZE; i++) {
      const PlayerState &player =
          mpObserver->UnknownPlayerBugInfo(index).mSide == mSelfSide
              ? mpWorldState->GetTeammate(i)
              : mpWorldState->GetOpponent(i);
      const PlayerState &opp_player =
          mpObserver->UnknownPlayerBugInfo(index).mSide == mSelfSide
              ? mpWorldState->GetOpponent(i)
              : mpWorldState->GetTeammate(i);
      if (i >= least_num) {
        if (player.GetPosDelay() != 0 && (player.GetPos() - pos).Mod() < min) {
          min = (player.GetPos() - pos).Mod();
          min_index = player.GetUnum();
        }
      }

      if (opp_player.GetPosDelay() != 0 &&
          (opp_player.GetPos() - pos).Mod() < min) {
        min = (opp_player.GetPos() - pos).Mod();
        min_index = opp_player.GetUnum();
      }
    }
  }

  if (min_index != 0) {
    bool is_teammate = min_index > 0;
    this->UpdateSpecificUnknownPlayer(mpObserver->UnknownPlayer(index),
                                      abs(min_index), is_teammate);
    return true;
  } else {
    return false;
  }
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %rbx
pushq %rax
movl %edx, %r8d
movq %rsi, %rcx
movq (%rdi), %r9
pushq $0x16
popq %rsi
movl %edx, %eax
cltd
idivl %esi
movslq %edx, %rax
imulq $0x70, %rax, %rax
leaq (%r9,%rax), %rsi
addq $0x2840, %rsi           # imm = 0x2840
movslq %r8d, %rax
shlq $0x4, %rax
leaq (%r9,%rax), %rdx
addq $0x31e4, %rdx           # imm = 0x31E4
movslq 0x4(%rdx), %rax
cmpb $0x0, 0x40(%rsi)
je 0x53f57
movb 0x41(%rsi), %r8b
cmpb (%rdx), %r8b
pushq $0x1
popq %rdx
cmoveq %rax, %rdx
imulq $0x178, %rdx, %rax      # imm = 0x178
leaq 0x10d0(%rax), %r9
addq $0xa8, %rax
cmpb 0x10(%rdi), %r8b
movq 0x8(%rdi), %r8
movsd (%rcx), %xmm0
cmovneq %r9, %rax
movsd 0x8(%rcx), %xmm1
addq %r8, %rax
addq $-0x170, %rax           # imm = 0xFE90
xorl %ebx, %ebx
movsd 0x7815(%rip), %xmm2     # 0x5b720
cmpq $0xb, %rdx
jg 0x54032
cmpl $0x0, 0x10(%rax)
je 0x53f4c
movsd (%rax), %xmm3
subsd %xmm0, %xmm3
movsd 0x8(%rax), %xmm4
subsd %xmm1, %xmm4
mulsd %xmm4, %xmm4
mulsd %xmm3, %xmm3
addsd %xmm4, %xmm3
sqrtsd %xmm3, %xmm3
ucomisd %xmm3, %xmm2
jbe 0x53f4c
movl 0x114(%rax), %ebx
movapd %xmm3, %xmm2
incq %rdx
addq $0x178, %rax            # imm = 0x178
jmp 0x53f0b
movb (%rdx), %r8b
movq 0x8(%rdi), %rdx
leaq 0x10d0(%rdx), %r9
addq $0xa8, %rdx
cmpb 0x10(%rdi), %r8b
movsd (%rcx), %xmm0
movsd 0x8(%rcx), %xmm1
movq %r9, %rcx
cmoveq %rdx, %rcx
cmoveq %r9, %rdx
xorl %ebx, %ebx
movsd 0x7792(%rip), %xmm2     # 0x5b720
pushq $0x1
popq %r8
pushq $0x8
popq %r9
cmpq $0xc, %r8
je 0x54032
cmpq %rax, %r8
jl 0x53fe4
cmpl $0x0, 0x10(%rcx,%r9)
je 0x53fe4
movsd (%rcx,%r9), %xmm3
movsd 0x8(%rcx,%r9), %xmm4
subsd %xmm0, %xmm3
subsd %xmm1, %xmm4
mulsd %xmm4, %xmm4
mulsd %xmm3, %xmm3
addsd %xmm4, %xmm3
sqrtsd %xmm3, %xmm3
ucomisd %xmm3, %xmm2
jbe 0x53fe4
movl 0x114(%rcx,%r9), %ebx
movapd %xmm3, %xmm2
cmpl $0x0, 0x10(%rdx,%r9)
je 0x54023
movsd (%rdx,%r9), %xmm3
movsd 0x8(%rdx,%r9), %xmm4
subsd %xmm0, %xmm3
subsd %xmm1, %xmm4
mulsd %xmm4, %xmm4
mulsd %xmm3, %xmm3
addsd %xmm4, %xmm3
sqrtsd %xmm3, %xmm3
ucomisd %xmm3, %xmm2
jbe 0x54023
movl 0x114(%rdx,%r9), %ebx
movapd %xmm3, %xmm2
incq %r8
addq $0x178, %r9             # imm = 0x178
jmp 0x53f96
testl %ebx, %ebx
je 0x54048
setg %al
movl %ebx, %edx
negl %edx
cmovsl %ebx, %edx
movzbl %al, %ecx
callq 0x532e6
testl %ebx, %ebx
setne %al
addq $0x8, %rsp
popq %rbx
popq %rbp
retq