// File: /workspace/github_cpp_makefile_star2_O1/Luthaf[P]zeopp/networkio.cc
// Function: writeToV1(char*, ATOM_NETWORK*)
bool writeToV1(char * filename, ATOM_NETWORK *cell){
  fstream output;
  output.open(filename, fstream::out);
  if(!output.is_open()){
    cerr << "Error: Failed to open .v1 output file " << filename << endl;
    //cerr << "Exiting ..." << "\n";
    //exit(1);
    return false;
  }
  else{
    cout << "Writing atom network information to " << filename << "\n";

    // Write information about the unit cell
    output << "Unit cell vectors:" << "\n";
    output.precision(8);
    output << "va= " << cell->v_a.x << " " << cell->v_a.y << " " << cell->v_a.z << "\n";
    output << "vb= " << cell->v_b.x << " " << cell->v_b.y << " " << cell->v_b.z << "\n";
    output << "vc= " << cell->v_c.x << " " << cell->v_c.y << " " << cell->v_c.z << "\n";
    output << cell->numAtoms << "\n";

    // Write information about each atom
    vector <ATOM> ::iterator iter = cell->atoms.begin();
    while(iter != cell->atoms.end()){
      output << iter->type << " " << iter->x << " " << iter->y << " " << iter->z << "\n";
      iter++;
    }
  }
  output.close();
  return true;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x218, %rsp            # imm = 0x218
movq %rsi, %r14
movq %rdi, %r15
leaq 0x8(%rsp), %rbx
movq %rbx, %rdi
callq 0x4520
movq %rbx, %rdi
movq %r15, %rsi
movl $0x10, %edx
callq 0x43d0
leaq 0x88(%rsp), %rdi
callq 0x4120
movl %eax, %ebx
testb %al, %al
je 0x2c555
movq 0x16aaa0(%rip), %r12    # 0x196fc0
leaq 0x123e33(%rip), %rsi    # 0x15035a
movl $0x24, %edx
movq %r12, %rdi
callq 0x44e0
testq %r15, %r15
je 0x2c598
movq %r15, %rdi
callq 0x41e0
movq 0x16aa78(%rip), %rdi    # 0x196fc0
movq %r15, %rsi
movq %rax, %rdx
callq 0x44e0
jmp 0x2c5b1
movq 0x16aa94(%rip), %r14    # 0x196ff0
leaq 0x12405d(%rip), %rsi    # 0x1505c0
movl $0x26, %edx
movq %r14, %rdi
callq 0x44e0
testq %r15, %r15
je 0x2c874
movq %r15, %rdi
callq 0x41e0
movq 0x16aa68(%rip), %rdi    # 0x196ff0
movq %r15, %rsi
movq %rax, %rdx
callq 0x44e0
jmp 0x2c88c
movq (%r12), %rax
movq -0x18(%rax), %rax
leaq (%r12,%rax), %rdi
movl 0x20(%r12,%rax), %esi
orl $0x1, %esi
callq 0x4710
movq 0x16aa08(%rip), %rdi    # 0x196fc0
leaq 0x128f6f(%rip), %rsi    # 0x15552e
movl $0x1, %edx
callq 0x44e0
leaq 0x18(%rsp), %r15
leaq 0x124012(%rip), %rsi    # 0x1505e7
movl $0x12, %edx
movq %r15, %rdi
callq 0x44e0
leaq 0x128f45(%rip), %rsi    # 0x15552e
movl $0x1, %edx
movq %r15, %rdi
callq 0x44e0
movq 0x8(%rsp), %rax
movq -0x18(%rax), %rax
movq $0x8, 0x10(%rsp,%rax)
leaq 0x123feb(%rip), %rsi    # 0x1505fa
movl $0x4, %edx
movq %r15, %rdi
callq 0x44e0
movsd 0x38(%r14), %xmm0
movq %r15, %rdi
callq 0x46b0
movq %rax, %r12
leaq 0x12ae52(%rip), %rsi    # 0x157486
movl $0x1, %edx
movq %rax, %rdi
callq 0x44e0
movsd 0x40(%r14), %xmm0
movq %r12, %rdi
callq 0x46b0
movq %rax, %r12
leaq 0x12ae2d(%rip), %rsi    # 0x157486
movl $0x1, %edx
movq %rax, %rdi
callq 0x44e0
movsd 0x48(%r14), %xmm0
movq %r12, %rdi
callq 0x46b0
leaq 0x128eb3(%rip), %rsi    # 0x15552e
movl $0x1, %edx
movq %rax, %rdi
callq 0x44e0
leaq 0x123f70(%rip), %rsi    # 0x1505ff
movl $0x4, %edx
movq %r15, %rdi
callq 0x44e0
movsd 0x50(%r14), %xmm0
movq %r15, %rdi
callq 0x46b0
movq %rax, %r12
leaq 0x12add2(%rip), %rsi    # 0x157486
movl $0x1, %edx
movq %rax, %rdi
callq 0x44e0
movsd 0x58(%r14), %xmm0
movq %r12, %rdi
callq 0x46b0
movq %rax, %r12
leaq 0x12adad(%rip), %rsi    # 0x157486
movl $0x1, %edx
movq %rax, %rdi
callq 0x44e0
movsd 0x60(%r14), %xmm0
movq %r12, %rdi
callq 0x46b0
leaq 0x128e33(%rip), %rsi    # 0x15552e
movl $0x1, %edx
movq %rax, %rdi
callq 0x44e0
leaq 0x123ef5(%rip), %rsi    # 0x150604
movl $0x4, %edx
movq %r15, %rdi
callq 0x44e0
movsd 0x68(%r14), %xmm0
movq %r15, %rdi
callq 0x46b0
movq %rax, %r12
leaq 0x12ad52(%rip), %rsi    # 0x157486
movl $0x1, %edx
movq %rax, %rdi
callq 0x44e0
movsd 0x70(%r14), %xmm0
movq %r12, %rdi
callq 0x46b0
movq %rax, %r12
leaq 0x12ad2d(%rip), %rsi    # 0x157486
movl $0x1, %edx
movq %rax, %rdi
callq 0x44e0
movsd 0x78(%r14), %xmm0
movq %r12, %rdi
callq 0x46b0
leaq 0x128db3(%rip), %rsi    # 0x15552e
movl $0x1, %edx
movq %rax, %rdi
callq 0x44e0
movl 0x110(%r14), %esi
movq %r15, %rdi
callq 0x4750
leaq 0x128d90(%rip), %rsi    # 0x15552e
movl $0x1, %edx
movq %rax, %rdi
callq 0x44e0
movb %bl, 0x7(%rsp)
movq 0x2f0(%r14), %rbx
cmpq 0x2f8(%r14), %rbx
je 0x2c864
leaq 0x12acbc(%rip), %r12    # 0x157486
leaq 0x128d5d(%rip), %r13    # 0x15552e
movq 0x40(%rbx), %rsi
movq 0x48(%rbx), %rdx
movq %r15, %rdi
callq 0x44e0
movq %rax, %rbp
movl $0x1, %edx
movq %rax, %rdi
movq %r12, %rsi
callq 0x44e0
movsd (%rbx), %xmm0
movq %rbp, %rdi
callq 0x46b0
movq %rax, %rbp
movl $0x1, %edx
movq %rax, %rdi
movq %r12, %rsi
callq 0x44e0
movsd 0x8(%rbx), %xmm0
movq %rbp, %rdi
callq 0x46b0
movq %rax, %rbp
movl $0x1, %edx
movq %rax, %rdi
movq %r12, %rsi
callq 0x44e0
movsd 0x10(%rbx), %xmm0
movq %rbp, %rdi
callq 0x46b0
movl $0x1, %edx
movq %rax, %rdi
movq %r13, %rsi
callq 0x44e0
addq $0x98, %rbx
cmpq 0x2f8(%r14), %rbx
jne 0x2c7d1
leaq 0x8(%rsp), %rdi
callq 0x4090
movb 0x7(%rsp), %bl
jmp 0x2c8b7
movq (%r14), %rax
movq -0x18(%rax), %rax
leaq (%r14,%rax), %rdi
movl 0x20(%r14,%rax), %esi
orl $0x1, %esi
callq 0x4710
movq (%r14), %rax
addq -0x18(%rax), %r14
movq %r14, %rdi
movl $0xa, %esi
callq 0x4420
movsbl %al, %esi
movq 0x16a746(%rip), %rdi    # 0x196ff0
callq 0x4040
movq %rax, %rdi
callq 0x42c0
leaq 0x8(%rsp), %rdi
callq 0x4110
movl %ebx, %eax
addq $0x218, %rsp            # imm = 0x218
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
jmp 0x2c8d7
movq %rax, %rbx
leaq 0x8(%rsp), %rdi
callq 0x4110
movq %rbx, %rdi
callq 0x4780