// File: /workspace/github_cpp_makefile_star2_O3/wrighteagle2d[P]wrighteaglebase/Debug/../src/PositionInfo.cpp
// Function: PositionInfo::UpdateDistMatrix()
void PositionInfo::UpdateDistMatrix() {
  for (int i = 0; i < 1 + 2 * TEAMSIZE; ++i) {
    for (int j = 0; j < 1 + 2 * TEAMSIZE; ++j) {
      mDistMatrix[i][j] = -1.0;
    }
  }

  for (int i = 0; i < TEAMSIZE; ++i) {
    mTeammateDir2Ball[i] = 0.0;
    mOpponentDir2Ball[i] = 0.0;
  }

  const vector<PlayerState *> &player_list = mpWorldState->GetPlayerList();

  for (vector<PlayerState *>::const_iterator it = player_list.begin();
       it != player_list.end(); ++it) {
    if ((*it)->IsAlive()) {
      int index = Unum2Index((*it)->GetUnum());
      Vector rel_pos = (*it)->GetPos() - mpWorldState->GetBall().GetPos();
      mDistMatrix[0][index] = rel_pos.Mod();
      mDistMatrix[index][index] = 0.0;

      // 更新球员相对于球的角度
      if ((*it)->GetUnum() > 0) {
        mTeammateDir2Ball[(*it)->GetUnum() - 1] = rel_pos.Dir();
      } else {
        mOpponentDir2Ball[-(*it)->GetUnum() - 1] = rel_pos.Dir();
      }
    }
  }

  const uint player_list_size = player_list.size();
  for (unsigned int i = 0; i < player_list_size; ++i) {
    const PlayerState *pi = player_list[i];
    if (pi->IsAlive()) {
      for (unsigned int j = i + 1; j < player_list_size; ++j) {
        const PlayerState *pj = player_list[j];
        if (pj->IsAlive()) {
          int index1 = Unum2Index(pi->GetUnum());
          int index2 = Unum2Index(pj->GetUnum());
          mDistMatrix[index1][index2] = mDistMatrix[index2][index1] =
              pi->GetPos().Dist(pj->GetPos());
        }
      }
    }
  }
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %r12
pushq %rbx
movq %rdi, %rbx
leaq 0x20(%rdi), %r14
xorl %eax, %eax
movabsq $-0x4010000000000000, %rcx # imm = 0xBFF0000000000000
movq %rdi, %rdx
movl $0x4, %esi
movq %rcx, (%rdx,%rsi,8)
incq %rsi
cmpq $0x1b, %rsi
jne 0x46a7c
incq %rax
addq $0xb8, %rdx
cmpq $0x17, %rax
jne 0x46a77
leaq 0x17f8(%rbx), %rdi
movl $0xb0, %edx
xorl %esi, %esi
callq 0x92b0
movq 0x10(%rbx), %r12
movq 0x20f8(%r12), %r15
cmpq 0x2100(%r12), %r15
je 0x46c14
movapd 0x22542(%rip), %xmm4    # 0x69010
movsd 0x2256a(%rip), %xmm5    # 0x69040
movq (%r15), %rcx
cmpb $0x1, 0x112(%rcx)
jne 0x46bf8
movl 0x11c(%rcx), %eax
movl $0xb, %edx
subl %eax, %edx
testl %eax, %eax
cmovgl %eax, %edx
movslq %edx, %rdx
imulq $0xb8, %rdx, %rsi
addq %r14, %rsi
movq 0x10(%rbx), %rdi
movsd 0x8(%rcx), %xmm1
subsd 0x38(%rdi), %xmm1
movsd 0x10(%rcx), %xmm2
subsd 0x40(%rdi), %xmm2
movapd %xmm2, %xmm0
mulsd %xmm2, %xmm0
movapd %xmm1, %xmm3
mulsd %xmm1, %xmm3
addsd %xmm0, %xmm3
xorps %xmm0, %xmm0
sqrtsd %xmm3, %xmm0
movsd %xmm0, 0x20(%rbx,%rdx,8)
movq $0x0, (%rsi,%rdx,8)
movapd %xmm1, %xmm0
andpd %xmm4, %xmm0
movapd %xmm2, %xmm3
andpd %xmm4, %xmm3
cmpltpd %xmm5, %xmm0
cmpltpd %xmm5, %xmm3
andpd %xmm0, %xmm3
movd %xmm3, %ecx
xorpd %xmm0, %xmm0
testl %eax, %eax
jle 0x46bb0
testb $0x1, %cl
jne 0x46ba7
movapd %xmm2, %xmm0
callq 0x90d0
movsd 0x224ba(%rip), %xmm5    # 0x69040
movapd 0x22482(%rip), %xmm4    # 0x69010
mulsd 0x224b2(%rip), %xmm0    # 0x69048
divsd 0x224b2(%rip), %xmm0    # 0x69050
movq (%r15), %rax
movl 0x11c(%rax), %eax
decl %eax
movl $0x17f8, %ecx           # imm = 0x17F8
jmp 0x46bee
testb $0x1, %cl
jne 0x46be7
movapd %xmm2, %xmm0
callq 0x90d0
movsd 0x2247a(%rip), %xmm5    # 0x69040
movapd 0x22442(%rip), %xmm4    # 0x69010
mulsd 0x22472(%rip), %xmm0    # 0x69048
divsd 0x22472(%rip), %xmm0    # 0x69050
movq (%r15), %rax
movl 0x11c(%rax), %eax
notl %eax
movl $0x1850, %ecx           # imm = 0x1850
addq %rbx, %rcx
cltq
movsd %xmm0, (%rcx,%rax,8)
addq $0x8, %r15
cmpq 0x2100(%r12), %r15
jne 0x46ad6
movq 0x20f8(%r12), %rax
jmp 0x46c17
movq %r15, %rax
subq %rax, %r15
shrq $0x3, %r15
testl %r15d, %r15d
je 0x46cf5
movl %r15d, %ecx
xorl %edx, %edx
movq %rax, %rsi
movq (%rax,%rdx,8), %rdi
incq %rdx
cmpb $0x1, 0x112(%rdi)
jne 0x46ce5
cmpq %rcx, %rdx
jae 0x46ce5
movl $0x1, %r8d
movq (%rsi,%r8,8), %r9
cmpb $0x1, 0x112(%r9)
jne 0x46cd9
movl 0x11c(%rdi), %r10d
movl $0xb, %r11d
subl %r10d, %r11d
testl %r10d, %r10d
cmovgl %r10d, %r11d
movl 0x11c(%r9), %r10d
movl $0xb, %ebx
subl %r10d, %ebx
testl %r10d, %r10d
cmovgl %r10d, %ebx
movsd 0x8(%rdi), %xmm0
movsd 0x10(%rdi), %xmm1
subsd 0x8(%r9), %xmm0
subsd 0x10(%r9), %xmm1
mulsd %xmm1, %xmm1
mulsd %xmm0, %xmm0
addsd %xmm1, %xmm0
sqrtsd %xmm0, %xmm0
movslq %ebx, %r9
imulq $0xb8, %r9, %r10
addq %r14, %r10
movslq %r11d, %r11
movsd %xmm0, (%r10,%r11,8)
imulq $0xb8, %r11, %r10
addq %r14, %r10
movsd %xmm0, (%r10,%r9,8)
incq %r8
cmpl %r8d, %r15d
jne 0x46c52
addq $0x8, %rsi
decq %r15
cmpq %rcx, %rdx
jne 0x46c2f
popq %rbx
popq %r12
popq %r14
popq %r15
popq %rbp
retq