// File: /workspace/github_cpp_makefile_star2_O3/Luthaf[P]zeopp/networkio.cc
// Function: readV1File(char*, ATOM_NETWORK*, bool)
bool readV1File(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 .v1 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 >> garbage >> cell->v_a.x >> cell->v_a.y >> cell->v_a.z;
    input >> garbage >> cell->v_b.x >> cell->v_b.y >> cell->v_b.z;
    input >> garbage >> 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. The coordinates
    // relative to the unit cell vectors remain unknown
    for(i=0; i<cell->numAtoms; i++){
      ATOM newAtom;
      input >> newAtom.type >> newAtom.x >> newAtom.y >> newAtom.z;
      Point abcCoords = cell->xyz_to_abc(newAtom.x, newAtom.y, newAtom.z);
      newAtom.a_coord = trans_to_origuc(abcCoords[0]); newAtom.b_coord = trans_to_origuc(abcCoords[1]); newAtom.c_coord = trans_to_origuc(abcCoords[2]);
      newAtom.radius = lookupRadius(newAtom.type, radial);
      cell->atoms.push_back(newAtom);
    }
    input.close();
  }
  return true;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x418, %rsp            # imm = 0x418
movl %edx, %ebp
movq %rsi, 0x8(%rsp)
movq %rdi, %r15
leaq 0xe8(%rsp), %rbx
movq %rbx, %rdi
callq 0x4520
movq %rbx, %rdi
movq %r15, %rsi
movl $0x18, %edx
callq 0x43d0
leaq 0x168(%rsp), %rdi
callq 0x4120
movb %al, 0x7(%rsp)
testb %al, %al
je 0x29714
movq 0x16b8e1(%rip), %r12    # 0x194fc0
leaq 0x1249df(%rip), %rsi    # 0x14e0c5
movl $0x13, %edx
movq %r12, %rdi
callq 0x44e0
testq %r15, %r15
je 0x29757
movq %r15, %rdi
callq 0x41e0
movq 0x16b8b9(%rip), %rdi    # 0x194fc0
movq %r15, %rsi
movq %rax, %rdx
callq 0x44e0
jmp 0x29770
movq 0x16b8a5(%rip), %rbx    # 0x194fc0
leaq 0x124c2d(%rip), %rsi    # 0x14e34f
movl $0x18, %edx
movq %rbx, %rdi
callq 0x44e0
testq %r15, %r15
je 0x29c81
movq %r15, %rdi
callq 0x41e0
movq 0x16b879(%rip), %rdi    # 0x194fc0
movq %r15, %rsi
movq %rax, %rdx
callq 0x44e0
jmp 0x29c98
movq (%r12), %rax
movq -0x18(%rax), %rax
leaq (%r12,%rax), %rdi
movl 0x20(%r12,%rax), %esi
orl $0x1, %esi
callq 0x4710
movq 0x16b849(%rip), %rdi    # 0x194fc0
leaq 0x129ea0(%rip), %rsi    # 0x15361e
movl $0x1, %edx
callq 0x44e0
movq 0xe8(%rsp), %rax
addq -0x18(%rax), %rbx
movq %rbx, %rdi
movl $0xa, %esi
callq 0x4420
movsbl %al, %ecx
leaq 0xe8(%rsp), %rdi
leaq 0x310(%rsp), %rsi
movl $0x100, %edx            # imm = 0x100
callq 0x4830
leaq 0xe8(%rsp), %rdi
movq (%rdi), %rax
movq -0x18(%rax), %rax
movq 0xf8(%rsp,%rax), %rbx
leaq 0x310(%rsp), %rsi
movl $0x100, %edx            # imm = 0x100
callq 0x4740
movq 0xe8(%rsp), %rax
movq -0x18(%rax), %rax
cmpl $0x0, 0x108(%rsp,%rax)
jne 0x29823
addq $-0x101, %rbx           # imm = 0xFEFF
cmpq $-0x101, %rbx           # imm = 0xFEFF
ja 0x29823
movq 0x1d0(%rsp,%rax), %rdi
movq 0x10(%rdi), %rax
cmpq 0x18(%rdi), %rax
jae 0x29d03
movq 0x8(%rsp), %rax
leaq 0x38(%rax), %rsi
leaq 0xe8(%rsp), %rdi
callq 0x42a0
movq 0x8(%rsp), %rcx
leaq 0x40(%rcx), %rsi
movq %rax, %rdi
callq 0x42a0
movq 0x8(%rsp), %rcx
leaq 0x48(%rcx), %rsi
movq %rax, %rdi
callq 0x42a0
leaq 0xe8(%rsp), %rdi
movq (%rdi), %rax
movq -0x18(%rax), %rax
movq 0xf8(%rsp,%rax), %rbx
leaq 0x310(%rsp), %rsi
movl $0x100, %edx            # imm = 0x100
callq 0x4740
movq 0xe8(%rsp), %rax
movq -0x18(%rax), %rax
cmpl $0x0, 0x108(%rsp,%rax)
jne 0x298c0
addq $-0x101, %rbx           # imm = 0xFEFF
cmpq $-0x101, %rbx           # imm = 0xFEFF
ja 0x298c0
movq 0x1d0(%rsp,%rax), %rdi
movq 0x10(%rdi), %rax
cmpq 0x18(%rdi), %rax
jae 0x29d39
movq 0x8(%rsp), %rax
leaq 0x50(%rax), %rsi
leaq 0xe8(%rsp), %rdi
callq 0x42a0
movq 0x8(%rsp), %rcx
leaq 0x58(%rcx), %rsi
movq %rax, %rdi
callq 0x42a0
movq 0x8(%rsp), %rcx
leaq 0x60(%rcx), %rsi
movq %rax, %rdi
callq 0x42a0
leaq 0xe8(%rsp), %rdi
movq (%rdi), %rax
movq -0x18(%rax), %rax
movq 0xf8(%rsp,%rax), %rbx
leaq 0x310(%rsp), %rsi
movl $0x100, %edx            # imm = 0x100
callq 0x4740
movq 0xe8(%rsp), %rax
movq -0x18(%rax), %rax
cmpl $0x0, 0x108(%rsp,%rax)
jne 0x2995d
addq $-0x101, %rbx           # imm = 0xFEFF
cmpq $-0x101, %rbx           # imm = 0xFEFF
ja 0x2995d
movq 0x1d0(%rsp,%rax), %rdi
movq 0x10(%rdi), %rax
cmpq 0x18(%rdi), %rax
jae 0x29d6f
movq 0x8(%rsp), %rax
leaq 0x68(%rax), %rsi
leaq 0xe8(%rsp), %rdi
callq 0x42a0
movq 0x8(%rsp), %rcx
leaq 0x70(%rcx), %rsi
movq %rax, %rdi
callq 0x42a0
movq 0x8(%rsp), %rcx
leaq 0x78(%rcx), %rsi
movq %rax, %rdi
callq 0x42a0
movq 0x8(%rsp), %rax
leaq 0x110(%rax), %rsi
leaq 0xe8(%rsp), %rdi
movq %rsi, 0x48(%rsp)
callq 0x4270
movq 0x8(%rsp), %rdi
callq 0x52330
movq 0x8(%rsp), %rbx
movsd 0x38(%rbx), %xmm0
movsd %xmm0, 0x8(%rbx)
movsd 0x58(%rbx), %xmm1
mulsd %xmm1, %xmm1
movsd 0x68(%rbx), %xmm0
movsd 0x70(%rbx), %xmm2
mulsd %xmm2, %xmm2
movapd %xmm0, %xmm3
mulsd %xmm0, %xmm3
addsd %xmm2, %xmm3
unpcklpd %xmm3, %xmm1            # xmm1 = xmm1[0],xmm3[0]
movsd 0x50(%rbx), %xmm2
movhpd 0x78(%rbx), %xmm2       # xmm2 = xmm2[0],mem[0]
mulpd %xmm2, %xmm2
addpd %xmm1, %xmm2
sqrtpd %xmm2, %xmm1
movupd %xmm1, 0x10(%rbx)
unpckhpd %xmm1, %xmm1            # xmm1 = xmm1[1,1]
divsd %xmm1, %xmm0
callq 0x4400
mulsd 0x1240dd(%rip), %xmm0   # 0x14db00
divsd 0x1240dd(%rip), %xmm0   # 0x14db08
movsd %xmm0, 0x28(%rbx)
movsd 0x50(%rbx), %xmm0
divsd 0x10(%rbx), %xmm0
callq 0x4400
movsd 0x1240b9(%rip), %xmm2   # 0x14db00
mulsd %xmm2, %xmm0
movsd 0x1240b5(%rip), %xmm3   # 0x14db08
divsd %xmm3, %xmm0
movsd %xmm0, 0x30(%rbx)
movsd 0x70(%rbx), %xmm1
divsd 0x18(%rbx), %xmm1
movsd %xmm1, 0x40(%rsp)
mulsd %xmm3, %xmm0
divsd %xmm2, %xmm0
callq 0x4100
movsd %xmm0, 0x38(%rsp)
movsd 0x30(%rbx), %xmm0
mulsd 0x124084(%rip), %xmm0   # 0x14db10
callq 0x4800
movsd %xmm0, 0x30(%rsp)
movsd 0x124071(%rip), %xmm0   # 0x14db10
mulsd 0x28(%rbx), %xmm0
callq 0x4800
mulsd 0x30(%rsp), %xmm0
movsd 0x38(%rsp), %xmm1
mulsd 0x40(%rsp), %xmm1
addsd %xmm1, %xmm0
callq 0x4400
mulsd 0x12404c(%rip), %xmm0   # 0x14db18
movsd %xmm0, 0x20(%rbx)
cmpl $0x0, 0x110(%rbx)
jle 0x29c72
movq 0x8(%rsp), %rax
leaq 0x2f0(%rax), %rbx
xorl %r14d, %r14d
leaq 0x50(%rsp), %r12
movl %ebp, %eax
leaq 0x2f8(%rsp), %rbp
leaq 0x10(%rsp), %r13
movzbl %al, %r15d
movq %r12, %rdi
callq 0x51264
leaq 0xe8(%rsp), %rdi
leaq 0x90(%rsp), %rsi
callq 0x4560
movq %rax, %rdi
movq %r12, %rsi
callq 0x42a0
movq %rax, %rdi
leaq 0x58(%rsp), %rsi
callq 0x42a0
movq %rax, %rdi
leaq 0x60(%rsp), %rsi
callq 0x42a0
movsd 0x50(%rsp), %xmm0
movsd 0x58(%rsp), %xmm1
movsd 0x60(%rsp), %xmm2
movq %rbp, %rdi
movq 0x8(%rsp), %rsi
callq 0x52eec
movq %rbp, %rdi
xorl %esi, %esi
callq 0x83f9a
movsd (%rax), %xmm0
callq 0x839b6
movsd %xmm0, 0x68(%rsp)
movq %rbp, %rdi
movl $0x1, %esi
callq 0x83f9a
movsd (%rax), %xmm0
callq 0x839b6
movsd %xmm0, 0x70(%rsp)
movq %rbp, %rdi
movl $0x2, %esi
callq 0x83f9a
movsd (%rax), %xmm0
callq 0x839b6
movsd %xmm0, 0x78(%rsp)
leaq 0x20(%rsp), %rax
movq %rax, 0x10(%rsp)
movq 0x90(%rsp), %rsi
movq 0x98(%rsp), %rdx
addq %rsi, %rdx
movq %r13, %rdi
callq 0xf3ce
movq %r13, %rdi
movl %r15d, %esi
callq 0x21d5e
movsd %xmm0, 0x80(%rsp)
movq 0x10(%rsp), %rdi
leaq 0x20(%rsp), %rax
cmpq %rax, %rdi
je 0x29c0c
movq 0x20(%rsp), %rsi
incq %rsi
callq 0x4470
movq %rbx, %rdi
movq %r12, %rsi
callq 0xe9a8
movq 0xb0(%rsp), %rdi
leaq 0xc0(%rsp), %rax
cmpq %rax, %rdi
je 0x29c3c
movq 0xc0(%rsp), %rsi
incq %rsi
callq 0x4470
movq 0x90(%rsp), %rdi
leaq 0xa0(%rsp), %rax
cmpq %rax, %rdi
je 0x29c61
movq 0xa0(%rsp), %rsi
incq %rsi
callq 0x4470
incl %r14d
movq 0x48(%rsp), %rax
cmpl (%rax), %r14d
jl 0x29b05
leaq 0xe8(%rsp), %rdi
callq 0x4090
jmp 0x29ce0
movq (%rbx), %rax
movq -0x18(%rax), %rax
leaq (%rbx,%rax), %rdi
movl 0x20(%rbx,%rax), %esi
orl $0x1, %esi
callq 0x4710
movq 0x16b321(%rip), %rdi    # 0x194fc0
leaq 0x129978(%rip), %rsi    # 0x15361e
movl $0x1, %edx
callq 0x44e0
movq 0x16b309(%rip), %rdi    # 0x194fc0
leaq 0x123ef5(%rip), %rsi    # 0x14dbb3
movl $0xb, %edx
callq 0x44e0
movq 0x16b2f1(%rip), %rdi    # 0x194fc0
leaq 0x129948(%rip), %rsi    # 0x15361e
movl $0x1, %edx
callq 0x44e0
leaq 0xe8(%rsp), %rdi
callq 0x4110
movb 0x7(%rsp), %al
addq $0x418, %rsp            # imm = 0x418
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq (%rdi), %rax
callq *0x48(%rax)
cmpl $-0x1, %eax
jne 0x29823
movq 0xe8(%rsp), %rax
movq -0x18(%rax), %rax
leaq (%rsp,%rax), %rdi
addq $0xe8, %rdi
movl 0x20(%rdi), %esi
orl $0x2, %esi
callq 0x4710
jmp 0x29823
movq (%rdi), %rax
callq *0x48(%rax)
cmpl $-0x1, %eax
jne 0x298c0
movq 0xe8(%rsp), %rax
movq -0x18(%rax), %rax
leaq (%rsp,%rax), %rdi
addq $0xe8, %rdi
movl 0x20(%rdi), %esi
orl $0x2, %esi
callq 0x4710
jmp 0x298c0
movq (%rdi), %rax
callq *0x48(%rax)
cmpl $-0x1, %eax
jne 0x2995d
movq 0xe8(%rsp), %rax
movq -0x18(%rax), %rax
leaq (%rsp,%rax), %rdi
addq $0xe8, %rdi
movl 0x20(%rdi), %esi
orl $0x2, %esi
callq 0x4710
jmp 0x2995d
jmp 0x29dc8
movq %rax, %rbx
movq 0x10(%rsp), %rdi
leaq 0x20(%rsp), %rax
cmpq %rax, %rdi
je 0x29dd2
movq 0x20(%rsp), %rsi
incq %rsi
callq 0x4470
jmp 0x29dd2
movq %rax, %rbx
jmp 0x29ddc
jmp 0x29dcf
movq %rax, %rbx
leaq 0x50(%rsp), %rdi
callq 0x2f5e8
leaq 0xe8(%rsp), %rdi
callq 0x4110
movq %rbx, %rdi
callq 0x4780