// File: /workspace/github_cpp_makefile_star2_O2/wrighteagle2d[P]wrighteaglebase/Debug/../src/Formation.cpp
// Function: TeammateFormation::SetHInterval(double, double)
void TeammateFormation::SetHInterval(double back_middle, double middle_front) {
  mHBallFactor = (m_FORMATION_MAX_X - (back_middle + middle_front) / 2.0) /
                 ServerParam::instance().PITCH_LENGTH * 2.0;
  mHBallFactor = Max(0.0, mHBallFactor);

  RoleType role_i, role_j;
  for (int i = 1; i <= TEAMSIZE; ++i) {
    role_i = mPlayerRole[i];
    if (role_i.mIndexX == 1) /** 后卫 */
    {
      mActiveField[i].SetLeft(-m_FORMATION_MAX_X);
      mActiveField[i].SetRight(m_FORMATION_MAX_X - mHInterval[0] -
                               mHInterval[1]);
      mOffsetMatrix[0][i].SetX(-mHInterval[0]);
      mOffsetMatrix[i][0].SetX(mHInterval[0]);
    } else if (role_i.mIndexX == 2) /** 中场 */
    {
      mActiveField[i].SetLeft(-m_FORMATION_MAX_X + mHInterval[0]);
      mActiveField[i].SetRight(m_FORMATION_MAX_X - mHInterval[1]);
      mOffsetMatrix[0][i].SetX(0.0);
      mOffsetMatrix[i][0].SetX(0.0);
    } else if (role_i.mIndexX == 3) /** 前锋 */
    {
      mActiveField[i].SetLeft(-m_FORMATION_MAX_X + mHInterval[0] +
                              mHInterval[1]);
      mActiveField[i].SetRight(m_FORMATION_MAX_X);
      mOffsetMatrix[0][i].SetX(mHInterval[1]);
      mOffsetMatrix[i][0].SetX(-mHInterval[1]);
    }

    for (int j = 1; j <= TEAMSIZE; ++j) {
      role_j = mPlayerRole[j];

      if (role_i.mIndexX == 1) {
        if (role_j.mIndexX == 1) {
          mOffsetMatrix[i][j].SetX(0.0);
        } else if (role_j.mIndexX == 2) {
          mOffsetMatrix[i][j].SetX(mHInterval[0]);
        } else if (role_j.mIndexX == 3) {
          mOffsetMatrix[i][j].SetX(mHInterval[0] + mHInterval[1]);
        }
      } else if (role_i.mIndexX == 2) {
        if (role_j.mIndexX == 1) {
          mOffsetMatrix[i][j].SetX(-mHInterval[0]);
        } else if (role_j.mIndexX == 2) {
          mOffsetMatrix[i][j].SetX(0.0);
        } else if (role_j.mIndexX == 3) {
          mOffsetMatrix[i][j].SetX(mHInterval[1]);
        }
      } else if (role_i.mIndexX == 3) {
        if (role_j.mIndexX == 1) {
          mOffsetMatrix[i][j].SetX(-mHInterval[0] - mHInterval[1]);
        } else if (role_j.mIndexX == 2) {
          mOffsetMatrix[i][j].SetX(-mHInterval[1]);
        } else if (role_j.mIndexX == 3) {
          mOffsetMatrix[i][j].SetX(0.0);
        }
      }
    }
  }
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %rbx
pushq %rax
movq %rdi, %rbx
addsd %xmm1, %xmm0
mulsd 0x3713f(%rip), %xmm0    # 0x57060
addsd 0xc90(%rdi), %xmm0
movsd %xmm0, -0x10(%rbp)
callq 0x3db2c
leaq 0x39f8e(%rip), %rax     # 0x59ec8
movsd -0x10(%rbp), %xmm1
divsd (%rax), %xmm1
addsd %xmm1, %xmm1
xorpd %xmm0, %xmm0
maxsd %xmm0, %xmm1
movsd %xmm1, 0x50(%rbx)
leaq 0x60(%rbx), %rax
leaq 0x380(%rbx), %rcx
movsd 0x10(%rbx), %xmm0
movsd 0x18(%rbx), %xmm1
movapd 0x370af(%rip), %xmm2    # 0x57020
movapd %xmm1, %xmm3
xorpd %xmm2, %xmm3
movapd %xmm0, %xmm4
xorpd %xmm2, %xmm4
movapd %xmm4, %xmm5
subsd %xmm1, %xmm5
movapd %xmm0, %xmm6
addsd %xmm1, %xmm6
leaq 0x110(%rbx), %rdx
movsd 0xc90(%rbx), %xmm7
movapd %xmm0, %xmm8
subsd %xmm7, %xmm8
movapd %xmm8, %xmm9
addsd %xmm1, %xmm9
movapd %xmm7, %xmm10
subsd %xmm1, %xmm10
xorpd %xmm7, %xmm2
subsd %xmm0, %xmm7
subsd %xmm1, %xmm7
leaq 0x450(%rbx), %rsi
pushq $0x1
popq %rdi
cmpq $0xc, %rdi
je 0x2011d
leaq -0x1(%rdi), %r9
movq %r9, %r8
shlq $0x4, %r8
movl (%rax,%r8), %r8d
cmpl $0x3, %r8d
je 0x2003f
cmpl $0x2, %r8d
je 0x20021
cmpl $0x1, %r8d
jne 0x20084
movq %r9, %r10
shlq $0x5, %r10
movsd %xmm2, (%rdx,%r10)
movapd %xmm7, %xmm12
movapd %xmm4, %xmm11
movapd %xmm0, %xmm13
jmp 0x2005f
movq %r9, %r10
shlq $0x5, %r10
movsd %xmm8, (%rdx,%r10)
xorpd %xmm11, %xmm11
movapd %xmm10, %xmm12
xorpd %xmm13, %xmm13
jmp 0x2005f
movq %r9, %r10
shlq $0x5, %r10
movsd %xmm9, (%rdx,%r10)
movsd 0xc90(%rbx), %xmm12
movapd %xmm1, %xmm11
movapd %xmm3, %xmm13
shlq $0x5, %r9
movsd %xmm12, 0x8(%rdx,%r9)
movq %rdi, %r9
shlq $0x4, %r9
movsd %xmm11, (%rcx,%r9)
imulq $0xc0, %rdi, %r9
movsd %xmm13, (%rcx,%r9)
xorl %r9d, %r9d
cmpq $0xb0, %r9
je 0x2010e
movl (%rax,%r9), %r10d
cmpl $0x3, %r8d
je 0x200dc
cmpl $0x2, %r8d
je 0x200be
cmpl $0x1, %r8d
jne 0x20105
cmpl $0x1, %r10d
je 0x200fa
movapd %xmm6, %xmm11
cmpl $0x3, %r10d
je 0x200ff
movapd %xmm0, %xmm11
jmp 0x200f2
movapd %xmm4, %xmm11
cmpl $0x1, %r10d
je 0x200ff
movapd %xmm1, %xmm11
cmpl $0x3, %r10d
je 0x200ff
cmpl $0x2, %r10d
je 0x200fa
jmp 0x20105
movapd %xmm5, %xmm11
cmpl $0x1, %r10d
je 0x200ff
cmpl $0x3, %r10d
je 0x200fa
movapd %xmm3, %xmm11
cmpl $0x2, %r10d
je 0x200ff
jmp 0x20105
xorpd %xmm11, %xmm11
movsd %xmm11, (%rsi,%r9)
addq $0x10, %r9
jmp 0x20087
incq %rdi
addq $0xc0, %rsi
jmp 0x1ffd4
addq $0x8, %rsp
popq %rbx
popq %rbp
retq