// File: 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
movq %rsp, %rbp
subq $0x180, %rsp            # imm = 0x180
movq %rdx, -0x130(%rbp)
movb %cl, %al
movq %rdi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
movq %rdx, -0x18(%rbp)
andb $0x1, %al
movb %al, -0x19(%rbp)
leaq -0x38(%rbp), %rdi
callq 0xada60
leaq -0x50(%rbp), %rdi
xorps %xmm2, %xmm2
movaps %xmm2, %xmm0
movaps %xmm2, %xmm1
callq 0xea8e0
jmp 0xac2f2
movq -0x10(%rbp), %rsi
leaq -0x78(%rbp), %rdi
xorps %xmm2, %xmm2
movaps %xmm2, %xmm0
movaps %xmm2, %xmm1
callq 0x97220
jmp 0xac30a
movq -0x68(%rbp), %rax
movq %rax, -0x40(%rbp)
movups -0x78(%rbp), %xmm0
movaps %xmm0, -0x50(%rbp)
leaq -0x38(%rbp), %rdi
leaq -0x50(%rbp), %rsi
callq 0xafc20
jmp 0xac329
movq -0x10(%rbp), %rsi
leaq -0x90(%rbp), %rdi
xorps %xmm1, %xmm1
movsd 0x145d11(%rip), %xmm2   # 0x1f2050
movaps %xmm1, %xmm0
callq 0x97220
jmp 0xac349
movq -0x80(%rbp), %rax
movq %rax, -0x40(%rbp)
movups -0x90(%rbp), %xmm0
movaps %xmm0, -0x50(%rbp)
leaq -0x38(%rbp), %rdi
leaq -0x50(%rbp), %rsi
callq 0xafc20
jmp 0xac36b
movq -0x10(%rbp), %rsi
leaq -0xa8(%rbp), %rdi
movsd 0x145cd2(%rip), %xmm1   # 0x1f2050
xorps %xmm2, %xmm2
movaps %xmm2, %xmm0
callq 0x97220
jmp 0xac38b
movq -0x98(%rbp), %rax
movq %rax, -0x40(%rbp)
movups -0xa8(%rbp), %xmm0
movaps %xmm0, -0x50(%rbp)
leaq -0x38(%rbp), %rdi
leaq -0x50(%rbp), %rsi
callq 0xafc20
jmp 0xac3b0
movq -0x10(%rbp), %rsi
leaq -0xc0(%rbp), %rdi
xorps %xmm0, %xmm0
movsd 0x145c8a(%rip), %xmm2   # 0x1f2050
movaps %xmm2, %xmm1
callq 0x97220
jmp 0xac3d0
movq -0xb0(%rbp), %rax
movq %rax, -0x40(%rbp)
movups -0xc0(%rbp), %xmm0
movaps %xmm0, -0x50(%rbp)
leaq -0x38(%rbp), %rdi
leaq -0x50(%rbp), %rsi
callq 0xafc20
jmp 0xac3f5
movq -0x10(%rbp), %rsi
leaq -0xd8(%rbp), %rdi
movsd 0x145c48(%rip), %xmm0   # 0x1f2050
xorps %xmm2, %xmm2
movaps %xmm2, %xmm1
callq 0x97220
jmp 0xac415
movq -0xc8(%rbp), %rax
movq %rax, -0x40(%rbp)
movups -0xd8(%rbp), %xmm0
movaps %xmm0, -0x50(%rbp)
leaq -0x38(%rbp), %rdi
leaq -0x50(%rbp), %rsi
callq 0xafc20
jmp 0xac43a
movq -0x10(%rbp), %rsi
leaq -0xf0(%rbp), %rdi
xorps %xmm1, %xmm1
movsd 0x145c00(%rip), %xmm2   # 0x1f2050
movaps %xmm2, %xmm0
callq 0x97220
jmp 0xac45a
movq -0xe0(%rbp), %rax
movq %rax, -0x40(%rbp)
movups -0xf0(%rbp), %xmm0
movaps %xmm0, -0x50(%rbp)
leaq -0x38(%rbp), %rdi
leaq -0x50(%rbp), %rsi
callq 0xafc20
jmp 0xac47f
movq -0x10(%rbp), %rsi
leaq -0x108(%rbp), %rdi
movsd 0x145bbe(%rip), %xmm1   # 0x1f2050
xorps %xmm2, %xmm2
movaps %xmm1, %xmm0
callq 0x97220
jmp 0xac49f
movq -0xf8(%rbp), %rax
movq %rax, -0x40(%rbp)
movups -0x108(%rbp), %xmm0
movaps %xmm0, -0x50(%rbp)
leaq -0x38(%rbp), %rdi
leaq -0x50(%rbp), %rsi
callq 0xafc20
jmp 0xac4c4
movq -0x10(%rbp), %rsi
leaq -0x120(%rbp), %rdi
movsd 0x145b79(%rip), %xmm2   # 0x1f2050
movaps %xmm2, %xmm0
movaps %xmm2, %xmm1
callq 0x97220
jmp 0xac4e4
movq -0x110(%rbp), %rax
movq %rax, -0x40(%rbp)
movups -0x120(%rbp), %xmm0
movaps %xmm0, -0x50(%rbp)
leaq -0x38(%rbp), %rdi
leaq -0x50(%rbp), %rsi
callq 0xafc20
jmp 0xac509
leaq -0x38(%rbp), %rdi
callq 0xae590
movq -0x130(%rbp), %rdi
movl %eax, -0x124(%rbp)
movq -0x8(%rbp), %rax
movq %rax, -0x138(%rbp)
callq 0x5200
movq -0x138(%rbp), %rdi
movq %rax, %rdx
leaq 0x14e76a(%rip), %rsi    # 0x1facaa
movb $0x0, %al
callq 0x5750
testb $0x1, -0x19(%rbp)
je 0xac57b
movq -0x8(%rbp), %rdi
leaq 0x14e770(%rip), %rsi    # 0x1facc8
movb $0x0, %al
callq 0x5750
jmp 0xac58d
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x58(%rbp)
movl %eax, -0x5c(%rbp)
leaq -0x38(%rbp), %rdi
callq 0x12210
jmp 0xac6f0
movq -0x8(%rbp), %rdi
leaq 0x14e77f(%rip), %rsi    # 0x1fad05
movb $0x0, %al
callq 0x5750
movq -0x8(%rbp), %rdi
movl -0x124(%rbp), %edx
leaq 0x14a7d7(%rip), %rsi    # 0x1f6d75
movb $0x0, %al
callq 0x5750
movl $0x0, -0x128(%rbp)
movl -0x128(%rbp), %eax
cmpl -0x124(%rbp), %eax
jge 0xac6cc
movq -0x8(%rbp), %rax
movq %rax, -0x148(%rbp)
movslq -0x128(%rbp), %rsi
leaq -0x38(%rbp), %rdi
callq 0xae5c0
movq %rax, -0x140(%rbp)
jmp 0xac5e5
movq -0x140(%rbp), %rdi
xorl %esi, %esi
callq 0xead40
movq %rax, -0x150(%rbp)
jmp 0xac5fc
movq -0x150(%rbp), %rax
movsd (%rax), %xmm0
movsd %xmm0, -0x160(%rbp)
movslq -0x128(%rbp), %rsi
leaq -0x38(%rbp), %rdi
callq 0xae5c0
movq %rax, -0x158(%rbp)
jmp 0xac628
movq -0x158(%rbp), %rdi
movl $0x1, %esi
callq 0xead40
movq %rax, -0x168(%rbp)
jmp 0xac642
movq -0x168(%rbp), %rax
movsd (%rax), %xmm0
movsd %xmm0, -0x178(%rbp)
movslq -0x128(%rbp), %rsi
leaq -0x38(%rbp), %rdi
callq 0xae5c0
movq %rax, -0x170(%rbp)
jmp 0xac66e
movq -0x170(%rbp), %rdi
movl $0x2, %esi
callq 0xead40
movq %rax, -0x180(%rbp)
jmp 0xac688
movsd -0x178(%rbp), %xmm1
movsd -0x160(%rbp), %xmm0
movq -0x148(%rbp), %rdi
movq -0x180(%rbp), %rax
movsd (%rax), %xmm2
leaq 0x14dd9c(%rip), %rsi    # 0x1fa44d
movb $0x3, %al
callq 0x5750
movl -0x128(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x128(%rbp)
jmp 0xac5af
movq -0x8(%rbp), %rdi
leaq 0x1472d4(%rip), %rsi    # 0x1f39ab
movb $0x0, %al
callq 0x5750
leaq -0x38(%rbp), %rdi
callq 0x12210
addq $0x180, %rsp            # imm = 0x180
popq %rbp
retq
movq -0x58(%rbp), %rdi
callq 0x58f0
nopl (%rax)