// File: /workspace/github_cpp_makefile_star2_O3/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 0x2e5db
movq 0x166a1a(%rip), %r12    # 0x194fc0
leaq 0x120190(%rip), %rsi    # 0x14e73d
movl $0x21, %edx
movq %r12, %rdi
callq 0x44e0
testq %r15, %r15
je 0x2e61e
movq %r15, %rdi
callq 0x41e0
movq 0x1669f2(%rip), %rdi    # 0x194fc0
movq %r15, %rsi
movq %rax, %rdx
callq 0x44e0
jmp 0x2e637
movq 0x166a0e(%rip), %r14    # 0x194ff0
leaq 0x12012c(%rip), %rsi    # 0x14e715
movl $0x27, %edx
movq %r14, %rdi
callq 0x44e0
testq %r15, %r15
je 0x2e6c2
movq %r15, %rdi
callq 0x41e0
movq 0x1669e2(%rip), %rdi    # 0x194ff0
movq %r15, %rsi
movq %rax, %rdx
callq 0x44e0
jmp 0x2e6da
movq (%r12), %rax
movq -0x18(%rax), %rax
leaq (%r12,%rax), %rdi
movl 0x20(%r12,%rax), %esi
orl $0x1, %esi
callq 0x4710
movq 0x166982(%rip), %rdi    # 0x194fc0
leaq 0x124fd9(%rip), %rsi    # 0x15361e
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 0x83f68
leaq 0x50(%rsp), %rdi
xorps %xmm0, %xmm0
xorps %xmm1, %xmm1
xorps %xmm2, %xmm2
movq %r14, %rsi
callq 0x52d94
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 0x2e70a
movq 0x40(%rsp), %rax
movq %rax, 0x10(%rsi)
movaps 0x30(%rsp), %xmm0
movups %xmm0, (%rsi)
addq $0x18, 0x18(%rsp)
jmp 0x2e719
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 0x1668f8(%rip), %rdi    # 0x194ff0
callq 0x4040
movq %rax, %rdi
callq 0x42c0
jmp 0x2eb2b
leaq 0x10(%rsp), %rdi
leaq 0x30(%rsp), %rdx
callq 0x2fec4
leaq 0x50(%rsp), %rdi
movsd 0x11e932(%rip), %xmm2   # 0x14d058
xorps %xmm0, %xmm0
xorps %xmm1, %xmm1
movq %r14, %rsi
callq 0x52d94
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 0x2e76d
movq 0x40(%rsp), %rax
movq %rax, 0x10(%rsi)
movaps 0x30(%rsp), %xmm0
movups %xmm0, (%rsi)
addq $0x18, 0x18(%rsp)
jmp 0x2e77c
leaq 0x10(%rsp), %rdi
leaq 0x30(%rsp), %rdx
callq 0x2fec4
leaq 0x50(%rsp), %rdi
movsd 0x11e8cf(%rip), %xmm1   # 0x14d058
xorps %xmm0, %xmm0
xorps %xmm2, %xmm2
movq %r14, %rsi
callq 0x52d94
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 0x2e7d0
movq 0x40(%rsp), %rax
movq %rax, 0x10(%rsi)
movaps 0x30(%rsp), %xmm0
movups %xmm0, (%rsi)
addq $0x18, 0x18(%rsp)
jmp 0x2e7df
leaq 0x10(%rsp), %rdi
leaq 0x30(%rsp), %rdx
callq 0x2fec4
leaq 0x50(%rsp), %rdi
movsd 0x11e86c(%rip), %xmm1   # 0x14d058
xorps %xmm0, %xmm0
movq %r14, %rsi
movaps %xmm1, %xmm2
callq 0x52d94
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 0x2e833
movq 0x40(%rsp), %rax
movq %rax, 0x10(%rsi)
movaps 0x30(%rsp), %xmm0
movups %xmm0, (%rsi)
addq $0x18, 0x18(%rsp)
jmp 0x2e842
leaq 0x10(%rsp), %rdi
leaq 0x30(%rsp), %rdx
callq 0x2fec4
leaq 0x50(%rsp), %rdi
movsd 0x11e809(%rip), %xmm0   # 0x14d058
xorps %xmm1, %xmm1
xorps %xmm2, %xmm2
movq %r14, %rsi
callq 0x52d94
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 0x2e896
movq 0x40(%rsp), %rax
movq %rax, 0x10(%rsi)
movaps 0x30(%rsp), %xmm0
movups %xmm0, (%rsi)
addq $0x18, 0x18(%rsp)
jmp 0x2e8a5
leaq 0x10(%rsp), %rdi
leaq 0x30(%rsp), %rdx
callq 0x2fec4
leaq 0x50(%rsp), %rdi
movsd 0x11e7a6(%rip), %xmm0   # 0x14d058
xorps %xmm1, %xmm1
movq %r14, %rsi
movaps %xmm0, %xmm2
callq 0x52d94
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 0x2e8f9
movq 0x40(%rsp), %rax
movq %rax, 0x10(%rsi)
movaps 0x30(%rsp), %xmm0
movups %xmm0, (%rsi)
addq $0x18, 0x18(%rsp)
jmp 0x2e908
leaq 0x10(%rsp), %rdi
leaq 0x30(%rsp), %rdx
callq 0x2fec4
leaq 0x50(%rsp), %rdi
movsd 0x11e743(%rip), %xmm0   # 0x14d058
xorps %xmm2, %xmm2
movq %r14, %rsi
movaps %xmm0, %xmm1
callq 0x52d94
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 0x2e95c
movq 0x40(%rsp), %rax
movq %rax, 0x10(%rsi)
movaps 0x30(%rsp), %xmm0
movups %xmm0, (%rsi)
addq $0x18, 0x18(%rsp)
jmp 0x2e96b
leaq 0x10(%rsp), %rdi
leaq 0x30(%rsp), %rdx
callq 0x2fec4
leaq 0x50(%rsp), %rdi
movsd 0x11e6e0(%rip), %xmm0   # 0x14d058
movq %r14, %rsi
movaps %xmm0, %xmm1
movaps %xmm0, %xmm2
callq 0x52d94
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 0x2e9bf
movq 0x40(%rsp), %rax
movq %rax, 0x10(%rsi)
movaps 0x30(%rsp), %xmm0
movups %xmm0, (%rsi)
addq $0x18, 0x18(%rsp)
jmp 0x2e9ce
leaq 0x10(%rsp), %rdi
leaq 0x30(%rsp), %rdx
callq 0x2fec4
leaq 0x78(%rsp), %rdi
leaq 0x11fd85(%rip), %rsi    # 0x14e75f
movl $0x72, %edx
callq 0x44e0
movb %bl, 0xf(%rsp)
xorl %ebx, %ebx
movabsq $-0x5555555555555555, %r14 # imm = 0xAAAAAAAAAAAAAAAB
leaq 0x126bdb(%rip), %r12    # 0x1555d6
leaq 0x124c1c(%rip), %r13    # 0x15361e
xorl %r15d, %r15d
movq 0x10(%rsp), %rdi
movq 0x18(%rsp), %rdx
subq %rdi, %rdx
sarq $0x3, %rdx
imulq %r14, %rdx
cmpq %r15, %rdx
jbe 0x2eb49
addq %rbx, %rdi
xorl %esi, %esi
callq 0x83f9a
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 0x2eb49
addq %rbx, %rdi
movl $0x1, %esi
callq 0x83f9a
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 0x2eb49
addq %rbx, %rdi
movl $0x2, %esi
callq 0x83f9a
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 0x2ea05
leaq 0x11fcdb(%rip), %rsi    # 0x14e7d2
movl $0x54, %edx
leaq 0x78(%rsp), %rdi
callq 0x44e0
movb 0xf(%rsp), %bl
movq 0x10(%rsp), %rdi
testq %rdi, %rdi
je 0x2eb21
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 0x11eba5(%rip), %rdi    # 0x14d6f5
movq %r15, %rsi
xorl %eax, %eax
callq 0x4630
jmp 0x2eb73
jmp 0x2eb73
jmp 0x2eb73
jmp 0x2eb73
jmp 0x2eb73
jmp 0x2eb73
jmp 0x2eb73
jmp 0x2eb73
jmp 0x2eb73
movq %rax, %rbx
jmp 0x2eb8d
jmp 0x2eb73
movq %rax, %rbx
movq 0x10(%rsp), %rdi
testq %rdi, %rdi
je 0x2eb8d
movq 0x20(%rsp), %rsi
subq %rdi, %rsi
callq 0x4470
leaq 0x68(%rsp), %rdi
callq 0x4110
movq %rbx, %rdi
callq 0x4780