// File: /workspace/github_cpp_makefile_star2_O2/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 0x209f4
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 0x209e6
movsd 0x10(%rbx), %xmm0
addsd 0x18(%rbx), %xmm0
mulsd 0x3720b(%rip), %xmm0    # 0x57848
movsd 0x377fb(%rip), %xmm1    # 0x57e40
subsd %xmm0, %xmm1
movsd %xmm1, -0x30(%rbp)
callq 0x3db2c
leaq 0x3986e(%rip), %rax     # 0x59ec8
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
cvtsi2sd %eax, %xmm0
movl 0x48(%rbx), %eax
mulsd 0x28(%rbx), %xmm0
decl %eax
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 0x3719a(%rip), %xmm2    # 0x57848
movsd 0x37f12(%rip), %xmm0    # 0x585c8
subsd %xmm2, %xmm0
movsd %xmm0, -0x30(%rbp)
callq 0x3db2c
leaq 0x39805(%rip), %rax     # 0x59ed0
movsd -0x30(%rbp), %xmm0
divsd (%rax), %xmm0
addsd %xmm0, %xmm0
maxsd 0x37c00(%rip), %xmm0    # 0x582e0
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 0x37ec7(%rip), %xmm2    # 0x585d0
addsd %xmm9, %xmm2
movapd %xmm2, %xmm0
addsd %xmm1, %xmm0
movsd %xmm0, -0x30(%rbp)
movsd 0x3771d(%rip), %xmm4    # 0x57e40
subsd %xmm1, %xmm4
movapd %xmm4, %xmm5
subsd %xmm9, %xmm5
leaq 0x380(%rbx), %rsi
movapd 0x368e1(%rip), %xmm6    # 0x57020
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
pushq $0x1
popq %r9
xorl %r10d, %r10d
movsd 0x37e4f(%rip), %xmm10   # 0x585d0
movsd 0x37e4e(%rip), %xmm11   # 0x585d8
movsd 0x368cd(%rip), %xmm12   # 0x57060
movapd 0x36884(%rip), %xmm13   # 0x57020
cmpq $0xc, %r9
je 0x209e6
cmpq %rax, %r9
je 0x209d3
leaq -0x1(%r9), %r14
movq %r14, %r15
shlq $0x4, %r15
cmpl $-0x1, 0x8(%rcx,%r15)
je 0x209d3
movslq (%rcx,%r15), %r11
movl 0x4(%rcx,%r15), %r12d
movapd %xmm10, %xmm14
movapd %xmm5, %xmm15
cmpl $0x1, %r11d
je 0x20806
cmpl $0x3, %r11d
je 0x207f7
movapd %xmm2, %xmm14
movapd %xmm4, %xmm15
cmpl $0x2, %r11d
je 0x20806
jmp 0x2081a
movsd -0x30(%rbp), %xmm14
movsd 0x3763a(%rip), %xmm15   # 0x57e40
movq %r14, %r15
shlq $0x5, %r15
movsd %xmm14, (%rdx,%r15)
movsd %xmm15, 0x8(%rdx,%r15)
shlq $0x5, %r14
movl 0x40(%rbx,%r11,4), %r15d
movl %r15d, %r13d
subl %r12d, %r13d
cvtsi2sd %r13d, %xmm0
mulsd 0x20(%rbx,%r11,8), %xmm0
movsd 0x37d8a(%rip), %xmm15   # 0x585c8
subsd %xmm0, %xmm15
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 0x20897
cmpl $0x3, %r11d
je 0x2088e
cmpl $0x2, %r11d
jne 0x208b1
xorpd %xmm15, %xmm15
xorpd %xmm0, %xmm0
jmp 0x20897
movapd %xmm1, %xmm15
movapd %xmm7, %xmm0
movq %r9, %r14
shlq $0x4, %r14
movsd %xmm15, (%rsi,%r14)
imulq $0xc0, %r9, %r14
movsd %xmm0, (%rsi,%r14)
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)
imulq $0xc0, %r9, %r14
movapd %xmm14, %xmm0
xorpd %xmm13, %xmm0
movlpd %xmm0, 0x8(%rsi,%r14)
xorl %r14d, %r14d
cmpq $0xa0, %r14
je 0x209d3
cmpq %r14, %r8
sete %r15b
cmpq %r14, %r10
sete %r12b
orb %r15b, %r12b
jne 0x209ca
cmpl $-0x1, 0x68(%rbx,%r14)
je 0x209ca
movslq 0x60(%rbx,%r14), %r15
movl 0x64(%rbx,%r14), %r12d
cmpl $0x3, %r11d
je 0x20972
cmpl $0x2, %r11d
je 0x20954
cmpl $0x1, %r11d
jne 0x2099c
cmpl $0x1, %r15d
je 0x20990
movapd %xmm3, %xmm15
cmpl $0x3, %r15d
je 0x20995
movapd %xmm9, %xmm15
jmp 0x20988
movapd %xmm6, %xmm15
cmpl $0x1, %r15d
je 0x20995
movapd %xmm1, %xmm15
cmpl $0x3, %r15d
je 0x20995
cmpl $0x2, %r15d
je 0x20990
jmp 0x2099c
movapd %xmm8, %xmm15
cmpl $0x1, %r15d
je 0x20995
cmpl $0x3, %r15d
je 0x20990
movapd %xmm7, %xmm15
cmpl $0x2, %r15d
je 0x20995
jmp 0x2099c
xorpd %xmm15, %xmm15
movsd %xmm15, -0x8(%rdi,%r14)
cvtsi2sd %r12d, %xmm0
movl 0x40(%rbx,%r15,4), %r12d
incl %r12d
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
jmp 0x208f0
incq %r9
addq $0xc0, %rdi
addq $0x10, %r10
jmp 0x2079c
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
nop