// File: /workspace/github_cpp_makefile_star2_O3/WolfgangLechner[P]StructureAnalysis/molecular_system.cpp
// Function: CMolecularSystem::calculate_globalqFromComplexVector()
void CMolecularSystem::calculate_globalqFromComplexVector()
{
  int nop;
  nop = this->parameter->nop;
  double realNQ6[13],imgNQ6[13];
  double realNQ4[9],imgNQ4[9];
  double sumGQ4,sumGQ6;
  sumGQ4 = 0.0;
  sumGQ6 = 0.0;
  for (int mi=0;mi<13;mi++)
  {
    realNQ6[mi] = 0.0;
    imgNQ6[mi] = 0.0;
  }
  for (int mi=0;mi<9;mi++)
  {
    realNQ4[mi] = 0.0;
    imgNQ4[mi] = 0.0;
  }

  for (int ti= 0;ti<nop;ti++)
  {
    for (int mi=0;mi<13;mi++)
    {
      realNQ6[mi] += this->molecules[ti].realQ6[mi]/double(nop);
      imgNQ6[mi]  += this->molecules[ti].imgQ6[mi]/double(nop);
    }

    for (int mi=0;mi<9;mi++)
    {
      realNQ4[mi] += this->molecules[ti].realQ4[mi]/double(nop);
      imgNQ4[mi]  += this->molecules[ti].imgQ4[mi]/double(nop);
    }
  }


  sumGQ6 = 0.0;
  for (int hi=0;hi<13;hi++)
  {
    sumGQ6 += realNQ6[hi]*realNQ6[hi] + imgNQ6[hi]*imgNQ6[hi];
  }
  sumGQ6  = sumGQ6 * 4.0*pi/13.0;
  sumGQ6  = pow(sumGQ6 ,0.5);

  sumGQ4 = 0.0;
  for (int hi=0;hi<9;hi++)
  {
    sumGQ4 += realNQ4[hi]*realNQ4[hi] + imgNQ4[hi]*imgNQ4[hi];
  }
  sumGQ4  = sumGQ4 * 4.0*pi/9.0;
  sumGQ4  = pow(sumGQ4 ,0.5);

  this->globalQ6 = sumGQ6;
  this->globalQ4 = sumGQ4;


}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %rbx
subq $0x188, %rsp            # imm = 0x188
movq %rdi, %rbx
movq 0xb4e8c0(%rdi), %rax
movslq 0x3208(%rax), %rax
xorl %ecx, %ecx
xorpd %xmm0, %xmm0
movapd %xmm0, -0x190(%rbp)
movapd %xmm0, -0x180(%rbp)
movapd %xmm0, -0x170(%rbp)
movapd %xmm0, -0x160(%rbp)
movapd %xmm0, -0x150(%rbp)
movapd %xmm0, -0x140(%rbp)
movq %rcx, -0x130(%rbp)
movapd %xmm0, -0x120(%rbp)
movapd %xmm0, -0x110(%rbp)
movapd %xmm0, -0x100(%rbp)
movapd %xmm0, -0xf0(%rbp)
movapd %xmm0, -0xe0(%rbp)
movapd %xmm0, -0xd0(%rbp)
movq %rcx, -0xc0(%rbp)
movapd %xmm0, -0xb0(%rbp)
movapd %xmm0, -0xa0(%rbp)
movapd %xmm0, -0x90(%rbp)
movapd %xmm0, -0x80(%rbp)
movq %rcx, -0x70(%rbp)
movq %rcx, -0x20(%rbp)
movapd %xmm0, -0x30(%rbp)
movapd %xmm0, -0x40(%rbp)
movapd %xmm0, -0x50(%rbp)
movapd %xmm0, -0x60(%rbp)
testq %rax, %rax
jle 0x5968
movq 0xb4e8b8(%rbx), %rcx
xorps %xmm0, %xmm0
cvtsi2sd %eax, %xmm0
leaq 0x650(%rcx), %rdx
addq $0x5a0, %rcx            # imm = 0x5A0
xorl %esi, %esi
movl $0x870, %edi            # imm = 0x870
xorl %r8d, %r8d
movsd -0x68(%rdx,%r8,8), %xmm1
divsd %xmm0, %xmm1
addsd -0x190(%rbp,%r8,8), %xmm1
movsd %xmm1, -0x190(%rbp,%r8,8)
movsd (%rdx,%r8,8), %xmm1
divsd %xmm0, %xmm1
addsd -0x120(%rbp,%r8,8), %xmm1
movsd %xmm1, -0x120(%rbp,%r8,8)
incq %r8
cmpq $0xd, %r8
jne 0x58cd
xorl %r8d, %r8d
movsd -0x48(%rcx,%r8,8), %xmm1
divsd %xmm0, %xmm1
addsd -0xb0(%rbp,%r8,8), %xmm1
movsd %xmm1, -0xb0(%rbp,%r8,8)
movsd (%rcx,%r8,8), %xmm1
divsd %xmm0, %xmm1
addsd -0x60(%rbp,%r8,8), %xmm1
movsd %xmm1, -0x60(%rbp,%r8,8)
incq %r8
cmpq $0x9, %r8
jne 0x5916
incq %rsi
addq %rdi, %rdx
addq %rdi, %rcx
cmpq %rax, %rsi
jne 0x58ca
xorpd %xmm0, %xmm0
xorl %eax, %eax
movsd -0x190(%rbp,%rax,8), %xmm1
movsd -0x120(%rbp,%rax,8), %xmm2
mulsd %xmm2, %xmm2
mulsd %xmm1, %xmm1
addsd %xmm2, %xmm1
addsd %xmm1, %xmm0
incq %rax
cmpq $0xd, %rax
jne 0x596e
mulsd 0x26cf(%rip), %xmm0     # 0x8070
mulsd 0x26cf(%rip), %xmm0     # 0x8078
divsd 0x26d7(%rip), %xmm0     # 0x8088
movsd 0x265f(%rip), %xmm1     # 0x8018
callq 0x2340
movsd %xmm0, -0x10(%rbp)
xorpd %xmm0, %xmm0
xorl %eax, %eax
movsd -0xb0(%rbp,%rax,8), %xmm1
movsd -0x60(%rbp,%rax,8), %xmm2
mulsd %xmm2, %xmm2
mulsd %xmm1, %xmm1
addsd %xmm2, %xmm1
addsd %xmm1, %xmm0
incq %rax
cmpq $0x9, %rax
jne 0x59c9
mulsd 0x2677(%rip), %xmm0     # 0x8070
mulsd 0x2677(%rip), %xmm0     # 0x8078
divsd 0x2677(%rip), %xmm0     # 0x8080
movsd 0x2607(%rip), %xmm1     # 0x8018
callq 0x2340
movsd -0x10(%rbp), %xmm1
movsd %xmm1, 0xb4ec08(%rbx)
movsd %xmm0, 0xb4ec10(%rbx)
addq $0x188, %rsp            # imm = 0x188
popq %rbx
popq %rbp
retq
nop