// File: /workspace/github_cpp_makefile_star2_O3/Luthaf[P]zeopp/networkio.cc
// Function: readPDBFile(char*, ATOM_NETWORK*, bool)
bool readPDBFile(char *filename, ATOM_NETWORK *cell, bool radial){
  string garbage; //this is a garbage string to read line
  int i,j;

  fstream input;
  input.open(filename);
  if(input.is_open()==true){
    // Read the header information
    cout << "Reading input file: " << filename << endl;
    getline(input, garbage); // skip the first comment line

    string PBCline;

    input >> PBCline;
    if(PBCline.compare("CRYST1") != 0)
      {
      cerr << "This .pdb files does not contain CRYST1 in the second line. File format not compatible. Exiting...\n";
      return false;
      };

    input >> cell->a >> cell->b >> cell->c;
    input >> cell->alpha >> cell->beta >> cell->gamma;
    getline(input,garbage); // reading rest of line

    cell->name = filename;
    cell->initialize();

    bool end=false;
    int na=0;
    while(!end)
      {
      string str1, str2, str3, str4;

      input >> str1; // reads ATOM or ENDMDL keyword

      if(str1.compare("ENDMDL") == 0)
        {
        end = true;
        } else
        {
        ATOM newAtom;
        input >> str2 ; // reading ID#
        input >> newAtom.type;
        input >> str4; // reading MDL
        input >> newAtom.x >> newAtom.y >> newAtom.z;
        input >> str2 >> str3 >> str4; // ignore 2 numbers and a string with label

//        if(!CAR_USE_ATOM_TYPE_OVER_NAME) newAtom.type = str1;

        Point newCoords = cell->xyz_to_abc(newAtom.x, newAtom.y, newAtom.z);
        newAtom.a_coord = newCoords[0]; newAtom.b_coord = newCoords[1]; newAtom.c_coord = newCoords[2];
        newAtom.radius = lookupRadius(newAtom.type, radial);
        cell->atoms.push_back(newAtom);
        na++;
        };

      };

    cell->numAtoms = na;
    cout << na << " atoms read." << endl;

    input.close();
  }
  else{
    cerr << "Error: PDB failed to open " << filename << endl;
//    abort();
    return false;
  }
  return true;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x3b8, %rsp            # imm = 0x3B8
movl %edx, 0xc(%rsp)
movq %rsi, (%rsp)
movq %rdi, %rbx
leaq 0xe0(%rsp), %r12
movq %r12, -0x10(%r12)
movq $0x0, -0x8(%r12)
movb $0x0, (%r12)
leaq 0x1a8(%rsp), %rdi
callq 0x4520
leaq 0x1a8(%rsp), %r14
movq %r14, %rdi
movq %rbx, %rsi
movl $0x18, %edx
callq 0x43d0
leaq 0x228(%rsp), %rdi
callq 0x4120
testb %al, %al
je 0x28f4f
movq 0x16c0a6(%rip), %r15    # 0x194fc0
leaq 0x12522d(%rip), %rsi    # 0x14e14e
movl $0x14, %edx
movq %r15, %rdi
callq 0x44e0
testq %rbx, %rbx
je 0x28f92
movq %rbx, %rdi
callq 0x41e0
movq 0x16c07e(%rip), %rdi    # 0x194fc0
movq %rbx, %rsi
movq %rax, %rdx
callq 0x44e0
jmp 0x28faa
movq 0x16c09a(%rip), %r14    # 0x194ff0
leaq 0x1253d7(%rip), %rsi    # 0x14e334
movl $0x1a, %edx
movq %r14, %rdi
callq 0x44e0
testq %rbx, %rbx
je 0x2906c
movq %rbx, %rdi
callq 0x41e0
movq 0x16c06e(%rip), %rdi    # 0x194ff0
movq %rbx, %rsi
movq %rax, %rdx
callq 0x44e0
jmp 0x29084
movq (%r15), %rax
movq -0x18(%rax), %rax
leaq (%r15,%rax), %rdi
movl 0x20(%r15,%rax), %esi
orl $0x1, %esi
callq 0x4710
movq (%r15), %rax
addq -0x18(%rax), %r15
movq %r15, %rdi
movl $0xa, %esi
callq 0x4420
movsbl %al, %esi
movq 0x16bff8(%rip), %rdi    # 0x194fc0
callq 0x4040
movq %rax, %rdi
callq 0x42c0
movq 0x1a8(%rsp), %rax
addq -0x18(%rax), %r14
movq %r14, %rdi
movl $0xa, %esi
callq 0x4420
movsbl %al, %edx
leaq 0x1a8(%rsp), %rdi
leaq 0xd0(%rsp), %rsi
callq 0x47e0
leaq 0xc0(%rsp), %r14
movq %r14, -0x10(%r14)
movq $0x0, -0x8(%r14)
movb $0x0, (%r14)
leaq 0x1a8(%rsp), %rdi
leaq 0xb0(%rsp), %rsi
callq 0x4560
leaq 0x125288(%rip), %rsi    # 0x14e2c2
leaq 0xb0(%rsp), %rdi
callq 0x4170
testl %eax, %eax
sete %bpl
je 0x290b6
movq 0x16bf9a(%rip), %rdi    # 0x194ff0
leaq 0x12526c(%rip), %rsi    # 0x14e2c9
movl $0x63, %edx
callq 0x44e0
jmp 0x294fb
movq (%r14), %rax
movq -0x18(%rax), %rax
leaq (%r14,%rax), %rdi
movl 0x20(%r14,%rax), %esi
orl $0x1, %esi
callq 0x4710
movq (%r14), %rax
addq -0x18(%rax), %r14
movq %r14, %rdi
movl $0xa, %esi
callq 0x4420
movsbl %al, %esi
movq 0x16bf4e(%rip), %rdi    # 0x194ff0
callq 0x4040
movq %rax, %rdi
callq 0x42c0
xorl %ebp, %ebp
jmp 0x29518
movq (%rsp), %rax
leaq 0x8(%rax), %rsi
leaq 0x1a8(%rsp), %rdi
callq 0x42a0
movq (%rsp), %rcx
leaq 0x10(%rcx), %rsi
movq %rax, %rdi
callq 0x42a0
movq (%rsp), %rcx
leaq 0x18(%rcx), %rsi
movq %rax, %rdi
callq 0x42a0
movq (%rsp), %rax
leaq 0x20(%rax), %rsi
leaq 0x1a8(%rsp), %r14
movq %r14, %rdi
callq 0x42a0
movq (%rsp), %rcx
leaq 0x28(%rcx), %rsi
movq %rax, %rdi
callq 0x42a0
movq (%rsp), %rcx
leaq 0x30(%rcx), %rsi
movq %rax, %rdi
callq 0x42a0
movq 0x1a8(%rsp), %rax
addq -0x18(%rax), %r14
movq %r14, %rdi
movl $0xa, %esi
callq 0x4420
movsbl %al, %edx
leaq 0x1a8(%rsp), %rdi
leaq 0xd0(%rsp), %rsi
callq 0x47e0
movq (%rsp), %rax
leaq 0x320(%rax), %r14
movq 0x328(%rax), %r15
movq %rbx, %rdi
callq 0x41e0
movq %r14, %rdi
xorl %esi, %esi
movq %r15, %rdx
movq %rbx, %rcx
movq %rax, %r8
callq 0x4670
movq (%rsp), %rdi
callq 0x51db4
movl %ebp, 0x8(%rsp)
movq (%rsp), %rax
addq $0x2f0, %rax            # imm = 0x2F0
movq %rax, 0xf0(%rsp)
xorl %ebp, %ebp
leaq 0x1a8(%rsp), %r15
leaq 0x70(%rsp), %r12
leaq 0x190(%rsp), %r13
xorl %ebx, %ebx
leaq 0x80(%rsp), %rax
movq %rax, 0x70(%rsp)
movq %rbp, 0x78(%rsp)
movb %bpl, 0x80(%rsp)
leaq 0x40(%rsp), %rax
movq %rax, 0x30(%rsp)
movq %rbp, 0x38(%rsp)
movb %bpl, 0x40(%rsp)
leaq 0x60(%rsp), %rax
movq %rax, 0x50(%rsp)
movq %rbp, 0x58(%rsp)
movb %bpl, 0x60(%rsp)
leaq 0x20(%rsp), %rax
movq %rax, 0x10(%rsp)
movq %rbp, 0x18(%rsp)
movb %bpl, 0x20(%rsp)
movq %r15, %rdi
movq %r12, %rsi
callq 0x4560
movq %r12, %rdi
leaq 0x125109(%rip), %rsi    # 0x14e32d
callq 0x4170
movl %eax, %r14d
testl %eax, %eax
je 0x29405
leaq 0xf8(%rsp), %rdi
callq 0x51264
movq %r15, %rdi
leaq 0x30(%rsp), %rsi
callq 0x4560
movq %r15, %rdi
leaq 0x138(%rsp), %rsi
callq 0x4560
movq %r15, %rdi
leaq 0x10(%rsp), %rsi
callq 0x4560
movq %r15, %rdi
leaq 0xf8(%rsp), %rsi
callq 0x42a0
movq %rax, %rdi
leaq 0x100(%rsp), %rsi
callq 0x42a0
movq %rax, %rdi
leaq 0x108(%rsp), %rsi
callq 0x42a0
movq %r15, %rdi
leaq 0x30(%rsp), %rsi
callq 0x4560
movq %rax, %rdi
leaq 0x50(%rsp), %rsi
callq 0x4560
movq %rax, %rdi
leaq 0x10(%rsp), %rsi
callq 0x4560
movsd 0xf8(%rsp), %xmm0
movsd 0x100(%rsp), %xmm1
movsd 0x108(%rsp), %xmm2
movq %r13, %rdi
movq (%rsp), %rsi
callq 0x52eec
movq %r13, %rdi
xorl %esi, %esi
callq 0x83f9a
movsd (%rax), %xmm0
movsd %xmm0, 0x110(%rsp)
movq %r13, %rdi
movl $0x1, %esi
callq 0x83f9a
movsd (%rax), %xmm0
movsd %xmm0, 0x118(%rsp)
movq %r13, %rdi
movl $0x2, %esi
callq 0x83f9a
movsd (%rax), %xmm0
movsd %xmm0, 0x120(%rsp)
leaq 0xa0(%rsp), %rax
movq %rax, 0x90(%rsp)
movq 0x138(%rsp), %rsi
movq 0x140(%rsp), %rdx
addq %rsi, %rdx
leaq 0x90(%rsp), %rdi
callq 0xf3ce
movzbl 0xc(%rsp), %esi
leaq 0x90(%rsp), %rdi
callq 0x21d5e
movsd %xmm0, 0x128(%rsp)
movq 0x90(%rsp), %rdi
leaq 0xa0(%rsp), %rax
cmpq %rax, %rdi
je 0x293a4
movq 0xa0(%rsp), %rsi
incq %rsi
callq 0x4470
movq 0xf0(%rsp), %rdi
leaq 0xf8(%rsp), %rsi
callq 0xe9a8
movq 0x158(%rsp), %rdi
leaq 0x168(%rsp), %rax
cmpq %rax, %rdi
je 0x293de
movq 0x168(%rsp), %rsi
incq %rsi
callq 0x4470
movq 0x138(%rsp), %rdi
leaq 0x148(%rsp), %rax
cmpq %rax, %rdi
je 0x29403
movq 0x148(%rsp), %rsi
incq %rsi
callq 0x4470
incl %ebx
movq 0x10(%rsp), %rdi
leaq 0x20(%rsp), %rax
cmpq %rax, %rdi
je 0x29421
movq 0x20(%rsp), %rsi
incq %rsi
callq 0x4470
movq 0x50(%rsp), %rdi
leaq 0x60(%rsp), %rax
cmpq %rax, %rdi
je 0x2943d
movq 0x60(%rsp), %rsi
incq %rsi
callq 0x4470
movq 0x30(%rsp), %rdi
leaq 0x40(%rsp), %rax
cmpq %rax, %rdi
je 0x29459
movq 0x40(%rsp), %rsi
incq %rsi
callq 0x4470
movq 0x70(%rsp), %rdi
leaq 0x80(%rsp), %rax
cmpq %rax, %rdi
je 0x2947b
movq 0x80(%rsp), %rsi
incq %rsi
callq 0x4470
testl %r14d, %r14d
jne 0x291b9
movq (%rsp), %rax
movl %ebx, 0x110(%rax)
movq 0x16bb2b(%rip), %rdi    # 0x194fc0
movl %ebx, %esi
leaq 0xe0(%rsp), %r12
leaq 0xc0(%rsp), %r14
callq 0x4750
movl 0x8(%rsp), %ebp
movq %rax, %rbx
leaq 0x124ce0(%rip), %rsi    # 0x14e19a
movl $0xc, %edx
movq %rax, %rdi
callq 0x44e0
movq (%rbx), %rax
movq -0x18(%rax), %rdi
addq %rbx, %rdi
movl $0xa, %esi
callq 0x4420
movsbl %al, %esi
movq %rbx, %rdi
callq 0x4040
movq %rax, %rdi
callq 0x42c0
leaq 0x1a8(%rsp), %rdi
callq 0x4090
movq 0xb0(%rsp), %rdi
cmpq %r14, %rdi
je 0x29518
movq 0xc0(%rsp), %rsi
incq %rsi
callq 0x4470
leaq 0x1a8(%rsp), %rdi
callq 0x4110
movq 0xd0(%rsp), %rdi
cmpq %r12, %rdi
je 0x29542
movq 0xe0(%rsp), %rsi
incq %rsi
callq 0x4470
movl %ebp, %eax
addq $0x3b8, %rsp            # imm = 0x3B8
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq %rax, %rbx
jmp 0x2965b
jmp 0x29560
movq %rax, %rbx
jmp 0x29629
jmp 0x29594
movq %rax, %rbx
movq 0x90(%rsp), %rdi
leaq 0xa0(%rsp), %rax
cmpq %rax, %rdi
je 0x295a6
movq 0xa0(%rsp), %rsi
incq %rsi
callq 0x4470
jmp 0x295a6
movq %rax, %rbx
jmp 0x295b3
movq %rax, %rbx
jmp 0x2964e
jmp 0x295a3
movq %rax, %rbx
leaq 0xf8(%rsp), %rdi
callq 0x2f5e8
movq 0x10(%rsp), %rdi
leaq 0x20(%rsp), %rax
cmpq %rax, %rdi
je 0x295cf
movq 0x20(%rsp), %rsi
incq %rsi
callq 0x4470
movq 0x50(%rsp), %rdi
leaq 0x60(%rsp), %rax
cmpq %rax, %rdi
je 0x295eb
movq 0x60(%rsp), %rsi
incq %rsi
callq 0x4470
movq 0x30(%rsp), %rdi
leaq 0x40(%rsp), %rax
cmpq %rax, %rdi
je 0x29607
movq 0x40(%rsp), %rsi
incq %rsi
callq 0x4470
movq 0x70(%rsp), %rdi
leaq 0x80(%rsp), %rax
cmpq %rax, %rdi
je 0x29629
movq 0x80(%rsp), %rsi
incq %rsi
callq 0x4470
movq 0xb0(%rsp), %rdi
leaq 0xc0(%rsp), %rax
cmpq %rax, %rdi
je 0x2964e
movq 0xc0(%rsp), %rsi
incq %rsi
callq 0x4470
leaq 0x1a8(%rsp), %rdi
callq 0x4110
movq 0xd0(%rsp), %rdi
leaq 0xe0(%rsp), %rax
cmpq %rax, %rdi
je 0x29680
movq 0xe0(%rsp), %rsi
incq %rsi
callq 0x4470
movq %rbx, %rdi
callq 0x4780