// File: /workspace/github_cpp_makefile_star2_O2/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 0x4540
pushq $0x10
popq %rdx
movq %rbx, %rdi
movq %r15, %rsi
callq 0x4410
leaq 0x88(%rsp), %rdi
callq 0x4130
movl %eax, %ebx
testb %al, %al
je 0x22bcb
movq 0x12d630(%rip), %rdi    # 0x14ffc0
leaq 0xdaa33(%rip), %rsi     # 0xfd3ca
callq 0x4480
movq %rax, %rdi
movq %r15, %rsi
callq 0x4480
leaq 0xdfbd0(%rip), %rsi     # 0x10257e
movq %rax, %rdi
callq 0x4480
leaq 0x18(%rsp), %r15
leaq 0xdac95(%rip), %rsi     # 0xfd657
movq %r15, %rdi
callq 0x4480
leaq 0xdfbad(%rip), %rsi     # 0x10257e
movq %rax, %rdi
callq 0x4480
movq 0x8(%rsp), %rax
movq -0x18(%rax), %rax
movq $0x8, 0x10(%rsp,%rax)
leaq 0xdac78(%rip), %rsi     # 0xfd66a
movq %r15, %rdi
callq 0x4480
movsd 0x38(%r14), %xmm0
movq %rax, %rdi
callq 0x46c0
leaq 0xe1b03(%rip), %rsi     # 0x104512
movq %rax, %rdi
callq 0x4480
movsd 0x40(%r14), %xmm0
movq %rax, %rdi
callq 0x46c0
leaq 0xe1ae6(%rip), %rsi     # 0x104512
movq %rax, %rdi
callq 0x4480
movsd 0x48(%r14), %xmm0
movq %rax, %rdi
callq 0x46c0
leaq 0xdfb35(%rip), %rsi     # 0x10257e
movq %rax, %rdi
callq 0x4480
leaq 0xdac17(%rip), %rsi     # 0xfd66f
movq %r15, %rdi
callq 0x4480
movsd 0x50(%r14), %xmm0
movq %rax, %rdi
callq 0x46c0
leaq 0xe1a9d(%rip), %rsi     # 0x104512
movq %rax, %rdi
callq 0x4480
movsd 0x58(%r14), %xmm0
movq %rax, %rdi
callq 0x46c0
leaq 0xe1a80(%rip), %rsi     # 0x104512
movq %rax, %rdi
callq 0x4480
movsd 0x60(%r14), %xmm0
movq %rax, %rdi
callq 0x46c0
leaq 0xdfacf(%rip), %rsi     # 0x10257e
movq %rax, %rdi
callq 0x4480
leaq 0xdabb6(%rip), %rsi     # 0xfd674
movq %r15, %rdi
callq 0x4480
movsd 0x68(%r14), %xmm0
movq %rax, %rdi
callq 0x46c0
leaq 0xe1a37(%rip), %rsi     # 0x104512
movq %rax, %rdi
callq 0x4480
movsd 0x70(%r14), %xmm0
movq %rax, %rdi
callq 0x46c0
leaq 0xe1a1a(%rip), %rsi     # 0x104512
movq %rax, %rdi
callq 0x4480
movsd 0x78(%r14), %xmm0
movq %rax, %rdi
callq 0x46c0
leaq 0xdfa69(%rip), %rsi     # 0x10257e
movq %rax, %rdi
callq 0x4480
movl 0x110(%r14), %esi
movq %r15, %rdi
callq 0x4760
leaq 0xdfa4b(%rip), %rsi     # 0x10257e
movq %rax, %rdi
callq 0x4480
movq 0x2f0(%r14), %r12
leaq 0xe19c9(%rip), %r13     # 0x104512
leaq 0xdfa2e(%rip), %rbp     # 0x10257e
cmpq 0x2f8(%r14), %r12
je 0x22bf3
addq $0x40, %r12
movq %r15, %rdi
movq %r12, %rsi
callq 0x43f0
movq %rax, %rdi
movq %r13, %rsi
callq 0x4480
movsd -0x40(%r12), %xmm0
movq %rax, %rdi
callq 0x46c0
movq %rax, %rdi
movq %r13, %rsi
callq 0x4480
movsd -0x38(%r12), %xmm0
movq %rax, %rdi
callq 0x46c0
movq %rax, %rdi
movq %r13, %rsi
callq 0x4480
movsd -0x30(%r12), %xmm0
movq %rax, %rdi
callq 0x46c0
movq %rax, %rdi
movq %rbp, %rsi
callq 0x4480
addq $0x58, %r12
jmp 0x22b50
movq 0x12d41e(%rip), %rdi    # 0x14fff0
leaq 0xdaa57(%rip), %rsi     # 0xfd630
callq 0x4480
movq %rax, %rdi
movq %r15, %rsi
callq 0x4480
movq %rax, %rdi
callq 0x4230
jmp 0x22bfd
leaq 0x8(%rsp), %rdi
callq 0x4080
leaq 0x8(%rsp), %rdi
callq 0x4120
movl %ebx, %eax
addq $0x218, %rsp            # imm = 0x218
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
jmp 0x22c1d
movq %rax, %rbx
leaq 0x8(%rsp), %rdi
callq 0x4120
movq %rbx, %rdi
callq 0x4780