// File: /workspace/github_cpp_makefile_star2_O2/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
movl 0x3208(%rax), %eax
xorl %ecx, %ecx
cmpq $0xd, %rcx
je 0x4f41
andq $0x0, -0x190(%rbp,%rcx,8)
andq $0x0, -0x120(%rbp,%rcx,8)
incq %rcx
jmp 0x4f24
xorl %ecx, %ecx
cmpq $0x9, %rcx
je 0x4f5d
andq $0x0, -0xb0(%rbp,%rcx,8)
andq $0x0, -0x60(%rbp,%rcx,8)
incq %rcx
jmp 0x4f43
cvtsi2sd %eax, %xmm0
xorl %ecx, %ecx
testl %eax, %eax
cmovlel %ecx, %eax
movq 0xb4e8b8(%rbx), %rdx
leaq 0x650(%rdx), %rsi
addq $0x5a0, %rdx            # imm = 0x5A0
movl $0x870, %edi            # imm = 0x870
cmpq %rax, %rcx
je 0x5029
xorl %r8d, %r8d
cmpq $0xd, %r8
je 0x4fd6
movsd -0x68(%rsi,%r8,8), %xmm1
divsd %xmm0, %xmm1
addsd -0x190(%rbp,%r8,8), %xmm1
movsd %xmm1, -0x190(%rbp,%r8,8)
movsd (%rsi,%r8,8), %xmm1
divsd %xmm0, %xmm1
addsd -0x120(%rbp,%r8,8), %xmm1
movsd %xmm1, -0x120(%rbp,%r8,8)
incq %r8
jmp 0x4f8e
xorl %r8d, %r8d
cmpq $0x9, %r8
je 0x501b
movsd -0x48(%rdx,%r8,8), %xmm1
divsd %xmm0, %xmm1
addsd -0xb0(%rbp,%r8,8), %xmm1
movsd %xmm1, -0xb0(%rbp,%r8,8)
movsd (%rdx,%r8,8), %xmm1
divsd %xmm0, %xmm1
addsd -0x60(%rbp,%r8,8), %xmm1
movsd %xmm1, -0x60(%rbp,%r8,8)
incq %r8
jmp 0x4fd9
incq %rcx
addq %rdi, %rsi
addq %rdi, %rdx
jmp 0x4f82
xorpd %xmm0, %xmm0
xorl %eax, %eax
cmpq $0xd, %rax
je 0x505c
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
jmp 0x502f
mulsd 0x200c(%rip), %xmm0     # 0x7070
mulsd 0x200c(%rip), %xmm0     # 0x7078
divsd 0x2014(%rip), %xmm0     # 0x7088
movsd 0x1f9c(%rip), %xmm1     # 0x7018
callq 0x2340
movsd %xmm0, -0x10(%rbp)
xorpd %xmm0, %xmm0
xorl %eax, %eax
cmpq $0x9, %rax
je 0x50b6
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
jmp 0x508c
mulsd 0x1fb2(%rip), %xmm0     # 0x7070
mulsd 0x1fb2(%rip), %xmm0     # 0x7078
divsd 0x1fb2(%rip), %xmm0     # 0x7080
movsd 0x1f42(%rip), %xmm1     # 0x7018
callq 0x2340
movsd -0x10(%rbp), %xmm1
movsd %xmm1, 0xb4ec08(%rbx)
movsd %xmm0, 0xb4ec10(%rbx)
addq $0x188, %rsp            # imm = 0x188
popq %rbx
popq %rbp
retq