// File: /workspace/github_cpp_makefile_star2_O1/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 0x2585c
movl %eax, %ebp
movq %rbx, %rdi
callq 0x2585c
cmpl %eax, %ebp
jne 0xd809
xorl %ebp, %ebp
leaq 0xc(%rsp), %r12
leaq 0x10(%rsp), %r13
movl %ebp, 0xc(%rsp)
movq %r15, %rdi
callq 0x2577c
cmpl %eax, %ebp
jae 0xd915
movq %r15, %rdi
movq %r12, %rsi
callq 0x24776
movq %rax, %rbp
movq %rax, %rdi
callq 0x14ae6
cmpb $0x0, (%rax)
je 0xd801
movq %rbp, %rdi
callq 0x14abe
movq %r13, %rdi
movq %rax, %rsi
callq 0x1254e
movl 0xc(%rsp), %ebp
incl %ebp
jmp 0xd7bf
movq 0x3e37e0(%rip), %rdi    # 0x3f0ff0
movq (%rdi), %rax
addq -0x18(%rax), %rdi
movl $0xa, %esi
callq 0x42a0
movsbl %al, %esi
movq 0x3e37c5(%rip), %rdi    # 0x3f0ff0
callq 0x4040
movq %rax, %rdi
callq 0x41f0
movq %rax, %r14
leaq 0x2ed71(%rip), %rsi     # 0x3c5b3
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 0x3e3773(%rip), %rdi    # 0x3f0ff0
leaq 0x2ed5f(%rip), %rsi     # 0x3c5e3
movl $0xb, %edx
callq 0x4340
movq %r15, %rdi
callq 0x2585c
movl %eax, %esi
movq 0x3e3751(%rip), %rdi    # 0x3f0ff0
callq 0x41e0
leaq 0x2ed44(%rip), %rsi     # 0x3c5ef
movl $0x2, %edx
movq %rax, %rdi
callq 0x4340
movq 0x3e3731(%rip), %rdi    # 0x3f0ff0
leaq 0x2ed2c(%rip), %rsi     # 0x3c5f2
movl $0xb, %edx
callq 0x4340
movq %rbx, %rdi
callq 0x2585c
movl %eax, %esi
movq 0x3e370f(%rip), %rdi    # 0x3f0ff0
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 0xd9b5
xorl %ebp, %ebp
leaq 0x30(%rsp), %r12
xorl %r14d, %r14d
movl %ebp, 0xc(%rsp)
movq %rbx, %rdi
callq 0x2577c
cmpl %eax, %ebp
jae 0xd9ae
movq %rbx, %rdi
leaq 0xc(%rsp), %rsi
callq 0x24776
movq %rax, %r13
movq %rax, %rdi
callq 0x14ae6
cmpb $0x0, (%rax)
je 0xd9a3
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 0xd9db
movq %r13, %rdi
callq 0x14abe
leaq (,%rbp,2), %rcx
addq %rbp, %rcx
leaq (%r15,%rcx,8), %rsi
movq %r12, %rdi
movq %rax, %rdx
callq 0x3a2d4
movq %r13, %rdi
movq %r12, %rsi
callq 0x1504e
incl %r14d
movl 0xc(%rsp), %ebp
incl %ebp
jmp 0xd91f
movq 0x28(%rsp), %rax
incl (%rax)
movq 0x10(%rsp), %rdi
testq %rdi, %rdi
je 0xd9cc
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 0x2e947(%rip), %rdi     # 0x3c329
movq %rbp, %rsi
xorl %eax, %eax
callq 0x4440
jmp 0xd9f4
jmp 0xd9f4
jmp 0xd9f4
jmp 0xd9f4
movq %rax, %rbx
movq 0x10(%rsp), %rdi
testq %rdi, %rdi
je 0xda0e
movq 0x20(%rsp), %rsi
subq %rdi, %rsi
callq 0x42e0
movq %rbx, %rdi
callq 0x4550