// File: /workspace/github_cpp_makefile_star2_O1/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 %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x38, %rsp
movq %rdi, %rbx
movq (%rdi), %rax
movslq %edx, %rdi
imulq $0x2e8ba2e9, %rdi, %rcx # imm = 0x2E8BA2E9
movq %rcx, %rdx
shrq $0x3f, %rdx
sarq $0x22, %rcx
addl %edx, %ecx
leal (%rcx,%rcx,4), %edx
leal (%rcx,%rdx,4), %edx
addl %ecx, %edx
movl %edi, %ecx
subl %edx, %ecx
movslq %ecx, %rcx
imulq $0x70, %rcx, %rcx
shlq $0x4, %rdi
movslq 0x31e8(%rax,%rdi), %rdx
cmpb $0x0, 0x2880(%rax,%rcx)
movq %rsi, -0x38(%rbp)
movq %rcx, -0x58(%rbp)
je 0x67eaa
addq %rax, %rcx
addq $0x2840, %rcx           # imm = 0x2840
addq %rdi, %rax
addq $0x31e4, %rax           # imm = 0x31E4
movb 0x41(%rcx), %cl
cmpb (%rax), %cl
movl $0x1, %eax
cmovel %edx, %eax
movl $0x0, -0x2c(%rbp)
cmpl $0xb, %eax
jg 0x68084
movslq %eax, %r15
imulq $0x178, %r15, %r12      # imm = 0x178
addq $-0x170, %r12           # imm = 0xFE90
incq %r15
movsd 0x79c7(%rip), %xmm3     # 0x6f780
movl $0x0, -0x2c(%rbp)
xorpd %xmm2, %xmm2
movq (%rbx), %rax
movq -0x58(%rbp), %rcx
movb 0x2881(%rax,%rcx), %al
movl $0xa8, %r14d
cmpb 0x10(%rbx), %al
je 0x67de3
movl $0x10d0, %r14d          # imm = 0x10D0
addq 0x8(%rbx), %r14
cmpl $0x0, 0x10(%r12,%r14)
je 0x67e8b
movsd (%r14,%r12), %xmm0
subsd (%rsi), %xmm0
movsd 0x8(%r14,%r12), %xmm1
subsd 0x8(%rsi), %xmm1
mulsd %xmm1, %xmm1
mulsd %xmm0, %xmm0
addsd %xmm1, %xmm0
ucomisd %xmm2, %xmm0
jb 0x67e21
sqrtsd %xmm0, %xmm0
jmp 0x67e38
movsd %xmm3, -0x40(%rbp)
callq 0x93c0
movsd -0x40(%rbp), %xmm3
xorpd %xmm2, %xmm2
movq -0x38(%rbp), %rsi
ucomisd %xmm0, %xmm3
jbe 0x67e8b
movsd (%r14,%r12), %xmm0
subsd (%rsi), %xmm0
movsd 0x8(%r14,%r12), %xmm1
subsd 0x8(%rsi), %xmm1
mulsd %xmm1, %xmm1
mulsd %xmm0, %xmm0
addsd %xmm1, %xmm0
ucomisd %xmm2, %xmm0
jb 0x67e6f
xorps %xmm3, %xmm3
sqrtsd %xmm0, %xmm3
jmp 0x67e80
callq 0x93c0
xorpd %xmm2, %xmm2
movq -0x38(%rbp), %rsi
movapd %xmm0, %xmm3
movl 0x114(%r14,%r12), %eax
movl %eax, -0x2c(%rbp)
addq $0x178, %r12            # imm = 0x178
movq %r15, %rax
incq %rax
cmpl $0xc, %r15d
movq %rax, %r15
jne 0x67dc4
jmp 0x68084
movsd 0x78ce(%rip), %xmm3     # 0x6f780
movl $0x0, -0x2c(%rbp)
movl $0x1, %r12d
movl $0x8, %r15d
xorpd %xmm2, %xmm2
movq %rdi, -0x50(%rbp)
movq %rdx, -0x48(%rbp)
movq (%rbx), %rax
movq 0x8(%rbx), %r13
movb 0x31e4(%rax,%rdi), %cl
leaq 0x10d0(%r13), %rax
addq $0xa8, %r13
cmpb 0x10(%rbx), %cl
je 0x67ef7
movq %rax, %r14
jmp 0x67efd
movq %r13, %r14
movq %rax, %r13
cmpq %rdx, %r12
jl 0x67fba
cmpl $0x0, 0x10(%r14,%r15)
je 0x67fba
movsd (%r14,%r15), %xmm0
subsd (%rsi), %xmm0
movsd 0x8(%r14,%r15), %xmm1
subsd 0x8(%rsi), %xmm1
mulsd %xmm1, %xmm1
mulsd %xmm0, %xmm0
addsd %xmm1, %xmm0
ucomisd %xmm2, %xmm0
jb 0x67f40
sqrtsd %xmm0, %xmm0
jmp 0x67f5f
movsd %xmm3, -0x40(%rbp)
callq 0x93c0
movsd -0x40(%rbp), %xmm3
xorpd %xmm2, %xmm2
movq -0x48(%rbp), %rdx
movq -0x50(%rbp), %rdi
movq -0x38(%rbp), %rsi
ucomisd %xmm0, %xmm3
jbe 0x67fba
movsd (%r14,%r15), %xmm0
subsd (%rsi), %xmm0
movsd 0x8(%r14,%r15), %xmm1
subsd 0x8(%rsi), %xmm1
mulsd %xmm1, %xmm1
mulsd %xmm0, %xmm0
addsd %xmm1, %xmm0
ucomisd %xmm2, %xmm0
jb 0x67f96
xorps %xmm3, %xmm3
sqrtsd %xmm0, %xmm3
jmp 0x67faf
callq 0x93c0
xorpd %xmm2, %xmm2
movq -0x48(%rbp), %rdx
movq -0x50(%rbp), %rdi
movq -0x38(%rbp), %rsi
movapd %xmm0, %xmm3
movl 0x114(%r14,%r15), %eax
movl %eax, -0x2c(%rbp)
cmpl $0x0, 0x10(%r13,%r15)
je 0x68070
movsd (%r13,%r15), %xmm0
subsd (%rsi), %xmm0
movsd 0x8(%r13,%r15), %xmm1
subsd 0x8(%rsi), %xmm1
mulsd %xmm1, %xmm1
mulsd %xmm0, %xmm0
addsd %xmm1, %xmm0
ucomisd %xmm2, %xmm0
jb 0x67ff5
sqrtsd %xmm0, %xmm0
jmp 0x68014
movsd %xmm3, -0x40(%rbp)
callq 0x93c0
movsd -0x40(%rbp), %xmm3
xorpd %xmm2, %xmm2
movq -0x48(%rbp), %rdx
movq -0x50(%rbp), %rdi
movq -0x38(%rbp), %rsi
ucomisd %xmm0, %xmm3
jbe 0x68070
movsd (%r13,%r15), %xmm0
subsd (%rsi), %xmm0
movsd 0x8(%r13,%r15), %xmm1
subsd 0x8(%rsi), %xmm1
mulsd %xmm1, %xmm1
mulsd %xmm0, %xmm0
addsd %xmm1, %xmm0
ucomisd %xmm2, %xmm0
jb 0x6804c
xorps %xmm3, %xmm3
sqrtsd %xmm0, %xmm3
jmp 0x68065
callq 0x93c0
xorpd %xmm2, %xmm2
movq -0x48(%rbp), %rdx
movq -0x50(%rbp), %rdi
movq -0x38(%rbp), %rsi
movapd %xmm0, %xmm3
movl 0x114(%r13,%r15), %eax
movl %eax, -0x2c(%rbp)
incq %r12
addq $0x178, %r15            # imm = 0x178
cmpq $0xc, %r12
jne 0x67ed1
movl -0x2c(%rbp), %r14d
testl %r14d, %r14d
je 0x680b6
setg %al
movq (%rbx), %rcx
movq -0x58(%rbp), %rdx
leaq (%rcx,%rdx), %rsi
addq $0x2840, %rsi           # imm = 0x2840
movl %r14d, %edx
negl %edx
cmovsl %r14d, %edx
movzbl %al, %ecx
movq %rbx, %rdi
callq 0x66992
testl %r14d, %r14d
setne %al
addq $0x38, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
nop