// File: /workspace/github_cpp_makefile_star2_O2/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 $0x3c8, %rsp            # imm = 0x3C8
movl %edx, %ebx
movq %rsi, %r15
movq %rdi, %r14
leaq 0xf0(%rsp), %rax
movq %rax, -0x10(%rax)
andq $0x0, -0x8(%rax)
movb $0x0, (%rax)
leaq 0x1b8(%rsp), %rdi
callq 0x4540
leaq 0x1b8(%rsp), %rdi
pushq $0x18
popq %rdx
movq %r14, %rsi
callq 0x4410
leaq 0x238(%rsp), %rdi
callq 0x4130
testb %al, %al
je 0x20841
movq 0x12f810(%rip), %rdi    # 0x14ffc0
leaq 0xdc997(%rip), %rsi     # 0xfd14e
callq 0x4480
movq %rax, %rdi
movq %r14, %rsi
callq 0x4480
movq %rax, %rdi
callq 0x4230
leaq 0x1b8(%rsp), %rdi
leaq 0xe0(%rsp), %rsi
callq 0x40e0
leaq 0xd0(%rsp), %rax
movq %rax, -0x10(%rax)
andq $0x0, -0x8(%rax)
movb $0x0, (%rax)
leaq 0x1b8(%rsp), %rdi
leaq 0xc0(%rsp), %rsi
callq 0x4580
leaq 0xdcaae(%rip), %rsi     # 0xfd2c2
leaq 0xc0(%rsp), %rdi
callq 0x4190
testl %eax, %eax
sete %bpl
je 0x2086e
movq 0x12f7c0(%rip), %rdi    # 0x14fff0
leaq 0xdca92(%rip), %rsi     # 0xfd2c9
callq 0x4480
jmp 0x20b90
movq 0x12f7a8(%rip), %rdi    # 0x14fff0
leaq 0xdcae5(%rip), %rsi     # 0xfd334
callq 0x4480
movq %rax, %rdi
movq %r14, %rsi
callq 0x4480
movq %rax, %rdi
callq 0x4230
xorl %ebp, %ebp
jmp 0x20b9d
leaq 0x8(%r15), %rsi
leaq 0x1b8(%rsp), %rdi
callq 0x42d0
leaq 0x10(%r15), %rsi
movq %rax, %rdi
callq 0x42d0
leaq 0x18(%r15), %rsi
movq %rax, %rdi
callq 0x42d0
leaq 0x20(%r15), %rsi
leaq 0x1b8(%rsp), %rdi
callq 0x42d0
leaq 0x28(%r15), %rsi
movq %rax, %rdi
callq 0x42d0
leaq 0x30(%r15), %rsi
movq %rax, %rdi
callq 0x42d0
leaq 0x1b8(%rsp), %rdi
leaq 0xe0(%rsp), %rsi
callq 0x40e0
leaq 0x320(%r15), %rdi
movq %r14, %rsi
callq 0x4810
movq %r15, %rdi
callq 0x3e5a4
movl %ebp, 0x10(%rsp)
movq %r15, 0x18(%rsp)
leaq 0x2f0(%r15), %rax
movq %rax, 0x20(%rsp)
xorl %r13d, %r13d
leaq 0x1b8(%rsp), %rbp
leaq 0x88(%rsp), %r15
movzbl %bl, %eax
movl %eax, 0x14(%rsp)
leaq 0x198(%rsp), %rbx
xorl %r14d, %r14d
movl $0x0, 0xc(%rsp)
testb $0x1, %r14b
jne 0x20b4d
leaq 0x98(%rsp), %rax
movq %rax, 0x88(%rsp)
andq $0x0, 0x90(%rsp)
leaq 0x58(%rsp), %rax
movq %rax, 0x48(%rsp)
andq $0x0, 0x50(%rsp)
leaq 0x78(%rsp), %rax
movq %rax, 0x68(%rsp)
andq $0x0, 0x70(%rsp)
movb %r13b, 0x98(%rsp)
movb %r13b, 0x58(%rsp)
movb %r13b, 0x78(%rsp)
leaq 0x38(%rsp), %rax
movq %rax, 0x28(%rsp)
andq $0x0, 0x30(%rsp)
movb %r13b, 0x38(%rsp)
movq %rbp, %rdi
movq %r15, %rsi
callq 0x4580
movq %r15, %rdi
leaq 0xdc980(%rip), %rsi     # 0xfd32d
callq 0x4190
testl %eax, %eax
sete %r14b
je 0x20b22
leaq 0x100(%rsp), %rdi
callq 0x3dc5a
movq %rbp, %rdi
leaq 0x48(%rsp), %rsi
callq 0x4580
movq %rbp, %rdi
leaq 0x140(%rsp), %rsi
callq 0x4580
movq %rbp, %rdi
leaq 0x28(%rsp), %rsi
callq 0x4580
movq %rbp, %rdi
leaq 0x100(%rsp), %rsi
callq 0x42d0
movq %rax, %rdi
leaq 0x108(%rsp), %rsi
callq 0x42d0
movq %rax, %rdi
leaq 0x110(%rsp), %rsi
callq 0x42d0
movq %rbp, %rdi
leaq 0x48(%rsp), %rsi
callq 0x4580
movq %rax, %rdi
leaq 0x68(%rsp), %rsi
callq 0x4580
movq %rax, %rdi
leaq 0x28(%rsp), %rsi
callq 0x4580
movsd 0x100(%rsp), %xmm0
movsd 0x108(%rsp), %xmm1
movsd 0x110(%rsp), %xmm2
leaq 0xa8(%rsp), %rdi
movq 0x18(%rsp), %rsi
callq 0x3f1ce
leaq 0xa8(%rsp), %rdi
xorl %esi, %esi
callq 0x63c78
movsd (%rax), %xmm0
movsd %xmm0, 0x118(%rsp)
leaq 0xa8(%rsp), %rdi
pushq $0x1
popq %rsi
callq 0x63c78
movsd (%rax), %xmm0
movsd %xmm0, 0x120(%rsp)
leaq 0xa8(%rsp), %rdi
pushq $0x2
popq %rsi
callq 0x63c78
movsd (%rax), %xmm0
movsd %xmm0, 0x128(%rsp)
movq %rbx, %rdi
leaq 0x140(%rsp), %rsi
callq 0x45d0
movq %rbx, %r12
movq %rbx, %rdi
movl 0x14(%rsp), %esi
callq 0x1b1bb
movsd %xmm0, 0x130(%rsp)
movq %r12, %rdi
callq 0x4210
movq 0x20(%rsp), %rdi
leaq 0x100(%rsp), %rsi
callq 0xa7d8
incl 0xc(%rsp)
leaq 0x100(%rsp), %rdi
callq 0xa808
leaq 0x28(%rsp), %rdi
callq 0x4210
leaq 0x68(%rsp), %rdi
callq 0x4210
leaq 0x48(%rsp), %rdi
callq 0x4210
movq %r15, %rdi
callq 0x4210
jmp 0x2092e
movq 0x18(%rsp), %rax
movl 0xc(%rsp), %esi
movl %esi, 0x110(%rax)
movq 0x12f45d(%rip), %rdi    # 0x14ffc0
callq 0x4760
movl 0x10(%rsp), %ebp
leaq 0xdc627(%rip), %rsi     # 0xfd19a
movq %rax, %rdi
callq 0x4480
movq %rax, %rdi
callq 0x4230
leaq 0x1b8(%rsp), %rdi
callq 0x4080
leaq 0xc0(%rsp), %rdi
callq 0x4210
leaq 0x1b8(%rsp), %rdi
callq 0x4120
leaq 0xe0(%rsp), %rdi
callq 0x4210
movl %ebp, %eax
addq $0x3c8, %rsp            # imm = 0x3C8
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
jmp 0x20bd2
movq %rax, %rbx
jmp 0x20c4c
movq %rax, %rbx
jmp 0x20c32
movq %rax, %rbx
leaq 0x198(%rsp), %rdi
callq 0x4210
jmp 0x20bfa
jmp 0x20bf0
movq %rax, %rbx
jmp 0x20c3f
movq %rax, %rbx
jmp 0x20c07
jmp 0x20bf7
movq %rax, %rbx
leaq 0x100(%rsp), %rdi
callq 0xa808
leaq 0x28(%rsp), %rdi
callq 0x4210
leaq 0x68(%rsp), %rdi
callq 0x4210
leaq 0x48(%rsp), %rdi
callq 0x4210
leaq 0x88(%rsp), %rdi
callq 0x4210
leaq 0xc0(%rsp), %rdi
callq 0x4210
leaq 0x1b8(%rsp), %rdi
callq 0x4120
leaq 0xe0(%rsp), %rdi
callq 0x4210
movq %rbx, %rdi
callq 0x4780