// File: 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
movq %rsp, %rbp
subq $0x510, %rsp            # imm = 0x510
movb %dl, %al
movq %rdi, -0x10(%rbp)
movq %rsi, -0x18(%rbp)
andb $0x1, %al
movb %al, -0x19(%rbp)
leaq -0x230(%rbp), %rdi
callq 0x5660
movq -0x10(%rbp), %rax
movq %rax, -0x428(%rbp)
movl $0x8, %edi
movl $0x10, %esi
callq 0x47640
movl %eax, -0x41c(%rbp)
jmp 0x52f28
movl -0x41c(%rbp), %edx
movq -0x428(%rbp), %rsi
leaq -0x230(%rbp), %rdi
callq 0x54b0
jmp 0x52f43
leaq -0x230(%rbp), %rdi
callq 0x58b0
movb %al, -0x429(%rbp)
jmp 0x52f57
movb -0x429(%rbp), %al
testb $0x1, %al
jne 0x5300c
jmp 0x52f67
movq 0x220052(%rip), %rdi    # 0x272fc0
leaq 0x1a05b3(%rip), %rsi    # 0x1f3528
callq 0x5540
movq %rax, -0x438(%rbp)
jmp 0x52f83
movq -0x438(%rbp), %rdi
movq -0x10(%rbp), %rsi
callq 0x5540
movq %rax, -0x440(%rbp)
jmp 0x52f9c
movq -0x440(%rbp), %rdi
leaq 0x1a667b(%rip), %rsi    # 0x1f9625
callq 0x5540
jmp 0x52fb1
movq 0x220008(%rip), %rdi    # 0x272fc0
leaq 0x19fc44(%rip), %rsi    # 0x1f2c03
callq 0x5540
movq %rax, -0x448(%rbp)
jmp 0x52fcd
movq -0x448(%rbp), %rdi
leaq 0x1a664a(%rip), %rsi    # 0x1f9625
callq 0x5540
jmp 0x52fe2
movb $0x0, -0x1(%rbp)
movl $0x1, -0x348(%rbp)
jmp 0x53613
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x340(%rbp)
movl %eax, -0x344(%rbp)
jmp 0x5362d
movq 0x21ffad(%rip), %rdi    # 0x272fc0
leaq 0x1a017e(%rip), %rsi    # 0x1f3198
callq 0x5540
movq %rax, -0x450(%rbp)
jmp 0x53028
movq -0x450(%rbp), %rdi
movq -0x10(%rbp), %rsi
callq 0x5540
movq %rax, -0x458(%rbp)
jmp 0x53041
movq -0x458(%rbp), %rdi
leaq 0x1a65d6(%rip), %rsi    # 0x1f9625
callq 0x5540
jmp 0x53056
leaq -0x230(%rbp), %rdi
leaq -0x330(%rbp), %rsi
movl $0x100, %edx            # imm = 0x100
callq 0x51d0
jmp 0x53070
leaq -0x230(%rbp), %rdi
leaq -0x330(%rbp), %rsi
callq 0x59560
movq %rax, -0x460(%rbp)
jmp 0x5308c
movq -0x460(%rbp), %rdi
movq -0x18(%rbp), %rsi
addq $0x38, %rsi
callq 0x5420
movq %rax, -0x468(%rbp)
jmp 0x530a9
movq -0x468(%rbp), %rdi
movq -0x18(%rbp), %rsi
addq $0x40, %rsi
callq 0x5420
movq %rax, -0x470(%rbp)
jmp 0x530c6
movq -0x470(%rbp), %rdi
movq -0x18(%rbp), %rsi
addq $0x48, %rsi
callq 0x5420
jmp 0x530dc
leaq -0x230(%rbp), %rdi
leaq -0x330(%rbp), %rsi
callq 0x59560
movq %rax, -0x478(%rbp)
jmp 0x530f8
movq -0x478(%rbp), %rdi
movq -0x18(%rbp), %rsi
addq $0x50, %rsi
callq 0x5420
movq %rax, -0x480(%rbp)
jmp 0x53115
movq -0x480(%rbp), %rdi
movq -0x18(%rbp), %rsi
addq $0x58, %rsi
callq 0x5420
movq %rax, -0x488(%rbp)
jmp 0x53132
movq -0x488(%rbp), %rdi
movq -0x18(%rbp), %rsi
addq $0x60, %rsi
callq 0x5420
jmp 0x53148
leaq -0x230(%rbp), %rdi
leaq -0x330(%rbp), %rsi
callq 0x59560
movq %rax, -0x490(%rbp)
jmp 0x53164
movq -0x490(%rbp), %rdi
movq -0x18(%rbp), %rsi
addq $0x68, %rsi
callq 0x5420
movq %rax, -0x498(%rbp)
jmp 0x53181
movq -0x498(%rbp), %rdi
movq -0x18(%rbp), %rsi
addq $0x70, %rsi
callq 0x5420
movq %rax, -0x4a0(%rbp)
jmp 0x5319e
movq -0x4a0(%rbp), %rdi
movq -0x18(%rbp), %rsi
addq $0x78, %rsi
callq 0x5420
jmp 0x531b4
movq -0x18(%rbp), %rsi
addq $0x110, %rsi            # imm = 0x110
leaq -0x230(%rbp), %rdi
callq 0x52f0
jmp 0x531cd
movq -0x18(%rbp), %rdi
callq 0x966b0
jmp 0x531d8
movq -0x18(%rbp), %rax
movsd 0x38(%rax), %xmm0
movq -0x18(%rbp), %rax
movsd %xmm0, 0x8(%rax)
movq -0x18(%rbp), %rax
movsd 0x50(%rax), %xmm0
movq -0x18(%rbp), %rax
movsd 0x50(%rax), %xmm2
movq -0x18(%rbp), %rax
movsd 0x58(%rax), %xmm1
movq -0x18(%rbp), %rax
mulsd 0x58(%rax), %xmm1
mulsd %xmm2, %xmm0
addsd %xmm1, %xmm0
callq 0x53f0
movq -0x18(%rbp), %rax
movsd %xmm0, 0x10(%rax)
movq -0x18(%rbp), %rax
movsd 0x68(%rax), %xmm1
movq -0x18(%rbp), %rax
movsd 0x68(%rax), %xmm2
movq -0x18(%rbp), %rax
movsd 0x70(%rax), %xmm0
movq -0x18(%rbp), %rax
mulsd 0x70(%rax), %xmm0
mulsd %xmm2, %xmm1
addsd %xmm0, %xmm1
movq -0x18(%rbp), %rax
movsd 0x78(%rax), %xmm0
movq -0x18(%rbp), %rax
movsd 0x78(%rax), %xmm2
mulsd %xmm2, %xmm0
addsd %xmm1, %xmm0
callq 0x53f0
movq -0x18(%rbp), %rax
movsd %xmm0, 0x18(%rax)
movq -0x18(%rbp), %rax
movsd 0x68(%rax), %xmm0
movq -0x18(%rbp), %rax
divsd 0x18(%rax), %xmm0
callq 0x54f0
movsd 0x19f801(%rip), %xmm1   # 0x1f2a98
mulsd %xmm1, %xmm0
movsd 0x19f7fd(%rip), %xmm1   # 0x1f2aa0
divsd %xmm1, %xmm0
movq -0x18(%rbp), %rax
movsd %xmm0, 0x28(%rax)
movq -0x18(%rbp), %rax
movsd 0x50(%rax), %xmm0
movq -0x18(%rbp), %rax
divsd 0x10(%rax), %xmm0
callq 0x54f0
movsd 0x19f7c9(%rip), %xmm1   # 0x1f2a98
mulsd %xmm1, %xmm0
movsd 0x19f7c5(%rip), %xmm1   # 0x1f2aa0
divsd %xmm1, %xmm0
movq -0x18(%rbp), %rax
movsd %xmm0, 0x30(%rax)
movq -0x18(%rbp), %rax
movsd 0x70(%rax), %xmm0
movq -0x18(%rbp), %rax
divsd 0x18(%rax), %xmm0
movsd %xmm0, -0x4a8(%rbp)
movq -0x18(%rbp), %rax
movsd 0x19f792(%rip), %xmm0   # 0x1f2aa0
mulsd 0x30(%rax), %xmm0
movsd 0x19f77d(%rip), %xmm1   # 0x1f2a98
divsd %xmm1, %xmm0
callq 0x5140
movsd %xmm0, -0x4b0(%rbp)
movq -0x18(%rbp), %rax
movsd 0x19f778(%rip), %xmm0   # 0x1f2ab0
mulsd 0x30(%rax), %xmm0
callq 0x5970
movsd %xmm0, -0x4b8(%rbp)
movq -0x18(%rbp), %rax
movsd 0x19f75a(%rip), %xmm0   # 0x1f2ab0
mulsd 0x28(%rax), %xmm0
callq 0x5970
movsd -0x4b8(%rbp), %xmm1
movsd -0x4b0(%rbp), %xmm2
movaps %xmm0, %xmm3
movsd -0x4a8(%rbp), %xmm0
mulsd %xmm3, %xmm1
mulsd %xmm2, %xmm0
addsd %xmm1, %xmm0
callq 0x54f0
movaps %xmm0, %xmm1
movsd 0x19f711(%rip), %xmm0   # 0x1f2aa8
mulsd %xmm1, %xmm0
movq -0x18(%rbp), %rax
movsd %xmm0, 0x20(%rax)
movl $0x0, -0x334(%rbp)
movl -0x334(%rbp), %eax
movq -0x18(%rbp), %rcx
cmpl 0x110(%rcx), %eax
jge 0x535f5
leaq -0x3e0(%rbp), %rdi
callq 0x954b0
jmp 0x533d2
leaq -0x3a0(%rbp), %rsi
leaq -0x230(%rbp), %rdi
callq 0x56a0
movq %rax, -0x4c0(%rbp)
jmp 0x533ee
movq -0x4c0(%rbp), %rdi
leaq -0x3e0(%rbp), %rsi
callq 0x5420
movq %rax, -0x4c8(%rbp)
jmp 0x5340a
movq -0x4c8(%rbp), %rdi
leaq -0x3d8(%rbp), %rsi
callq 0x5420
movq %rax, -0x4d0(%rbp)
jmp 0x53426
movq -0x4d0(%rbp), %rdi
leaq -0x3d0(%rbp), %rsi
callq 0x5420
jmp 0x5343b
movq -0x18(%rbp), %rsi
movsd -0x3e0(%rbp), %xmm0
movsd -0x3d8(%rbp), %xmm1
movsd -0x3d0(%rbp), %xmm2
leaq -0x3f8(%rbp), %rdi
callq 0x97360
jmp 0x53465
leaq -0x3f8(%rbp), %rdi
xorl %esi, %esi
callq 0xe9d70
movq %rax, -0x4d8(%rbp)
jmp 0x5347c
movq -0x4d8(%rbp), %rax
movsd (%rax), %xmm0
callq 0xe9290
movsd %xmm0, -0x4e0(%rbp)
jmp 0x53496
movsd -0x4e0(%rbp), %xmm0
movsd %xmm0, -0x3c8(%rbp)
leaq -0x3f8(%rbp), %rdi
movl $0x1, %esi
callq 0xe9d70
movq %rax, -0x4e8(%rbp)
jmp 0x534c0
movq -0x4e8(%rbp), %rax
movsd (%rax), %xmm0
callq 0xe9290
movsd %xmm0, -0x4f0(%rbp)
jmp 0x534da
movsd -0x4f0(%rbp), %xmm0
movsd %xmm0, -0x3c0(%rbp)
leaq -0x3f8(%rbp), %rdi
movl $0x2, %esi
callq 0xe9d70
movq %rax, -0x4f8(%rbp)
jmp 0x53504
movq -0x4f8(%rbp), %rax
movsd (%rax), %xmm0
callq 0xe9290
movsd %xmm0, -0x500(%rbp)
jmp 0x5351e
movsd -0x500(%rbp), %xmm0
movsd %xmm0, -0x3b8(%rbp)
leaq -0x3a0(%rbp), %rsi
leaq -0x418(%rbp), %rdi
callq 0x5220
jmp 0x53543
movzbl -0x19(%rbp), %esi
andl $0x1, %esi
leaq -0x418(%rbp), %rdi
callq 0x466e0
movsd %xmm0, -0x508(%rbp)
jmp 0x53560
movsd -0x508(%rbp), %xmm0
movsd %xmm0, -0x3b0(%rbp)
leaq -0x418(%rbp), %rdi
callq 0x5300
movq -0x18(%rbp), %rdi
addq $0x2f0, %rdi            # imm = 0x2F0
leaq -0x3e0(%rbp), %rsi
callq 0xf190
jmp 0x53595
leaq -0x3e0(%rbp), %rdi
callq 0xf200
movl -0x334(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x334(%rbp)
jmp 0x533ae
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x340(%rbp)
movl %eax, -0x344(%rbp)
jmp 0x535e7
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x340(%rbp)
movl %eax, -0x344(%rbp)
leaq -0x418(%rbp), %rdi
callq 0x5300
leaq -0x3e0(%rbp), %rdi
callq 0xf200
jmp 0x5362d
leaq -0x230(%rbp), %rdi
callq 0x50a0
jmp 0x53603
jmp 0x53605
movb $0x1, -0x1(%rbp)
movl $0x1, -0x348(%rbp)
leaq -0x230(%rbp), %rdi
callq 0x5150
movb -0x1(%rbp), %al
andb $0x1, %al
addq $0x510, %rsp            # imm = 0x510
popq %rbp
retq
leaq -0x230(%rbp), %rdi
callq 0x5150
movq -0x340(%rbp), %rdi
callq 0x58f0
nopw %cs:(%rax,%rax)