// File: /workspace/github_cpp_makefile_star2_O3/Luthaf[P]zeopp/networkstorage.cc
// Function: write_unit_cell(_IO_FILE*, ATOM_NETWORK*, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>>, bool)
void write_unit_cell(FILE *orig_uc, ATOM_NETWORK *cell, string name, bool is_net) {
  //printf("DEBUG: called write_unit_cell()\n");
  //For each corner in abc, get the coords in xyz
  vector<XYZ> corners; XYZ p;
  p = cell->abc_to_xyz_returning_XYZ(0, 0, 0); corners.push_back(p);
  p = cell->abc_to_xyz_returning_XYZ(0, 0, 1); corners.push_back(p);
  p = cell->abc_to_xyz_returning_XYZ(0, 1, 0); corners.push_back(p);
  p = cell->abc_to_xyz_returning_XYZ(0, 1, 1); corners.push_back(p);
  p = cell->abc_to_xyz_returning_XYZ(1, 0, 0); corners.push_back(p);
  p = cell->abc_to_xyz_returning_XYZ(1, 0, 1); corners.push_back(p);
  p = cell->abc_to_xyz_returning_XYZ(1, 1, 0); corners.push_back(p);
  p = cell->abc_to_xyz_returning_XYZ(1, 1, 1); corners.push_back(p);
  // Write header, information about the cell, and footer
  int num_c = corners.size();
  fprintf(orig_uc, "# vtk DataFile Version 2.0\n%s", name.c_str());
  if(is_net) fprintf(orig_uc, " - vtk format representation of original unit cell boundary\n"); else fprintf(orig_uc, " - vtk format representation of structure's unit cell boundary\n");
  fprintf(orig_uc, "ASCII\nDATASET POLYDATA\nPOINTS %d double\n", num_c);
  for(int i=0; i<num_c; i++) fprintf(orig_uc, "%.3f %.3f %.3f\n", corners.at(i)[0], corners.at(i)[1], corners.at(i)[2]);
  fprintf(orig_uc, "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");
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x68, %rsp
movl %ecx, %ebp
movq %rdx, %r14
movq %rsi, %r15
movq %rdi, %rbx
xorps %xmm0, %xmm0
movaps %xmm0, (%rsp)
movq $0x0, 0x10(%rsp)
leaq 0x20(%rsp), %rdi
xorps %xmm0, %xmm0
xorps %xmm1, %xmm1
xorps %xmm2, %xmm2
callq 0x84364
leaq 0x40(%rsp), %rdi
xorps %xmm0, %xmm0
xorps %xmm1, %xmm1
xorps %xmm2, %xmm2
movq %r15, %rsi
callq 0x52dd8
movq 0x50(%rsp), %rax
movq %rax, 0x30(%rsp)
movups 0x40(%rsp), %xmm0
movaps %xmm0, 0x20(%rsp)
movq 0x8(%rsp), %rsi
cmpq 0x10(%rsp), %rsi
je 0x65827
movq 0x30(%rsp), %rax
movq %rax, 0x10(%rsi)
movaps 0x20(%rsp), %xmm0
movups %xmm0, (%rsi)
addq $0x18, 0x8(%rsp)
jmp 0x65834
movq %rsp, %rdi
leaq 0x20(%rsp), %rdx
callq 0x69b82
leaq 0x40(%rsp), %rdi
movsd 0xe7817(%rip), %xmm2    # 0x14d058
xorps %xmm0, %xmm0
xorps %xmm1, %xmm1
movq %r15, %rsi
callq 0x52dd8
movq 0x50(%rsp), %rax
movq %rax, 0x30(%rsp)
movups 0x40(%rsp), %xmm0
movaps %xmm0, 0x20(%rsp)
movq 0x8(%rsp), %rsi
cmpq 0x10(%rsp), %rsi
je 0x65888
movq 0x30(%rsp), %rax
movq %rax, 0x10(%rsi)
movaps 0x20(%rsp), %xmm0
movups %xmm0, (%rsi)
addq $0x18, 0x8(%rsp)
jmp 0x65895
movq %rsp, %rdi
leaq 0x20(%rsp), %rdx
callq 0x69b82
leaq 0x40(%rsp), %rdi
movsd 0xe77b6(%rip), %xmm1    # 0x14d058
xorps %xmm0, %xmm0
xorps %xmm2, %xmm2
movq %r15, %rsi
callq 0x52dd8
movq 0x50(%rsp), %rax
movq %rax, 0x30(%rsp)
movups 0x40(%rsp), %xmm0
movaps %xmm0, 0x20(%rsp)
movq 0x8(%rsp), %rsi
cmpq 0x10(%rsp), %rsi
je 0x658e9
movq 0x30(%rsp), %rax
movq %rax, 0x10(%rsi)
movaps 0x20(%rsp), %xmm0
movups %xmm0, (%rsi)
addq $0x18, 0x8(%rsp)
jmp 0x658f6
movq %rsp, %rdi
leaq 0x20(%rsp), %rdx
callq 0x69b82
leaq 0x40(%rsp), %rdi
movsd 0xe7755(%rip), %xmm1    # 0x14d058
xorps %xmm0, %xmm0
movq %r15, %rsi
movaps %xmm1, %xmm2
callq 0x52dd8
movq 0x50(%rsp), %rax
movq %rax, 0x30(%rsp)
movups 0x40(%rsp), %xmm0
movaps %xmm0, 0x20(%rsp)
movq 0x8(%rsp), %rsi
cmpq 0x10(%rsp), %rsi
je 0x6594a
movq 0x30(%rsp), %rax
movq %rax, 0x10(%rsi)
movaps 0x20(%rsp), %xmm0
movups %xmm0, (%rsi)
addq $0x18, 0x8(%rsp)
jmp 0x65957
movq %rsp, %rdi
leaq 0x20(%rsp), %rdx
callq 0x69b82
leaq 0x40(%rsp), %rdi
movsd 0xe76f4(%rip), %xmm0    # 0x14d058
xorps %xmm1, %xmm1
xorps %xmm2, %xmm2
movq %r15, %rsi
callq 0x52dd8
movq 0x50(%rsp), %rax
movq %rax, 0x30(%rsp)
movups 0x40(%rsp), %xmm0
movaps %xmm0, 0x20(%rsp)
movq 0x8(%rsp), %rsi
cmpq 0x10(%rsp), %rsi
je 0x659ab
movq 0x30(%rsp), %rax
movq %rax, 0x10(%rsi)
movaps 0x20(%rsp), %xmm0
movups %xmm0, (%rsi)
addq $0x18, 0x8(%rsp)
jmp 0x659b8
movq %rsp, %rdi
leaq 0x20(%rsp), %rdx
callq 0x69b82
leaq 0x40(%rsp), %rdi
movsd 0xe7693(%rip), %xmm0    # 0x14d058
xorps %xmm1, %xmm1
movq %r15, %rsi
movaps %xmm0, %xmm2
callq 0x52dd8
movq 0x50(%rsp), %rax
movq %rax, 0x30(%rsp)
movups 0x40(%rsp), %xmm0
movaps %xmm0, 0x20(%rsp)
movq 0x8(%rsp), %rsi
cmpq 0x10(%rsp), %rsi
je 0x65a0c
movq 0x30(%rsp), %rax
movq %rax, 0x10(%rsi)
movaps 0x20(%rsp), %xmm0
movups %xmm0, (%rsi)
addq $0x18, 0x8(%rsp)
jmp 0x65a19
movq %rsp, %rdi
leaq 0x20(%rsp), %rdx
callq 0x69b82
leaq 0x40(%rsp), %rdi
movsd 0xe7632(%rip), %xmm0    # 0x14d058
xorps %xmm2, %xmm2
movq %r15, %rsi
movaps %xmm0, %xmm1
callq 0x52dd8
movq 0x50(%rsp), %rax
movq %rax, 0x30(%rsp)
movups 0x40(%rsp), %xmm0
movaps %xmm0, 0x20(%rsp)
movq 0x8(%rsp), %rsi
cmpq 0x10(%rsp), %rsi
je 0x65a6d
movq 0x30(%rsp), %rax
movq %rax, 0x10(%rsi)
movaps 0x20(%rsp), %xmm0
movups %xmm0, (%rsi)
addq $0x18, 0x8(%rsp)
jmp 0x65a7a
movq %rsp, %rdi
leaq 0x20(%rsp), %rdx
callq 0x69b82
leaq 0x40(%rsp), %rdi
movsd 0xe75d1(%rip), %xmm0    # 0x14d058
movq %r15, %rsi
movaps %xmm0, %xmm1
movaps %xmm0, %xmm2
callq 0x52dd8
movq 0x50(%rsp), %rax
movq %rax, 0x30(%rsp)
movups 0x40(%rsp), %xmm0
movaps %xmm0, 0x20(%rsp)
movq 0x8(%rsp), %rsi
cmpq 0x10(%rsp), %rsi
je 0x65ad6
movq 0x30(%rsp), %rax
movq %rax, 0x10(%rsi)
movaps 0x20(%rsp), %xmm0
movups %xmm0, (%rsi)
movq 0x8(%rsp), %r15
addq $0x18, %r15
movq %r15, 0x8(%rsp)
jmp 0x65ae8
movq %rsp, %rdi
leaq 0x20(%rsp), %rdx
callq 0x69b82
movq 0x8(%rsp), %r15
subq (%rsp), %r15
sarq $0x3, %r15
movabsq $-0x5555555555555555, %r13 # imm = 0xAAAAAAAAAAAAAAAB
imulq %r13, %r15
movq (%r14), %rdx
leaq 0xee1e3(%rip), %rsi     # 0x153ceb
movq %rbx, %rdi
xorl %eax, %eax
callq 0x45f0
testb %bpl, %bpl
je 0x65b25
leaq 0xee1eb(%rip), %rdi     # 0x153d09
movl $0x3c, %esi
jmp 0x65b31
leaq 0xee21a(%rip), %rdi     # 0x153d46
movl $0x3f, %esi
movl $0x1, %edx
movq %rbx, %rcx
callq 0x4850
leaq 0xec260(%rip), %rsi     # 0x151da5
movq %rbx, %rdi
movl %r15d, %edx
xorl %eax, %eax
callq 0x45f0
testl %r15d, %r15d
jle 0x65c2a
andl $0x7fffffff, %r15d      # imm = 0x7FFFFFFF
xorl %ebp, %ebp
leaq 0xec472(%rip), %r12     # 0x151fdd
xorl %r14d, %r14d
movq (%rsp), %rdi
movq 0x8(%rsp), %rdx
subq %rdi, %rdx
sarq $0x3, %rdx
imulq %r13, %rdx
cmpq %r14, %rdx
jbe 0x65c68
addq %rbp, %rdi
xorl %esi, %esi
callq 0x845b8
movq (%rsp), %rdi
movq 0x8(%rsp), %rdx
subq %rdi, %rdx
sarq $0x3, %rdx
imulq %r13, %rdx
cmpq %r14, %rdx
jbe 0x65c68
movsd (%rax), %xmm0
movsd %xmm0, 0x60(%rsp)
addq %rbp, %rdi
movl $0x1, %esi
callq 0x845b8
movq (%rsp), %rdi
movq 0x8(%rsp), %rdx
subq %rdi, %rdx
sarq $0x3, %rdx
imulq %r13, %rdx
cmpq %r14, %rdx
jbe 0x65c68
movsd (%rax), %xmm0
movsd %xmm0, 0x58(%rsp)
addq %rbp, %rdi
movl $0x2, %esi
callq 0x845b8
movsd (%rax), %xmm2
movq %rbx, %rdi
movq %r12, %rsi
movsd 0x60(%rsp), %xmm0
movsd 0x58(%rsp), %xmm1
movb $0x3, %al
callq 0x45f0
incq %r14
addq $0x18, %rbp
cmpq %r14, %r15
jne 0x65b6e
leaq 0xe8ba1(%rip), %rdi     # 0x14e7d2
movl $0x54, %esi
movl $0x1, %edx
movq %rbx, %rcx
callq 0x4850
movq (%rsp), %rdi
testq %rdi, %rdi
je 0x65c59
movq 0x10(%rsp), %rsi
subq %rdi, %rsi
callq 0x4470
addq $0x68, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
leaq 0xe7a86(%rip), %rdi     # 0x14d6f5
movq %r14, %rsi
xorl %eax, %eax
callq 0x4630
jmp 0x65c8d
jmp 0x65c8d
jmp 0x65c8d
jmp 0x65c8d
jmp 0x65c8d
jmp 0x65c8d
jmp 0x65c8d
jmp 0x65c8d
jmp 0x65c8d
jmp 0x65c8d
movq %rax, %rbx
movq (%rsp), %rdi
testq %rdi, %rdi
je 0x65ca6
movq 0x10(%rsp), %rsi
subq %rdi, %rsi
callq 0x4470
movq %rbx, %rdi
callq 0x4780