// File: /workspace/github_cpp_makefile_star2_O3/wrighteagle2d[P]wrighteaglebase/Debug/../src/Formation.cpp
// Function: OpponentFormation::SetOffsetMatrix()
void OpponentFormation::SetOffsetMatrix() {
  if (mHIntervalTimes[0] == 0 || mHIntervalTimes[1] == 0)
    return;
  RoleType iRole, jRole;
  const double MAXX = 50.0;
  const double MINX = -50.0;
  const double MAXY = 23.0;
  const double MINY = -23.0;

  mHBallFactor = (MAXX - (mHInterval[0] + mHInterval[1]) * 0.5) /
                 ServerParam::instance().PITCH_LENGTH * 2;
  mHBallFactor = Max(0.0, mHBallFactor);

  double maxwide = Max(mVInterval[1] * (mLineArrange[1] - 1),
                       mVInterval[2] * (mLineArrange[2] - 1));
  maxwide = Max(maxwide, mVInterval[3] * (mLineArrange[3] - 1));
  mVBallFactor =
      (MAXY - maxwide * 0.5) / ServerParam::instance().PITCH_WIDTH * 2;
  mVBallFactor = Max(0.0, mVBallFactor);

  for (int i = 1; i <= TEAMSIZE; i++) {
    if (i == mGoalieUnum)
      continue;
    iRole = mPlayerRole[i];
    if (iRole.mLineType == LT_Null)
      continue;
    if (iRole.mIndexX == 1) {
      mActiveField[i].SetLeft(MINX);
      mActiveField[i].SetRight(MAXX - mHInterval[1] - mHInterval[0]);
    } else if (iRole.mIndexX == 2) {
      mActiveField[i].SetLeft(MINX + mHInterval[0]);
      mActiveField[i].SetRight(MAXX - mHInterval[1]);
    } else if (iRole.mIndexX == 3) {
      mActiveField[i].SetLeft(MINX + mHInterval[0] + mHInterval[1]);
      mActiveField[i].SetRight(MAXX);
    }
    mActiveField[i].SetBottom(MAXY -
                              (mLineArrange[iRole.mIndexX] - iRole.mIndexY) *
                                  mVInterval[iRole.mIndexX]);
    mActiveField[i].SetTop(MINY + iRole.mIndexY * mVInterval[iRole.mIndexX]);
    //与中心的相互偏移
    if (iRole.mIndexX == 1) {
      mOffsetMatrix[0][i].SetX(-mHInterval[0]);
      mOffsetMatrix[i][0].SetX(mHInterval[0]);
    } else if (iRole.mIndexX == 2) {
      mOffsetMatrix[0][i].SetX(0);
      mOffsetMatrix[i][0].SetX(0);
    } else if (iRole.mIndexX == 3) {
      mOffsetMatrix[0][i].SetX(mHInterval[1]);
      mOffsetMatrix[i][0].SetX(-mHInterval[1]);
    }

    double iy = (iRole.mIndexY - mLineArrange[iRole.mIndexX] * 0.5) *
                mVInterval[iRole.mIndexX];
    mOffsetMatrix[0][i].SetY(iy);
    mOffsetMatrix[i][0].SetY(-iy);

    for (int j = 1; j < 11; j++) {
      if (j == mGoalieUnum || i == j)
        continue;
      jRole = mPlayerRole[j];
      if (jRole.mLineType == LT_Null)
        continue;
      //与其他队员的相互偏移
      if (iRole.mIndexX == 1) {
        if (jRole.mIndexX == 1) {
          mOffsetMatrix[i][j].SetX(0.0);
        } else if (jRole.mIndexX == 2) {
          mOffsetMatrix[i][j].SetX(mHInterval[0]);
        } else if (jRole.mIndexX == 3) {
          mOffsetMatrix[i][j].SetX(mHInterval[0] + mHInterval[1]);
        }
      } else if (iRole.mIndexX == 2) {
        if (jRole.mIndexX == 1) {
          mOffsetMatrix[i][j].SetX(-mHInterval[0]);
        } else if (jRole.mIndexX == 2) {
          mOffsetMatrix[i][j].SetX(0);
        } else if (jRole.mIndexX == 3) {
          mOffsetMatrix[i][j].SetX(mHInterval[1]);
        }
      } else if (iRole.mIndexX == 3) {
        if (jRole.mIndexX == 1) {
          mOffsetMatrix[i][j].SetX(-mHInterval[0] - mHInterval[1]);
        } else if (jRole.mIndexX == 2) {
          mOffsetMatrix[i][j].SetX(-mHInterval[1]);
        } else if (jRole.mIndexX == 3) {
          mOffsetMatrix[i][j].SetX(0.0);
        }
      }
      double jy = (jRole.mIndexY - (mLineArrange[jRole.mIndexX] + 1) * 0.5) *
                  mVInterval[jRole.mIndexX];
      mOffsetMatrix[i][j].SetY(jy - iy);
    }
  }
}

// Assembly:
cmpl $0x0, 0xce0(%rdi)
je 0x2664a
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
pushq %rax
movq %rdi, %rbx
cmpl $0x0, 0xce4(%rdi)
je 0x2663c
movsd 0x10(%rbx), %xmm0
addsd 0x18(%rbx), %xmm0
mulsd 0x435f3(%rip), %xmm0    # 0x69878
movsd 0x43bf3(%rip), %xmm1    # 0x69e80
subsd %xmm0, %xmm1
movsd %xmm1, -0x30(%rbp)
callq 0x49360
leaq 0x45c46(%rip), %rax     # 0x6bee8
movsd -0x30(%rbp), %xmm1
divsd (%rax), %xmm1
addsd %xmm1, %xmm1
xorpd %xmm0, %xmm0
maxsd %xmm0, %xmm1
movsd %xmm1, 0x50(%rbx)
movl 0x44(%rbx), %eax
decl %eax
xorps %xmm0, %xmm0
cvtsi2sd %eax, %xmm0
movl 0x48(%rbx), %eax
mulsd 0x28(%rbx), %xmm0
decl %eax
xorps %xmm1, %xmm1
cvtsi2sd %eax, %xmm1
mulsd 0x30(%rbx), %xmm1
movl 0x4c(%rbx), %eax
decl %eax
cvtsi2sd %eax, %xmm2
maxsd %xmm0, %xmm1
mulsd 0x38(%rbx), %xmm2
maxsd %xmm1, %xmm2
mulsd 0x4357c(%rip), %xmm2    # 0x69878
movsd 0x442f4(%rip), %xmm0    # 0x6a5f8
subsd %xmm2, %xmm0
movsd %xmm0, -0x30(%rbp)
callq 0x49360
leaq 0x45bd7(%rip), %rax     # 0x6bef0
movsd -0x30(%rbp), %xmm0
divsd (%rax), %xmm0
addsd %xmm0, %xmm0
maxsd 0x42d62(%rip), %xmm0    # 0x69090
movsd %xmm0, 0x58(%rbx)
movl 0xce8(%rbx), %eax
leaq 0x60(%rbx), %rcx
leaq 0x110(%rbx), %rdx
movsd 0x10(%rbx), %xmm9
movsd 0x18(%rbx), %xmm1
movsd 0x442a9(%rip), %xmm2    # 0x6a600
addsd %xmm9, %xmm2
movapd %xmm2, %xmm0
addsd %xmm1, %xmm0
movsd %xmm0, -0x30(%rbp)
movsd 0x43b0f(%rip), %xmm4    # 0x69e80
subsd %xmm1, %xmm4
movapd %xmm4, %xmm5
subsd %xmm9, %xmm5
leaq 0x380(%rbx), %rsi
movapd 0x42c93(%rip), %xmm6    # 0x69020
movapd %xmm1, %xmm7
xorpd %xmm6, %xmm7
xorpd %xmm9, %xmm6
movapd %xmm6, %xmm8
subsd %xmm1, %xmm8
movapd %xmm9, %xmm3
addsd %xmm1, %xmm3
leaq 0x458(%rbx), %rdi
movq %rax, %r8
shlq $0x4, %r8
addq $-0x10, %r8
movl $0x1, %r9d
xorl %r10d, %r10d
movsd 0x4422f(%rip), %xmm10   # 0x6a600
movsd 0x4422e(%rip), %xmm11   # 0x6a608
movsd 0x42ca5(%rip), %xmm12   # 0x69088
movapd 0x42c34(%rip), %xmm13   # 0x69020
cmpq %rax, %r9
je 0x26624
leaq -0x1(%r9), %r14
movq %r14, %r15
shlq $0x4, %r15
cmpl $-0x1, 0x8(%rcx,%r15)
je 0x26624
movslq (%rcx,%r15), %r11
movl 0x4(%rcx,%r15), %r12d
movapd %xmm10, %xmm14
movapd %xmm5, %xmm0
cmpl $0x1, %r11d
je 0x26449
cmpl $0x3, %r11d
je 0x2643b
movapd %xmm2, %xmm14
movapd %xmm4, %xmm0
cmpl $0x2, %r11d
je 0x26449
jmp 0x2645d
movsd -0x30(%rbp), %xmm14
movsd 0x43a37(%rip), %xmm0    # 0x69e80
movq %r14, %r15
shlq $0x5, %r15
movsd %xmm14, (%rdx,%r15)
movsd %xmm0, 0x8(%rdx,%r15)
shlq $0x5, %r14
movl 0x40(%rbx,%r11,4), %r15d
movl %r15d, %r13d
subl %r12d, %r13d
xorps %xmm0, %xmm0
cvtsi2sd %r13d, %xmm0
mulsd 0x20(%rbx,%r11,8), %xmm0
movsd 0x44174(%rip), %xmm15   # 0x6a5f8
subsd %xmm0, %xmm15
xorps %xmm14, %xmm14
cvtsi2sd %r12d, %xmm14
movsd %xmm15, 0x18(%rdx,%r14)
movsd 0x20(%rbx,%r11,8), %xmm0
mulsd %xmm14, %xmm0
addsd %xmm11, %xmm0
movsd %xmm0, 0x10(%rdx,%r14)
movapd %xmm6, %xmm15
movapd %xmm9, %xmm0
cmpl $0x1, %r11d
je 0x264e1
cmpl $0x3, %r11d
je 0x264d8
cmpl $0x2, %r11d
jne 0x264fc
xorpd %xmm15, %xmm15
xorpd %xmm0, %xmm0
jmp 0x264e1
movapd %xmm1, %xmm15
movapd %xmm7, %xmm0
movq %r9, %r14
shlq $0x4, %r14
movsd %xmm15, (%rsi,%r14)
leaq (%r9,%r9,2), %r14
shlq $0x6, %r14
movsd %xmm0, (%rsi,%r14)
xorps %xmm0, %xmm0
cvtsi2sd %r15d, %xmm0
mulsd %xmm12, %xmm0
addsd %xmm0, %xmm14
mulsd 0x20(%rbx,%r11,8), %xmm14
movq %r9, %r14
shlq $0x4, %r14
movsd %xmm14, 0x8(%rsi,%r14)
leaq (%r9,%r9,2), %r14
shlq $0x6, %r14
movapd %xmm14, %xmm0
xorpd %xmm13, %xmm0
movlpd %xmm0, 0x8(%rsi,%r14)
xorl %r14d, %r14d
cmpq %r14, %r8
sete %r15b
cmpq %r14, %r10
sete %r12b
orb %r15b, %r12b
jne 0x26613
cmpl $-0x1, 0x68(%rbx,%r14)
je 0x26613
movslq 0x60(%rbx,%r14), %r15
movl 0x64(%rbx,%r14), %r12d
cmpl $0x3, %r11d
je 0x265b4
cmpl $0x2, %r11d
je 0x26596
cmpl $0x1, %r11d
jne 0x265de
cmpl $0x1, %r15d
je 0x265d2
movapd %xmm3, %xmm15
cmpl $0x3, %r15d
je 0x265d7
movapd %xmm9, %xmm15
jmp 0x265ca
movapd %xmm6, %xmm15
cmpl $0x1, %r15d
je 0x265d7
movapd %xmm1, %xmm15
cmpl $0x3, %r15d
je 0x265d7
cmpl $0x2, %r15d
je 0x265d2
jmp 0x265de
movapd %xmm8, %xmm15
cmpl $0x1, %r15d
je 0x265d7
cmpl $0x3, %r15d
je 0x265d2
movapd %xmm7, %xmm15
cmpl $0x2, %r15d
je 0x265d7
jmp 0x265de
xorpd %xmm15, %xmm15
movsd %xmm15, -0x8(%rdi,%r14)
xorps %xmm0, %xmm0
cvtsi2sd %r12d, %xmm0
movl 0x40(%rbx,%r15,4), %r12d
incl %r12d
xorps %xmm15, %xmm15
cvtsi2sd %r12d, %xmm15
mulsd %xmm12, %xmm15
addsd %xmm0, %xmm15
mulsd 0x20(%rbx,%r15,8), %xmm15
subsd %xmm14, %xmm15
movsd %xmm15, (%rdi,%r14)
addq $0x10, %r14
cmpq $0xa0, %r14
jne 0x2653f
incq %r9
addq $0xc0, %rdi
addq $0x10, %r10
cmpq $0xc, %r9
jne 0x263ec
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
nop