// File: /workspace/github_cpp_makefile_star2_O3/atfrank[P]PCASA/lib/Molecule.cpp
// Function: Molecule::cat(Molecule*, bool, bool)
void Molecule::cat (Molecule* catmol, bool selFlag, bool keep){
  //Deep copy
  Chain *c, *chnEntry;
  Residue *r, *resEntry;
  Atom *a, *atmEntry;

  c=NULL;
  r=NULL;
  a=NULL;
  chnEntry=NULL;
  resEntry=NULL;
  atmEntry=NULL;
  this->setCopyFlag(false); //Not a copy
  this->setYear(catmol->getYear());
  this->setExp(catmol->getExp());
  this->setTag(catmol->getTag());

  for (unsigned int i=0; i< catmol->getChnVecSize(); i++){
    c=catmol->getChain(i);
    chnEntry=new Chain; //Deleted later if no residues/atoms

    for (unsigned int j=0; j< c->getResVecSize(); j++){
      r=c->getResidue(j);
      resEntry=new Residue; //Deleted later if no atoms

      for (unsigned int k=0; k< r->getAtmVecSize(); k++){
        a=r->getAtom(k);
        if(selFlag == true && a->getSel() == false){
          continue;
        }
        //Add each selected atom
        atmEntry=new Atom; //This is necessary!
        atmEntry->clone(a); //Clone Atom
        this->addAtom(atmEntry);
        resEntry->addAtom(atmEntry);
        chnEntry->addAtom(atmEntry);
      }
      if (resEntry->getAtmVecSize() > 0){
        //Add each residue with selected atoms
        this->addResidue(resEntry);
        chnEntry->addResidue(resEntry);
      }
      else{
        delete resEntry;
      }
    }
    if (chnEntry->getResVecSize() > 0){
      //Add each chain with selected atoms
      this->addChain(chnEntry);
    }
    else{
      delete chnEntry;
    }
  }

  if (keep == false){
    delete catmol;
  }

}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x58, %rsp
movl %ecx, 0x24(%rsp)
movl %edx, %r14d
movq %rsi, %rcx
movq %rdi, %r12
movb $0x0, 0x50(%rdi)
movl 0x158(%rsi), %eax
movl %eax, 0x158(%rdi)
leaq 0x38(%rsp), %r15
movq %r15, -0x10(%r15)
movq 0x160(%rsi), %rsi
movq %rcx, 0x10(%rsp)
movq 0x168(%rcx), %rdx
addq %rsi, %rdx
leaq 0x28(%rsp), %rbx
movq %rbx, %rdi
callq 0x647c
movq %r12, 0x18(%rsp)
leaq 0x160(%r12), %rdi
movq %rbx, %rsi
callq 0x4180
movq 0x28(%rsp), %rdi
cmpq %r15, %rdi
je 0x242af
movq 0x38(%rsp), %rsi
incq %rsi
callq 0x42e0
leaq 0x28(%rsp), %rbx
movq %r15, (%rbx)
movq 0x10(%rsp), %rax
movq 0x180(%rax), %rsi
movq 0x188(%rax), %rdx
addq %rsi, %rdx
movq %rbx, %rdi
callq 0x647c
movq 0x18(%rsp), %rax
leaq 0x180(%rax), %rdi
movq %rbx, %rsi
callq 0x4180
movq 0x28(%rsp), %rdi
cmpq %r15, %rdi
je 0x24300
movq 0x38(%rsp), %rsi
incq %rsi
callq 0x42e0
movq 0x10(%rsp), %rcx
movq 0x8(%rcx), %rax
movq 0x10(%rcx), %rcx
subq %rax, %rcx
movq %rcx, %rdx
shrq $0x3, %rdx
testl %edx, %edx
je 0x2450b
xorl %esi, %esi
sarq $0x3, %rcx
cmpq %rsi, %rcx
movq %rsi, 0x50(%rsp)
jbe 0x24335
movq (%rax,%rsi,8), %r15
jmp 0x24338
xorl %r15d, %r15d
movl $0x30, %edi
callq 0x42d0
movq %rax, %rbp
movq %rax, %rdi
callq 0x203b4
movl $0x0, 0x28(%rsp)
movq %r15, %rdi
callq 0x204e0
testl %eax, %eax
movq %r15, 0x48(%rsp)
je 0x2448f
movq %r15, %rdi
leaq 0x28(%rsp), %rsi
callq 0x20486
movq %rax, %rbx
movl $0x18, %edi
callq 0x42d0
movq %rax, %r12
movq %rax, %rdi
callq 0x2f47c
movl $0x0, 0xc(%rsp)
movq %rbx, %rdi
callq 0x2f5c2
testl %eax, %eax
je 0x24422
movq %rbx, %rdi
leaq 0xc(%rsp), %rsi
callq 0x2f4ec
movq %rax, %r15
testb %r14b, %r14b
je 0x243c5
movq %r15, %rdi
callq 0x1496e
cmpb $0x0, (%rax)
je 0x24408
movl $0x238, %edi            # imm = 0x238
callq 0x42d0
movq %rax, %r13
movq %rax, %rdi
callq 0x138dc
movq %r13, %rdi
movq %r15, %rsi
callq 0x1474e
movq 0x18(%rsp), %rdi
movq %r13, %rsi
callq 0x23978
movq %r12, %rdi
movq %r13, %rsi
callq 0x2f49a
movq %rbp, %rdi
movq %r13, %rsi
callq 0x20422
movl 0xc(%rsp), %r15d
incl %r15d
movl %r15d, 0xc(%rsp)
movq %rbx, %rdi
callq 0x2f5c2
cmpl %eax, %r15d
jb 0x243a3
movq %r12, %rdi
callq 0x2f5c2
testl %eax, %eax
je 0x2444d
movq 0x18(%rsp), %rdi
movq %r12, %rsi
callq 0x23dc0
movq %rbp, %rdi
movq %r12, %rsi
callq 0x203e0
movq 0x48(%rsp), %r15
jmp 0x24475
movq (%r12), %rdi
testq %rdi, %rdi
movq 0x48(%rsp), %r15
je 0x24468
movq 0x10(%r12), %rsi
subq %rdi, %rsi
callq 0x42e0
movl $0x18, %esi
movq %r12, %rdi
callq 0x42e0
movl 0x28(%rsp), %ebx
incl %ebx
movl %ebx, 0x28(%rsp)
movq %r15, %rdi
callq 0x204e0
cmpl %eax, %ebx
jb 0x2436a
movq %rbp, %rdi
callq 0x204e0
testl %eax, %eax
je 0x244aa
movq 0x18(%rsp), %rdi
movq %rbp, %rsi
callq 0x23e06
jmp 0x244e1
movq 0x18(%rbp), %rdi
testq %rdi, %rdi
je 0x244bf
movq 0x28(%rbp), %rsi
subq %rdi, %rsi
callq 0x42e0
movq (%rbp), %rdi
testq %rdi, %rdi
je 0x244d4
movq 0x10(%rbp), %rsi
subq %rdi, %rsi
callq 0x42e0
movl $0x30, %esi
movq %rbp, %rdi
callq 0x42e0
movq 0x50(%rsp), %rsi
incq %rsi
movq 0x10(%rsp), %rcx
movq 0x8(%rcx), %rax
movq 0x10(%rcx), %rcx
subq %rax, %rcx
movq %rcx, %rdx
shrq $0x3, %rdx
movl %edx, %edx
cmpq %rdx, %rsi
jb 0x24321
cmpb $0x0, 0x24(%rsp)
jne 0x2451d
movq 0x10(%rsp), %rdi
movq (%rdi), %rax
callq *0x8(%rax)
addq $0x58, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
jmp 0x2452e
movq %rax, %rbx
movq 0x28(%rsp), %rdi
cmpq %r15, %rdi
je 0x2456f
movq 0x38(%rsp), %rsi
incq %rsi
jmp 0x2456a
movq %rax, %rbx
movl $0x30, %esi
movq %rbp, %rdi
jmp 0x2456a
movq %rax, %rbx
movl $0x18, %esi
movq %r12, %rdi
jmp 0x2456a
movq %rax, %rbx
movl $0x238, %esi            # imm = 0x238
movq %r13, %rdi
callq 0x42e0
movq %rbx, %rdi
callq 0x4550
nop