// File: atfrank[P]PCASA/lib/Molecule.cpp
// Function: Molecule::modPseudoCenter()
void Molecule::modPseudoCenter(){
  Atom *atmEntry;
  Atom *lastAtom;

  for (unsigned int i=0; i< this->getChnVecSize(); i++){
    atmEntry=NULL;
    lastAtom=NULL;
    for (unsigned int j=0; j< this->getChain(i)->getAtmVecSize(); j++){
      atmEntry=this->getChain(i)->getAtom(j);

      if(lastAtom !=NULL){
        if (lastAtom->getResId()+1 == atmEntry->getResId()){
          //Compute pseudocenter for last atom
          lastAtom->setCoor((lastAtom->getCoor()+atmEntry->getCoor())/2.0);
        }
        else if (lastAtom->getResId() == atmEntry->getResId() && (lastAtom->getICode().compare(0,1,atmEntry->getICode(),0,1) != 0)){
          //Compute pseudocenter for last atom
          lastAtom->setCoor((lastAtom->getCoor()+atmEntry->getCoor())/2.0);
        }
        else{
          //No i+1 neighbor, modify coordinates
          lastAtom->setCoor(Coor(9999.9, 9999.9, 9999.9));
        }
      }
      lastAtom=atmEntry;
    }
    //No i+1 neighbor for last atom in chain, modify coordinates
    lastAtom->setCoor(Coor(9999.9, 9999.9, 9999.9));
  }
}

// Assembly:
subq $0x108, %rsp            # imm = 0x108
movq %rdi, 0x100(%rsp)
movq 0x100(%rsp), %rax
movq %rax, 0x50(%rsp)
movl $0x0, 0xec(%rsp)
movq 0x50(%rsp), %rdi
movl 0xec(%rsp), %eax
movl %eax, 0x4c(%rsp)
callq 0x41e20
movl %eax, %ecx
movl 0x4c(%rsp), %eax
cmpl %ecx, %eax
jae 0x45a55
movq $0x0, 0xf8(%rsp)
movq $0x0, 0xf0(%rsp)
movl $0x0, 0xe8(%rsp)
movq 0x50(%rsp), %rdi
movl 0xe8(%rsp), %eax
movl %eax, 0x48(%rsp)
leaq 0xec(%rsp), %rsi
callq 0x41e40
movq %rax, %rdi
callq 0x3a550
movl %eax, %ecx
movl 0x48(%rsp), %eax
cmpl %ecx, %eax
jae 0x45a0d
movq 0x50(%rsp), %rdi
leaq 0xec(%rsp), %rsi
callq 0x41e40
movq %rax, %rdi
leaq 0xe8(%rsp), %rsi
callq 0x3a420
movq %rax, 0xf8(%rsp)
cmpq $0x0, 0xf0(%rsp)
je 0x459e7
movq 0xf0(%rsp), %rdi
callq 0x1f6a0
movl (%rax), %eax
addl $0x1, %eax
movl %eax, 0x44(%rsp)
movq 0xf8(%rsp), %rdi
callq 0x1f6a0
movq %rax, %rcx
movl 0x44(%rsp), %eax
cmpl (%rcx), %eax
jne 0x458cc
movq 0xf0(%rsp), %rax
movq %rax, 0x38(%rsp)
movq 0xf0(%rsp), %rdi
callq 0x1f6e0
movq %rax, 0x30(%rsp)
movq 0xf8(%rsp), %rdi
callq 0x1f6e0
movq 0x30(%rsp), %rsi
movq %rax, %rdx
leaq 0xb8(%rsp), %rdi
callq 0x76190
leaq 0xd0(%rsp), %rdi
leaq 0xb8(%rsp), %rsi
movsd 0x35ae0(%rip), %xmm0    # 0x7b390
callq 0x76630
movq 0x38(%rsp), %rdi
leaq 0xd0(%rsp), %rsi
callq 0x1ffe0
jmp 0x459e5
movq 0xf0(%rsp), %rdi
callq 0x1f6a0
movl (%rax), %eax
movl %eax, 0x2c(%rsp)
movq 0xf8(%rsp), %rdi
callq 0x1f6a0
movq %rax, %rcx
movl 0x2c(%rsp), %eax
cmpl (%rcx), %eax
jne 0x459af
movq 0xf0(%rsp), %rdi
callq 0x1f6c0
movq %rax, 0x20(%rsp)
movq 0xf8(%rsp), %rdi
callq 0x1f6c0
movq 0x20(%rsp), %rdi
movq %rax, %rcx
xorl %eax, %eax
movl %eax, %r8d
movl $0x1, %r9d
movq %r8, %rsi
movq %r9, %rdx
callq 0x5090
cmpl $0x0, %eax
je 0x459af
movq 0xf0(%rsp), %rax
movq %rax, 0x18(%rsp)
movq 0xf0(%rsp), %rdi
callq 0x1f6e0
movq %rax, 0x10(%rsp)
movq 0xf8(%rsp), %rdi
callq 0x1f6e0
movq 0x10(%rsp), %rsi
movq %rax, %rdx
leaq 0x88(%rsp), %rdi
callq 0x76190
leaq 0xa0(%rsp), %rdi
leaq 0x88(%rsp), %rsi
movsd 0x359fa(%rip), %xmm0    # 0x7b390
callq 0x76630
movq 0x18(%rsp), %rdi
leaq 0xa0(%rsp), %rsi
callq 0x1ffe0
jmp 0x459e3
movq 0xf0(%rsp), %rax
movq %rax, 0x8(%rsp)
leaq 0x70(%rsp), %rdi
movsd 0x359cf(%rip), %xmm2    # 0x7b398
movaps %xmm2, %xmm0
movaps %xmm2, %xmm1
callq 0x76090
movq 0x8(%rsp), %rdi
leaq 0x70(%rsp), %rsi
callq 0x1ffe0
jmp 0x459e5
jmp 0x459e7
movq 0xf8(%rsp), %rax
movq %rax, 0xf0(%rsp)
movl 0xe8(%rsp), %eax
addl $0x1, %eax
movl %eax, 0xe8(%rsp)
jmp 0x457bd
movq 0xf0(%rsp), %rax
movq %rax, (%rsp)
leaq 0x58(%rsp), %rdi
movsd 0x35972(%rip), %xmm2    # 0x7b398
movaps %xmm2, %xmm0
movaps %xmm2, %xmm1
callq 0x76090
movq (%rsp), %rdi
leaq 0x58(%rsp), %rsi
callq 0x1ffe0
movl 0xec(%rsp), %eax
addl $0x1, %eax
movl %eax, 0xec(%rsp)
jmp 0x45777
addq $0x108, %rsp            # imm = 0x108
retq
nopl (%rax)