// File: /workspace/github_cpp_makefile_star2_O1/Luthaf[P]zeopp/networkstorage.cc
// Function: add_2c_vertices_and_normal_edges(ATOM_NETWORK*)
void add_2c_vertices_and_normal_edges(ATOM_NETWORK *cell) { //just add the 2-c vertices and normal edges - dummy edges are handled later, once we know all the vertices by symmetry, and can make a better guess of the orthogonal direction of the 2-c vertices
  bool verbose = false;
  if(verbose) printf("augmenting underlying net with 2-c vertices\n");
  int num_v = cell->vertices.size();
  vector<XYZ> candidates;
  vector<XYZ> from_abc_vector, to_abc_vector; //, orthogonal_abc_vector;
  for(int i=0; i<num_v; i++) {
    XYZ v_abc = cell->vertices.at(i).abc;
    XYZ v_xyz = cell->abc_to_xyz_returning_XYZ(v_abc);
    int num_e = cell->vertices.at(i).edges.size();
    for(int j=0; j<num_e; j++) {
      XYZ e_abc = cell->vertices.at(i).edges.at(j);
      XYZ e_xyz = cell->abc_to_xyz_returning_XYZ(e_abc);
      XYZ this_edge_vector = get_vector_from_to(v_xyz, e_xyz);
      double this_edge_length = this_edge_vector.magnitude();
      XYZ this_candidate_abc = v_abc+(e_abc-v_abc).scale(0.5);
      XYZ this_candidate_xyz = cell->abc_to_xyz_returning_XYZ(this_candidate_abc);
      candidates.push_back(this_candidate_abc);
      from_abc_vector.push_back(v_abc);
      to_abc_vector.push_back(e_abc);
      //forget dummy edges for now - they are handled later
    }
  }
  int num_candidates = candidates.size();
  //find and remove any duplicates
  vector<bool> keep_vector;
  int num_new_vertices = 0;
  for(int i=0; i<num_candidates; i++) {
    //check against all previous candidates to see if we should reject this one
    bool keep = true;
    for(int j=0; j<i && keep; j++) {
      if(overlaps_abc(candidates.at(i),candidates.at(j),cell)) keep = false;
    }
    keep_vector.push_back(keep);
    if(keep) num_new_vertices++;
  }
  if(num_new_vertices>0) {
    //halve the edge lengths of all previous vertices to match these new short edges!
    for(int i=0; i<num_v; i++) {
      XYZ v_abc = cell->vertices.at(i).abc;
      int num_e = cell->vertices.at(i).edges.size();
      for(int j=0; j<num_e; j++) {
        XYZ e_abc = cell->vertices.at(i).edges.at(j);
        XYZ new_e_abc = v_abc+(e_abc-v_abc).scale(0.5);
        cell->vertices.at(i).edges.at(j) = new_e_abc;
      }
    }
    //set up final vertices
    for(int i=0; i<num_candidates; i++) {
      if(keep_vector.at(i)) {
        if(verbose) printf("accepted candidate ID %d: %.3f %.3f %.3f\n", i, candidates.at(i).x, candidates.at(i).y, candidates.at(i).z);
        VERTEX v(candidates.at(i).x, candidates.at(i).y, candidates.at(i).z);
        v.expected_edges = 2; //it is a 2-c vertex
        v.edges.push_back(from_abc_vector.at(i));
        v.edges.push_back(to_abc_vector.at(i));
        cell->vertices.push_back(v);
      }
    }
  }
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x1e8, %rsp            # imm = 0x1E8
movq %rdi, %rbx
movq 0x3c8(%rdi), %rax
subq 0x3c0(%rdi), %rax
sarq $0x4, %rax
movabsq $0x6db6db6db6db6db7, %rcx # imm = 0x6DB6DB6DB6DB6DB7
imulq %rcx, %rax
xorl %ecx, %ecx
movq %rcx, 0x50(%rsp)
xorps %xmm0, %xmm0
movaps %xmm0, 0x40(%rsp)
movq %rcx, 0xe0(%rsp)
movaps %xmm0, 0xd0(%rsp)
movq %rcx, 0xc0(%rsp)
movaps %xmm0, 0xb0(%rsp)
movq %rax, 0x38(%rsp)
testl %eax, %eax
jle 0x64257
movq 0x38(%rsp), %rax
andl $0x7fffffff, %eax       # imm = 0x7FFFFFFF
movq %rax, 0xf0(%rsp)
xorl %r14d, %r14d
movq 0x3c0(%rbx), %rax
movq 0x3c8(%rbx), %rdx
subq %rax, %rdx
sarq $0x4, %rdx
movabsq $0x6db6db6db6db6db7, %rcx # imm = 0x6DB6DB6DB6DB6DB7
imulq %rcx, %rdx
cmpq %r14, %rdx
jbe 0x64876
imulq $0x70, %r14, %r13
movq 0x10(%rax,%r13), %rcx
movq %rcx, 0x120(%rsp)
movups (%rax,%r13), %xmm0
movaps %xmm0, 0x110(%rsp)
movsd 0x110(%rsp), %xmm0
movsd 0x118(%rsp), %xmm1
movsd 0x120(%rsp), %xmm2
leaq 0x68(%rsp), %rdi
movq %rbx, %rsi
callq 0x530d6
movq 0x3c0(%rbx), %rax
movq 0x3c8(%rbx), %rdx
subq %rax, %rdx
sarq $0x4, %rdx
movabsq $0x6db6db6db6db6db7, %rcx # imm = 0x6DB6DB6DB6DB6DB7
imulq %rcx, %rdx
movq %r14, 0x30(%rsp)
cmpq %r14, %rdx
jbe 0x64863
movq 0x28(%rax,%r13), %rbp
subq 0x20(%rax,%r13), %rbp
sarq $0x3, %rbp
movabsq $-0x5555555555555555, %rax # imm = 0xAAAAAAAAAAAAAAAB
imulq %rax, %rbp
testl %ebp, %ebp
jle 0x64241
andl $0x7fffffff, %ebp       # imm = 0x7FFFFFFF
xorl %r12d, %r12d
xorl %r14d, %r14d
movq 0x3c0(%rbx), %rcx
movq 0x3c8(%rbx), %rdx
subq %rcx, %rdx
sarq $0x4, %rdx
movabsq $0x6db6db6db6db6db7, %rax # imm = 0x6DB6DB6DB6DB6DB7
imulq %rax, %rdx
cmpq 0x30(%rsp), %rdx
jbe 0x64828
movq 0x20(%rcx,%r13), %rax
movq 0x28(%rcx,%r13), %rdx
subq %rax, %rdx
sarq $0x3, %rdx
movabsq $-0x5555555555555555, %rcx # imm = 0xAAAAAAAAAAAAAAAB
imulq %rcx, %rdx
cmpq %r14, %rdx
jbe 0x64823
movq 0x10(%rax,%r12), %rcx
movq %rcx, 0xa0(%rsp)
movups (%rax,%r12), %xmm0
movaps %xmm0, 0x90(%rsp)
movsd 0x90(%rsp), %xmm0
movsd 0x98(%rsp), %xmm1
movsd 0xa0(%rsp), %xmm2
leaq 0x188(%rsp), %rdi
movq %rbx, %rsi
callq 0x530d6
movq 0x198(%rsp), %rax
movq %rax, 0x28(%rsp)
movups 0x188(%rsp), %xmm0
movups %xmm0, 0x18(%rsp)
movq 0x78(%rsp), %rax
movq %rax, 0x10(%rsp)
movups 0x68(%rsp), %xmm0
movups %xmm0, (%rsp)
leaq 0x1a0(%rsp), %r15
movq %r15, %rdi
callq 0x85e6b
movq %r15, %rdi
callq 0x84e36
leaq 0x1b8(%rsp), %rdi
leaq 0x90(%rsp), %rsi
leaq 0x110(%rsp), %rdx
callq 0x85da6
leaq 0x1d0(%rsp), %r15
movq %r15, %rdi
leaq 0x1b8(%rsp), %rsi
movsd 0xeaf19(%rip), %xmm0    # 0x14f038
callq 0x85a34
leaq 0xf8(%rsp), %rdi
leaq 0x110(%rsp), %rsi
movq %r15, %rdx
callq 0x85dd4
movsd 0xf8(%rsp), %xmm0
movsd 0x100(%rsp), %xmm1
movsd 0x108(%rsp), %xmm2
movq %r15, %rdi
movq %rbx, %rsi
callq 0x530d6
movq 0x48(%rsp), %rsi
cmpq 0x50(%rsp), %rsi
je 0x6418d
movq 0x108(%rsp), %rax
movq %rax, 0x10(%rsi)
movups 0xf8(%rsp), %xmm0
movups %xmm0, (%rsi)
addq $0x18, 0x48(%rsp)
jmp 0x6419f
leaq 0x40(%rsp), %rdi
leaq 0xf8(%rsp), %rdx
callq 0x6a5be
movq 0xd8(%rsp), %rsi
cmpq 0xe0(%rsp), %rsi
je 0x641d3
movq 0x120(%rsp), %rax
movq %rax, 0x10(%rsi)
movaps 0x110(%rsp), %xmm0
movups %xmm0, (%rsi)
addq $0x18, 0xd8(%rsp)
jmp 0x641e8
leaq 0xd0(%rsp), %rdi
leaq 0x110(%rsp), %rdx
callq 0x6a5be
movq 0xb8(%rsp), %rsi
cmpq 0xc0(%rsp), %rsi
je 0x6421c
movq 0xa0(%rsp), %rax
movq %rax, 0x10(%rsi)
movaps 0x90(%rsp), %xmm0
movups %xmm0, (%rsi)
addq $0x18, 0xb8(%rsp)
jmp 0x64231
leaq 0xb0(%rsp), %rdi
leaq 0x90(%rsp), %rdx
callq 0x6a5be
incq %r14
addq $0x18, %r12
cmpq %r14, %rbp
jne 0x64007
movq 0x30(%rsp), %r14
incq %r14
cmpq 0xf0(%rsp), %r14
jne 0x63f34
movq 0x48(%rsp), %rcx
subq 0x40(%rsp), %rcx
sarq $0x3, %rcx
movabsq $-0x5555555555555555, %rax # imm = 0xAAAAAAAAAAAAAAAB
imulq %rax, %rcx
xorl %eax, %eax
movq %rax, 0x68(%rsp)
movl %eax, 0x70(%rsp)
movq %rax, 0x78(%rsp)
movl %eax, 0x80(%rsp)
movq %rax, 0x88(%rsp)
movq %rcx, 0x60(%rsp)
testl %ecx, %ecx
jle 0x64773
leaq 0x3c0(%rbx), %rax
movq %rax, 0x180(%rsp)
movq 0x60(%rsp), %rax
andl $0x7fffffff, %eax       # imm = 0x7FFFFFFF
movq %rax, 0xf0(%rsp)
xorl %ebp, %ebp
xorl %r12d, %r12d
testq %rbp, %rbp
je 0x6437c
movl %r12d, 0x30(%rsp)
movb $0x1, %r15b
leaq (,%rbp,2), %r12
addq %rbp, %r12
xorl %r13d, %r13d
xorl %r14d, %r14d
movq 0x40(%rsp), %rax
movq 0x48(%rsp), %rdx
subq %rax, %rdx
sarq $0x3, %rdx
movabsq $-0x5555555555555555, %rcx # imm = 0xAAAAAAAAAAAAAAAB
imulq %rcx, %rdx
cmpq %rbp, %rdx
jbe 0x64812
cmpq %r14, %rdx
jbe 0x6480f
movq 0x10(%rax,%r13), %rcx
movq %rcx, 0x28(%rsp)
movups (%rax,%r13), %xmm0
movups %xmm0, 0x18(%rsp)
movq 0x10(%rax,%r12,8), %rcx
movq %rcx, 0x10(%rsp)
movups (%rax,%r12,8), %xmm0
movups %xmm0, (%rsp)
movq %rbx, %rdi
callq 0x5a244
movzbl %r15b, %r15d
testb %al, %al
movl $0x0, %eax
cmovnel %eax, %r15d
incq %r14
cmpq %rbp, %r14
jae 0x6436c
addq $0x18, %r13
testb $0x1, %r15b
jne 0x642e7
movl %r15d, %eax
andb $0x1, %al
movzbl %al, %r14d
movl 0x30(%rsp), %r12d
jmp 0x64385
movb $0x1, %r15b
movl $0x1, %r14d
movzbl %r15b, %esi
andl $0x1, %esi
leaq 0x68(%rsp), %rdi
callq 0xe9e6
addl %r14d, %r12d
incq %rbp
cmpq 0xf0(%rsp), %rbp
jne 0x642c5
testl %r12d, %r12d
je 0x64773
cmpl $0x0, 0x38(%rsp)
jle 0x6459c
movq 0x38(%rsp), %rax
andl $0x7fffffff, %eax       # imm = 0x7FFFFFFF
movq %rax, 0x38(%rsp)
xorl %ebp, %ebp
movq 0x3c0(%rbx), %rax
movq 0x3c8(%rbx), %rdx
subq %rax, %rdx
sarq $0x4, %rdx
movabsq $0x6db6db6db6db6db7, %rcx # imm = 0x6DB6DB6DB6DB6DB7
imulq %rcx, %rdx
cmpq %rbp, %rdx
jbe 0x648a9
imulq $0x70, %rbp, %r13
movq 0x10(%rax,%r13), %rcx
movq %rcx, 0x120(%rsp)
movups (%rax,%r13), %xmm0
movaps %xmm0, 0x110(%rsp)
movq 0x28(%rax,%r13), %r12
subq 0x20(%rax,%r13), %r12
sarq $0x3, %r12
movabsq $-0x5555555555555555, %rax # imm = 0xAAAAAAAAAAAAAAAB
imulq %rax, %r12
testl %r12d, %r12d
jle 0x6458e
andl $0x7fffffff, %r12d      # imm = 0x7FFFFFFF
xorl %r14d, %r14d
xorl %r15d, %r15d
movq 0x3c0(%rbx), %rcx
movq 0x3c8(%rbx), %rdx
subq %rcx, %rdx
sarq $0x4, %rdx
movabsq $0x6db6db6db6db6db7, %rax # imm = 0x6DB6DB6DB6DB6DB7
imulq %rax, %rdx
cmpq %rbp, %rdx
jbe 0x6483e
movq 0x20(%rcx,%r13), %rax
movq 0x28(%rcx,%r13), %rdx
subq %rax, %rdx
sarq $0x3, %rdx
movabsq $-0x5555555555555555, %rcx # imm = 0xAAAAAAAAAAAAAAAB
imulq %rcx, %rdx
cmpq %r15, %rdx
jbe 0x6483b
movq 0x10(%rax,%r14), %rcx
movq %rcx, 0xa0(%rsp)
movups (%rax,%r14), %xmm0
movaps %xmm0, 0x90(%rsp)
leaq 0xf8(%rsp), %rdi
leaq 0x90(%rsp), %rsi
leaq 0x110(%rsp), %rdx
callq 0x85da6
leaq 0x1a0(%rsp), %rdi
leaq 0xf8(%rsp), %rsi
movsd 0xeab4a(%rip), %xmm0    # 0x14f038
callq 0x85a34
leaq 0x188(%rsp), %rdi
leaq 0x110(%rsp), %rsi
leaq 0x1a0(%rsp), %rdx
callq 0x85dd4
movq 0x3c0(%rbx), %rcx
movq 0x3c8(%rbx), %rdx
subq %rcx, %rdx
sarq $0x4, %rdx
movabsq $0x6db6db6db6db6db7, %rax # imm = 0x6DB6DB6DB6DB6DB7
imulq %rax, %rdx
cmpq %rbp, %rdx
jbe 0x64852
movq 0x20(%rcx,%r13), %rax
movq 0x28(%rcx,%r13), %rdx
subq %rax, %rdx
sarq $0x3, %rdx
movabsq $-0x5555555555555555, %rcx # imm = 0xAAAAAAAAAAAAAAAB
imulq %rcx, %rdx
cmpq %r15, %rdx
jbe 0x6484f
movq 0x198(%rsp), %rcx
movq %rcx, 0x10(%rax,%r14)
movups 0x188(%rsp), %xmm0
movups %xmm0, (%rax,%r14)
incq %r15
addq $0x18, %r14
cmpq %r15, %r12
jne 0x6444b
incq %rbp
cmpq 0x38(%rsp), %rbp
jne 0x643cf
leaq 0x130(%rsp), %r15
leaq 0x170(%rsp), %r14
movq 0x60(%rsp), %rax
andl $0x7fffffff, %eax       # imm = 0x7FFFFFFF
movq %rax, 0x60(%rsp)
xorl %ebp, %ebp
leaq 0x68(%rsp), %r12
leaq 0x110(%rsp), %r13
xorl %ebx, %ebx
movq %r12, %rdi
movq %rbx, %rsi
callq 0xedb6
testq %rdx, (%rax)
je 0x64761
movq 0x40(%rsp), %rax
movq 0x48(%rsp), %rdx
subq %rax, %rdx
sarq $0x3, %rdx
movabsq $-0x5555555555555555, %rcx # imm = 0xAAAAAAAAAAAAAAAB
imulq %rcx, %rdx
cmpq %rbx, %rdx
jbe 0x64898
movsd (%rax,%rbp), %xmm0
movsd 0x8(%rax,%rbp), %xmm1
movsd 0x10(%rax,%rbp), %xmm2
movq %r13, %rdi
callq 0x9f1d4
movl $0x2, 0x128(%rsp)
movq 0xd0(%rsp), %rax
movq 0xd8(%rsp), %rdx
subq %rax, %rdx
sarq $0x3, %rdx
movabsq $-0x5555555555555555, %rcx # imm = 0xAAAAAAAAAAAAAAAB
imulq %rcx, %rdx
cmpq %rbx, %rdx
jbe 0x64887
addq %rbp, %rax
movq 0x138(%rsp), %rsi
cmpq 0x140(%rsp), %rsi
je 0x64688
movq 0x10(%rax), %rcx
movq %rcx, 0x10(%rsi)
movups (%rax), %xmm0
movups %xmm0, (%rsi)
addq $0x18, 0x138(%rsp)
jmp 0x64693
movq %r15, %rdi
movq %rax, %rdx
callq 0x6a5be
movq 0xb0(%rsp), %rax
movq 0xb8(%rsp), %rdx
subq %rax, %rdx
sarq $0x3, %rdx
movabsq $-0x5555555555555555, %rcx # imm = 0xAAAAAAAAAAAAAAAB
imulq %rcx, %rdx
cmpq %rbx, %rdx
jbe 0x64887
addq %rbp, %rax
movq 0x138(%rsp), %rsi
cmpq 0x140(%rsp), %rsi
je 0x646ef
movq 0x10(%rax), %rcx
movq %rcx, 0x10(%rsi)
movups (%rax), %xmm0
movups %xmm0, (%rsi)
addq $0x18, 0x138(%rsp)
jmp 0x646fa
movq %r15, %rdi
movq %rax, %rdx
callq 0x6a5be
movq 0x180(%rsp), %rdi
movq %r13, %rsi
callq 0x68242
movq 0x160(%rsp), %rdi
cmpq %r14, %rdi
je 0x64727
movq 0x170(%rsp), %rsi
incq %rsi
callq 0x4470
movq 0x148(%rsp), %rdi
testq %rdi, %rdi
je 0x64744
movq 0x158(%rsp), %rsi
subq %rdi, %rsi
callq 0x4470
movq 0x130(%rsp), %rdi
testq %rdi, %rdi
je 0x64761
movq 0x140(%rsp), %rsi
subq %rdi, %rsi
callq 0x4470
incq %rbx
addq $0x18, %rbp
cmpq %rbx, 0x60(%rsp)
jne 0x645cc
movq 0x68(%rsp), %rdi
testq %rdi, %rdi
je 0x647ac
movq 0x88(%rsp), %rsi
subq %rdi, %rsi
callq 0x4470
xorl %eax, %eax
movq %rax, 0x68(%rsp)
movl %eax, 0x70(%rsp)
movq %rax, 0x78(%rsp)
movl %eax, 0x80(%rsp)
movq %rax, 0x88(%rsp)
movq 0xb0(%rsp), %rdi
testq %rdi, %rdi
je 0x647c9
movq 0xc0(%rsp), %rsi
subq %rdi, %rsi
callq 0x4470
movq 0xd0(%rsp), %rdi
testq %rdi, %rdi
je 0x647e6
movq 0xe0(%rsp), %rsi
subq %rdi, %rsi
callq 0x4470
movq 0x40(%rsp), %rdi
testq %rdi, %rdi
je 0x647fd
movq 0x50(%rsp), %rsi
subq %rdi, %rsi
callq 0x4470
addq $0x1e8, %rsp            # imm = 0x1E8
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq %r14, %rbp
leaq 0xeae8c(%rip), %rdi     # 0x14f6a5
movq %rbp, %rsi
xorl %eax, %eax
callq 0x4630
movq %r14, %rsi
jmp 0x6482d
movq 0x30(%rsp), %rsi
leaq 0xeae71(%rip), %rdi     # 0x14f6a5
xorl %eax, %eax
callq 0x4630
movq %r15, %rbp
leaq 0xeae60(%rip), %rdi     # 0x14f6a5
movq %rbp, %rsi
xorl %eax, %eax
callq 0x4630
movq %r15, %rbp
leaq 0xeae4c(%rip), %rdi     # 0x14f6a5
movq %rbp, %rsi
xorl %eax, %eax
callq 0x4630
leaq 0xeae3b(%rip), %rdi     # 0x14f6a5
movq 0x30(%rsp), %rsi
xorl %eax, %eax
callq 0x4630
leaq 0xeae28(%rip), %rdi     # 0x14f6a5
movq %r14, %rsi
xorl %eax, %eax
callq 0x4630
leaq 0xeae17(%rip), %rdi     # 0x14f6a5
movq %rbx, %rsi
xorl %eax, %eax
callq 0x4630
leaq 0xeae06(%rip), %rdi     # 0x14f6a5
movq %rbx, %rsi
xorl %eax, %eax
callq 0x4630
leaq 0xeadf5(%rip), %rdi     # 0x14f6a5
movq %rbp, %rsi
xorl %eax, %eax
callq 0x4630
jmp 0x648ee
jmp 0x648ee
jmp 0x648ee
jmp 0x648ee
jmp 0x648c4
movq %rax, %rbx
leaq 0x110(%rsp), %rdi
callq 0x679f6
jmp 0x648f1
jmp 0x6492e
jmp 0x6492e
jmp 0x6492e
jmp 0x648ee
jmp 0x648ee
jmp 0x648ee
jmp 0x6492e
jmp 0x6492e
jmp 0x6492e
jmp 0x648ee
jmp 0x648ee
jmp 0x6492e
movq %rax, %rbx
movq 0x68(%rsp), %rdi
testq %rdi, %rdi
je 0x64931
movq 0x88(%rsp), %rsi
subq %rdi, %rsi
callq 0x4470
xorl %eax, %eax
movq %rax, 0x68(%rsp)
movl %eax, 0x70(%rsp)
movq %rax, 0x78(%rsp)
movl %eax, 0x80(%rsp)
movq %rax, 0x88(%rsp)
jmp 0x64931
jmp 0x6492e
movq %rax, %rbx
movq 0xb0(%rsp), %rdi
testq %rdi, %rdi
je 0x6494e
movq 0xc0(%rsp), %rsi
subq %rdi, %rsi
callq 0x4470
movq 0xd0(%rsp), %rdi
testq %rdi, %rdi
je 0x6496b
movq 0xe0(%rsp), %rsi
subq %rdi, %rsi
callq 0x4470
movq 0x40(%rsp), %rdi
testq %rdi, %rdi
je 0x64982
movq 0x50(%rsp), %rsi
subq %rdi, %rsi
callq 0x4470
movq %rbx, %rdi
callq 0x4780