// File: /workspace/github_cpp_makefile_star2_O3/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 0x2c354
movq 0x168ca1(%rip), %r12    # 0x194fc0
leaq 0x1220a4(%rip), %rsi    # 0x14e3ca
movl $0x24, %edx
movq %r12, %rdi
callq 0x44e0
testq %r15, %r15
je 0x2c397
movq %r15, %rdi
callq 0x41e0
movq 0x168c79(%rip), %rdi    # 0x194fc0
movq %r15, %rsi
movq %rax, %rdx
callq 0x44e0
jmp 0x2c3b0
movq 0x168c95(%rip), %r14    # 0x194ff0
leaq 0x1222ce(%rip), %rsi    # 0x14e630
movl $0x26, %edx
movq %r14, %rdi
callq 0x44e0
testq %r15, %r15
je 0x2c673
movq %r15, %rdi
callq 0x41e0
movq 0x168c69(%rip), %rdi    # 0x194ff0
movq %r15, %rsi
movq %rax, %rdx
callq 0x44e0
jmp 0x2c68b
movq (%r12), %rax
movq -0x18(%rax), %rax
leaq (%r12,%rax), %rdi
movl 0x20(%r12,%rax), %esi
orl $0x1, %esi
callq 0x4710
movq 0x168c09(%rip), %rdi    # 0x194fc0
leaq 0x127260(%rip), %rsi    # 0x15361e
movl $0x1, %edx
callq 0x44e0
leaq 0x18(%rsp), %r15
leaq 0x122283(%rip), %rsi    # 0x14e657
movl $0x12, %edx
movq %r15, %rdi
callq 0x44e0
leaq 0x127236(%rip), %rsi    # 0x15361e
movl $0x1, %edx
movq %r15, %rdi
callq 0x44e0
movq 0x8(%rsp), %rax
movq -0x18(%rax), %rax
movq $0x8, 0x10(%rsp,%rax)
leaq 0x12225c(%rip), %rsi    # 0x14e66a
movl $0x4, %edx
movq %r15, %rdi
callq 0x44e0
movsd 0x38(%r14), %xmm0
movq %r15, %rdi
callq 0x46b0
movq %rax, %r12
leaq 0x1291a3(%rip), %rsi    # 0x1555d6
movl $0x1, %edx
movq %rax, %rdi
callq 0x44e0
movsd 0x40(%r14), %xmm0
movq %r12, %rdi
callq 0x46b0
movq %rax, %r12
leaq 0x12917e(%rip), %rsi    # 0x1555d6
movl $0x1, %edx
movq %rax, %rdi
callq 0x44e0
movsd 0x48(%r14), %xmm0
movq %r12, %rdi
callq 0x46b0
leaq 0x1271a4(%rip), %rsi    # 0x15361e
movl $0x1, %edx
movq %rax, %rdi
callq 0x44e0
leaq 0x1221e1(%rip), %rsi    # 0x14e66f
movl $0x4, %edx
movq %r15, %rdi
callq 0x44e0
movsd 0x50(%r14), %xmm0
movq %r15, %rdi
callq 0x46b0
movq %rax, %r12
leaq 0x129123(%rip), %rsi    # 0x1555d6
movl $0x1, %edx
movq %rax, %rdi
callq 0x44e0
movsd 0x58(%r14), %xmm0
movq %r12, %rdi
callq 0x46b0
movq %rax, %r12
leaq 0x1290fe(%rip), %rsi    # 0x1555d6
movl $0x1, %edx
movq %rax, %rdi
callq 0x44e0
movsd 0x60(%r14), %xmm0
movq %r12, %rdi
callq 0x46b0
leaq 0x127124(%rip), %rsi    # 0x15361e
movl $0x1, %edx
movq %rax, %rdi
callq 0x44e0
leaq 0x122166(%rip), %rsi    # 0x14e674
movl $0x4, %edx
movq %r15, %rdi
callq 0x44e0
movsd 0x68(%r14), %xmm0
movq %r15, %rdi
callq 0x46b0
movq %rax, %r12
leaq 0x1290a3(%rip), %rsi    # 0x1555d6
movl $0x1, %edx
movq %rax, %rdi
callq 0x44e0
movsd 0x70(%r14), %xmm0
movq %r12, %rdi
callq 0x46b0
movq %rax, %r12
leaq 0x12907e(%rip), %rsi    # 0x1555d6
movl $0x1, %edx
movq %rax, %rdi
callq 0x44e0
movsd 0x78(%r14), %xmm0
movq %r12, %rdi
callq 0x46b0
leaq 0x1270a4(%rip), %rsi    # 0x15361e
movl $0x1, %edx
movq %rax, %rdi
callq 0x44e0
movl 0x110(%r14), %esi
movq %r15, %rdi
callq 0x4750
leaq 0x127081(%rip), %rsi    # 0x15361e
movl $0x1, %edx
movq %rax, %rdi
callq 0x44e0
movb %bl, 0x7(%rsp)
movq 0x2f0(%r14), %rbx
cmpq 0x2f8(%r14), %rbx
je 0x2c663
leaq 0x12900d(%rip), %r12    # 0x1555d6
leaq 0x12704e(%rip), %r13    # 0x15361e
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 0x2c5d0
leaq 0x8(%rsp), %rdi
callq 0x4090
movb 0x7(%rsp), %bl
jmp 0x2c6b6
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 0x168947(%rip), %rdi    # 0x194ff0
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 0x2c6d6
movq %rax, %rbx
leaq 0x8(%rsp), %rdi
callq 0x4110
movq %rbx, %rdi
callq 0x4780