// File: 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:
subq $0x118, %rsp            # imm = 0x118
movb %cl, %al
movb %dl, %cl
movq %rdi, 0x110(%rsp)
movq %rsi, 0x108(%rsp)
andb $0x1, %cl
movb %cl, 0x107(%rsp)
andb $0x1, %al
movb %al, 0x106(%rsp)
movq 0x110(%rsp), %rdi
movq %rdi, 0x58(%rsp)
movq $0x0, 0xf8(%rsp)
movq $0x0, 0xe8(%rsp)
movq $0x0, 0xd8(%rsp)
movq $0x0, 0xf0(%rsp)
movq $0x0, 0xe0(%rsp)
movq $0x0, 0xd0(%rsp)
xorl %esi, %esi
callq 0x428b0
movq 0x108(%rsp), %rdi
callq 0x428f0
movq 0x58(%rsp), %rdi
movl %eax, 0xcc(%rsp)
leaq 0xcc(%rsp), %rsi
callq 0x428d0
movq 0x108(%rsp), %rsi
leaq 0xa8(%rsp), %rdi
movq %rdi, 0x60(%rsp)
callq 0x42940
movq 0x58(%rsp), %rdi
movq 0x60(%rsp), %rsi
callq 0x42910
jmp 0x4316b
leaq 0xa8(%rsp), %rdi
callq 0x5250
movq 0x108(%rsp), %rsi
leaq 0x78(%rsp), %rdi
movq %rdi, 0x50(%rsp)
callq 0x429a0
movq 0x58(%rsp), %rdi
movq 0x50(%rsp), %rsi
callq 0x42970
jmp 0x431a0
leaq 0x78(%rsp), %rdi
callq 0x5250
movl $0x0, 0x74(%rsp)
movl 0x74(%rsp), %eax
movl %eax, 0x4c(%rsp)
movq 0x108(%rsp), %rdi
callq 0x41e20
movl %eax, %ecx
movl 0x4c(%rsp), %eax
cmpl %ecx, %eax
jae 0x4352e
movq 0x108(%rsp), %rdi
leaq 0x74(%rsp), %rsi
callq 0x41e40
movq %rax, 0xf8(%rsp)
movl $0x30, %edi
callq 0x5410
movq %rax, %rdi
movq %rdi, %rax
movq %rax, 0x40(%rsp)
callq 0x3a320
jmp 0x4320b
movq 0x40(%rsp), %rax
movq %rax, 0xf0(%rsp)
movl $0x0, 0x70(%rsp)
movl 0x70(%rsp), %eax
movl %eax, 0x3c(%rsp)
movq 0xf8(%rsp), %rdi
callq 0x3a570
movl %eax, %ecx
movl 0x3c(%rsp), %eax
cmpl %ecx, %eax
jae 0x434c8
movq 0xf8(%rsp), %rdi
leaq 0x70(%rsp), %rsi
callq 0x3a490
movq %rax, 0xe8(%rsp)
movl $0x18, %edi
callq 0x5410
movq %rax, %rdi
movq %rdi, %rax
movq %rax, 0x30(%rsp)
callq 0x5de80
jmp 0x43279
movq 0x30(%rsp), %rax
movq %rax, 0xe0(%rsp)
movl $0x0, 0x6c(%rsp)
movl 0x6c(%rsp), %eax
movl %eax, 0x2c(%rsp)
movq 0xe8(%rsp), %rdi
callq 0x5e110
movl %eax, %ecx
movl 0x2c(%rsp), %eax
cmpl %ecx, %eax
jae 0x4344d
movq 0xe8(%rsp), %rdi
leaq 0x6c(%rsp), %rsi
callq 0x5df30
movq %rax, 0xd8(%rsp)
movb 0x107(%rsp), %al
andb $0x1, %al
movzbl %al, %eax
cmpl $0x1, %eax
jne 0x4339b
movq 0xd8(%rsp), %rdi
callq 0x1f780
movb (%rax), %al
andb $0x1, %al
movzbl %al, %eax
cmpl $0x0, %eax
jne 0x4339b
jmp 0x43415
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0xa0(%rsp)
movl %eax, 0x9c(%rsp)
leaq 0xa8(%rsp), %rdi
callq 0x5250
jmp 0x43567
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0xa0(%rsp)
movl %eax, 0x9c(%rsp)
leaq 0x78(%rsp), %rdi
callq 0x5250
jmp 0x43567
movq 0x40(%rsp), %rdi
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0xa0(%rsp)
movl %eax, 0x9c(%rsp)
movl $0x30, %esi
callq 0x5420
jmp 0x43567
movq 0x30(%rsp), %rdi
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0xa0(%rsp)
movl %eax, 0x9c(%rsp)
movl $0x18, %esi
callq 0x5420
jmp 0x43567
movl $0x238, %edi            # imm = 0x238
callq 0x5410
movq %rax, %rdi
movq %rdi, %rax
movq %rax, 0x20(%rsp)
callq 0x1e7f0
jmp 0x433b7
movq 0x20(%rsp), %rax
movq %rax, 0xd0(%rsp)
movq 0xd0(%rsp), %rdi
movq 0xd8(%rsp), %rsi
callq 0x1f2a0
movq 0x58(%rsp), %rdi
movq 0xd0(%rsp), %rsi
callq 0x422b0
movq 0xe0(%rsp), %rdi
movq 0xd0(%rsp), %rsi
callq 0x5dec0
movq 0xf0(%rsp), %rdi
movq 0xd0(%rsp), %rsi
callq 0x3a3e0
movl 0x6c(%rsp), %eax
addl $0x1, %eax
movl %eax, 0x6c(%rsp)
jmp 0x4328e
movq 0x20(%rsp), %rdi
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0xa0(%rsp)
movl %eax, 0x9c(%rsp)
movl $0x238, %esi            # imm = 0x238
callq 0x5420
jmp 0x43567
movq 0xe0(%rsp), %rdi
callq 0x5e110
cmpl $0x0, %eax
jbe 0x43488
movq 0x58(%rsp), %rdi
movq 0xe0(%rsp), %rsi
callq 0x429d0
movq 0xf0(%rsp), %rdi
movq 0xe0(%rsp), %rsi
callq 0x3a3a0
jmp 0x434b6
movq 0xe0(%rsp), %rax
movq %rax, 0x18(%rsp)
cmpq $0x0, %rax
je 0x434b4
movq 0x18(%rsp), %rdi
callq 0x46fa0
movq 0x18(%rsp), %rdi
movl $0x18, %esi
callq 0x5420
jmp 0x434b6
jmp 0x434b8
movl 0x70(%rsp), %eax
addl $0x1, %eax
movl %eax, 0x70(%rsp)
jmp 0x43220
movq 0xf0(%rsp), %rdi
callq 0x3a570
cmpl $0x0, %eax
jbe 0x434ee
movq 0x58(%rsp), %rdi
movq 0xf0(%rsp), %rsi
callq 0x42a10
jmp 0x4351c
movq 0xf0(%rsp), %rax
movq %rax, 0x10(%rsp)
cmpq $0x0, %rax
je 0x4351a
movq 0x10(%rsp), %rdi
callq 0x46fb0
movq 0x10(%rsp), %rdi
movl $0x30, %esi
callq 0x5420
jmp 0x4351c
jmp 0x4351e
movl 0x74(%rsp), %eax
addl $0x1, %eax
movl %eax, 0x74(%rsp)
jmp 0x431b2
movb 0x106(%rsp), %al
andb $0x1, %al
movzbl %al, %eax
cmpl $0x0, %eax
jne 0x4355f
movq 0x108(%rsp), %rax
movq %rax, 0x8(%rsp)
cmpq $0x0, %rax
je 0x4355d
movq 0x8(%rsp), %rdi
movq (%rdi), %rax
callq *0x8(%rax)
jmp 0x4355f
addq $0x118, %rsp            # imm = 0x118
retq
movq 0xa0(%rsp), %rdi
callq 0x5720
nopw %cs:(%rax,%rax)