// File: tomfunkhouser[P]gaps/pkgs/R3Shapes/R3Mesh.cpp
// Function: gaps::R3Mesh::SubdivideLongEdges(double)
void R3Mesh::
SubdivideLongEdges(RNLength max_edge_length)
{
  // Create priority queue for long edges
  RNHeap<R3MeshEdge *> heap(EdgeLengthCallback, NULL, this, FALSE);

  // Add long edges to priority queue
  for (int i = 0; i < NEdges(); i++) {
    R3MeshEdge *edge = Edge(i);
    RNLength length = EdgeLength(edge);
    if (length > max_edge_length) heap.Push(edge);
  }

  // Split edges in longest to shortest order
  while (!heap.IsEmpty()) {
    R3MeshEdge *edge = heap.Pop();
    R3MeshVertex *vertex = SubdivideEdge(edge);
    for (int i = 0; i < VertexValence(vertex); i++) {
      R3MeshEdge *edge = EdgeOnVertex(vertex, i);
      RNLength length = EdgeLength(edge);
      if (length > max_edge_length) heap.Push(edge);
    }
  }
}

// Assembly:
subq $0xe8, %rsp
movq %rdi, 0xe0(%rsp)
movsd %xmm0, 0xd8(%rsp)
movq 0xe0(%rsp), %rcx
movq %rcx, 0x48(%rsp)
leaq 0xa0(%rsp), %rdi
leaq -0x64(%rip), %rsi       # 0x1ec30
xorl %eax, %eax
movl %eax, %edx
xorl %r8d, %r8d
callq 0x37b90
movl $0x0, 0x9c(%rsp)
movq 0x48(%rsp), %rdi
movl 0x9c(%rsp), %eax
movl %eax, 0x40(%rsp)
callq 0x135c0
movl %eax, 0x44(%rsp)
jmp 0x1ecc6
movl 0x40(%rsp), %eax
movl 0x44(%rsp), %ecx
cmpl %ecx, %eax
jge 0x1ed89
movq 0x48(%rsp), %rdi
movl 0x9c(%rsp), %esi
callq 0x36930
movq %rax, 0x38(%rsp)
jmp 0x1ecee
movq 0x48(%rsp), %rdi
movq 0x38(%rsp), %rax
movq %rax, 0x80(%rsp)
movq 0x80(%rsp), %rsi
callq 0x13cc0
movsd %xmm0, 0x30(%rsp)
jmp 0x1ed15
movsd 0x30(%rsp), %xmm0
movsd %xmm0, 0x78(%rsp)
movsd 0x78(%rsp), %xmm0
ucomisd 0xd8(%rsp), %xmm0
jbe 0x1ed71
movq 0x80(%rsp), %rsi
leaq 0xa0(%rsp), %rdi
callq 0x37c20
jmp 0x1ed49
jmp 0x1ed71
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x90(%rsp)
movl %eax, 0x8c(%rsp)
leaq 0xa0(%rsp), %rdi
callq 0x38280
jmp 0x1eec1
jmp 0x1ed73
movl 0x9c(%rsp), %eax
addl $0x1, %eax
movl %eax, 0x9c(%rsp)
jmp 0x1ecab
jmp 0x1ed8b
leaq 0xa0(%rsp), %rdi
callq 0x37e40
movl %eax, 0x2c(%rsp)
jmp 0x1ed9e
movl 0x2c(%rsp), %eax
cmpl $0x0, %eax
setne %al
xorb $-0x1, %al
testb $0x1, %al
jne 0x1edb3
jmp 0x1eeac
leaq 0xa0(%rsp), %rdi
callq 0x37e60
movq %rax, 0x20(%rsp)
jmp 0x1edc7
movq 0x48(%rsp), %rdi
movq 0x20(%rsp), %rax
movq %rax, 0x70(%rsp)
movq 0x70(%rsp), %rsi
movq (%rdi), %rax
movq 0xc8(%rax), %rax
callq *%rax
movq %rax, 0x18(%rsp)
jmp 0x1edee
movq 0x18(%rsp), %rax
movq %rax, 0x68(%rsp)
movl $0x0, 0x64(%rsp)
movq 0x48(%rsp), %rdi
movl 0x64(%rsp), %eax
movl %eax, 0x10(%rsp)
movq 0x68(%rsp), %rsi
callq 0x36b50
movl %eax, 0x14(%rsp)
jmp 0x1ee1d
movl 0x10(%rsp), %eax
movl 0x14(%rsp), %ecx
cmpl %ecx, %eax
jge 0x1eea7
movq 0x48(%rsp), %rdi
movq 0x68(%rsp), %rsi
movl 0x64(%rsp), %edx
callq 0x36ec0
movq %rax, 0x8(%rsp)
jmp 0x1ee43
movq 0x48(%rsp), %rdi
movq 0x8(%rsp), %rax
movq %rax, 0x58(%rsp)
movq 0x58(%rsp), %rsi
callq 0x13cc0
movsd %xmm0, (%rsp)
jmp 0x1ee63
movsd (%rsp), %xmm0
movsd %xmm0, 0x50(%rsp)
movsd 0x50(%rsp), %xmm0
ucomisd 0xd8(%rsp), %xmm0
jbe 0x1ee95
movq 0x58(%rsp), %rsi
leaq 0xa0(%rsp), %rdi
callq 0x37c20
jmp 0x1ee93
jmp 0x1ee95
jmp 0x1ee97
movl 0x64(%rsp), %eax
addl $0x1, %eax
movl %eax, 0x64(%rsp)
jmp 0x1ee00
jmp 0x1ed8b
leaq 0xa0(%rsp), %rdi
callq 0x38280
addq $0xe8, %rsp
retq
movq 0x90(%rsp), %rdi
callq 0xf890
nop