// File: /workspace/github_cpp_makefile_star2_O1/tomfunkhouser[P]gaps/pkgs/R3Shapes/R3Mesh.cpp
// Function: gaps::R3Mesh::CollapseShortEdges(double)
void R3Mesh::
CollapseShortEdges(RNLength min_edge_length)
{
  // Create priority queue for short edges
  RNHeap<R3MeshEdge *> heap(EdgeLengthCallback, NULL, this, TRUE);
  R3mesh_mark++;

  // Add short edges to priority queue
  for (int i = 0; i < NEdges(); i++) {
    R3MeshEdge *edge = Edge(i);
    RNLength length = EdgeLength(edge);
    if (length < min_edge_length) {
      SetEdgeMark(edge, R3mesh_mark);
      heap.Push(edge);
    }
  }

  // Collapse edges in shortest to longest order
  while (!heap.IsEmpty()) {
    R3MeshEdge *edge = heap.Pop();
    assert(EdgeMark(edge) == R3mesh_mark);
    assert(IsEdgeOnMesh(edge));

    // Remove edges to be deleted from queue (e01, e11)
    R3MeshVertex *v1 = VertexOnEdge(edge, 1);
    R3MeshFace *f0 = FaceOnEdge(edge, 0);  
    R3MeshFace *f1 = FaceOnEdge(edge, 1);  
    R3MeshEdge *e01 = (f0) ? EdgeAcrossVertex(v1, edge, f0) : NULL;
    R3MeshEdge *e11 = (f1) ? EdgeAcrossVertex(v1, edge, f1) : NULL;
    if (e01 && (EdgeMark(e01) == R3mesh_mark)) { heap.Remove(e01); SetEdgeMark(e01, 0); }
    if (e11 && (EdgeMark(e11) == R3mesh_mark)) { heap.Remove(e11); SetEdgeMark(e11, 0); }

    // Collapse edge
    R3MeshVertex *vertex = CollapseEdge(edge);
    if (!vertex) continue;

    // Update adjacent edges
    for (int i = 0; i < VertexValence(vertex); i++) {
      R3MeshEdge *edge = EdgeOnVertex(vertex, i);
      if (EdgeMark(edge) == R3mesh_mark) {
        heap.Update(edge);
      }
      else {
        RNLength length = EdgeLength(edge);
        if (length < min_edge_length) {
          SetEdgeMark(edge, R3mesh_mark);
          heap.Push(edge);
        }
      }
    }
  }
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x48, %rsp
movsd %xmm0, 0x8(%rsp)
movq %rdi, %rbx
xorpd %xmm0, %xmm0
movapd %xmm0, 0x10(%rsp)
movq $-0x1, 0x20(%rsp)
leaq 0x1f8(%rip), %rax       # 0x17167
movq %rax, 0x28(%rsp)
movq $0x0, 0x30(%rsp)
incl 0xce52d(%rip)           # 0xe54b0
movq %rdi, 0x38(%rsp)
movl $0x1, 0x40(%rsp)
cmpl $0x0, 0x24(%rdi)
jle 0x16feb
xorl %r12d, %r12d
leaq 0x10(%rsp), %r14
movq 0x18(%rbx), %rax
movq (%rax,%r12,8), %r15
testb $0x2, 0x38(%r15)
jne 0x16fbc
movq (%rbx), %rax
movq %rbx, %rdi
movq %r15, %rsi
callq *0x2b8(%rax)
movsd 0x8(%rsp), %xmm0
ucomisd 0x28(%r15), %xmm0
jbe 0x16fdf
movl 0xce4e0(%rip), %eax     # 0xe54b0
movl %eax, 0x48(%r15)
movq %r14, %rdi
movq %r15, %rsi
callq 0x23e1c
incq %r12
movslq 0x24(%rbx), %rax
cmpq %rax, %r12
jl 0x16f9e
cmpl $0x0, 0x18(%rsp)
je 0x17125
leaq 0x10(%rsp), %r14
movq %r14, %rdi
callq 0x23f18
movq %rax, %r15
movq 0x10(%rax), %r12
movq 0x18(%rax), %rcx
movq 0x20(%rax), %rbp
testq %rcx, %rcx
je 0x17027
movq %r12, %rsi
movq %r15, %rdx
callq 0x13922
movq %rax, %r13
jmp 0x1702a
xorl %r13d, %r13d
testq %rbp, %rbp
je 0x17042
movq %r12, %rsi
movq %r15, %rdx
movq %rbp, %rcx
callq 0x13922
movq %rax, %r12
jmp 0x17045
xorl %r12d, %r12d
testq %r13, %r13
je 0x17069
movl 0x48(%r13), %eax
cmpl 0xce45c(%rip), %eax     # 0xe54b0
jne 0x17069
movq %r14, %rdi
movq %r13, %rsi
callq 0x23fb2
movl $0x0, 0x48(%r13)
testq %r12, %r12
je 0x1708f
movl 0x48(%r12), %eax
cmpl 0xce437(%rip), %eax     # 0xe54b0
jne 0x1708f
movq %r14, %rdi
movq %r12, %rsi
callq 0x23fb2
movl $0x0, 0x48(%r12)
movq (%rbx), %rax
movq %rbx, %rdi
movq %r15, %rsi
callq *0xa8(%rax)
movq %rax, %r15
testq %rax, %rax
je 0x1711a
cmpl $0x0, 0x14(%r15)
jle 0x1711a
xorl %r13d, %r13d
movq 0x8(%r15), %rax
movq (%rax,%r13,8), %r12
movl 0x48(%r12), %eax
cmpl 0xce3ed(%rip), %eax     # 0xe54b0
jne 0x170d2
movq %r14, %rdi
movq %r12, %rsi
callq 0x240be
jmp 0x1710e
testb $0x2, 0x38(%r12)
jne 0x170e9
movq (%rbx), %rax
movq %rbx, %rdi
movq %r12, %rsi
callq *0x2b8(%rax)
movsd 0x8(%rsp), %xmm0
ucomisd 0x28(%r12), %xmm0
jbe 0x1710e
movl 0xce3b2(%rip), %eax     # 0xe54b0
movl %eax, 0x48(%r12)
movq %r14, %rdi
movq %r12, %rsi
callq 0x23e1c
incq %r13
movslq 0x14(%r15), %rax
cmpq %rax, %r13
jl 0x170b0
cmpl $0x0, 0x18(%rsp)
jne 0x16ffb
movq 0x10(%rsp), %rdi
testq %rdi, %rdi
je 0x17134
callq 0xe5b0
addq $0x48, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
jmp 0x1714d
jmp 0x1714d
jmp 0x1714d
jmp 0x1714d
jmp 0x1714d
movq %rax, %rbx
movq 0x10(%rsp), %rdi
testq %rdi, %rdi
je 0x1715f
callq 0xe5b0
movq %rbx, %rdi
callq 0xe7e0