// File: /workspace/github_cpp_makefile_star2_O2/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, %r12d
movq %rsi, %r14
movq %rdi, %rbx
leaq 0xf0(%rsp), %r15
movq %r15, %rdi
callq 0x4540
pushq $0x18
popq %rdx
movq %r15, %rdi
movq %rbx, %rsi
callq 0x4410
leaq 0x170(%rsp), %rdi
callq 0x4130
movl %eax, %ebp
testb %al, %al
je 0x214ed
movq 0x12ee7f(%rip), %rdi    # 0x14ffc0
leaq 0xdbf7d(%rip), %rsi     # 0xfd0c5
callq 0x4480
movq %rax, %rdi
movq %rbx, %rsi
callq 0x4480
leaq 0xe141f(%rip), %rsi     # 0x10257e
movq %rax, %rdi
callq 0x4480
leaq 0xf0(%rsp), %rdi
leaq 0x300(%rsp), %rsi
movl $0x100, %edx            # imm = 0x100
callq 0x41b0
leaq 0x38(%r14), %rsi
leaq 0xf0(%rsp), %rdi
callq 0x42d0
leaq 0x40(%r14), %rsi
movq %rax, %rdi
callq 0x42d0
leaq 0x48(%r14), %rsi
movq %rax, %rdi
callq 0x42d0
leaq 0x50(%r14), %rsi
leaq 0xf0(%rsp), %rdi
callq 0x42d0
leaq 0x58(%r14), %rsi
movq %rax, %rdi
callq 0x42d0
leaq 0x60(%r14), %rsi
movq %rax, %rdi
callq 0x42d0
leaq 0x68(%r14), %rsi
leaq 0xf0(%rsp), %rdi
callq 0x42d0
leaq 0x70(%r14), %rsi
movq %rax, %rdi
callq 0x42d0
leaq 0x78(%r14), %rsi
movq %rax, %rdi
callq 0x42d0
movq %r14, %rdi
callq 0x3e88c
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 0x4450
mulsd 0xdb87e(%rip), %xmm0    # 0xfcaf0
divsd 0xdb87e(%rip), %xmm0    # 0xfcaf8
movsd %xmm0, 0x28(%r14)
movsd 0x50(%r14), %xmm0
divsd 0x10(%r14), %xmm0
callq 0x4450
movsd 0xdb857(%rip), %xmm2    # 0xfcaf0
mulsd %xmm2, %xmm0
movsd 0xdb853(%rip), %xmm3    # 0xfcaf8
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 0x4110
movsd %xmm0, 0x18(%rsp)
movsd 0x30(%r14), %xmm0
mulsd 0xdb81e(%rip), %xmm0    # 0xfcb00
callq 0x47e0
movsd %xmm0, 0x10(%rsp)
movsd 0xdb80b(%rip), %xmm0    # 0xfcb00
mulsd 0x28(%r14), %xmm0
callq 0x47e0
mulsd 0x10(%rsp), %xmm0
movsd 0x18(%rsp), %xmm1
mulsd 0x8(%rsp), %xmm1
addsd %xmm1, %xmm0
callq 0x4450
mulsd 0xdb7e5(%rip), %xmm0    # 0xfcb08
movsd %xmm0, 0x20(%r14)
movq %r14, 0x8(%rsp)
leaq 0x2f0(%r14), %rax
movq %rax, 0x10(%rsp)
xorl %r15d, %r15d
leaq 0x20(%rsp), %rbx
movl %r12d, %eax
leaq 0xf0(%rsp), %r12
leaq 0xd8(%rsp), %r13
movzbl %al, %eax
movl %eax, 0x18(%rsp)
movq 0xf0(%rsp), %rax
movq -0x18(%rax), %rax
testb $0x2, 0x110(%rsp,%rax)
jne 0x214cd
movq %rbx, %rdi
callq 0x3dc5a
movq %r12, %rdi
leaq 0x60(%rsp), %rsi
callq 0x4580
movq 0x68(%rsp), %rbp
testq %rbp, %rbp
je 0x214bc
movl $0x100, %edx            # imm = 0x100
movq %r12, %rdi
leaq 0x300(%rsp), %rsi
callq 0x41b0
movq %r12, %rdi
movq %rbx, %rsi
callq 0x42d0
movq %rax, %rdi
leaq 0x28(%rsp), %rsi
callq 0x42d0
movq %rax, %rdi
leaq 0x30(%rsp), %rsi
callq 0x42d0
movl $0x100, %edx            # imm = 0x100
movq %r12, %rdi
leaq 0x300(%rsp), %rsi
callq 0x41b0
movsd 0x20(%rsp), %xmm0
movsd 0x28(%rsp), %xmm1
movsd 0x30(%rsp), %xmm2
movq %r13, %rdi
movq 0x8(%rsp), %rsi
callq 0x3f1ce
movq %r13, %rdi
xorl %esi, %esi
callq 0x63c78
movsd (%rax), %xmm0
movsd %xmm0, 0x38(%rsp)
movq %r13, %rdi
pushq $0x1
popq %rsi
callq 0x63c78
movsd (%rax), %xmm0
movsd %xmm0, 0x40(%rsp)
movq %r13, %rdi
pushq $0x2
popq %rsi
callq 0x63c78
movsd (%rax), %xmm0
movsd %xmm0, 0x48(%rsp)
movsd 0x38(%rsp), %xmm0
callq 0x6377f
movsd %xmm0, 0x38(%rsp)
movsd 0x40(%rsp), %xmm0
callq 0x6377f
movsd %xmm0, 0x40(%rsp)
movsd 0x48(%rsp), %xmm0
callq 0x6377f
movsd %xmm0, 0x48(%rsp)
leaq 0xb8(%rsp), %rdi
leaq 0x60(%rsp), %rsi
callq 0x45d0
leaq 0xb8(%rsp), %r14
movq %r14, %rdi
movl 0x18(%rsp), %esi
callq 0x1b1bb
movsd %xmm0, 0x50(%rsp)
movq %r14, %rdi
callq 0x4210
movq 0x10(%rsp), %rdi
movq %rbx, %rsi
callq 0xa7d8
incl %r15d
movq %rbx, %rdi
callq 0xa808
testq %rbp, %rbp
jne 0x2135c
movq 0x8(%rsp), %rax
movl %r15d, 0x110(%rax)
leaq 0xf0(%rsp), %rdi
callq 0x4080
movb 0x7(%rsp), %bpl
jmp 0x2153c
movq 0x12eacc(%rip), %rdi    # 0x14ffc0
leaq 0xdbe6d(%rip), %rsi     # 0xfd368
callq 0x4480
movq %rax, %rdi
movq %rbx, %rsi
callq 0x4480
leaq 0xe106c(%rip), %rsi     # 0x10257e
movq %rax, %rdi
callq 0x4480
movq 0x12ea9f(%rip), %rdi    # 0x14ffc0
leaq 0xdb68b(%rip), %rsi     # 0xfcbb3
callq 0x4480
leaq 0xe104a(%rip), %rsi     # 0x10257e
movq %rax, %rdi
callq 0x4480
leaq 0xf0(%rsp), %rdi
callq 0x4120
movl %ebp, %eax
addq $0x408, %rsp            # imm = 0x408
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
jmp 0x21573
movq %rax, %rbx
leaq 0xb8(%rsp), %rdi
callq 0x4210
jmp 0x2157d
jmp 0x21573
movq %rax, %rbx
jmp 0x21587
jmp 0x2157a
movq %rax, %rbx
leaq 0x20(%rsp), %rdi
callq 0xa808
leaq 0xf0(%rsp), %rdi
callq 0x4120
movq %rbx, %rdi
callq 0x4780