// File: /workspace/github_cpp_makefile_star2_O3/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 0x29e7a
movq 0x16b17b(%rip), %r12    # 0x194fc0
leaq 0x124279(%rip), %rsi    # 0x14e0c5
movl $0x13, %edx
movq %r12, %rdi
callq 0x44e0
testq %r15, %r15
je 0x29ebd
movq %r15, %rdi
callq 0x41e0
movq 0x16b153(%rip), %rdi    # 0x194fc0
movq %r15, %rsi
movq %rax, %rdx
callq 0x44e0
jmp 0x29ed6
movq 0x16b13f(%rip), %rbx    # 0x194fc0
leaq 0x1244e0(%rip), %rsi    # 0x14e368
movl $0x19, %edx
movq %rbx, %rdi
callq 0x44e0
testq %r15, %r15
je 0x2a324
movq %r15, %rdi
callq 0x41e0
movq 0x16b113(%rip), %rdi    # 0x194fc0
movq %r15, %rsi
movq %rax, %rdx
callq 0x44e0
jmp 0x2a33b
movq (%r12), %rax
movq -0x18(%rax), %rax
leaq (%r12,%rax), %rdi
movl 0x20(%r12,%rax), %esi
orl $0x1, %esi
callq 0x4710
movq 0x16b0e3(%rip), %rdi    # 0x194fc0
leaq 0x12973a(%rip), %rsi    # 0x15361e
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 0x52330
movb %bpl, 0x7(%rsp)
movsd 0x38(%r14), %xmm0
movsd %xmm0, 0x8(%r14)
movsd 0x58(%r14), %xmm1
mulsd %xmm1, %xmm1
movsd 0x68(%r14), %xmm0
movsd 0x70(%r14), %xmm2
mulsd %xmm2, %xmm2
movapd %xmm0, %xmm3
mulsd %xmm0, %xmm3
addsd %xmm2, %xmm3
unpcklpd %xmm3, %xmm1            # xmm1 = xmm1[0],xmm3[0]
movsd 0x50(%r14), %xmm2
movhpd 0x78(%r14), %xmm2       # xmm2 = xmm2[0],mem[0]
mulpd %xmm2, %xmm2
addpd %xmm1, %xmm2
sqrtpd %xmm2, %xmm1
movupd %xmm1, 0x10(%r14)
unpckhpd %xmm1, %xmm1            # xmm1 = xmm1[1,1]
divsd %xmm1, %xmm0
callq 0x4400
mulsd 0x123ae8(%rip), %xmm0   # 0x14db00
divsd 0x123ae8(%rip), %xmm0   # 0x14db08
movsd %xmm0, 0x28(%r14)
movsd 0x50(%r14), %xmm0
divsd 0x10(%r14), %xmm0
callq 0x4400
movsd 0x123ac1(%rip), %xmm2   # 0x14db00
mulsd %xmm2, %xmm0
movsd 0x123abd(%rip), %xmm3   # 0x14db08
divsd %xmm3, %xmm0
movsd %xmm0, 0x30(%r14)
movsd 0x70(%r14), %xmm1
divsd 0x18(%r14), %xmm1
movsd %xmm1, 0x10(%rsp)
mulsd %xmm3, %xmm0
divsd %xmm2, %xmm0
callq 0x4100
movsd %xmm0, 0x8(%rsp)
movsd 0x30(%r14), %xmm0
mulsd 0x123a88(%rip), %xmm0   # 0x14db10
callq 0x4800
movsd %xmm0, 0x38(%rsp)
movsd 0x123a75(%rip), %xmm0   # 0x14db10
mulsd 0x28(%r14), %xmm0
callq 0x4800
mulsd 0x38(%rsp), %xmm0
movsd 0x8(%rsp), %xmm1
mulsd 0x10(%rsp), %xmm1
addsd %xmm1, %xmm0
callq 0x4400
mulsd 0x123a4f(%rip), %xmm0   # 0x14db18
movsd %xmm0, 0x20(%r14)
leaq 0x2f0(%r14), %rax
movq %rax, 0x8(%rsp)
xorl %ebp, %ebp
movl %r13d, %eax
leaq 0x40(%rsp), %r13
leaq 0xd8(%rsp), %r12
movzbl %al, %eax
movl %eax, 0x10(%rsp)
movq 0xf0(%rsp), %rax
movq -0x18(%rax), %rax
testb $0x2, 0x110(%rsp,%rax)
jne 0x2a309
movq %r13, %rdi
callq 0x51264
movq %r15, %rdi
leaq 0x80(%rsp), %rsi
callq 0x4560
movq 0x88(%rsp), %rbx
testq %rbx, %rbx
je 0x2a2b6
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 0x52eec
movq %r12, %rdi
xorl %esi, %esi
callq 0x83f9a
movsd (%rax), %xmm0
movsd %xmm0, 0x58(%rsp)
movq %r12, %rdi
movl $0x1, %esi
callq 0x83f9a
movsd (%rax), %xmm0
movsd %xmm0, 0x60(%rsp)
movq %r12, %rdi
movl $0x2, %esi
callq 0x83f9a
movsd (%rax), %xmm0
movsd %xmm0, 0x68(%rsp)
movsd 0x58(%rsp), %xmm0
callq 0x839b6
movsd %xmm0, 0x58(%rsp)
movsd 0x60(%rsp), %xmm0
callq 0x839b6
movsd %xmm0, 0x60(%rsp)
movsd 0x68(%rsp), %xmm0
callq 0x839b6
movsd %xmm0, 0x68(%rsp)
leaq 0x28(%rsp), %rax
movq %rax, 0x18(%rsp)
movq 0x80(%rsp), %rsi
movq 0x88(%rsp), %rdx
addq %rsi, %rdx
leaq 0x18(%rsp), %rdi
callq 0xf3ce
leaq 0x18(%rsp), %rdi
movl 0x10(%rsp), %esi
callq 0x21d5e
movsd %xmm0, 0x70(%rsp)
movq 0x18(%rsp), %rdi
leaq 0x28(%rsp), %rax
cmpq %rax, %rdi
je 0x2a2a7
movq 0x28(%rsp), %rsi
incq %rsi
callq 0x4470
movq 0x8(%rsp), %rdi
movq %r13, %rsi
callq 0xe9a8
incl %ebp
movq 0xa0(%rsp), %rdi
leaq 0xb0(%rsp), %rax
cmpq %rax, %rdi
je 0x2a2db
movq 0xb0(%rsp), %rsi
incq %rsi
callq 0x4470
movq 0x80(%rsp), %rdi
leaq 0x90(%rsp), %rax
cmpq %rax, %rdi
je 0x2a300
movq 0x90(%rsp), %rsi
incq %rsi
callq 0x4470
testq %rbx, %rbx
jne 0x2a0f4
movl %ebp, 0x110(%r14)
leaq 0xf0(%rsp), %rdi
callq 0x4090
movb 0x7(%rsp), %bpl
jmp 0x2a383
movq (%rbx), %rax
movq -0x18(%rax), %rax
leaq (%rbx,%rax), %rdi
movl 0x20(%rbx,%rax), %esi
orl $0x1, %esi
callq 0x4710
movq 0x16ac7e(%rip), %rdi    # 0x194fc0
leaq 0x1292d5(%rip), %rsi    # 0x15361e
movl $0x1, %edx
callq 0x44e0
movq 0x16ac66(%rip), %rdi    # 0x194fc0
leaq 0x123852(%rip), %rsi    # 0x14dbb3
movl $0xb, %edx
callq 0x44e0
movq 0x16ac4e(%rip), %rdi    # 0x194fc0
leaq 0x1292a5(%rip), %rsi    # 0x15361e
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 0x2a3c9
movq %rax, %rbx
movq 0x18(%rsp), %rdi
leaq 0x28(%rsp), %rax
cmpq %rax, %rdi
je 0x2a3d3
movq 0x28(%rsp), %rsi
incq %rsi
callq 0x4470
jmp 0x2a3d3
jmp 0x2a3c9
movq %rax, %rbx
jmp 0x2a3dd
jmp 0x2a3d0
movq %rax, %rbx
leaq 0x40(%rsp), %rdi
callq 0x2f5e8
leaq 0xf0(%rsp), %rdi
callq 0x4110
movq %rbx, %rdi
callq 0x4780