// File: /workspace/github_cpp_makefile_star2_O2/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 $0x108, %rsp            # imm = 0x108
movq %rdx, 0x8(%rsp)
movq %rsi, %rbx
movq %rdi, 0x10(%rsp)
xorps %xmm0, %xmm0
movaps %xmm0, 0x20(%rsp)
andq $0x0, 0x30(%rsp)
leaq 0xd0(%rsp), %rdi
xorps %xmm0, %xmm0
xorps %xmm1, %xmm1
xorps %xmm2, %xmm2
callq 0x6402e
leaq 0xa0(%rsp), %rax
xorps %xmm0, %xmm0
movaps %xmm0, (%rax)
andq $0x0, 0x10(%rax)
movq %rbx, %r13
leaq 0x3c0(%rbx), %rbp
leaq 0x80(%rsp), %r12
xorl %r14d, %r14d
movq $0x0, 0x18(%rsp)
movq 0x3c8(%r13), %rax
subq 0x3c0(%r13), %rax
cqto
pushq $0x70
popq %rcx
idivq %rcx
cmpq %r14, %rax
jbe 0x4acba
movq %rbp, %rdi
movq %r14, %rsi
callq 0x4b63c
movq 0x10(%rax), %rcx
movq %rcx, 0x100(%rsp)
movups (%rax), %xmm0
movaps %xmm0, 0xf0(%rsp)
movq %r12, %rdi
movq %r13, %rsi
leaq 0xf0(%rsp), %rdx
callq 0x3f1b2
movq 0x90(%rsp), %rax
movq %rax, 0xe0(%rsp)
movups 0x80(%rsp), %xmm0
movaps %xmm0, 0xd0(%rsp)
leaq 0x20(%rsp), %rdi
leaq 0xd0(%rsp), %rsi
callq 0x4beaa
movq %r12, %r15
movq %rbp, %rdi
movq %r14, %rsi
callq 0x4b63c
movq 0x20(%rax), %r12
movq 0x28(%rax), %rbx
movq %rbp, %rdi
movq %r14, %rsi
callq 0x4b63c
movq %rax, %rcx
subq %r12, %rbx
movq %rbx, %rax
cqto
pushq $0x18
popq %rsi
idivq %rsi
movq %rax, %r12
movq 0x40(%rcx), %rax
subq 0x38(%rcx), %rax
cqto
idivq %rsi
movq %rax, (%rsp)
xorps %xmm0, %xmm0
movaps %xmm0, 0x80(%rsp)
andq $0x0, 0x90(%rsp)
testl %r12d, %r12d
movl $0x0, %eax
cmovlel %eax, %r12d
xorl %ebx, %ebx
cmpq %rbx, %r12
je 0x4abea
xorps %xmm0, %xmm0
xorps %xmm1, %xmm1
xorps %xmm2, %xmm2
leaq 0x40(%rsp), %rdi
callq 0x6402e
movq %rbp, %rdi
movq %r14, %rsi
callq 0x4b63c
addq $0x20, %rax
movq %rax, %rdi
movq %rbx, %rsi
callq 0x4b6d6
movq 0x10(%rax), %rcx
movq %rcx, 0x70(%rsp)
movups (%rax), %xmm0
movaps %xmm0, 0x60(%rsp)
leaq 0xb8(%rsp), %rdi
movq %r13, %rsi
leaq 0x60(%rsp), %rdx
callq 0x3f1b2
movq 0xc8(%rsp), %rax
movq %rax, 0x50(%rsp)
movups 0xb8(%rsp), %xmm0
movaps %xmm0, 0x40(%rsp)
movq %r15, %rdi
leaq 0x40(%rsp), %rsi
callq 0x4beaa
incq %rbx
jmp 0x4ab5f
movq 0x18(%rsp), %rax
addl %r12d, %eax
movq (%rsp), %rdx
testl %edx, %edx
movl $0x0, %ecx
cmovlel %ecx, %edx
addl %edx, %eax
movq %rax, 0x18(%rsp)
xorl %ebx, %ebx
movq %r15, %r12
movq %rdx, %r15
cmpq %rbx, %r15
je 0x4ac9a
xorps %xmm0, %xmm0
xorps %xmm1, %xmm1
xorps %xmm2, %xmm2
leaq 0x40(%rsp), %rdi
callq 0x6402e
movq %rbp, %rdi
movq %r14, %rsi
callq 0x4b63c
addq $0x38, %rax
movq %rax, %rdi
movq %rbx, %rsi
callq 0x4b6d6
movq 0x10(%rax), %rcx
movq %rcx, 0x70(%rsp)
movups (%rax), %xmm0
movaps %xmm0, 0x60(%rsp)
leaq 0xb8(%rsp), %rdi
movq %r13, %rsi
leaq 0x60(%rsp), %rdx
callq 0x3f1b2
movq 0xc8(%rsp), %rax
movq %rax, 0x50(%rsp)
movups 0xb8(%rsp), %xmm0
movaps %xmm0, 0x40(%rsp)
movq %r12, %rdi
leaq 0x40(%rsp), %rsi
callq 0x4beaa
incq %rbx
jmp 0x4ac0f
leaq 0xa0(%rsp), %rdi
movq %r12, %rsi
callq 0x4bf4a
movq %r12, %rdi
callq 0xb132
incq %r14
jmp 0x4aa71
leaq 0x20(%rsp), %rcx
movq 0x8(%rcx), %rax
subq (%rcx), %rax
cqto
pushq $0x18
popq %rcx
idivq %rcx
movq %rax, %rbx
movq 0x8(%rsp), %rax
movq (%rax), %rdx
movq 0x18(%rsp), %rax
leal (%rax,%rbx), %ecx
leaq 0xb807a(%rip), %rsi     # 0x102d62
xorl %r14d, %r14d
movq 0x10(%rsp), %rdi
xorl %eax, %eax
callq 0x4610
testl %ebx, %ebx
cmovlel %r14d, %ebx
movq %rbx, 0x38(%rsp)
pushq $0x2
popq %r14
leaq 0xb6240(%rip), %r12     # 0x100f4d
leaq 0xa0(%rsp), %r13
xorl %ebx, %ebx
cmpq 0x38(%rsp), %rbx
je 0x4ae74
leaq 0x20(%rsp), %rdi
movq %rbx, %rsi
callq 0x4b6d6
movq %rax, %rdi
xorl %esi, %esi
callq 0x6424a
movsd (%rax), %xmm0
movsd %xmm0, (%rsp)
leaq 0x20(%rsp), %rdi
movq %rbx, %rsi
callq 0x4b6d6
movq %rax, %rdi
pushq $0x1
popq %rsi
callq 0x6424a
movsd (%rax), %xmm0
movsd %xmm0, 0x8(%rsp)
leaq 0x20(%rsp), %rdi
movq %rbx, %rsi
callq 0x4b6d6
movq %rax, %rdi
movl %r14d, %esi
callq 0x6424a
movsd (%rax), %xmm2
movq 0x10(%rsp), %rdi
movq %r12, %rsi
movsd (%rsp), %xmm0
movsd 0x8(%rsp), %xmm1
movb $0x3, %al
callq 0x4610
movq %r13, %rdi
movq %rbx, %rsi
callq 0x4bf76
movq 0x8(%rax), %rcx
subq (%rax), %rcx
movq %rcx, %rax
cqto
pushq $0x18
popq %rcx
idivq %rcx
movq %rax, %r15
testl %r15d, %r15d
movl $0x0, %eax
cmovlel %eax, %r15d
xorl %ebp, %ebp
cmpq %rbp, %r15
je 0x4ae6c
movq %r13, %rdi
movq %rbx, %rsi
callq 0x4bf76
movq %rax, %rdi
movq %rbp, %rsi
callq 0x4b6d6
movq %rax, %rdi
xorl %esi, %esi
callq 0x6424a
movsd (%rax), %xmm0
movsd %xmm0, (%rsp)
movq %r13, %rdi
movq %rbx, %rsi
callq 0x4bf76
movq %rax, %rdi
movq %rbp, %rsi
callq 0x4b6d6
movq %rax, %rdi
pushq $0x1
popq %rsi
callq 0x6424a
movsd (%rax), %xmm0
movsd %xmm0, 0x8(%rsp)
movq %r13, %rdi
movq %rbx, %rsi
callq 0x4bf76
movq %rax, %rdi
movq %rbp, %rsi
callq 0x4b6d6
movq %rax, %rdi
movl %r14d, %esi
callq 0x6424a
movsd (%rax), %xmm2
movq 0x10(%rsp), %rdi
movq %r12, %rsi
movsd (%rsp), %xmm0
movsd 0x8(%rsp), %xmm1
movb $0x3, %al
callq 0x4610
incq %rbp
jmp 0x4adc8
incq %rbx
jmp 0x4ad17
movq 0x18(%rsp), %rdx
leal (%rdx,%rdx,2), %ecx
leaq 0xb5ebb(%rip), %rsi     # 0x100d3e
movq 0x10(%rsp), %rdi
xorl %eax, %eax
callq 0x4610
leaq 0xb5eb5(%rip), %r14     # 0x100d4b
xorl %esi, %esi
xorl %r12d, %r12d
cmpq 0x38(%rsp), %rsi
je 0x4af14
leaq 0xa0(%rsp), %rdi
movq %rsi, (%rsp)
callq 0x4bf76
movq 0x8(%rax), %rcx
subq (%rax), %rcx
movq %rcx, %rax
cqto
pushq $0x18
popq %rcx
idivq %rcx
movq %rax, %r13
leal 0x1(%r12), %ebp
testl %r13d, %r13d
movl $0x0, %ebx
cmovgl %r13d, %ebx
negl %ebx
pushq $0x1
popq %rax
movl %eax, %r15d
leal (%rbx,%r15), %eax
cmpl $0x1, %eax
je 0x4af05
leal (%r12,%r15), %ecx
movq 0x10(%rsp), %rdi
movq %r14, %rsi
movl %r12d, %edx
xorl %eax, %eax
callq 0x4610
incl %r15d
jmp 0x4aee1
addl %r13d, %ebp
movq (%rsp), %rsi
incq %rsi
movl %ebp, %r12d
jmp 0x4ae9b
leaq 0xa0(%rsp), %rdi
callq 0x4bf94
leaq 0x20(%rsp), %rdi
callq 0xb132
addq $0x108, %rsp            # imm = 0x108
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq %rax, %rbx
jmp 0x4af7e
jmp 0x4af6e
jmp 0x4af6e
jmp 0x4af5c
jmp 0x4af6e
jmp 0x4af6e
jmp 0x4af6e
jmp 0x4af6e
jmp 0x4af6e
jmp 0x4af5c
jmp 0x4af5c
jmp 0x4af5c
jmp 0x4af5c
jmp 0x4af5c
movq %rax, %rbx
leaq 0x80(%rsp), %rdi
callq 0xb132
jmp 0x4af71
movq %rax, %rbx
leaq 0xa0(%rsp), %rdi
callq 0x4bf94
leaq 0x20(%rsp), %rdi
callq 0xb132
movq %rbx, %rdi
callq 0x4780