// File: atfrank[P]PCASA/lib/Molecule.cpp
// Function: Molecule::addMissingChainIds()
void Molecule::addMissingChainIds(){
  Chain *chn;
  Atom *atm;
  char currId;
  std::map<char, int> mapIds;
  unsigned int i, j;
  std::string id;

  currId='A';

  //Create map of chainIds
  for (i=0; i< this->getChnVecSize(); i++){
    chn=this->getChain(i);
    if (chn->getChainId().compare(" ") != 0){
      mapIds[chn->getChainId().at(0)]=1;
    }
  }

  for (i=0; i< this->getChnVecSize(); i++){
    chn=this->getChain(i);
    for (j=0; j< chn->getAtmVecSize(); j++){
      atm=chn->getAtom(j);
      if (atm->getChainId().compare(" ") == 0){
        while (mapIds.find(currId) != mapIds.end()){
          currId++;
        }
        id=currId;
        atm->setChainId(id);
      }
    }
    mapIds[currId]=1;
  }
}

// Assembly:
subq $0x148, %rsp            # imm = 0x148
movq %rdi, 0x140(%rsp)
movq 0x140(%rsp), %rax
movq %rax, 0x68(%rsp)
leaq 0xf8(%rsp), %rdi
callq 0x472a0
leaq 0xd0(%rsp), %rdi
callq 0x5600
movb $0x41, 0x12f(%rsp)
movl $0x0, 0xf4(%rsp)
movq 0x68(%rsp), %rdi
movl 0xf4(%rsp), %eax
movl %eax, 0x60(%rsp)
callq 0x41e20
movl %eax, 0x64(%rsp)
jmp 0x43864
movl 0x60(%rsp), %eax
movl 0x64(%rsp), %ecx
cmpl %ecx, %eax
jae 0x4399c
movq 0x68(%rsp), %rdi
leaq 0xf4(%rsp), %rsi
callq 0x41e40
movq %rax, 0x58(%rsp)
jmp 0x4388d
movq 0x58(%rsp), %rax
movq %rax, 0x138(%rsp)
movq 0x138(%rsp), %rsi
leaq 0xa0(%rsp), %rdi
callq 0x3a500
jmp 0x438b1
leaq 0xa0(%rsp), %rdi
leaq 0x38cd8(%rip), %rsi     # 0x7c598
callq 0x5140
movl %eax, 0x54(%rsp)
leaq 0xa0(%rsp), %rdi
callq 0x5250
movl 0x54(%rsp), %eax
cmpl $0x0, %eax
je 0x43984
movq 0x138(%rsp), %rsi
leaq 0x80(%rsp), %rdi
callq 0x3a500
jmp 0x438fa
xorl %eax, %eax
movl %eax, %esi
leaq 0x80(%rsp), %rdi
callq 0x57a0
movq %rax, 0x48(%rsp)
jmp 0x43912
movq 0x48(%rsp), %rsi
leaq 0xf8(%rsp), %rdi
callq 0x472b0
movq %rax, 0x40(%rsp)
jmp 0x4392b
movq 0x40(%rsp), %rax
movl $0x1, (%rax)
leaq 0x80(%rsp), %rdi
callq 0x5250
jmp 0x43984
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0xc8(%rsp)
movl %eax, 0xc4(%rsp)
jmp 0x43b90
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0xc8(%rsp)
movl %eax, 0xc4(%rsp)
leaq 0x80(%rsp), %rdi
callq 0x5250
jmp 0x43b90
jmp 0x43986
movl 0xf4(%rsp), %eax
addl $0x1, %eax
movl %eax, 0xf4(%rsp)
jmp 0x43849
movl $0x0, 0xf4(%rsp)
movq 0x68(%rsp), %rdi
movl 0xf4(%rsp), %eax
movl %eax, 0x38(%rsp)
callq 0x41e20
movl %eax, 0x3c(%rsp)
jmp 0x439c2
movl 0x38(%rsp), %eax
movl 0x3c(%rsp), %ecx
cmpl %ecx, %eax
jae 0x43b6e
movq 0x68(%rsp), %rdi
leaq 0xf4(%rsp), %rsi
callq 0x41e40
movq %rax, 0x30(%rsp)
jmp 0x439eb
movq 0x30(%rsp), %rax
movq %rax, 0x138(%rsp)
movl $0x0, 0xf0(%rsp)
movl 0xf0(%rsp), %eax
movl %eax, 0x28(%rsp)
movq 0x138(%rsp), %rdi
callq 0x3a550
movl %eax, 0x2c(%rsp)
jmp 0x43a21
movl 0x28(%rsp), %eax
movl 0x2c(%rsp), %ecx
cmpl %ecx, %eax
jae 0x43b31
movq 0x138(%rsp), %rdi
leaq 0xf0(%rsp), %rsi
callq 0x3a420
movq %rax, 0x20(%rsp)
jmp 0x43a4d
movq 0x20(%rsp), %rax
movq %rax, 0x130(%rsp)
movq 0x130(%rsp), %rdi
callq 0x1f660
movq %rax, 0x18(%rsp)
jmp 0x43a6e
movq 0x18(%rsp), %rdi
leaq 0x38b1e(%rip), %rsi     # 0x7c598
callq 0x5140
cmpl $0x0, %eax
jne 0x43b19
jmp 0x43a8a
leaq 0xf8(%rsp), %rdi
leaq 0x12f(%rsp), %rsi
callq 0x473c0
movq %rax, 0x10(%rsp)
jmp 0x43aa6
movq 0x10(%rsp), %rax
movq %rax, 0x78(%rsp)
leaq 0xf8(%rsp), %rdi
callq 0x473f0
movq %rax, 0x70(%rsp)
leaq 0x78(%rsp), %rdi
leaq 0x70(%rsp), %rsi
callq 0x473a0
testb $0x1, %al
jne 0x43ad7
jmp 0x43ae9
movb 0x12f(%rsp), %al
addb $0x1, %al
movb %al, 0x12f(%rsp)
jmp 0x43a8a
movsbl 0x12f(%rsp), %esi
leaq 0xd0(%rsp), %rdi
callq 0x56c0
jmp 0x43b00
movq 0x130(%rsp), %rdi
leaq 0xd0(%rsp), %rsi
callq 0x1fe10
jmp 0x43b17
jmp 0x43b19
jmp 0x43b1b
movl 0xf0(%rsp), %eax
addl $0x1, %eax
movl %eax, 0xf0(%rsp)
jmp 0x43a03
leaq 0xf8(%rsp), %rdi
leaq 0x12f(%rsp), %rsi
callq 0x472b0
movq %rax, 0x8(%rsp)
jmp 0x43b4d
movq 0x8(%rsp), %rax
movl $0x1, (%rax)
movl 0xf4(%rsp), %eax
addl $0x1, %eax
movl %eax, 0xf4(%rsp)
jmp 0x439a7
leaq 0xd0(%rsp), %rdi
callq 0x5250
leaq 0xf8(%rsp), %rdi
callq 0x47420
addq $0x148, %rsp            # imm = 0x148
retq
leaq 0xd0(%rsp), %rdi
callq 0x5250
leaq 0xf8(%rsp), %rdi
callq 0x47420
movq 0xc8(%rsp), %rdi
callq 0x5720
nopw (%rax,%rax)