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

    //For each corner in abc, get the coords in xyz
    vector<Point> corners; Point p;
    p = cell->abc_to_xyz(0, 0, 0); corners.push_back(p);
    p = cell->abc_to_xyz(0, 0, 1); corners.push_back(p);
    p = cell->abc_to_xyz(0, 1, 0); corners.push_back(p);
    p = cell->abc_to_xyz(0, 1, 1); corners.push_back(p);
    p = cell->abc_to_xyz(1, 0, 0); corners.push_back(p);
    p = cell->abc_to_xyz(1, 0, 1); corners.push_back(p);
    p = cell->abc_to_xyz(1, 1, 0); corners.push_back(p);
    p = cell->abc_to_xyz(1, 1, 1); corners.push_back(p);
    // Write header, information about the cell, and footer
    output << "# vtk DataFile Version 2.0\nvtk format representation of unit cell boundary\nASCII\nDATASET POLYDATA\nPOINTS 8 double\n";
    for(int i=0; i<8; i++) output << corners.at(i)[0] << " " << corners.at(i)[1] << " " << corners.at(i)[2] << "\n";
    output << "LINES 12 36\n2 0 1\n2 0 2\n2 1 3\n2 2 3\n2 4 5\n2 4 6\n2 5 7\n2 6 7\n2 0 4\n2 1 5\n2 2 6\n2 3 7\n";
  }
  output.close();
  return true;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x278, %rsp            # imm = 0x278
movq %rsi, %r14
movq %rdi, %r15
leaq 0x68(%rsp), %rbx
movq %rbx, %rdi
callq 0x4520
movq %rbx, %rdi
movq %r15, %rsi
movl $0x10, %edx
callq 0x43d0
leaq 0xe8(%rsp), %rdi
callq 0x4120
movl %eax, %ebx
testb %al, %al
je 0x2e808
movq 0x1687ed(%rip), %r12    # 0x196fc0
leaq 0x121ef3(%rip), %rsi    # 0x1506cd
movl $0x21, %edx
movq %r12, %rdi
callq 0x44e0
testq %r15, %r15
je 0x2e84b
movq %r15, %rdi
callq 0x41e0
movq 0x1687c5(%rip), %rdi    # 0x196fc0
movq %r15, %rsi
movq %rax, %rdx
callq 0x44e0
jmp 0x2e864
movq 0x1687e1(%rip), %r14    # 0x196ff0
leaq 0x121e8f(%rip), %rsi    # 0x1506a5
movl $0x27, %edx
movq %r14, %rdi
callq 0x44e0
testq %r15, %r15
je 0x2e8ef
movq %r15, %rdi
callq 0x41e0
movq 0x1687b5(%rip), %rdi    # 0x196ff0
movq %r15, %rsi
movq %rax, %rdx
callq 0x44e0
jmp 0x2e907
movq (%r12), %rax
movq -0x18(%rax), %rax
leaq (%r12,%rax), %rdi
movl 0x20(%r12,%rax), %esi
orl $0x1, %esi
callq 0x4710
movq 0x168755(%rip), %rdi    # 0x196fc0
leaq 0x126cbc(%rip), %rsi    # 0x15552e
movl $0x1, %edx
callq 0x44e0
xorps %xmm0, %xmm0
movaps %xmm0, 0x10(%rsp)
movq $0x0, 0x20(%rsp)
leaq 0x30(%rsp), %rdi
xorps %xmm0, %xmm0
xorps %xmm1, %xmm1
xorps %xmm2, %xmm2
callq 0x85436
leaq 0x50(%rsp), %rdi
xorps %xmm0, %xmm0
xorps %xmm1, %xmm1
xorps %xmm2, %xmm2
movq %r14, %rsi
callq 0x53092
movq 0x60(%rsp), %rax
movq %rax, 0x40(%rsp)
movups 0x50(%rsp), %xmm0
movaps %xmm0, 0x30(%rsp)
movq 0x18(%rsp), %rsi
cmpq 0x20(%rsp), %rsi
je 0x2e937
movq 0x40(%rsp), %rax
movq %rax, 0x10(%rsi)
movaps 0x30(%rsp), %xmm0
movups %xmm0, (%rsi)
addq $0x18, 0x18(%rsp)
jmp 0x2e946
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 0x1686cb(%rip), %rdi    # 0x196ff0
callq 0x4040
movq %rax, %rdi
callq 0x42c0
jmp 0x2ed58
leaq 0x10(%rsp), %rdi
leaq 0x30(%rsp), %rdx
callq 0x3012c
leaq 0x50(%rsp), %rdi
movsd 0x120705(%rip), %xmm2   # 0x14f058
xorps %xmm0, %xmm0
xorps %xmm1, %xmm1
movq %r14, %rsi
callq 0x53092
movq 0x60(%rsp), %rax
movq %rax, 0x40(%rsp)
movups 0x50(%rsp), %xmm0
movaps %xmm0, 0x30(%rsp)
movq 0x18(%rsp), %rsi
cmpq 0x20(%rsp), %rsi
je 0x2e99a
movq 0x40(%rsp), %rax
movq %rax, 0x10(%rsi)
movaps 0x30(%rsp), %xmm0
movups %xmm0, (%rsi)
addq $0x18, 0x18(%rsp)
jmp 0x2e9a9
leaq 0x10(%rsp), %rdi
leaq 0x30(%rsp), %rdx
callq 0x3012c
leaq 0x50(%rsp), %rdi
movsd 0x1206a2(%rip), %xmm1   # 0x14f058
xorps %xmm0, %xmm0
xorps %xmm2, %xmm2
movq %r14, %rsi
callq 0x53092
movq 0x60(%rsp), %rax
movq %rax, 0x40(%rsp)
movups 0x50(%rsp), %xmm0
movaps %xmm0, 0x30(%rsp)
movq 0x18(%rsp), %rsi
cmpq 0x20(%rsp), %rsi
je 0x2e9fd
movq 0x40(%rsp), %rax
movq %rax, 0x10(%rsi)
movaps 0x30(%rsp), %xmm0
movups %xmm0, (%rsi)
addq $0x18, 0x18(%rsp)
jmp 0x2ea0c
leaq 0x10(%rsp), %rdi
leaq 0x30(%rsp), %rdx
callq 0x3012c
leaq 0x50(%rsp), %rdi
movsd 0x12063f(%rip), %xmm1   # 0x14f058
xorps %xmm0, %xmm0
movq %r14, %rsi
movaps %xmm1, %xmm2
callq 0x53092
movq 0x60(%rsp), %rax
movq %rax, 0x40(%rsp)
movups 0x50(%rsp), %xmm0
movaps %xmm0, 0x30(%rsp)
movq 0x18(%rsp), %rsi
cmpq 0x20(%rsp), %rsi
je 0x2ea60
movq 0x40(%rsp), %rax
movq %rax, 0x10(%rsi)
movaps 0x30(%rsp), %xmm0
movups %xmm0, (%rsi)
addq $0x18, 0x18(%rsp)
jmp 0x2ea6f
leaq 0x10(%rsp), %rdi
leaq 0x30(%rsp), %rdx
callq 0x3012c
leaq 0x50(%rsp), %rdi
movsd 0x1205dc(%rip), %xmm0   # 0x14f058
xorps %xmm1, %xmm1
xorps %xmm2, %xmm2
movq %r14, %rsi
callq 0x53092
movq 0x60(%rsp), %rax
movq %rax, 0x40(%rsp)
movups 0x50(%rsp), %xmm0
movaps %xmm0, 0x30(%rsp)
movq 0x18(%rsp), %rsi
cmpq 0x20(%rsp), %rsi
je 0x2eac3
movq 0x40(%rsp), %rax
movq %rax, 0x10(%rsi)
movaps 0x30(%rsp), %xmm0
movups %xmm0, (%rsi)
addq $0x18, 0x18(%rsp)
jmp 0x2ead2
leaq 0x10(%rsp), %rdi
leaq 0x30(%rsp), %rdx
callq 0x3012c
leaq 0x50(%rsp), %rdi
movsd 0x120579(%rip), %xmm0   # 0x14f058
xorps %xmm1, %xmm1
movq %r14, %rsi
movaps %xmm0, %xmm2
callq 0x53092
movq 0x60(%rsp), %rax
movq %rax, 0x40(%rsp)
movups 0x50(%rsp), %xmm0
movaps %xmm0, 0x30(%rsp)
movq 0x18(%rsp), %rsi
cmpq 0x20(%rsp), %rsi
je 0x2eb26
movq 0x40(%rsp), %rax
movq %rax, 0x10(%rsi)
movaps 0x30(%rsp), %xmm0
movups %xmm0, (%rsi)
addq $0x18, 0x18(%rsp)
jmp 0x2eb35
leaq 0x10(%rsp), %rdi
leaq 0x30(%rsp), %rdx
callq 0x3012c
leaq 0x50(%rsp), %rdi
movsd 0x120516(%rip), %xmm0   # 0x14f058
xorps %xmm2, %xmm2
movq %r14, %rsi
movaps %xmm0, %xmm1
callq 0x53092
movq 0x60(%rsp), %rax
movq %rax, 0x40(%rsp)
movups 0x50(%rsp), %xmm0
movaps %xmm0, 0x30(%rsp)
movq 0x18(%rsp), %rsi
cmpq 0x20(%rsp), %rsi
je 0x2eb89
movq 0x40(%rsp), %rax
movq %rax, 0x10(%rsi)
movaps 0x30(%rsp), %xmm0
movups %xmm0, (%rsi)
addq $0x18, 0x18(%rsp)
jmp 0x2eb98
leaq 0x10(%rsp), %rdi
leaq 0x30(%rsp), %rdx
callq 0x3012c
leaq 0x50(%rsp), %rdi
movsd 0x1204b3(%rip), %xmm0   # 0x14f058
movq %r14, %rsi
movaps %xmm0, %xmm1
movaps %xmm0, %xmm2
callq 0x53092
movq 0x60(%rsp), %rax
movq %rax, 0x40(%rsp)
movups 0x50(%rsp), %xmm0
movaps %xmm0, 0x30(%rsp)
movq 0x18(%rsp), %rsi
cmpq 0x20(%rsp), %rsi
je 0x2ebec
movq 0x40(%rsp), %rax
movq %rax, 0x10(%rsi)
movaps 0x30(%rsp), %xmm0
movups %xmm0, (%rsi)
addq $0x18, 0x18(%rsp)
jmp 0x2ebfb
leaq 0x10(%rsp), %rdi
leaq 0x30(%rsp), %rdx
callq 0x3012c
leaq 0x78(%rsp), %rdi
leaq 0x121ae8(%rip), %rsi    # 0x1506ef
movl $0x72, %edx
callq 0x44e0
movb %bl, 0xf(%rsp)
xorl %ebx, %ebx
movabsq $-0x5555555555555555, %r14 # imm = 0xAAAAAAAAAAAAAAAB
leaq 0x12885e(%rip), %r12    # 0x157486
leaq 0x1268ff(%rip), %r13    # 0x15552e
xorl %r15d, %r15d
movq 0x10(%rsp), %rdi
movq 0x18(%rsp), %rdx
subq %rdi, %rdx
sarq $0x3, %rdx
imulq %r14, %rdx
cmpq %r15, %rdx
jbe 0x2ed76
addq %rbx, %rdi
xorl %esi, %esi
callq 0x85478
movsd (%rax), %xmm0
leaq 0x78(%rsp), %rdi
callq 0x46b0
movq %rax, %rbp
movl $0x1, %edx
movq %rax, %rdi
movq %r12, %rsi
callq 0x44e0
movq 0x10(%rsp), %rdi
movq 0x18(%rsp), %rdx
subq %rdi, %rdx
sarq $0x3, %rdx
imulq %r14, %rdx
cmpq %r15, %rdx
jbe 0x2ed76
addq %rbx, %rdi
movl $0x1, %esi
callq 0x85478
movsd (%rax), %xmm0
movq %rbp, %rdi
callq 0x46b0
movq %rax, %rbp
movl $0x1, %edx
movq %rax, %rdi
movq %r12, %rsi
callq 0x44e0
movq 0x10(%rsp), %rdi
movq 0x18(%rsp), %rdx
subq %rdi, %rdx
sarq $0x3, %rdx
imulq %r14, %rdx
cmpq %r15, %rdx
jbe 0x2ed76
addq %rbx, %rdi
movl $0x2, %esi
callq 0x85478
movsd (%rax), %xmm0
movq %rbp, %rdi
callq 0x46b0
movl $0x1, %edx
movq %rax, %rdi
movq %r13, %rsi
callq 0x44e0
incq %r15
addq $0x18, %rbx
cmpq $0x8, %r15
jne 0x2ec32
leaq 0x121a3e(%rip), %rsi    # 0x150762
movl $0x54, %edx
leaq 0x78(%rsp), %rdi
callq 0x44e0
movb 0xf(%rsp), %bl
movq 0x10(%rsp), %rdi
testq %rdi, %rdi
je 0x2ed4e
movq 0x20(%rsp), %rsi
subq %rdi, %rsi
callq 0x4470
leaq 0x68(%rsp), %rdi
callq 0x4090
leaq 0x68(%rsp), %rdi
callq 0x4110
movl %ebx, %eax
addq $0x278, %rsp            # imm = 0x278
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
leaq 0x120928(%rip), %rdi    # 0x14f6a5
movq %r15, %rsi
xorl %eax, %eax
callq 0x4630
jmp 0x2eda0
jmp 0x2eda0
jmp 0x2eda0
jmp 0x2eda0
jmp 0x2eda0
jmp 0x2eda0
jmp 0x2eda0
jmp 0x2eda0
jmp 0x2eda0
movq %rax, %rbx
jmp 0x2edba
jmp 0x2eda0
movq %rax, %rbx
movq 0x10(%rsp), %rdi
testq %rdi, %rdi
je 0x2edba
movq 0x20(%rsp), %rsi
subq %rdi, %rsi
callq 0x4470
leaq 0x68(%rsp), %rdi
callq 0x4110
movq %rbx, %rdi
callq 0x4780