// File: /workspace/github_cpp_makefile_star2_O2/atfrank[P]PCASA/lib/PDB.cpp
// Function: PDB::processAtomLine(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>>, Atom*)
Atom* PDB::processAtomLine (std::string line, Atom* lastAtom){
  double x,y,z;
  std::string recname; //Record name: "ATOM  ", "HETATM"
  int  atmnum; //Atom serial number
  std::string chainid;
  int  resid; //Residue sequence number
  double occu; //Occupancy
  double bfac; //B-factor or Temperature factor
  std::string segid; //Segment identifier
  Atom *atmEntry=new Atom;

  //substr: first character is denoted by a value of 0 (not 1)
  if (Misc::isdigit(Misc::trim(line.substr(4,7)))){
    atmEntry->setRecName(line.substr(0,4));
    std::stringstream(line.substr(4,7)) >> atmnum;
    atmEntry->setAtmNum(atmnum);
  }
  else{
    atmEntry->setRecName(line.substr(0,6)); //PDB format
    std::stringstream(line.substr(6,5)) >> atmnum; //PDB format
    atmEntry->setAtmNum(atmnum); //PDB format
  }
  atmEntry->setAtmName(Misc::trim(line.substr(12,4)));
  atmEntry->setAlt(line.substr(16,1));
  //atmEntry->setResName(line.substr(17,3)); //PDB format
  atmEntry->setResName(Misc::trim(line.substr(17,4)));
  chainid=line.substr(21,1);
  if(lastAtom == NULL || lastAtom->getChainId().compare(chainid) != 0){
    //New chain, check if duplicate
    if (chnMap.find(chainid) == chnMap.end()){
      chnMap[chainid]=chnMap.size();
    }
    else{
      //Duplicate, likely HETATM ligand bound to same chain
      //Assign numeric chainid, this is valid PDB format
      //std::ostringstream ossChainId;
      //ossChainId<< chnMap.find(chainid)->second;
      //chainid=ossChainId.str();
      //Set chainid to blank
      chainid=" ";
    }
  }
  atmEntry->setChainId(chainid);
  atmEntry->setRealId(line.substr(21,1)); 
  //std::stringstream(line.substr(22,4)) >> resid; //PDB format
  std::stringstream(line.substr(22,6)) >> resid; //Automagically truncates anything that is not numeric, i.e. iCode
  atmEntry->setResId(resid);
  atmEntry->setICode(line.substr(26,1));
  std::stringstream(line.substr(30,8)) >> x;
  std::stringstream(line.substr(38,8)) >> y;
  std::stringstream(line.substr(46,8)) >> z;
  atmEntry->setCoor(Coor(x,y,z));
  if (line.size() >= 60){
    std::stringstream(line.substr(54,6)) >> occu;
    atmEntry->setOccu(occu);
  }
  if (line.size() >= 66){
    std::stringstream(line.substr(60,6)) >> bfac;
    atmEntry->setBFac(bfac);
  }
  if (line.size() >= 76){
    segid=line.substr(72,4);
    atmEntry->setSegId(segid);
  }
  if (line.size() >= 78){
    if (line.substr(77,1).compare(" ") == 0){
      atmEntry->setElem(atmEntry->getAtmName().substr(0,1));
    }
    else{
      atmEntry->setElem(line.substr(77,1));
    }
  }
  atmEntry->setSel(true);
  std::stringstream ss;
  ss << resid;
  atmEntry->setSummary(chainid+":"+atmEntry->getResName()+ss.str()+Misc::trim(atmEntry->getICode())+"."+Misc::trim(atmEntry->getAtmName()));

  return atmEntry;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x3e8, %rsp            # imm = 0x3E8
movq %rdx, %r12
leaq 0x3d8(%rsp), %rax
movq %rax, -0x10(%rax)
andq $0x0, -0x8(%rax)
movq %rsi, %r14
movq %rdi, %r15
xorl %ecx, %ecx
leaq 0x48(%rsp), %rdx
movq %rdx, -0x10(%rdx)
andq $0x0, -0x8(%rdx)
movb %cl, (%rax)
movb %cl, (%rdx)
leaq 0x3b8(%rsp), %rax
movq %rax, -0x10(%rax)
andq $0x0, -0x8(%rax)
movb %cl, (%rax)
movl $0x238, %edi            # imm = 0x238
callq 0x4320
movq %rax, %rbx
movq %rax, %rdi
callq 0xdee4
leaq 0x8(%rsp), %rdi
pushq $0x4
popq %rdx
pushq $0x7
popq %rcx
movq %r14, %rsi
callq 0x4340
leaq 0xdc0f(%rip), %rsi      # 0x2e5c4
leaq 0x388(%rsp), %rdi
leaq 0x80(%rsp), %rdx
callq 0x58d8
leaq 0xa0(%rsp), %rdi
leaq 0x8(%rsp), %rsi
leaq 0x388(%rsp), %rdx
callq 0x18be4
leaq 0xa0(%rsp), %rdi
callq 0x18ad6
movl %eax, %ebp
leaq 0xa0(%rsp), %rdi
callq 0x4170
leaq 0x388(%rsp), %rdi
callq 0x4170
leaq 0x8(%rsp), %rdi
callq 0x4170
testb %bpl, %bpl
je 0x20a8a
leaq 0xa0(%rsp), %rdi
pushq $0x4
popq %rcx
movq %r14, %rsi
xorl %edx, %edx
callq 0x4340
leaq 0xa0(%rsp), %rsi
movq %rbx, %rdi
callq 0xed16
leaq 0xa0(%rsp), %rdi
callq 0x4170
leaq 0x8(%rsp), %rdi
pushq $0x4
popq %rdx
pushq $0x7
popq %rcx
movq %r14, %rsi
callq 0x4340
leaq 0xa0(%rsp), %rdi
leaq 0x8(%rsp), %rsi
pushq $0x18
popq %rdx
callq 0x44b0
leaq 0xa0(%rsp), %rdi
leaq 0x34(%rsp), %rsi
callq 0x41d0
jmp 0x20af6
leaq 0xa0(%rsp), %rdi
pushq $0x6
popq %rcx
movq %r14, %rsi
xorl %edx, %edx
callq 0x4340
leaq 0xa0(%rsp), %rsi
movq %rbx, %rdi
callq 0xed16
leaq 0xa0(%rsp), %rdi
callq 0x4170
leaq 0x8(%rsp), %rdi
pushq $0x6
popq %rdx
pushq $0x5
popq %rcx
movq %r14, %rsi
callq 0x4340
leaq 0xa0(%rsp), %rdi
leaq 0x8(%rsp), %rsi
pushq $0x18
popq %rdx
callq 0x44b0
leaq 0xa0(%rsp), %rdi
leaq 0x34(%rsp), %rsi
callq 0x41d0
leaq 0xa0(%rsp), %rdi
callq 0x4260
leaq 0x8(%rsp), %rdi
callq 0x4170
leaq 0x34(%rsp), %rsi
movq %rbx, %rdi
callq 0xed20
leaq 0x8(%rsp), %rdi
pushq $0xc
popq %rdx
pushq $0x4
popq %rcx
movq %r14, %rsi
callq 0x4340
leaq 0xda90(%rip), %rsi      # 0x2e5c4
leaq 0x368(%rsp), %rdi
leaq 0x80(%rsp), %rdx
callq 0x58d8
leaq 0xa0(%rsp), %rdi
leaq 0x8(%rsp), %rsi
leaq 0x368(%rsp), %rdx
callq 0x18be4
leaq 0xa0(%rsp), %rsi
movq %rbx, %rdi
callq 0xed26
leaq 0xa0(%rsp), %rdi
callq 0x4170
leaq 0x368(%rsp), %rdi
callq 0x4170
leaq 0x8(%rsp), %rdi
callq 0x4170
leaq 0xa0(%rsp), %rdi
pushq $0x10
popq %rdx
pushq $0x1
popq %rcx
movq %r14, %rsi
callq 0x4340
leaq 0xa0(%rsp), %rsi
movq %rbx, %rdi
callq 0xed5a
leaq 0xa0(%rsp), %rdi
callq 0x4170
leaq 0x8(%rsp), %rdi
pushq $0x11
popq %rdx
pushq $0x4
popq %rcx
movq %r14, %rsi
callq 0x4340
leaq 0xd9e0(%rip), %rsi      # 0x2e5c4
leaq 0x348(%rsp), %rdi
leaq 0x80(%rsp), %rdx
callq 0x58d8
leaq 0xa0(%rsp), %rdi
leaq 0x8(%rsp), %rsi
leaq 0x348(%rsp), %rdx
callq 0x18be4
leaq 0xa0(%rsp), %rsi
movq %rbx, %rdi
callq 0xed82
leaq 0xa0(%rsp), %rdi
callq 0x4170
leaq 0x348(%rsp), %rdi
callq 0x4170
leaq 0x8(%rsp), %rdi
callq 0x4170
leaq 0xa0(%rsp), %rdi
pushq $0x15
popq %rdx
pushq $0x1
popq %rcx
movq %r14, %rsi
callq 0x4340
leaq 0x38(%rsp), %rdi
leaq 0xa0(%rsp), %r13
movq %r13, %rsi
callq 0x4390
movq %r13, %rdi
callq 0x4170
testq %r12, %r12
je 0x20c98
movq %r12, %rdi
callq 0xea1c
leaq 0x38(%rsp), %rsi
movq %rax, %rdi
callq 0x4040
testl %eax, %eax
je 0x20cd5
leaq 0x38(%rsp), %rsi
movq %r15, %rdi
callq 0x21920
leaq 0x8(%r15), %rcx
cmpq %rcx, %rax
je 0x20cc1
leaq 0xd90f(%rip), %rsi      # 0x2e5c4
leaq 0x38(%rsp), %rdi
callq 0x45c0
jmp 0x20cd5
movq 0x28(%r15), %r12
leaq 0x38(%rsp), %rsi
movq %r15, %rdi
callq 0x21828
movl %r12d, (%rax)
leaq 0x38(%rsp), %rsi
movq %rbx, %rdi
callq 0xedaa
leaq 0xa0(%rsp), %rdi
pushq $0x15
popq %rdx
pushq $0x1
popq %rcx
movq %r14, %rsi
callq 0x4340
leaq 0xa0(%rsp), %rsi
movq %rbx, %rdi
callq 0xedb6
leaq 0xa0(%rsp), %rdi
callq 0x4170
leaq 0x8(%rsp), %rdi
pushq $0x16
popq %rdx
pushq $0x6
popq %rcx
movq %r14, %rsi
callq 0x4340
leaq 0xa0(%rsp), %rdi
leaq 0x8(%rsp), %rsi
pushq $0x18
popq %rdx
callq 0x44b0
leaq 0xa0(%rsp), %rdi
leaq 0x30(%rsp), %rsi
callq 0x41d0
leaq 0xa0(%rsp), %rdi
callq 0x4260
leaq 0x8(%rsp), %rdi
callq 0x4170
leaq 0x30(%rsp), %rsi
movq %rbx, %rdi
callq 0xedea
leaq 0xa0(%rsp), %rdi
pushq $0x1a
popq %rdx
pushq $0x1
popq %rcx
movq %r14, %rsi
callq 0x4340
leaq 0xa0(%rsp), %rsi
movq %rbx, %rdi
callq 0xedf4
leaq 0xa0(%rsp), %rdi
callq 0x4170
leaq 0x8(%rsp), %rdi
pushq $0x1e
popq %rdx
pushq $0x8
popq %rcx
movq %r14, %rsi
callq 0x4340
leaq 0xa0(%rsp), %rdi
leaq 0x8(%rsp), %rsi
pushq $0x18
popq %rdx
callq 0x44b0
leaq 0xa0(%rsp), %rdi
leaq 0x78(%rsp), %rsi
callq 0x41f0
leaq 0xa0(%rsp), %rdi
callq 0x4260
leaq 0x8(%rsp), %rdi
callq 0x4170
leaq 0x8(%rsp), %rdi
pushq $0x26
popq %rdx
pushq $0x8
popq %rcx
movq %r14, %rsi
callq 0x4340
leaq 0xa0(%rsp), %rdi
leaq 0x8(%rsp), %rsi
pushq $0x18
popq %rdx
callq 0x44b0
leaq 0xa0(%rsp), %rdi
leaq 0x70(%rsp), %rsi
callq 0x41f0
leaq 0xa0(%rsp), %rdi
callq 0x4260
leaq 0x8(%rsp), %rdi
callq 0x4170
leaq 0x8(%rsp), %rdi
pushq $0x2e
popq %rdx
pushq $0x8
popq %rcx
movq %r14, %rsi
callq 0x4340
leaq 0xa0(%rsp), %rdi
leaq 0x8(%rsp), %rsi
pushq $0x18
popq %rdx
callq 0x44b0
leaq 0xa0(%rsp), %rdi
leaq 0x68(%rsp), %rsi
callq 0x41f0
leaq 0xa0(%rsp), %rdi
callq 0x4260
leaq 0x8(%rsp), %rdi
callq 0x4170
movsd 0x78(%rsp), %xmm0
movsd 0x70(%rsp), %xmm1
movsd 0x68(%rsp), %xmm2
leaq 0xa0(%rsp), %rdi
callq 0x2bf40
leaq 0xa0(%rsp), %rsi
movq %rbx, %rdi
callq 0xee3e
cmpq $0x3c, 0x8(%r14)
jb 0x21091
leaq 0x8(%rsp), %rdi
pushq $0x36
popq %rdx
pushq $0x6
popq %rcx
movq %r14, %rsi
callq 0x4340
leaq 0xa0(%rsp), %rdi
leaq 0x8(%rsp), %rsi
pushq $0x18
popq %rdx
callq 0x44b0
leaq 0xa0(%rsp), %rdi
leaq 0x60(%rsp), %rsi
callq 0x41f0
leaq 0xa0(%rsp), %rdi
callq 0x4260
leaq 0x8(%rsp), %rdi
callq 0x4170
leaq 0x60(%rsp), %rsi
movq %rbx, %rdi
callq 0xee4a
cmpq $0x42, 0x8(%r14)
jb 0x21091
leaq 0x8(%rsp), %rdi
pushq $0x3c
popq %rdx
pushq $0x6
popq %rcx
movq %r14, %rsi
callq 0x4340
leaq 0xa0(%rsp), %rdi
leaq 0x8(%rsp), %rsi
pushq $0x18
popq %rdx
callq 0x44b0
leaq 0xa0(%rsp), %rdi
leaq 0x58(%rsp), %rsi
callq 0x41f0
leaq 0xa0(%rsp), %rdi
callq 0x4260
leaq 0x8(%rsp), %rdi
callq 0x4170
leaq 0x58(%rsp), %rsi
movq %rbx, %rdi
callq 0xee58
cmpq $0x4c, 0x8(%r14)
jb 0x21091
leaq 0xa0(%rsp), %rdi
pushq $0x48
popq %rdx
pushq $0x4
popq %rcx
movq %r14, %rsi
callq 0x4340
leaq 0x3a8(%rsp), %r15
leaq 0xa0(%rsp), %r12
movq %r15, %rdi
movq %r12, %rsi
callq 0x4390
movq %r12, %rdi
callq 0x4170
movq %rbx, %rdi
movq %r15, %rsi
callq 0xee72
cmpq $0x4e, 0x8(%r14)
jb 0x21091
leaq 0xa0(%rsp), %rdi
pushq $0x4d
popq %rdx
pushq $0x1
popq %rcx
movq %r14, %rsi
callq 0x4340
leaq 0xd5b3(%rip), %rsi      # 0x2e5c4
leaq 0xa0(%rsp), %r15
movq %r15, %rdi
callq 0x4100
movl %eax, %ebp
movq %r15, %rdi
callq 0x4170
testl %ebp, %ebp
je 0x21057
leaq 0xa0(%rsp), %rdi
pushq $0x4d
popq %rdx
pushq $0x1
popq %rcx
movq %r14, %rsi
callq 0x4340
leaq 0xa0(%rsp), %rsi
movq %rbx, %rdi
callq 0xee66
jmp 0x21084
movq %rbx, %rdi
callq 0xe9f0
leaq 0xa0(%rsp), %rdi
pushq $0x1
popq %rcx
movq %rax, %rsi
xorl %edx, %edx
callq 0x4340
leaq 0xa0(%rsp), %rsi
movq %rbx, %rdi
callq 0xee66
leaq 0xa0(%rsp), %rdi
callq 0x4170
pushq $0x1
popq %rsi
movq %rbx, %rdi
callq 0xee92
leaq 0xa0(%rsp), %rdi
callq 0x4220
leaq 0xb0(%rsp), %rdi
movl 0x30(%rsp), %esi
callq 0x4520
leaq 0xc172(%rip), %rdx      # 0x2d233
leaq 0x2c8(%rsp), %rdi
leaq 0x38(%rsp), %rsi
callq 0xc97d
movq %rbx, %rdi
callq 0xea0c
leaq 0x2e8(%rsp), %rdi
leaq 0x2c8(%rsp), %rsi
movq %rax, %rdx
callq 0x1715d
leaq 0xb8(%rsp), %rsi
leaq 0x2a8(%rsp), %rdi
callq 0x44a0
leaq 0x308(%rsp), %rdi
leaq 0x2e8(%rsp), %rsi
leaq 0x2a8(%rsp), %rdx
callq 0xc890
movq %rbx, %rdi
callq 0xea34
movq %rax, %r14
leaq 0xd48d(%rip), %rsi      # 0x2e5c4
leaq 0x268(%rsp), %rdi
leaq 0x2f(%rsp), %rdx
callq 0x58d8
leaq 0x288(%rsp), %rdi
leaq 0x268(%rsp), %rdx
movq %r14, %rsi
callq 0x18be4
leaq 0x328(%rsp), %rdi
leaq 0x308(%rsp), %rsi
leaq 0x288(%rsp), %rdx
callq 0xc890
leaq 0xd5fd(%rip), %rdx      # 0x2e782
leaq 0x80(%rsp), %rdi
leaq 0x328(%rsp), %rsi
callq 0xc871
movq %rbx, %rdi
callq 0xe9f0
movq %rax, %r14
leaq 0xd418(%rip), %rsi      # 0x2e5c4
leaq 0x228(%rsp), %rdi
leaq 0x2e(%rsp), %rdx
callq 0x58d8
leaq 0x248(%rsp), %rdi
leaq 0x228(%rsp), %rdx
movq %r14, %rsi
callq 0x18be4
leaq 0x8(%rsp), %rdi
leaq 0x80(%rsp), %rsi
leaq 0x248(%rsp), %rdx
callq 0xc890
leaq 0x8(%rsp), %rsi
movq %rbx, %rdi
callq 0xee9a
leaq 0x8(%rsp), %rdi
callq 0x4170
leaq 0x248(%rsp), %rdi
callq 0x4170
leaq 0x228(%rsp), %rdi
callq 0x4170
leaq 0x80(%rsp), %rdi
callq 0x4170
leaq 0x328(%rsp), %rdi
callq 0x4170
leaq 0x288(%rsp), %rdi
callq 0x4170
leaq 0x268(%rsp), %rdi
callq 0x4170
leaq 0x308(%rsp), %rdi
callq 0x4170
leaq 0x2a8(%rsp), %rdi
callq 0x4170
leaq 0x2e8(%rsp), %rdi
callq 0x4170
leaq 0x2c8(%rsp), %rdi
callq 0x4170
leaq 0xa0(%rsp), %rdi
callq 0x4260
leaq 0x3a8(%rsp), %rdi
callq 0x4170
leaq 0x38(%rsp), %rdi
callq 0x4170
leaq 0x3c8(%rsp), %rdi
callq 0x4170
movq %rbx, %rax
addq $0x3e8, %rsp            # imm = 0x3E8
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
jmp 0x2149c
jmp 0x2149c
jmp 0x2151f
jmp 0x2151f
jmp 0x2151f
jmp 0x2151f
jmp 0x2144b
jmp 0x214f2
jmp 0x2151f
jmp 0x2144b
jmp 0x214f2
jmp 0x2151f
jmp 0x2144b
jmp 0x2144b
jmp 0x214f2
jmp 0x214f2
jmp 0x2151f
jmp 0x2151f
jmp 0x2149c
jmp 0x2149c
jmp 0x2151f
jmp 0x2151f
jmp 0x2151f
movq %rax, %r14
leaq 0x8(%rsp), %rdi
callq 0x4170
jmp 0x21354
movq %rax, %r14
leaq 0x248(%rsp), %rdi
callq 0x4170
jmp 0x21366
movq %rax, %r14
leaq 0x228(%rsp), %rdi
callq 0x4170
jmp 0x2137a
jmp 0x21377
movq %rax, %r14
leaq 0x80(%rsp), %rdi
callq 0x4170
leaq 0x328(%rsp), %rdi
callq 0x4170
leaq 0x288(%rsp), %rdi
callq 0x4170
leaq 0x268(%rsp), %rdi
callq 0x4170
jmp 0x213c4
movq %rax, %r14
jmp 0x21387
movq %rax, %r14
jmp 0x21394
movq %rax, %r14
jmp 0x213a1
jmp 0x213c1
movq %rax, %r14
leaq 0x308(%rsp), %rdi
callq 0x4170
leaq 0x2a8(%rsp), %rdi
callq 0x4170
leaq 0x2e8(%rsp), %rdi
callq 0x4170
leaq 0x2c8(%rsp), %rdi
callq 0x4170
leaq 0xa0(%rsp), %rdi
callq 0x4260
jmp 0x21522
movq %rax, %r14
jmp 0x213d1
movq %rax, %r14
jmp 0x213de
jmp 0x21416
movq %rax, %r14
jmp 0x213f8
jmp 0x2151f
jmp 0x2144b
jmp 0x214f2
jmp 0x2151f
jmp 0x2144b
jmp 0x214f2
jmp 0x2151f
jmp 0x2144b
jmp 0x214f2
jmp 0x2151f
jmp 0x2149c
jmp 0x2151f
movq %rax, %r14
leaq 0xa0(%rsp), %rdi
callq 0x4260
jmp 0x214f5
jmp 0x214f2
jmp 0x2151f
jmp 0x2149c
jmp 0x2151f
jmp 0x2151f
movq %rax, %r14
leaq 0xa0(%rsp), %rdi
callq 0x4170
jmp 0x2148b
movq %rax, %r14
leaq 0x348(%rsp), %rdi
jmp 0x214eb
jmp 0x214f2
jmp 0x2151f
movq %rax, %r14
leaq 0xa0(%rsp), %rdi
jmp 0x214fa
jmp 0x2151f
movq %rax, %r14
leaq 0xa0(%rsp), %rdi
callq 0x4170
jmp 0x214c0
movq %rax, %r14
leaq 0x368(%rsp), %rdi
jmp 0x214eb
jmp 0x214f2
jmp 0x2151f
movq %rax, %r14
leaq 0xa0(%rsp), %rdi
callq 0x4170
jmp 0x214e3
movq %rax, %r14
leaq 0x388(%rsp), %rdi
callq 0x4170
jmp 0x214f5
movq %rax, %r14
leaq 0x8(%rsp), %rdi
callq 0x4170
jmp 0x21522
jmp 0x2151f
movq %rax, %r14
movl $0x238, %esi            # imm = 0x238
movq %rbx, %rdi
callq 0x4330
jmp 0x21522
movq %rax, %r14
jmp 0x213eb
jmp 0x2151f
movq %rax, %r14
leaq 0x3a8(%rsp), %rdi
callq 0x4170
leaq 0x38(%rsp), %rdi
callq 0x4170
leaq 0x3c8(%rsp), %rdi
callq 0x4170
movq %r14, %rdi
callq 0x4560