// File: 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:
subq $0x108, %rsp            # imm = 0x108
movq %rdi, 0x100(%rsp)
movq %rsi, 0xf8(%rsp)
movq %rdx, 0xf0(%rsp)
leaq 0xc8(%rsp), %rdi
callq 0x17350
movq 0x100(%rsp), %rdi
callq 0x44ba0
movl %eax, 0x9c(%rsp)
jmp 0xf3a2
movq 0xf8(%rsp), %rdi
callq 0x44ba0
movl %eax, 0x98(%rsp)
jmp 0xf3b8
movl 0x9c(%rsp), %eax
movl 0x98(%rsp), %ecx
cmpl %ecx, %eax
je 0xf4fa
movq 0x42bc1b(%rip), %rdi    # 0x43aff0
movq 0x42bbcc(%rip), %rsi    # 0x43afa8
callq 0x5460
movq %rax, 0x90(%rsp)
jmp 0xf3eb
movq 0x90(%rsp), %rdi
leaq 0x6c0b5(%rip), %rsi     # 0x7b4af
callq 0x53f0
movq %rax, 0x88(%rsp)
jmp 0xf409
movq 0x88(%rsp), %rdi
movq 0x42bb90(%rip), %rsi    # 0x43afa8
callq 0x5460
jmp 0xf41f
movq 0x42bbca(%rip), %rdi    # 0x43aff0
leaq 0x6c0b2(%rip), %rsi     # 0x7b4df
callq 0x53f0
movq %rax, 0x80(%rsp)
jmp 0xf43c
movq 0x100(%rsp), %rdi
callq 0x44ba0
movl %eax, 0x7c(%rsp)
jmp 0xf44f
movl 0x7c(%rsp), %esi
movq 0x80(%rsp), %rdi
callq 0x55b0
movq %rax, 0x70(%rsp)
jmp 0xf467
movq 0x70(%rsp), %rdi
leaq 0x6c078(%rip), %rsi     # 0x7b4eb
callq 0x53f0
jmp 0xf47a
movq 0x42bb6f(%rip), %rdi    # 0x43aff0
leaq 0x6c066(%rip), %rsi     # 0x7b4ee
callq 0x53f0
movq %rax, 0x68(%rsp)
jmp 0xf494
movq 0xf8(%rsp), %rdi
callq 0x44ba0
movl %eax, 0x64(%rsp)
jmp 0xf4a7
movl 0x64(%rsp), %esi
movq 0x68(%rsp), %rdi
callq 0x55b0
movq %rax, 0x58(%rsp)
jmp 0xf4bc
movq 0x58(%rsp), %rdi
movq 0x42bae0(%rip), %rsi    # 0x43afa8
callq 0x5460
jmp 0xf4cf
jmp 0xf6f8
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0xc0(%rsp)
movl %eax, 0xbc(%rsp)
leaq 0xc8(%rsp), %rdi
callq 0x17410
jmp 0xf70d
movl $0x0, 0xec(%rsp)
movl 0xec(%rsp), %eax
movl %eax, 0x50(%rsp)
movq 0x100(%rsp), %rdi
callq 0x44a80
movl %eax, 0x54(%rsp)
jmp 0xf523
movl 0x50(%rsp), %eax
movl 0x54(%rsp), %ecx
cmpl %ecx, %eax
jae 0xf5c3
movq 0x100(%rsp), %rdi
leaq 0xec(%rsp), %rsi
callq 0x43580
movq %rax, 0x48(%rsp)
jmp 0xf54f
movq 0x48(%rsp), %rax
movq %rax, 0xe0(%rsp)
movq 0xe0(%rsp), %rdi
callq 0x1f780
movq %rax, 0x40(%rsp)
jmp 0xf570
movq 0x40(%rsp), %rax
movb (%rax), %al
andb $0x1, %al
movzbl %al, %eax
cmpl $0x0, %eax
jne 0xf583
jmp 0xf5ad
movq 0xe0(%rsp), %rdi
callq 0x1f6e0
movq %rax, 0x38(%rsp)
jmp 0xf597
movq 0x38(%rsp), %rsi
leaq 0xc8(%rsp), %rdi
callq 0x17360
jmp 0xf5ab
jmp 0xf5ad
movl 0xec(%rsp), %eax
addl $0x1, %eax
movl %eax, 0xec(%rsp)
jmp 0xf505
movl $0x0, 0xe8(%rsp)
movl $0x0, 0xec(%rsp)
movl 0xec(%rsp), %eax
movl %eax, 0x30(%rsp)
movq 0xf8(%rsp), %rdi
callq 0x44a80
movl %eax, 0x34(%rsp)
jmp 0xf5f7
movl 0x30(%rsp), %eax
movl 0x34(%rsp), %ecx
cmpl %ecx, %eax
jae 0xf6e9
movq 0xf8(%rsp), %rdi
leaq 0xec(%rsp), %rsi
callq 0x43580
movq %rax, 0x28(%rsp)
jmp 0xf623
movq 0x28(%rsp), %rax
movq %rax, 0xe0(%rsp)
movq 0xe0(%rsp), %rdi
callq 0x1f780
movq %rax, 0x20(%rsp)
jmp 0xf644
movq 0x20(%rsp), %rax
movb (%rax), %al
andb $0x1, %al
movzbl %al, %eax
cmpl $0x0, %eax
jne 0xf657
jmp 0xf6d3
movq 0xe0(%rsp), %rax
movq %rax, 0x10(%rsp)
movl 0xe8(%rsp), %eax
movl %eax, %esi
leaq 0xc8(%rsp), %rdi
callq 0x173d0
movq %rax, 0x18(%rsp)
jmp 0xf681
movq 0xe0(%rsp), %rdi
callq 0x1f6e0
movq %rax, 0x8(%rsp)
jmp 0xf695
movq 0x8(%rsp), %rdx
movq 0x18(%rsp), %rsi
leaq 0xa0(%rsp), %rdi
callq 0x76190
jmp 0xf6ae
movq 0x10(%rsp), %rdi
leaq 0xa0(%rsp), %rsi
callq 0x1ffe0
jmp 0xf6c2
movl 0xe8(%rsp), %eax
addl $0x1, %eax
movl %eax, 0xe8(%rsp)
movl 0xec(%rsp), %eax
addl $0x1, %eax
movl %eax, 0xec(%rsp)
jmp 0xf5d9
movq 0xf0(%rsp), %rax
movl (%rax), %ecx
addl $0x1, %ecx
movl %ecx, (%rax)
leaq 0xc8(%rsp), %rdi
callq 0x17410
addq $0x108, %rsp            # imm = 0x108
retq
movq 0xc0(%rsp), %rdi
callq 0x5720
nopw (%rax,%rax)