// File: 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
subq $0x1d0, %rsp            # imm = 0x1D0
movq %rdi, -0x8(%rbp)
movq -0x8(%rbp), %rax
movq %rax, -0x1c8(%rbp)
movq 0xb4e8c0(%rax), %rax
movl 0x3208(%rax), %eax
movl %eax, -0xc(%rbp)
xorps %xmm0, %xmm0
movsd %xmm0, -0x198(%rbp)
xorps %xmm0, %xmm0
movsd %xmm0, -0x1a0(%rbp)
movl $0x0, -0x1a4(%rbp)
cmpl $0xd, -0x1a4(%rbp)
jge 0x80c7
movslq -0x1a4(%rbp), %rax
xorps %xmm0, %xmm0
movsd %xmm0, -0x80(%rbp,%rax,8)
movslq -0x1a4(%rbp), %rax
xorps %xmm0, %xmm0
movsd %xmm0, -0xf0(%rbp,%rax,8)
movl -0x1a4(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x1a4(%rbp)
jmp 0x808a
movl $0x0, -0x1a8(%rbp)
cmpl $0x9, -0x1a8(%rbp)
jge 0x8111
movslq -0x1a8(%rbp), %rax
xorps %xmm0, %xmm0
movsd %xmm0, -0x140(%rbp,%rax,8)
movslq -0x1a8(%rbp), %rax
xorps %xmm0, %xmm0
movsd %xmm0, -0x190(%rbp,%rax,8)
movl -0x1a8(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x1a8(%rbp)
jmp 0x80d1
movl $0x0, -0x1ac(%rbp)
movl -0x1ac(%rbp), %eax
cmpl -0xc(%rbp), %eax
jge 0x82c6
movl $0x0, -0x1b0(%rbp)
cmpl $0xd, -0x1b0(%rbp)
jge 0x81ea
movq -0x1c8(%rbp), %rax
movq 0xb4e8b8(%rax), %rcx
movslq -0x1ac(%rbp), %rdx
imulq $0x870, %rdx, %rdx      # imm = 0x870
addq %rdx, %rcx
movslq -0x1b0(%rbp), %rdx
movsd 0x5e8(%rcx,%rdx,8), %xmm0
cvtsi2sdl -0xc(%rbp), %xmm1
divsd %xmm1, %xmm0
movslq -0x1b0(%rbp), %rcx
addsd -0x80(%rbp,%rcx,8), %xmm0
movsd %xmm0, -0x80(%rbp,%rcx,8)
movq 0xb4e8b8(%rax), %rax
movslq -0x1ac(%rbp), %rcx
imulq $0x870, %rcx, %rcx      # imm = 0x870
addq %rcx, %rax
movslq -0x1b0(%rbp), %rcx
movsd 0x650(%rax,%rcx,8), %xmm0
cvtsi2sdl -0xc(%rbp), %xmm1
divsd %xmm1, %xmm0
movslq -0x1b0(%rbp), %rax
addsd -0xf0(%rbp,%rax,8), %xmm0
movsd %xmm0, -0xf0(%rbp,%rax,8)
movl -0x1b0(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x1b0(%rbp)
jmp 0x8134
movl $0x0, -0x1b4(%rbp)
cmpl $0x9, -0x1b4(%rbp)
jge 0x82b0
movq -0x1c8(%rbp), %rax
movq 0xb4e8b8(%rax), %rcx
movslq -0x1ac(%rbp), %rdx
imulq $0x870, %rdx, %rdx      # imm = 0x870
addq %rdx, %rcx
movslq -0x1b4(%rbp), %rdx
movsd 0x558(%rcx,%rdx,8), %xmm0
cvtsi2sdl -0xc(%rbp), %xmm1
divsd %xmm1, %xmm0
movslq -0x1b4(%rbp), %rcx
addsd -0x140(%rbp,%rcx,8), %xmm0
movsd %xmm0, -0x140(%rbp,%rcx,8)
movq 0xb4e8b8(%rax), %rax
movslq -0x1ac(%rbp), %rcx
imulq $0x870, %rcx, %rcx      # imm = 0x870
addq %rcx, %rax
movslq -0x1b4(%rbp), %rcx
movsd 0x5a0(%rax,%rcx,8), %xmm0
cvtsi2sdl -0xc(%rbp), %xmm1
divsd %xmm1, %xmm0
movslq -0x1b4(%rbp), %rax
addsd -0x190(%rbp,%rax,8), %xmm0
movsd %xmm0, -0x190(%rbp,%rax,8)
movl -0x1b4(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x1b4(%rbp)
jmp 0x81f4
jmp 0x82b2
movl -0x1ac(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x1ac(%rbp)
jmp 0x811b
xorps %xmm0, %xmm0
movsd %xmm0, -0x1a0(%rbp)
movl $0x0, -0x1b8(%rbp)
cmpl $0xd, -0x1b8(%rbp)
jge 0x8347
movslq -0x1b8(%rbp), %rax
movsd -0x80(%rbp,%rax,8), %xmm0
movslq -0x1b8(%rbp), %rax
movsd -0x80(%rbp,%rax,8), %xmm2
movslq -0x1b8(%rbp), %rax
movsd -0xf0(%rbp,%rax,8), %xmm1
movslq -0x1b8(%rbp), %rax
mulsd -0xf0(%rbp,%rax,8), %xmm1
mulsd %xmm2, %xmm0
addsd %xmm1, %xmm0
addsd -0x1a0(%rbp), %xmm0
movsd %xmm0, -0x1a0(%rbp)
movl -0x1b8(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x1b8(%rbp)
jmp 0x82db
movsd 0x3e51(%rip), %xmm0     # 0xc1a0
mulsd -0x1a0(%rbp), %xmm0
movsd 0x3e39(%rip), %xmm1     # 0xc198
mulsd %xmm1, %xmm0
movsd 0x3e3d(%rip), %xmm1     # 0xc1a8
divsd %xmm1, %xmm0
movsd %xmm0, -0x1a0(%rbp)
movsd -0x1a0(%rbp), %xmm0
movsd 0x3df1(%rip), %xmm1     # 0xc178
callq 0x3420
movsd %xmm0, -0x1a0(%rbp)
xorps %xmm0, %xmm0
movsd %xmm0, -0x198(%rbp)
movl $0x0, -0x1bc(%rbp)
cmpl $0x9, -0x1bc(%rbp)
jge 0x841b
movslq -0x1bc(%rbp), %rax
movsd -0x140(%rbp,%rax,8), %xmm0
movslq -0x1bc(%rbp), %rax
movsd -0x140(%rbp,%rax,8), %xmm2
movslq -0x1bc(%rbp), %rax
movsd -0x190(%rbp,%rax,8), %xmm1
movslq -0x1bc(%rbp), %rax
mulsd -0x190(%rbp,%rax,8), %xmm1
mulsd %xmm2, %xmm0
addsd %xmm1, %xmm0
addsd -0x198(%rbp), %xmm0
movsd %xmm0, -0x198(%rbp)
movl -0x1bc(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x1bc(%rbp)
jmp 0x83a9
movsd 0x3d7d(%rip), %xmm0     # 0xc1a0
mulsd -0x198(%rbp), %xmm0
movsd 0x3d65(%rip), %xmm1     # 0xc198
mulsd %xmm1, %xmm0
movsd 0x3d51(%rip), %xmm1     # 0xc190
divsd %xmm1, %xmm0
movsd %xmm0, -0x198(%rbp)
movsd -0x198(%rbp), %xmm0
movsd 0x3d1d(%rip), %xmm1     # 0xc178
callq 0x3420
movq -0x1c8(%rbp), %rax
movsd %xmm0, -0x198(%rbp)
movsd -0x1a0(%rbp), %xmm0
movsd %xmm0, 0xb4ec08(%rax)
movsd -0x198(%rbp), %xmm0
movsd %xmm0, 0xb4ec10(%rax)
addq $0x1d0, %rsp            # imm = 0x1D0
popq %rbp
retq
nopl (%rax,%rax)