// File: /workspace/github_cpp_makefile_star2_O1/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 $0x48, %rsp
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 0x47e1f
incq %rax
addq $0xb8, %rdx
cmpq $0x17, %rax
jne 0x47e1a
movq %rdi, %r14
addq $0x17f8, %rdi           # imm = 0x17F8
movl $0xb0, %edx
xorl %esi, %esi
callq 0x92b0
movq %r14, %rsi
movq 0x10(%r14), %r13
movq 0x20f8(%r13), %r15
movq 0x2100(%r13), %rdi
cmpq %rdi, %r15
je 0x47fd4
leaq 0x20(%rsi), %r12
movq (%r15), %rax
cmpb $0x1, 0x112(%rax)
jne 0x47fc0
movl 0x11c(%rax), %ecx
movl $0xb, %ebx
subl %ecx, %ebx
testl %ecx, %ecx
cmovgl %ecx, %ebx
movq 0x10(%rsi), %rcx
movsd 0x8(%rax), %xmm3
movsd 0x10(%rax), %xmm4
subsd 0x38(%rcx), %xmm3
subsd 0x40(%rcx), %xmm4
movapd %xmm4, %xmm1
mulsd %xmm4, %xmm1
movapd %xmm3, %xmm0
mulsd %xmm3, %xmm0
addsd %xmm1, %xmm0
ucomisd 0x231c6(%rip), %xmm0    # 0x6b090
jb 0x47ed2
sqrtsd %xmm0, %xmm0
jmp 0x47eee
movapd %xmm3, -0x60(%rbp)
movapd %xmm4, -0x50(%rbp)
callq 0x93c0
movapd -0x50(%rbp), %xmm4
movapd -0x60(%rbp), %xmm3
movq %r14, %rsi
movslq %ebx, %rax
leaq (%r12,%rax,8), %rcx
movsd %xmm0, (%r12,%rax,8)
imulq $0xb8, %rax, %rax
movq $0x0, (%rax,%rcx)
movq (%r15), %rax
cmpl $0x0, 0x11c(%rax)
movapd %xmm3, %xmm0
movapd 0x230f0(%rip), %xmm2    # 0x6b010
andpd %xmm2, %xmm0
movapd %xmm4, %xmm1
andpd %xmm2, %xmm1
movsd 0x2310c(%rip), %xmm2    # 0x6b040
cmpltpd %xmm2, %xmm0
cmpltpd %xmm2, %xmm1
andpd %xmm0, %xmm1
movd %xmm1, %eax
xorpd %xmm0, %xmm0
jle 0x47f82
testb $0x1, %al
jne 0x47f70
movapd %xmm4, %xmm0
movapd %xmm3, %xmm1
callq 0x90d0
movq %r14, %rsi
mulsd 0x230e0(%rip), %xmm0    # 0x6b048
divsd 0x230e0(%rip), %xmm0    # 0x6b050
movq (%r15), %rax
movl 0x11c(%rax), %eax
decl %eax
movl $0x17f8, %ecx           # imm = 0x17F8
jmp 0x47fb6
testb $0x1, %al
jne 0x47fa6
movapd %xmm4, %xmm0
movapd %xmm3, %xmm1
callq 0x90d0
movq %r14, %rsi
mulsd 0x230aa(%rip), %xmm0    # 0x6b048
divsd 0x230aa(%rip), %xmm0    # 0x6b050
movq (%r15), %rax
movl 0x11c(%rax), %eax
notl %eax
movl $0x1850, %ecx           # imm = 0x1850
addq %rsi, %rcx
cltq
movsd %xmm0, (%rcx,%rax,8)
addq $0x8, %r15
movq 0x2100(%r13), %rdi
cmpq %rdi, %r15
jne 0x47e74
subq 0x20f8(%r13), %rdi
shrq $0x3, %rdi
testl %edi, %edi
je 0x48107
addq $0x20, %rsi
movl %edi, %eax
movq %rax, -0x38(%rbp)
movl $0x1, %eax
movq %rax, -0x30(%rbp)
xorl %ecx, %ecx
xorpd %xmm2, %xmm2
movq %r13, -0x68(%rbp)
movq 0x20f8(%r13), %rax
movq (%rax,%rcx,8), %r8
incq %rcx
movq %rcx, -0x50(%rbp)
cmpb $0x1, 0x112(%r8)
jne 0x480f5
movq -0x50(%rbp), %rax
cmpq -0x38(%rbp), %rax
jae 0x480f5
movq -0x30(%rbp), %r12
movq %r8, -0x60(%rbp)
movq 0x20f8(%r13), %rax
movq (%rax,%r12,8), %rax
cmpb $0x1, 0x112(%rax)
jne 0x480e9
movl 0x11c(%r8), %ecx
movl $0xb, %ebx
subl %ecx, %ebx
testl %ecx, %ecx
cmovgl %ecx, %ebx
movl 0x11c(%rax), %ecx
movl $0xb, %r14d
subl %ecx, %r14d
testl %ecx, %ecx
cmovgl %ecx, %r14d
movsd 0x8(%r8), %xmm0
subsd 0x8(%rax), %xmm0
movsd 0x10(%r8), %xmm1
subsd 0x10(%rax), %xmm1
mulsd %xmm1, %xmm1
mulsd %xmm0, %xmm0
addsd %xmm1, %xmm0
ucomisd %xmm2, %xmm0
jb 0x480a8
sqrtsd %xmm0, %xmm0
jmp 0x480c5
movq %rsi, %r13
movq %rdi, %r15
callq 0x93c0
movq -0x60(%rbp), %r8
xorpd %xmm2, %xmm2
movq %r15, %rdi
movq %r13, %rsi
movq -0x68(%rbp), %r13
movslq %r14d, %rax
imulq $0xb8, %rax, %rcx
addq %rsi, %rcx
movslq %ebx, %rdx
movsd %xmm0, (%rcx,%rdx,8)
imulq $0xb8, %rdx, %rcx
addq %rsi, %rcx
movsd %xmm0, (%rcx,%rax,8)
incq %r12
cmpl %r12d, %edi
jne 0x4803a
incq -0x30(%rbp)
movq -0x50(%rbp), %rcx
cmpq -0x38(%rbp), %rcx
jne 0x48004
addq $0x48, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq