// File: 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
movq %rsp, %rbp
subq $0x2c0, %rsp            # imm = 0x2C0
movq %rdx, -0x1c0(%rbp)
movq %rdi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
movq %rdx, -0x18(%rbp)
movb $0x0, -0x19(%rbp)
leaq -0x38(%rbp), %rdi
callq 0xada60
leaq -0x50(%rbp), %rdi
xorps %xmm2, %xmm2
movaps %xmm2, %xmm0
movaps %xmm2, %xmm1
callq 0xea8e0
jmp 0xacb6f
leaq -0x78(%rbp), %rdi
callq 0xafd80
movl $0x0, -0x7c(%rbp)
movl $0x0, -0x80(%rbp)
movslq -0x80(%rbp), %rax
movq %rax, -0x1c8(%rbp)
movq -0x10(%rbp), %rdi
addq $0x3c0, %rdi            # imm = 0x3C0
callq 0xae470
movq %rax, %rcx
movq -0x1c8(%rbp), %rax
cmpq %rcx, %rax
jae 0xacf12
movq -0x10(%rbp), %rdi
addq $0x3c0, %rdi            # imm = 0x3C0
movslq -0x80(%rbp), %rsi
callq 0xae4a0
movq %rax, -0x1d0(%rbp)
jmp 0xacbd1
movq -0x1d0(%rbp), %rax
movq 0x10(%rax), %rcx
movq %rcx, -0x90(%rbp)
movups (%rax), %xmm0
movaps %xmm0, -0xa0(%rbp)
movq -0x10(%rbp), %rsi
leaq -0xb8(%rbp), %rdi
leaq -0xa0(%rbp), %rdx
callq 0x97310
jmp 0xacc06
movq -0xa8(%rbp), %rax
movq %rax, -0x40(%rbp)
movups -0xb8(%rbp), %xmm0
movaps %xmm0, -0x50(%rbp)
leaq -0x38(%rbp), %rdi
leaq -0x50(%rbp), %rsi
callq 0xafc20
jmp 0xacc2b
movq -0x10(%rbp), %rdi
addq $0x3c0, %rdi            # imm = 0x3C0
movslq -0x80(%rbp), %rsi
callq 0xae4a0
movq %rax, -0x1d8(%rbp)
jmp 0xacc48
movq -0x1d8(%rbp), %rdi
addq $0x20, %rdi
callq 0xae590
movl %eax, -0xbc(%rbp)
movq -0x10(%rbp), %rdi
addq $0x3c0, %rdi            # imm = 0x3C0
movslq -0x80(%rbp), %rsi
callq 0xae4a0
movq %rax, -0x1e0(%rbp)
jmp 0xacc7b
movq -0x1e0(%rbp), %rdi
addq $0x38, %rdi
callq 0xae590
movl %eax, -0xc0(%rbp)
testb $0x1, -0x19(%rbp)
je 0xaccd7
movl -0xbc(%rbp), %esi
movl -0xc0(%rbp), %edx
leaq 0x14e117(%rip), %rdi    # 0x1fadc1
xorl %eax, %eax
callq 0x5070
jmp 0xaccb3
jmp 0xaccd7
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x58(%rbp)
movl %eax, -0x5c(%rbp)
jmp 0xad32f
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x58(%rbp)
movl %eax, -0x5c(%rbp)
jmp 0xad326
leaq -0xd8(%rbp), %rdi
callq 0xada60
movl $0x0, -0xdc(%rbp)
movl -0xdc(%rbp), %eax
cmpl -0xbc(%rbp), %eax
jge 0xacdf3
leaq -0x100(%rbp), %rdi
xorps %xmm2, %xmm2
movaps %xmm2, %xmm0
movaps %xmm2, %xmm1
callq 0xea8e0
jmp 0xacd16
movq -0x10(%rbp), %rdi
addq $0x3c0, %rdi            # imm = 0x3C0
movslq -0x80(%rbp), %rsi
callq 0xae4a0
movq %rax, -0x1e8(%rbp)
jmp 0xacd33
movq -0x1e8(%rbp), %rdi
addq $0x20, %rdi
movslq -0xdc(%rbp), %rsi
callq 0xae5c0
movq %rax, -0x1f0(%rbp)
jmp 0xacd53
movq -0x1f0(%rbp), %rax
movq 0x10(%rax), %rcx
movq %rcx, -0x110(%rbp)
movups (%rax), %xmm0
movaps %xmm0, -0x120(%rbp)
movq -0x10(%rbp), %rsi
leaq -0x138(%rbp), %rdi
leaq -0x120(%rbp), %rdx
callq 0x97310
jmp 0xacd88
movq -0x128(%rbp), %rax
movq %rax, -0xf0(%rbp)
movups -0x138(%rbp), %xmm0
movaps %xmm0, -0x100(%rbp)
leaq -0xd8(%rbp), %rdi
leaq -0x100(%rbp), %rsi
callq 0xafc20
jmp 0xacdb9
movl -0x7c(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x7c(%rbp)
movl -0xdc(%rbp), %eax
addl $0x1, %eax
movl %eax, -0xdc(%rbp)
jmp 0xacced
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x58(%rbp)
movl %eax, -0x5c(%rbp)
leaq -0xd8(%rbp), %rdi
callq 0x12210
jmp 0xad326
movl $0x0, -0x13c(%rbp)
movl -0x13c(%rbp), %eax
cmpl -0xc0(%rbp), %eax
jge 0xacee6
leaq -0x160(%rbp), %rdi
xorps %xmm2, %xmm2
movaps %xmm2, %xmm0
movaps %xmm2, %xmm1
callq 0xea8e0
jmp 0xace26
movq -0x10(%rbp), %rdi
addq $0x3c0, %rdi            # imm = 0x3C0
movslq -0x80(%rbp), %rsi
callq 0xae4a0
movq %rax, -0x1f8(%rbp)
jmp 0xace43
movq -0x1f8(%rbp), %rdi
addq $0x38, %rdi
movslq -0x13c(%rbp), %rsi
callq 0xae5c0
movq %rax, -0x200(%rbp)
jmp 0xace63
movq -0x200(%rbp), %rax
movq 0x10(%rax), %rcx
movq %rcx, -0x170(%rbp)
movups (%rax), %xmm0
movaps %xmm0, -0x180(%rbp)
movq -0x10(%rbp), %rsi
leaq -0x198(%rbp), %rdi
leaq -0x180(%rbp), %rdx
callq 0x97310
jmp 0xace98
movq -0x188(%rbp), %rax
movq %rax, -0x150(%rbp)
movups -0x198(%rbp), %xmm0
movaps %xmm0, -0x160(%rbp)
leaq -0xd8(%rbp), %rdi
leaq -0x160(%rbp), %rsi
callq 0xafc20
jmp 0xacec9
movl -0x7c(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x7c(%rbp)
movl -0x13c(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x13c(%rbp)
jmp 0xacdfd
leaq -0x78(%rbp), %rdi
leaq -0xd8(%rbp), %rsi
callq 0xafda0
jmp 0xacef8
leaq -0xd8(%rbp), %rdi
callq 0x12210
movl -0x80(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x80(%rbp)
jmp 0xacb86
leaq -0x38(%rbp), %rdi
callq 0xae590
movq -0x1c0(%rbp), %rdi
movl %eax, -0x19c(%rbp)
movq -0x8(%rbp), %rax
movq %rax, -0x208(%rbp)
callq 0x5200
movq -0x208(%rbp), %rdi
movq %rax, %rdx
movl -0x7c(%rbp), %ecx
addl -0x19c(%rbp), %ecx
leaq 0x14dea3(%rip), %rsi    # 0x1fadf5
movb $0x0, %al
callq 0x5750
movl $0x0, -0x1a0(%rbp)
movl -0x1a0(%rbp), %eax
cmpl -0x19c(%rbp), %eax
jge 0xad228
movq -0x8(%rbp), %rax
movq %rax, -0x218(%rbp)
movslq -0x1a0(%rbp), %rsi
leaq -0x38(%rbp), %rdi
callq 0xae5c0
movq %rax, -0x210(%rbp)
jmp 0xacf99
movq -0x210(%rbp), %rdi
xorl %esi, %esi
callq 0xead40
movq %rax, -0x220(%rbp)
jmp 0xacfb0
movq -0x220(%rbp), %rax
movsd (%rax), %xmm0
movsd %xmm0, -0x230(%rbp)
movslq -0x1a0(%rbp), %rsi
leaq -0x38(%rbp), %rdi
callq 0xae5c0
movq %rax, -0x228(%rbp)
jmp 0xacfdc
movq -0x228(%rbp), %rdi
movl $0x1, %esi
callq 0xead40
movq %rax, -0x238(%rbp)
jmp 0xacff6
movq -0x238(%rbp), %rax
movsd (%rax), %xmm0
movsd %xmm0, -0x248(%rbp)
movslq -0x1a0(%rbp), %rsi
leaq -0x38(%rbp), %rdi
callq 0xae5c0
movq %rax, -0x240(%rbp)
jmp 0xad022
movq -0x240(%rbp), %rdi
movl $0x2, %esi
callq 0xead40
movq %rax, -0x250(%rbp)
jmp 0xad03c
movsd -0x248(%rbp), %xmm1
movsd -0x230(%rbp), %xmm0
movq -0x218(%rbp), %rdi
movq -0x250(%rbp), %rax
movsd (%rax), %xmm2
leaq 0x14d3e8(%rip), %rsi    # 0x1fa44d
movb $0x3, %al
callq 0x5750
movslq -0x1a0(%rbp), %rsi
leaq -0x78(%rbp), %rdi
callq 0xafe10
movq %rax, -0x258(%rbp)
jmp 0xad085
movq -0x258(%rbp), %rdi
callq 0xae590
movl %eax, -0x1a4(%rbp)
movl $0x0, -0x1a8(%rbp)
movl -0x1a8(%rbp), %eax
cmpl -0x1a4(%rbp), %eax
jge 0xad212
movq -0x8(%rbp), %rax
movq %rax, -0x268(%rbp)
movslq -0x1a0(%rbp), %rsi
leaq -0x78(%rbp), %rdi
callq 0xafe10
movq %rax, -0x260(%rbp)
jmp 0xad0d7
movq -0x260(%rbp), %rdi
movslq -0x1a8(%rbp), %rsi
callq 0xae5c0
movq %rax, -0x270(%rbp)
jmp 0xad0f3
movq -0x270(%rbp), %rdi
xorl %esi, %esi
callq 0xead40
movq %rax, -0x278(%rbp)
jmp 0xad10a
movq -0x278(%rbp), %rax
movsd (%rax), %xmm0
movsd %xmm0, -0x288(%rbp)
movslq -0x1a0(%rbp), %rsi
leaq -0x78(%rbp), %rdi
callq 0xafe10
movq %rax, -0x280(%rbp)
jmp 0xad136
movq -0x280(%rbp), %rdi
movslq -0x1a8(%rbp), %rsi
callq 0xae5c0
movq %rax, -0x290(%rbp)
jmp 0xad152
movq -0x290(%rbp), %rdi
movl $0x1, %esi
callq 0xead40
movq %rax, -0x298(%rbp)
jmp 0xad16c
movq -0x298(%rbp), %rax
movsd (%rax), %xmm0
movsd %xmm0, -0x2a8(%rbp)
movslq -0x1a0(%rbp), %rsi
leaq -0x78(%rbp), %rdi
callq 0xafe10
movq %rax, -0x2a0(%rbp)
jmp 0xad198
movq -0x2a0(%rbp), %rdi
movslq -0x1a8(%rbp), %rsi
callq 0xae5c0
movq %rax, -0x2b0(%rbp)
jmp 0xad1b4
movq -0x2b0(%rbp), %rdi
movl $0x2, %esi
callq 0xead40
movq %rax, -0x2b8(%rbp)
jmp 0xad1ce
movsd -0x2a8(%rbp), %xmm1
movsd -0x288(%rbp), %xmm0
movq -0x268(%rbp), %rdi
movq -0x2b8(%rbp), %rax
movsd (%rax), %xmm2
leaq 0x14d256(%rip), %rsi    # 0x1fa44d
movb $0x3, %al
callq 0x5750
movl -0x1a8(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x1a8(%rbp)
jmp 0xad0a1
jmp 0xad214
movl -0x1a0(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x1a0(%rbp)
jmp 0xacf63
movq -0x8(%rbp), %rdi
movl -0x7c(%rbp), %edx
imull $0x3, -0x7c(%rbp), %ecx
leaq 0x149b64(%rip), %rsi    # 0x1f6d9e
movb $0x0, %al
callq 0x5750
movl $0x0, -0x1ac(%rbp)
movl $0x0, -0x1b0(%rbp)
movl -0x1b0(%rbp), %eax
cmpl -0x19c(%rbp), %eax
jge 0xad30b
movslq -0x1b0(%rbp), %rsi
leaq -0x78(%rbp), %rdi
callq 0xafe10
movq %rax, -0x2c0(%rbp)
jmp 0xad280
movq -0x2c0(%rbp), %rdi
callq 0xae590
movl %eax, -0x1b4(%rbp)
movl $0x0, -0x1b8(%rbp)
movl -0x1b8(%rbp), %eax
cmpl -0x1b4(%rbp), %eax
jge 0xad2e2
movq -0x8(%rbp), %rdi
movl -0x1ac(%rbp), %edx
movl -0x1ac(%rbp), %ecx
addl -0x1b8(%rbp), %ecx
addl $0x1, %ecx
leaq 0x149ae1(%rip), %rsi    # 0x1f6dab
movb $0x0, %al
callq 0x5750
movl -0x1b8(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x1b8(%rbp)
jmp 0xad29c
movl -0x1b4(%rbp), %eax
addl $0x1, %eax
addl -0x1ac(%rbp), %eax
movl %eax, -0x1ac(%rbp)
movl -0x1b0(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x1b0(%rbp)
jmp 0xad255
leaq -0x78(%rbp), %rdi
callq 0xafe50
leaq -0x38(%rbp), %rdi
callq 0x12210
addq $0x2c0, %rsp            # imm = 0x2C0
popq %rbp
retq
leaq -0x78(%rbp), %rdi
callq 0xafe50
leaq -0x38(%rbp), %rdi
callq 0x12210
movq -0x58(%rbp), %rdi
callq 0x58f0
nopw %cs:(%rax,%rax)