// File: /workspace/github_cpp_makefile_star2_O1/Luthaf[P]zeopp/networkio.cc
// Function: readDLPFile(char*, ATOM_NETWORK*, bool)
bool readDLPFile(char *filename, ATOM_NETWORK *cell, bool radial){
  fstream input;
  char garbage[256];
  int i;
  input.open(filename);
  if(!input.is_open()){
    cout<< "Failed to open .dlp file " << filename << "\n";
    cout<<"Exiting ..." << "\n";
//    exit(1);
    return false;
  }
  else{
    cout  << "Reading input file " << filename << "\n";
    input.getline(garbage, 256);

    // Read and store information about the unit cell. While the
    // vector components are known, the side lengths and angles remain unknown
    input >> cell->v_a.x >> cell->v_a.y >> cell->v_a.z;
    input >> cell->v_b.x >> cell->v_b.y >> cell->v_b.z;
    input >> cell->v_c.x >> cell->v_c.y >> cell->v_c.z;

//    input >> cell->numAtoms;
    cell->initMatrices();

    //Recover information about unit cell angles and side lengths from
    //vector components. Essentially reverses the steps performed in
    //the initialize() method for ATOM_NETWORK instances as contained
    //in the file networkstorage.cc
    cell->a = cell->v_a.x;
    cell->b = sqrt(cell->v_b.x*cell->v_b.x+cell->v_b.y*cell->v_b.y);
    cell->c = sqrt(cell->v_c.x*cell->v_c.x+cell->v_c.y*cell->v_c.y+cell->v_c.z*cell->v_c.z);
    cell->beta = acos(cell->v_c.x/cell->c)*360.0/(2.0*PI);
    cell->gamma = acos(cell->v_b.x/cell->b)*360.0/(2.0*PI);
    cell->alpha = 360.0/(2*PI)*acos((cell->v_c.y/cell->c*sin(2.0*PI*cell->gamma/360.0))
				    +cos(2.0*PI/360.0*cell->gamma)*cos(2.0*PI/360.0*cell->beta));

    // Read and store information about each atom
    int numAtoms = 0;
    while(!input.eof()){
      ATOM newAtom;
      input >> newAtom.type;
      if(newAtom.type.empty())
	break;

      input.getline(garbage,256); // reading remaining data from a line

      input >> newAtom.x >> newAtom.y >> newAtom.z;
      input.getline(garbage,256); // read end of line

      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.a_coord = trans_to_origuc(newAtom.a_coord);
      newAtom.b_coord = trans_to_origuc(newAtom.b_coord);
      newAtom.c_coord = trans_to_origuc(newAtom.c_coord);
      newAtom.radius = lookupRadius(newAtom.type, radial);
      cell->atoms.push_back(newAtom);
      numAtoms++;
    }
    cell->numAtoms= numAtoms;

    input.close();
  }
  return true;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x408, %rsp            # imm = 0x408
movl %edx, %r13d
movq %rsi, %r14
movq %rdi, %r15
leaq 0xf0(%rsp), %rbx
movq %rbx, %rdi
callq 0x4520
movq %rbx, %rdi
movq %r15, %rsi
movl $0x18, %edx
callq 0x43d0
leaq 0x170(%rsp), %rdi
callq 0x4120
movl %eax, %ebp
testb %al, %al
je 0x2a097
movq 0x16cf5e(%rip), %r12    # 0x196fc0
leaq 0x125fec(%rip), %rsi    # 0x150055
movl $0x13, %edx
movq %r12, %rdi
callq 0x44e0
testq %r15, %r15
je 0x2a0da
movq %r15, %rdi
callq 0x41e0
movq 0x16cf36(%rip), %rdi    # 0x196fc0
movq %r15, %rsi
movq %rax, %rdx
callq 0x44e0
jmp 0x2a0f3
movq 0x16cf22(%rip), %rbx    # 0x196fc0
leaq 0x126253(%rip), %rsi    # 0x1502f8
movl $0x19, %edx
movq %rbx, %rdi
callq 0x44e0
testq %r15, %r15
je 0x2a577
movq %r15, %rdi
callq 0x41e0
movq 0x16cef6(%rip), %rdi    # 0x196fc0
movq %r15, %rsi
movq %rax, %rdx
callq 0x44e0
jmp 0x2a58e
movq (%r12), %rax
movq -0x18(%rax), %rax
leaq (%r12,%rax), %rdi
movl 0x20(%r12,%rax), %esi
orl $0x1, %esi
callq 0x4710
movq 0x16cec6(%rip), %rdi    # 0x196fc0
leaq 0x12b42d(%rip), %rsi    # 0x15552e
movl $0x1, %edx
callq 0x44e0
movq 0xf0(%rsp), %rax
addq -0x18(%rax), %rbx
movq %rbx, %rdi
movl $0xa, %esi
callq 0x4420
movsbl %al, %ecx
leaq 0xf0(%rsp), %rdi
leaq 0x300(%rsp), %rsi
movl $0x100, %edx            # imm = 0x100
callq 0x4830
leaq 0x38(%r14), %rsi
leaq 0xf0(%rsp), %rdi
callq 0x42a0
leaq 0x40(%r14), %rsi
movq %rax, %rdi
callq 0x42a0
leaq 0x48(%r14), %rsi
movq %rax, %rdi
callq 0x42a0
leaq 0x50(%r14), %rsi
leaq 0xf0(%rsp), %rdi
callq 0x42a0
leaq 0x58(%r14), %rsi
movq %rax, %rdi
callq 0x42a0
leaq 0x60(%r14), %rsi
movq %rax, %rdi
callq 0x42a0
leaq 0x68(%r14), %rsi
leaq 0xf0(%rsp), %r15
movq %r15, %rdi
callq 0x42a0
leaq 0x70(%r14), %rsi
movq %rax, %rdi
callq 0x42a0
leaq 0x78(%r14), %rsi
movq %rax, %rdi
callq 0x42a0
movq %r14, %rdi
callq 0x52604
movsd 0x38(%r14), %xmm1
movsd 0x50(%r14), %xmm0
movsd %xmm1, 0x8(%r14)
movsd 0x58(%r14), %xmm1
mulsd %xmm1, %xmm1
mulsd %xmm0, %xmm0
addsd %xmm1, %xmm0
xorpd %xmm2, %xmm2
ucomisd %xmm2, %xmm0
jb 0x2a1fb
sqrtsd %xmm0, %xmm0
jmp 0x2a204
callq 0x4350
xorpd %xmm2, %xmm2
movsd %xmm0, 0x10(%r14)
movsd 0x68(%r14), %xmm1
movsd 0x70(%r14), %xmm0
mulsd %xmm0, %xmm0
mulsd %xmm1, %xmm1
addsd %xmm0, %xmm1
movsd 0x78(%r14), %xmm0
mulsd %xmm0, %xmm0
addsd %xmm1, %xmm0
ucomisd %xmm2, %xmm0
movb %bpl, 0x3(%rsp)
movl %r13d, 0x4(%rsp)
jb 0x2a246
sqrtsd %xmm0, %xmm0
jmp 0x2a24b
callq 0x4350
movsd %xmm0, 0x18(%r14)
movsd 0x68(%r14), %xmm1
divsd %xmm0, %xmm1
movapd %xmm1, %xmm0
callq 0x4400
mulsd 0x125844(%rip), %xmm0   # 0x14fab0
divsd 0x125844(%rip), %xmm0   # 0x14fab8
movsd %xmm0, 0x28(%r14)
movsd 0x50(%r14), %xmm0
divsd 0x10(%r14), %xmm0
callq 0x4400
movsd 0x12581d(%rip), %xmm2   # 0x14fab0
mulsd %xmm2, %xmm0
movsd 0x125819(%rip), %xmm3   # 0x14fab8
divsd %xmm3, %xmm0
movsd %xmm0, 0x30(%r14)
movsd 0x70(%r14), %xmm1
divsd 0x18(%r14), %xmm1
movsd %xmm1, 0x8(%rsp)
mulsd %xmm3, %xmm0
divsd %xmm2, %xmm0
callq 0x4100
movsd %xmm0, 0x38(%rsp)
movsd 0x30(%r14), %xmm0
mulsd 0x1257e4(%rip), %xmm0   # 0x14fac0
callq 0x4800
movsd %xmm0, 0x30(%rsp)
movsd 0x1257d1(%rip), %xmm0   # 0x14fac0
mulsd 0x28(%r14), %xmm0
callq 0x4800
mulsd 0x30(%rsp), %xmm0
movsd 0x38(%rsp), %xmm1
mulsd 0x8(%rsp), %xmm1
addsd %xmm1, %xmm0
callq 0x4400
mulsd 0x1257ab(%rip), %xmm0   # 0x14fac8
movsd %xmm0, 0x20(%r14)
leaq 0x2f0(%r14), %rax
movq %rax, 0x8(%rsp)
xorl %ebx, %ebx
leaq 0x40(%rsp), %r13
leaq 0xd8(%rsp), %r12
movzbl 0x4(%rsp), %eax
movl %eax, 0x4(%rsp)
movq 0xf0(%rsp), %rax
movq -0x18(%rax), %rax
testb $0x2, 0x110(%rsp,%rax)
jne 0x2a55c
movq %r13, %rdi
callq 0x5162c
movq %r15, %rdi
leaq 0x80(%rsp), %rsi
callq 0x4560
movq 0x88(%rsp), %rbp
testq %rbp, %rbp
je 0x2a509
movq 0xf0(%rsp), %rax
movq -0x18(%rax), %rdi
addq %r15, %rdi
movl $0xa, %esi
callq 0x4420
movsbl %al, %ecx
movl $0x100, %edx            # imm = 0x100
movq %r15, %rdi
leaq 0x300(%rsp), %rsi
callq 0x4830
movq %r15, %rdi
movq %r13, %rsi
callq 0x42a0
movq %rax, %rdi
leaq 0x48(%rsp), %rsi
callq 0x42a0
movq %rax, %rdi
leaq 0x50(%rsp), %rsi
callq 0x42a0
movq 0xf0(%rsp), %rax
movq -0x18(%rax), %rdi
addq %r15, %rdi
movl $0xa, %esi
callq 0x4420
movsbl %al, %ecx
movl $0x100, %edx            # imm = 0x100
movq %r15, %rdi
leaq 0x300(%rsp), %rsi
callq 0x4830
movsd 0x40(%rsp), %xmm0
movsd 0x48(%rsp), %xmm1
movsd 0x50(%rsp), %xmm2
movq %r12, %rdi
movq %r14, %rsi
callq 0x531ea
movq %r12, %rdi
xorl %esi, %esi
callq 0x85478
movsd (%rax), %xmm0
movsd %xmm0, 0x58(%rsp)
movq %r12, %rdi
movl $0x1, %esi
callq 0x85478
movsd (%rax), %xmm0
movsd %xmm0, 0x60(%rsp)
movq %r12, %rdi
movl $0x2, %esi
callq 0x85478
movsd (%rax), %xmm0
movsd %xmm0, 0x68(%rsp)
movsd 0x58(%rsp), %xmm0
callq 0x84e6b
movsd %xmm0, 0x58(%rsp)
movsd 0x60(%rsp), %xmm0
callq 0x84e6b
movsd %xmm0, 0x60(%rsp)
movsd 0x68(%rsp), %xmm0
callq 0x84e6b
movsd %xmm0, 0x68(%rsp)
leaq 0x20(%rsp), %rax
movq %rax, 0x10(%rsp)
movq 0x80(%rsp), %rsi
movq 0x88(%rsp), %rdx
addq %rsi, %rdx
leaq 0x10(%rsp), %rdi
callq 0xf32a
leaq 0x10(%rsp), %rdi
movl 0x4(%rsp), %esi
callq 0x21e42
movsd %xmm0, 0x70(%rsp)
movq 0x10(%rsp), %rdi
leaq 0x20(%rsp), %rax
cmpq %rax, %rdi
je 0x2a4fa
movq 0x20(%rsp), %rsi
incq %rsi
callq 0x4470
movq 0x8(%rsp), %rdi
movq %r13, %rsi
callq 0xe936
incl %ebx
movq 0xa0(%rsp), %rdi
leaq 0xb0(%rsp), %rax
cmpq %rax, %rdi
je 0x2a52e
movq 0xb0(%rsp), %rsi
incq %rsi
callq 0x4470
movq 0x80(%rsp), %rdi
leaq 0x90(%rsp), %rax
cmpq %rax, %rdi
je 0x2a553
movq 0x90(%rsp), %rsi
incq %rsi
callq 0x4470
testq %rbp, %rbp
jne 0x2a347
movl %ebx, 0x110(%r14)
leaq 0xf0(%rsp), %rdi
callq 0x4090
movb 0x3(%rsp), %bpl
jmp 0x2a5d6
movq (%rbx), %rax
movq -0x18(%rax), %rax
leaq (%rbx,%rax), %rdi
movl 0x20(%rbx,%rax), %esi
orl $0x1, %esi
callq 0x4710
movq 0x16ca2b(%rip), %rdi    # 0x196fc0
leaq 0x12af92(%rip), %rsi    # 0x15552e
movl $0x1, %edx
callq 0x44e0
movq 0x16ca13(%rip), %rdi    # 0x196fc0
leaq 0x12558f(%rip), %rsi    # 0x14fb43
movl $0xb, %edx
callq 0x44e0
movq 0x16c9fb(%rip), %rdi    # 0x196fc0
leaq 0x12af62(%rip), %rsi    # 0x15552e
movl $0x1, %edx
callq 0x44e0
leaq 0xf0(%rsp), %rdi
callq 0x4110
movl %ebp, %eax
addq $0x408, %rsp            # imm = 0x408
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
jmp 0x2a61c
movq %rax, %rbx
movq 0x10(%rsp), %rdi
leaq 0x20(%rsp), %rax
cmpq %rax, %rdi
je 0x2a626
movq 0x20(%rsp), %rsi
incq %rsi
callq 0x4470
jmp 0x2a626
jmp 0x2a61c
movq %rax, %rbx
jmp 0x2a630
jmp 0x2a623
movq %rax, %rbx
leaq 0x40(%rsp), %rdi
callq 0x2f814
leaq 0xf0(%rsp), %rdi
callq 0x4110
movq %rbx, %rdi
callq 0x4780