// File: /workspace/github_cpp_makefile_star2_O2/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 %r13
pushq %r12
pushq %rbx
subq $0x38, %rsp
leaq 0x20(%rdi), %rax
movq %rax, -0x50(%rbp)
xorl %eax, %eax
pushq $0x4
popq %rcx
movabsq $-0x4010000000000000, %rdx # imm = 0xBFF0000000000000
movq %rdi, -0x30(%rbp)
movq %rdi, %rsi
cmpq $0x17, %rax
je 0x3b519
movq %rcx, %rdi
cmpq $0x1b, %rdi
je 0x3b50d
movq %rdx, (%rsi,%rdi,8)
incq %rdi
jmp 0x3b4fe
incq %rax
addq $0xb8, %rsi
jmp 0x3b4f5
movq -0x30(%rbp), %rax
leaq 0x17f8(%rax), %rcx
movq %rcx, -0x40(%rbp)
leaq 0x1850(%rax), %r14
pushq $-0x58
popq %rax
testq %rax, %rax
je 0x3b548
andq $0x0, (%r14,%rax)
andq $0x0, 0x58(%r14,%rax)
addq $0x8, %rax
jmp 0x3b532
movq -0x30(%rbp), %rax
movq 0x10(%rax), %r12
movq 0x20f8(%r12), %rbx
movq %rbx, %rcx
negq %rcx
cmpq 0x2100(%r12), %rbx
je 0x3b622
movq (%rbx), %rax
cmpb $0x1, 0x112(%rax)
jne 0x3b615
movl 0x11c(%rax), %r15d
movq %rcx, -0x38(%rbp)
pushq $0xb
popq %rcx
subl %r15d, %ecx
testl %r15d, %r15d
cmovgl %r15d, %ecx
movq -0x30(%rbp), %rsi
movq 0x10(%rsi), %rdx
movsd 0x8(%rax), %xmm0
movsd 0x10(%rax), %xmm1
subsd 0x38(%rdx), %xmm0
subsd 0x40(%rdx), %xmm1
movsd %xmm0, -0x60(%rbp)
movsd %xmm1, -0x58(%rbp)
mulsd %xmm1, %xmm1
mulsd %xmm0, %xmm0
addsd %xmm1, %xmm0
sqrtsd %xmm0, %xmm0
movslq %ecx, %rax
movsd %xmm0, 0x20(%rsi,%rax,8)
movq %r14, %r13
cmovgq -0x40(%rbp), %r13
imulq $0xb8, %rax, %rcx
addq -0x50(%rbp), %rcx
andq $0x0, (%rcx,%rax,8)
leaq -0x60(%rbp), %rdi
callq 0xcd30
movq (%rbx), %rax
movl 0x11c(%rax), %eax
leal -0x1(%rax), %ecx
testl %r15d, %r15d
notl %eax
cmovgl %ecx, %eax
movq -0x38(%rbp), %rcx
cltq
movsd %xmm0, (%r13,%rax,8)
addq $0x8, %rbx
addq $-0x8, %rcx
jmp 0x3b55e
addq 0x20f8(%r12), %rcx
negq %rcx
shrq $0x3, %rcx
movl %ecx, %r14d
pushq $0x1
popq %rax
movq %rax, -0x48(%rbp)
xorl %ecx, %ecx
cmpq %r14, %rcx
je 0x3b707
movq 0x20f8(%r12), %rax
movq %rcx, -0x40(%rbp)
movq (%rax,%rcx,8), %rax
movq %rax, -0x38(%rbp)
cmpb $0x1, 0x112(%rax)
jne 0x3b6f7
movq -0x38(%rbp), %rax
addq $0x8, %rax
movq %rax, -0x30(%rbp)
movq -0x48(%rbp), %r15
cmpq %r14, %r15
jae 0x3b6f7
movq 0x20f8(%r12), %rax
movq (%rax,%r15,8), %rsi
cmpb $0x1, 0x112(%rsi)
jne 0x3b6f2
movq -0x38(%rbp), %rax
movl 0x11c(%rax), %eax
movq %r12, %r13
pushq $0xb
popq %rbx
movl %ebx, %r12d
subl %eax, %r12d
testl %eax, %eax
cmovgl %eax, %r12d
movl 0x11c(%rsi), %eax
subl %eax, %ebx
testl %eax, %eax
cmovgl %eax, %ebx
addq $0x8, %rsi
movq -0x30(%rbp), %rdi
callq 0x2198a
movslq %ebx, %rax
imulq $0xb8, %rax, %rcx
movq -0x50(%rbp), %rsi
addq %rsi, %rcx
movslq %r12d, %rdx
movq %r13, %r12
movsd %xmm0, (%rcx,%rdx,8)
imulq $0xb8, %rdx, %rcx
addq %rsi, %rcx
movsd %xmm0, (%rcx,%rax,8)
incq %r15
jmp 0x3b677
movq -0x40(%rbp), %rcx
incq %rcx
incq -0x48(%rbp)
jmp 0x3b63d
addq $0x38, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq