// File: /workspace/github_cpp_makefile_star2_O3/atfrank[P]PCASA/lib/Analyze.cpp
// Function: Analyze::averageMol(Molecule*, Molecule*, int&)
void Analyze::averageMol (Molecule* cmpmol, Molecule* refmol, int &ndataIO){
  unsigned int i,j;
  Atom *atm;
  std::vector<Coor> coor;

  //Check selection sizes and resize matrices
  if (cmpmol->getNAtomSelected() != refmol->getNAtomSelected()){
    std::cerr << std::endl << "Error: Atom number mismatch in RMSD calculation" << std::endl;
    std::cerr << "CMP-NATOM: " << cmpmol->getNAtomSelected() << ", ";
    std::cerr << "REF-NATOM: " << refmol->getNAtomSelected() << std::endl;
  }
  else{
    for (i=0; i< cmpmol->getNAtom(); i++){
      atm=cmpmol->getAtom(i);
      if (atm->getSel() == false){
        continue;
      }
      coor.push_back(atm->getCoor());
    }

    j=0;
    for (i=0; i< refmol->getNAtom(); i++){
      atm=refmol->getAtom(i);
      if (atm->getSel() == false){
        continue;
      }
      atm->setCoor(coor.at(j)+atm->getCoor());
      j++;
    }
    ndataIO++;
  }
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x48, %rsp
movq %rdx, 0x28(%rsp)
movq %rsi, %rbx
movq %rdi, %r15
xorps %xmm0, %xmm0
movaps %xmm0, 0x10(%rsp)
movq $0x0, 0x20(%rsp)
callq 0x2565c
movl %eax, %ebp
movq %rbx, %rdi
callq 0x2565c
cmpl %eax, %ebp
jne 0xd689
xorl %ebp, %ebp
leaq 0xc(%rsp), %r12
leaq 0x10(%rsp), %r13
movl %ebp, 0xc(%rsp)
movq %r15, %rdi
callq 0x2557c
cmpl %eax, %ebp
jae 0xd795
movq %r15, %rdi
movq %r12, %rsi
callq 0x24578
movq %rax, %rbp
movq %rax, %rdi
callq 0x1496e
cmpb $0x0, (%rax)
je 0xd681
movq %rbp, %rdi
callq 0x14946
movq %r13, %rdi
movq %rax, %rsi
callq 0x123a8
movl 0xc(%rsp), %ebp
incl %ebp
jmp 0xd63f
movq 0x3e2960(%rip), %rdi    # 0x3efff0
movq (%rdi), %rax
addq -0x18(%rax), %rdi
movl $0xa, %esi
callq 0x42a0
movsbl %al, %esi
movq 0x3e2945(%rip), %rdi    # 0x3efff0
callq 0x4040
movq %rax, %rdi
callq 0x41f0
movq %rax, %r14
leaq 0x2def1(%rip), %rsi     # 0x3b5b3
movl $0x2f, %edx
movq %rax, %rdi
callq 0x4340
movq (%r14), %rax
movq -0x18(%rax), %rdi
addq %r14, %rdi
movl $0xa, %esi
callq 0x42a0
movsbl %al, %esi
movq %r14, %rdi
callq 0x4040
movq %rax, %rdi
callq 0x41f0
movq 0x3e28f3(%rip), %rdi    # 0x3efff0
leaq 0x2dedf(%rip), %rsi     # 0x3b5e3
movl $0xb, %edx
callq 0x4340
movq %r15, %rdi
callq 0x2565c
movl %eax, %esi
movq 0x3e28d1(%rip), %rdi    # 0x3efff0
callq 0x41e0
leaq 0x2dec4(%rip), %rsi     # 0x3b5ef
movl $0x2, %edx
movq %rax, %rdi
callq 0x4340
movq 0x3e28b1(%rip), %rdi    # 0x3efff0
leaq 0x2deac(%rip), %rsi     # 0x3b5f2
movl $0xb, %edx
callq 0x4340
movq %rbx, %rdi
callq 0x2565c
movl %eax, %esi
movq 0x3e288f(%rip), %rdi    # 0x3efff0
callq 0x41e0
movq %rax, %rbx
movq (%rax), %rax
movq -0x18(%rax), %rdi
addq %rbx, %rdi
movl $0xa, %esi
callq 0x42a0
movsbl %al, %esi
movq %rbx, %rdi
callq 0x4040
movq %rax, %rdi
callq 0x41f0
jmp 0xd835
xorl %ebp, %ebp
leaq 0x30(%rsp), %r12
xorl %r14d, %r14d
movl %ebp, 0xc(%rsp)
movq %rbx, %rdi
callq 0x2557c
cmpl %eax, %ebp
jae 0xd82e
movq %rbx, %rdi
leaq 0xc(%rsp), %rsi
callq 0x24578
movq %rax, %r13
movq %rax, %rdi
callq 0x1496e
cmpb $0x0, (%rax)
je 0xd823
movl %r14d, %ebp
movq 0x10(%rsp), %r15
movq 0x18(%rsp), %rdx
subq %r15, %rdx
sarq $0x3, %rdx
movabsq $-0x5555555555555555, %rax # imm = 0xAAAAAAAAAAAAAAAB
imulq %rax, %rdx
cmpq %rbp, %rdx
jbe 0xd85b
movq %r13, %rdi
callq 0x14946
leaq (,%rbp,2), %rcx
addq %rbp, %rcx
leaq (%r15,%rcx,8), %rsi
movq %r12, %rdi
movq %rax, %rdx
callq 0x3a02c
movq %r13, %rdi
movq %r12, %rsi
callq 0x14edc
incl %r14d
movl 0xc(%rsp), %ebp
incl %ebp
jmp 0xd79f
movq 0x28(%rsp), %rax
incl (%rax)
movq 0x10(%rsp), %rdi
testq %rdi, %rdi
je 0xd84c
movq 0x20(%rsp), %rsi
subq %rdi, %rsi
callq 0x42e0
addq $0x48, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
leaq 0x2dac7(%rip), %rdi     # 0x3b329
movq %rbp, %rsi
xorl %eax, %eax
callq 0x4440
jmp 0xd874
jmp 0xd874
jmp 0xd874
jmp 0xd874
movq %rax, %rbx
movq 0x10(%rsp), %rdi
testq %rdi, %rdi
je 0xd88e
movq 0x20(%rsp), %rsi
subq %rdi, %rsi
callq 0x42e0
movq %rbx, %rdi
callq 0x4550