// File: /workspace/github_cpp_makefile_star2_O1/Luthaf[P]zeopp/networkstorage.cc
// Function: write_edges(_IO_FILE*, ATOM_NETWORK*, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>>)
void write_edges(FILE *orig_e, ATOM_NETWORK *cell, string name) {
  bool verbose = false;
  //printf("DEBUG: called write_edges_dir()\n");
  //For each vertex in abc, get the coords in xyz, and find all edge end points
  vector<XYZ> vertices;
  XYZ v;
  vector< vector<XYZ> > edges;
  int total_num_e = 0;
  for(int i=0; i<cell->vertices.size(); i++) {
    XYZ vabc = cell->vertices.at(i).abc;
    v = cell->abc_to_xyz_returning_XYZ(vabc);
    vertices.push_back(v);
    int num_e = cell->vertices.at(i).edges.size();
    int num_dummy_e = cell->vertices.at(i).dummy_edges.size();
if(verbose) printf("DEBUG: this vertex has %d edges and %d dummy_edges\n", num_e, num_dummy_e);
    vector<XYZ> these_edges;
    for(int j=0; j<num_e; j++) {
      XYZ e;
      XYZ eabc = cell->vertices.at(i).edges.at(j);
      e = cell->abc_to_xyz_returning_XYZ(eabc); //treat the edge coords as positions
      these_edges.push_back(e);
      total_num_e++;
    }
    for(int j=0; j<num_dummy_e; j++) {
      XYZ e;
      XYZ eabc = cell->vertices.at(i).dummy_edges.at(j);
      e = cell->abc_to_xyz_returning_XYZ(eabc); //treat the edge coords as positions
      these_edges.push_back(e);
      total_num_e++;
    }
    edges.push_back(these_edges);
  }
  // Write header, information about the cell, and footer
  int num_v = vertices.size();
  fprintf(orig_e, "# vtk DataFile Version 2.0\n%s - vtk format representation of original edges\nASCII\nDATASET POLYDATA\nPOINTS %d double\n", name.c_str(), total_num_e+num_v);
  for(int i=0; i<num_v; i++) { //for each vertex ...
    fprintf(orig_e, "%.3f %.3f %.3f\n", vertices.at(i)[0], vertices.at(i)[1], vertices.at(i)[2]); //...print the vertex coords ...
    int num_e = edges.at(i).size();
    for(int j=0; j<num_e; j++) fprintf(orig_e, "%.3f %.3f %.3f\n", edges.at(i).at(j)[0], edges.at(i).at(j)[1], edges.at(i).at(j)[2]); //...and print the edge coords
  }
  //now this is trickier - print the edge connectivity with respect to vtk points
  fprintf(orig_e, "LINES %d %d\n", total_num_e, total_num_e*3);
  int v_index = 0;
  for(int i=0; i<num_v; i++) { //for each vertex ...
    int num_e = edges.at(i).size();
    for(int j=0; j<num_e; j++) { //...for each edge of this vertex ...
      fprintf(orig_e, "2 %d %d\n", v_index, v_index+j+1); //...print that this vertex is connected to each of its edges
    }
    v_index+=num_e+1;
  }
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0xe8, %rsp
movq %rdx, %rbx
movq %rsi, %r13
movq %rdi, %rbp
xorps %xmm0, %xmm0
movaps %xmm0, 0x40(%rsp)
movq $0x0, 0x50(%rsp)
leaq 0xb0(%rsp), %rdi
xorps %xmm0, %xmm0
xorps %xmm1, %xmm1
xorps %xmm2, %xmm2
callq 0x85982
movq %rbx, 0xa0(%rsp)
xorps %xmm0, %xmm0
movaps %xmm0, 0x60(%rsp)
movq $0x0, 0x70(%rsp)
movq 0x3c0(%r13), %rax
movabsq $-0x5555555555555555, %r15 # imm = 0xAAAAAAAAAAAAAAAB
cmpq %rax, 0x3c8(%r13)
movq %rbp, 0xa8(%rsp)
je 0x66e54
xorl %ebx, %ebx
movq $0x0, 0x8(%rsp)
imulq $0x70, %rbx, %r14
movsd (%rax,%r14), %xmm0
movsd 0x8(%rax,%r14), %xmm1
movsd 0x10(%rax,%r14), %xmm2
leaq 0x20(%rsp), %rdi
movq %r13, %rsi
callq 0x530d6
movq 0x30(%rsp), %rax
movq %rax, 0xc0(%rsp)
movups 0x20(%rsp), %xmm0
movaps %xmm0, 0xb0(%rsp)
movq 0x48(%rsp), %rsi
cmpq 0x50(%rsp), %rsi
je 0x66af8
movq 0xc0(%rsp), %rax
movq %rax, 0x10(%rsi)
movaps 0xb0(%rsp), %xmm0
movups %xmm0, (%rsi)
addq $0x18, 0x48(%rsp)
jmp 0x66b0a
leaq 0x40(%rsp), %rdi
leaq 0xb0(%rsp), %rdx
callq 0x6a5be
movq 0x3c0(%r13), %rax
movq 0x3c8(%r13), %rdx
subq %rax, %rdx
sarq $0x4, %rdx
movabsq $0x6db6db6db6db6db7, %rcx # imm = 0x6DB6DB6DB6DB6DB7
imulq %rcx, %rdx
cmpq %rbx, %rdx
jbe 0x67261
movq 0x28(%rax,%r14), %rdx
movq 0x40(%rax,%r14), %rcx
subq 0x20(%rax,%r14), %rdx
sarq $0x3, %rdx
imulq %r15, %rdx
subq 0x38(%rax,%r14), %rcx
movq %rcx, 0x10(%rsp)
xorps %xmm0, %xmm0
movaps %xmm0, 0x20(%rsp)
movq $0x0, 0x30(%rsp)
movq 0x8(%rsp), %r12
movq %rdx, 0x18(%rsp)
testl %edx, %edx
jle 0x66ca2
movq 0x8(%rsp), %rax
movq 0x18(%rsp), %r15
addl %r15d, %eax
movq %rax, 0x58(%rsp)
andl $0x7fffffff, %r15d      # imm = 0x7FFFFFFF
movl $0x10, %ebp
xorl %r12d, %r12d
xorps %xmm0, %xmm0
xorps %xmm1, %xmm1
xorps %xmm2, %xmm2
leaq 0x80(%rsp), %rdi
callq 0x85982
movq 0x3c0(%r13), %rcx
movq 0x3c8(%r13), %rdx
subq %rcx, %rdx
sarq $0x4, %rdx
movabsq $0x6db6db6db6db6db7, %rax # imm = 0x6DB6DB6DB6DB6DB7
imulq %rax, %rdx
cmpq %rbx, %rdx
jbe 0x6722b
movq 0x20(%rcx,%r14), %rax
movq 0x28(%rcx,%r14), %rdx
subq %rax, %rdx
sarq $0x3, %rdx
movabsq $-0x5555555555555555, %rcx # imm = 0xAAAAAAAAAAAAAAAB
imulq %rcx, %rdx
cmpq %r12, %rdx
jbe 0x67228
movsd -0x10(%rax,%rbp), %xmm0
movsd -0x8(%rax,%rbp), %xmm1
movsd (%rax,%rbp), %xmm2
leaq 0xd0(%rsp), %rdi
movq %r13, %rsi
callq 0x530d6
movq 0xe0(%rsp), %rax
movq %rax, 0x90(%rsp)
movups 0xd0(%rsp), %xmm0
movaps %xmm0, 0x80(%rsp)
movq 0x28(%rsp), %rsi
cmpq 0x30(%rsp), %rsi
je 0x66c71
movq 0x90(%rsp), %rax
movq %rax, 0x10(%rsi)
movaps 0x80(%rsp), %xmm0
movups %xmm0, (%rsi)
addq $0x18, 0x28(%rsp)
jmp 0x66c83
leaq 0x20(%rsp), %rdi
leaq 0x80(%rsp), %rdx
callq 0x6a5be
incq %r12
addq $0x18, %rbp
cmpq %r12, %r15
jne 0x66b9b
movabsq $-0x5555555555555555, %r15 # imm = 0xAAAAAAAAAAAAAAAB
movq 0x58(%rsp), %r12
movq 0x10(%rsp), %rbp
sarq $0x3, %rbp
imulq %r15, %rbp
testl %ebp, %ebp
jle 0x66ded
movq 0x18(%rsp), %rcx
testl %ecx, %ecx
movl $0x0, %eax
cmovgl %ecx, %eax
movq 0x8(%rsp), %rcx
addl %ebp, %ecx
addl %eax, %ecx
movq %rcx, 0x58(%rsp)
andl $0x7fffffff, %ebp       # imm = 0x7FFFFFFF
movl $0x10, %r15d
xorl %r12d, %r12d
xorps %xmm0, %xmm0
xorps %xmm1, %xmm1
xorps %xmm2, %xmm2
leaq 0x80(%rsp), %rdi
callq 0x85982
movq 0x3c0(%r13), %rcx
movq 0x3c8(%r13), %rdx
subq %rcx, %rdx
sarq $0x4, %rdx
movabsq $0x6db6db6db6db6db7, %rax # imm = 0x6DB6DB6DB6DB6DB7
imulq %rax, %rdx
cmpq %rbx, %rdx
jbe 0x6723f
movq 0x38(%rcx,%r14), %rax
movq 0x40(%rcx,%r14), %rdx
subq %rax, %rdx
sarq $0x3, %rdx
movabsq $-0x5555555555555555, %rcx # imm = 0xAAAAAAAAAAAAAAAB
imulq %rcx, %rdx
cmpq %r12, %rdx
jbe 0x6723c
movsd -0x10(%rax,%r15), %xmm0
movsd -0x8(%rax,%r15), %xmm1
movsd (%rax,%r15), %xmm2
leaq 0xd0(%rsp), %rdi
movq %r13, %rsi
callq 0x530d6
movq 0xe0(%rsp), %rax
movq %rax, 0x90(%rsp)
movups 0xd0(%rsp), %xmm0
movaps %xmm0, 0x80(%rsp)
movq 0x28(%rsp), %rsi
cmpq 0x30(%rsp), %rsi
je 0x66dbc
movq 0x90(%rsp), %rax
movq %rax, 0x10(%rsi)
movaps 0x80(%rsp), %xmm0
movups %xmm0, (%rsi)
addq $0x18, 0x28(%rsp)
jmp 0x66dce
leaq 0x20(%rsp), %rdi
leaq 0x80(%rsp), %rdx
callq 0x6a5be
incq %r12
addq $0x18, %r15
cmpq %r12, %rbp
jne 0x66ce3
movabsq $-0x5555555555555555, %r15 # imm = 0xAAAAAAAAAAAAAAAB
movq 0x58(%rsp), %r12
leaq 0x60(%rsp), %rdi
leaq 0x20(%rsp), %rsi
callq 0x6826c
movq 0x20(%rsp), %rdi
testq %rdi, %rdi
movq 0xa8(%rsp), %rbp
je 0x66e1b
movq 0x30(%rsp), %rsi
subq %rdi, %rsi
callq 0x4470
incq %rbx
movq 0x3c0(%r13), %rax
movq 0x3c8(%r13), %rcx
subq %rax, %rcx
sarq $0x4, %rcx
movabsq $0x6db6db6db6db6db7, %rdx # imm = 0x6DB6DB6DB6DB6DB7
imulq %rdx, %rcx
movl %r12d, %edx
movq %rdx, 0x8(%rsp)
cmpq %rbx, %rcx
ja 0x66a8e
jmp 0x66e57
xorl %r12d, %r12d
movq 0x48(%rsp), %rbx
subq 0x40(%rsp), %rbx
sarq $0x3, %rbx
imulq %r15, %rbx
movq 0xa0(%rsp), %rax
movq (%rax), %rdx
movq %r12, 0x58(%rsp)
leal (%r12,%rbx), %ecx
leaq 0xeee8e(%rip), %rsi     # 0x155d12
movq %rbp, %rdi
xorl %eax, %eax
callq 0x45f0
movq %rbx, 0x10(%rsp)
testl %ebx, %ebx
jle 0x67107
movq 0x10(%rsp), %rax
andl $0x7fffffff, %eax       # imm = 0x7FFFFFFF
movq %rax, 0xa0(%rsp)
xorl %r13d, %r13d
movq 0x40(%rsp), %rax
movq 0x48(%rsp), %rdx
subq %rax, %rdx
sarq $0x3, %rdx
imulq %r15, %rdx
cmpq %r13, %rdx
jbe 0x67250
leaq (,%r13,2), %r12
addq %r13, %r12
leaq (%rax,%r12,8), %rdi
xorl %esi, %esi
callq 0x85d40
movq 0x40(%rsp), %rcx
movq 0x48(%rsp), %rdx
subq %rcx, %rdx
sarq $0x3, %rdx
imulq %r15, %rdx
cmpq %r13, %rdx
jbe 0x67250
movsd (%rax), %xmm0
movsd %xmm0, 0x8(%rsp)
leaq (%rcx,%r12,8), %rdi
movl $0x1, %esi
callq 0x85d40
movq 0x40(%rsp), %rcx
movq 0x48(%rsp), %rdx
subq %rcx, %rdx
sarq $0x3, %rdx
imulq %r15, %rdx
cmpq %r13, %rdx
jbe 0x67250
movsd (%rax), %xmm0
movsd %xmm0, 0x18(%rsp)
leaq (%rcx,%r12,8), %rdi
movl $0x2, %esi
callq 0x85d40
movsd (%rax), %xmm2
movq %rbp, %rdi
leaq 0xecfcf(%rip), %rsi     # 0x153f2d
movsd 0x8(%rsp), %xmm0
movsd 0x18(%rsp), %xmm1
movb $0x3, %al
callq 0x45f0
movq 0x60(%rsp), %rax
movq 0x68(%rsp), %rdx
subq %rax, %rdx
sarq $0x3, %rdx
imulq %r15, %rdx
cmpq %r13, %rdx
jbe 0x67283
movq 0x8(%rax,%r12,8), %rbx
subq (%rax,%r12,8), %rbx
sarq $0x3, %rbx
imulq %r15, %rbx
testl %ebx, %ebx
jle 0x670ec
andl $0x7fffffff, %ebx       # imm = 0x7FFFFFFF
xorl %r15d, %r15d
xorl %r14d, %r14d
movq 0x60(%rsp), %rax
movq 0x68(%rsp), %rdx
subq %rax, %rdx
sarq $0x3, %rdx
movabsq $-0x5555555555555555, %rcx # imm = 0xAAAAAAAAAAAAAAAB
imulq %rcx, %rdx
cmpq %r13, %rdx
jbe 0x67217
movq (%rax,%r12,8), %rdi
movq 0x8(%rax,%r12,8), %rdx
subq %rdi, %rdx
sarq $0x3, %rdx
imulq %rcx, %rdx
cmpq %r14, %rdx
jbe 0x67214
addq %r15, %rdi
xorl %esi, %esi
callq 0x85d40
movq 0x60(%rsp), %rcx
movq 0x68(%rsp), %rdx
subq %rcx, %rdx
sarq $0x3, %rdx
movabsq $-0x5555555555555555, %rsi # imm = 0xAAAAAAAAAAAAAAAB
imulq %rsi, %rdx
cmpq %r13, %rdx
jbe 0x67217
movq (%rcx,%r12,8), %rdi
movq 0x8(%rcx,%r12,8), %rdx
subq %rdi, %rdx
sarq $0x3, %rdx
imulq %rsi, %rdx
cmpq %r14, %rdx
jbe 0x67214
movsd (%rax), %xmm0
movsd %xmm0, 0x8(%rsp)
addq %r15, %rdi
movl $0x1, %esi
callq 0x85d40
movq 0x60(%rsp), %rcx
movq 0x68(%rsp), %rdx
subq %rcx, %rdx
sarq $0x3, %rdx
movabsq $-0x5555555555555555, %rsi # imm = 0xAAAAAAAAAAAAAAAB
imulq %rsi, %rdx
cmpq %r13, %rdx
jbe 0x67217
movq (%rcx,%r12,8), %rdi
movq 0x8(%rcx,%r12,8), %rdx
subq %rdi, %rdx
sarq $0x3, %rdx
imulq %rsi, %rdx
cmpq %r14, %rdx
jbe 0x67214
movsd (%rax), %xmm0
movsd %xmm0, 0x18(%rsp)
addq %r15, %rdi
movl $0x2, %esi
callq 0x85d40
movsd (%rax), %xmm2
movq %rbp, %rdi
leaq 0xece64(%rip), %rsi     # 0x153f2d
movsd 0x8(%rsp), %xmm0
movsd 0x18(%rsp), %xmm1
movb $0x3, %al
callq 0x45f0
incq %r14
addq $0x18, %r15
cmpq %r14, %rbx
jne 0x66fb4
incq %r13
cmpq 0xa0(%rsp), %r13
movabsq $-0x5555555555555555, %r15 # imm = 0xAAAAAAAAAAAAAAAB
jne 0x66eb0
movq 0x58(%rsp), %rdx
leal (%rdx,%rdx,2), %ecx
leaq 0xecc08(%rip), %rsi     # 0x153d1e
movq %rbp, %rdi
xorl %eax, %eax
callq 0x45f0
cmpl $0x0, 0x10(%rsp)
jle 0x671e1
movq 0x10(%rsp), %rax
andl $0x7fffffff, %eax       # imm = 0x7FFFFFFF
movq %rax, 0x10(%rsp)
leaq 0xecbea(%rip), %r15     # 0x153d2b
xorl %r14d, %r14d
xorl %r12d, %r12d
movq 0xa8(%rsp), %rbx
movq 0x60(%rsp), %rax
movq 0x68(%rsp), %rdx
subq %rax, %rdx
sarq $0x3, %rdx
movabsq $-0x5555555555555555, %rcx # imm = 0xAAAAAAAAAAAAAAAB
imulq %rcx, %rdx
cmpq %r14, %rdx
jbe 0x67272
leaq (%r14,%r14,2), %rcx
movq 0x8(%rax,%rcx,8), %rdx
subq (%rax,%rcx,8), %rdx
shrq $0x3, %rdx
imull $0xaaaaaaab, %edx, %ecx # imm = 0xAAAAAAAB
movq %rcx, 0x8(%rsp)
testl %ecx, %ecx
jle 0x671c8
movq 0x8(%rsp), %r13
negl %r13d
movl $0x1, %ebp
leal (%r12,%rbp), %ecx
movq %rbx, %rdi
movq %r15, %rsi
movl %r12d, %edx
xorl %eax, %eax
callq 0x45f0
leal 0x1(%r13,%rbp), %eax
movl %ebp, %ecx
incl %ecx
movl %ecx, %ebp
cmpl $0x1, %eax
jne 0x671a4
movq 0x8(%rsp), %rax
addl %eax, %r12d
incl %r12d
incq %r14
cmpq 0x10(%rsp), %r14
jne 0x6714f
leaq 0x60(%rsp), %rdi
callq 0x68298
movq 0x40(%rsp), %rdi
testq %rdi, %rdi
je 0x67202
movq 0x50(%rsp), %rsi
subq %rdi, %rsi
callq 0x4470
addq $0xe8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq %r14, %r13
leaq 0xe8487(%rip), %rdi     # 0x14f6a5
movq %r13, %rsi
xorl %eax, %eax
callq 0x4630
movq %r12, %rbx
leaq 0xe8473(%rip), %rdi     # 0x14f6a5
movq %rbx, %rsi
xorl %eax, %eax
callq 0x4630
movq %r12, %rbx
leaq 0xe845f(%rip), %rdi     # 0x14f6a5
movq %rbx, %rsi
xorl %eax, %eax
callq 0x4630
leaq 0xe844e(%rip), %rdi     # 0x14f6a5
movq %r13, %rsi
xorl %eax, %eax
callq 0x4630
leaq 0xe843d(%rip), %rdi     # 0x14f6a5
movq %rbx, %rsi
xorl %eax, %eax
callq 0x4630
leaq 0xe842c(%rip), %rdi     # 0x14f6a5
movq %r14, %rsi
xorl %eax, %eax
callq 0x4630
leaq 0xe841b(%rip), %rdi     # 0x14f6a5
movq %r13, %rsi
xorl %eax, %eax
callq 0x4630
movq %rax, %rbx
jmp 0x672e2
jmp 0x672d5
jmp 0x672d5
jmp 0x672d5
jmp 0x672b7
jmp 0x672d5
jmp 0x672d5
jmp 0x672d5
jmp 0x672d5
jmp 0x672b7
jmp 0x672b7
jmp 0x672b7
jmp 0x672b7
jmp 0x672b7
jmp 0x672b7
jmp 0x672b7
movq %rax, %rbx
movq 0x20(%rsp), %rdi
testq %rdi, %rdi
je 0x672d8
movq 0x30(%rsp), %rsi
subq %rdi, %rsi
callq 0x4470
jmp 0x672d8
jmp 0x672d5
movq %rax, %rbx
leaq 0x60(%rsp), %rdi
callq 0x68298
movq 0x40(%rsp), %rdi
testq %rdi, %rdi
je 0x672f9
movq 0x50(%rsp), %rsi
subq %rdi, %rsi
callq 0x4470
movq %rbx, %rdi
callq 0x4780