// File: tomfunkhouser[P]gaps/apps/msh2prp/msh2prp.cpp
// Function: ComputeDijkstraDistanceProperties(gaps::R3Mesh*)
static R3MeshPropertySet *
ComputeDijkstraDistanceProperties(R3Mesh *mesh)
{
  // Start statistics
  RNTime start_time;
  start_time.Read();
  if (print_verbose) {
    printf("Computing dijkstra distance properties ...\n");
    fflush(stdout);
  }

  // Allocate property set
  R3MeshPropertySet *properties = new R3MeshPropertySet(mesh);
  if (!properties) {
    RNFail("Unable to allocate property set.\n");
    return NULL;
  }

  // Allocate/insert properties
  R3MeshProperty *mean_property = new R3MeshProperty(mesh, "DijkstraDistanceMean");
  R3MeshProperty *stddev_property = new R3MeshProperty(mesh, "DijkstraDistanceStddev");
  R3MeshProperty *median_property = new R3MeshProperty(mesh, "DijkstraDistanceMedian");
  R3MeshProperty *ten_property = new R3MeshProperty(mesh, "DijkstraDistanceTen");
  R3MeshProperty *ninety_property = new R3MeshProperty(mesh, "DijkstraDistanceNinety");
  R3MeshProperty *maximum_property = new R3MeshProperty(mesh, "DijkstraDistanceMaximum");
 
  // Compute properties
  for (int i = 0; i < mesh->NVertices(); i++) {
    R3MeshVertex *vertex = mesh->Vertex(i);
    RNLength *distances = mesh->DijkstraDistances(vertex);
    mean_property->SetVertexValue(i, Mean(distances, mesh->NVertices()));
    stddev_property->SetVertexValue(i, StandardDeviation(distances, mesh->NVertices()));
    median_property->SetVertexValue(i, Median(distances, mesh->NVertices()));
    ten_property->SetVertexValue(i, Percentile(distances, mesh->NVertices(), 10));
    ninety_property->SetVertexValue(i, Percentile(distances, mesh->NVertices(), 90));
    maximum_property->SetVertexValue(i, Maximum(distances, mesh->NVertices()));
    delete [] distances;
  }

  // Insert properties
  InsertProperty(properties, mean_property);
  InsertProperty(properties, stddev_property);
  InsertProperty(properties, median_property);
  InsertProperty(properties, ten_property);
  InsertProperty(properties, ninety_property);
  InsertProperty(properties, maximum_property);

  // Print statistics
  if (print_verbose) {
    printf("  Time = %.2f seconds\n", start_time.Elapsed());
    printf("  # Properties = %d\n", properties->NProperties());
    fflush(stdout);
  }

  // Return property set
  return properties;
}

// Assembly:
subq $0x158, %rsp            # imm = 0x158
movq %rdi, 0x148(%rsp)
leaq 0x138(%rsp), %rdi
callq 0xe98e0
leaq 0x138(%rsp), %rdi
callq 0x1f280
cmpl $0x0, 0x1b0c80(%rip)    # 0x1ca740
je 0x19adf
leaq 0x15a9cf(%rip), %rdi    # 0x174498
movb $0x0, %al
callq 0x11090
movq 0x1a74b9(%rip), %rax    # 0x1c0f90
movq (%rax), %rdi
callq 0x117f0
movl $0x18, %edi
callq 0x11680
movq %rax, %rdi
movq %rdi, %rax
movq %rax, 0xd0(%rsp)
movq 0x148(%rsp), %rsi
callq 0x24ce0
jmp 0x19b06
movq 0xd0(%rsp), %rax
movq %rax, 0x130(%rsp)
cmpq $0x0, 0x130(%rsp)
jne 0x19b6b
leaq 0x15a72e(%rip), %rdi    # 0x174256
movb $0x0, %al
callq 0xedb00
movq $0x0, 0x150(%rsp)
jmp 0x1a177
movq 0xd0(%rsp), %rdi
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x128(%rsp)
movl %eax, 0x124(%rsp)
movl $0x18, %esi
callq 0x11690
jmp 0x1a187
movl $0x448, %edi            # imm = 0x448
callq 0x11680
movq %rax, %rdi
movq %rdi, %rax
movq %rax, 0xc8(%rsp)
movq 0x148(%rsp), %rsi
leaq 0x15a932(%rip), %rdx    # 0x1744c4
xorl %eax, %eax
movl %eax, %ecx
callq 0x27ef0
jmp 0x19b9d
movq 0xc8(%rsp), %rax
movq %rax, 0x118(%rsp)
movl $0x448, %edi            # imm = 0x448
callq 0x11680
movq %rax, %rdi
movq %rdi, %rax
movq %rax, 0xc0(%rsp)
movq 0x148(%rsp), %rsi
leaq 0x15a905(%rip), %rdx    # 0x1744d9
xorl %eax, %eax
movl %eax, %ecx
callq 0x27ef0
jmp 0x19bdf
movq 0xc0(%rsp), %rax
movq %rax, 0x110(%rsp)
movl $0x448, %edi            # imm = 0x448
callq 0x11680
movq %rax, %rdi
movq %rdi, %rax
movq %rax, 0xb8(%rsp)
movq 0x148(%rsp), %rsi
leaq 0x15a8da(%rip), %rdx    # 0x1744f0
xorl %eax, %eax
movl %eax, %ecx
callq 0x27ef0
jmp 0x19c21
movq 0xb8(%rsp), %rax
movq %rax, 0x108(%rsp)
movl $0x448, %edi            # imm = 0x448
callq 0x11680
movq %rax, %rdi
movq %rdi, %rax
movq %rax, 0xb0(%rsp)
movq 0x148(%rsp), %rsi
leaq 0x15a8af(%rip), %rdx    # 0x174507
xorl %eax, %eax
movl %eax, %ecx
callq 0x27ef0
jmp 0x19c63
movq 0xb0(%rsp), %rax
movq %rax, 0x100(%rsp)
movl $0x448, %edi            # imm = 0x448
callq 0x11680
movq %rax, %rdi
movq %rdi, %rax
movq %rax, 0xa8(%rsp)
movq 0x148(%rsp), %rsi
leaq 0x15a881(%rip), %rdx    # 0x17451b
xorl %eax, %eax
movl %eax, %ecx
callq 0x27ef0
jmp 0x19ca5
movq 0xa8(%rsp), %rax
movq %rax, 0xf8(%rsp)
movl $0x448, %edi            # imm = 0x448
callq 0x11680
movq %rax, %rdi
movq %rdi, %rax
movq %rax, 0xa0(%rsp)
movq 0x148(%rsp), %rsi
leaq 0x15a856(%rip), %rdx    # 0x174532
xorl %eax, %eax
movl %eax, %ecx
callq 0x27ef0
jmp 0x19ce7
movq 0xa0(%rsp), %rax
movq %rax, 0xf0(%rsp)
movl $0x0, 0xec(%rsp)
movl 0xec(%rsp), %eax
movl %eax, 0x9c(%rsp)
movq 0x148(%rsp), %rdi
callq 0x1f2e0
movl %eax, %ecx
movl 0x9c(%rsp), %eax
cmpl %ecx, %eax
jge 0x1a08d
movq 0x148(%rsp), %rdi
movl 0xec(%rsp), %esi
callq 0x1f380
movq %rax, 0xe0(%rsp)
movq 0x148(%rsp), %rdi
movq 0xe0(%rsp), %rsi
xorps %xmm0, %xmm0
xorl %eax, %eax
movl %eax, %edx
callq 0x42780
movq %rax, 0xd8(%rsp)
movq 0x118(%rsp), %rax
movq %rax, 0x8(%rsp)
movl 0xec(%rsp), %eax
movl %eax, 0x14(%rsp)
movq 0xd8(%rsp), %rax
movq %rax, (%rsp)
movq 0x148(%rsp), %rdi
callq 0x1f2e0
movq (%rsp), %rdi
movl %eax, %esi
callq 0x1ce70
movq 0x8(%rsp), %rdi
movl 0x14(%rsp), %esi
callq 0x2ae50
movq 0x110(%rsp), %rax
movq %rax, 0x20(%rsp)
movl 0xec(%rsp), %eax
movl %eax, 0x2c(%rsp)
movq 0xd8(%rsp), %rax
movq %rax, 0x18(%rsp)
movq 0x148(%rsp), %rdi
callq 0x1f2e0
movq 0x18(%rsp), %rdi
movl %eax, %esi
callq 0x1cef0
movq 0x20(%rsp), %rdi
movl 0x2c(%rsp), %esi
callq 0x2ae50
movq 0x108(%rsp), %rax
movq %rax, 0x38(%rsp)
movl 0xec(%rsp), %eax
movl %eax, 0x44(%rsp)
movq 0xd8(%rsp), %rax
movq %rax, 0x30(%rsp)
movq 0x148(%rsp), %rdi
callq 0x1f2e0
movq 0x30(%rsp), %rdi
movl %eax, %esi
callq 0x1cfb0
movq 0x38(%rsp), %rdi
movl 0x44(%rsp), %esi
callq 0x2ae50
movq 0x100(%rsp), %rax
movq %rax, 0x50(%rsp)
movl 0xec(%rsp), %eax
movl %eax, 0x5c(%rsp)
movq 0xd8(%rsp), %rax
movq %rax, 0x48(%rsp)
movq 0x148(%rsp), %rdi
callq 0x1f2e0
movq 0x48(%rsp), %rdi
movl %eax, %esi
movsd 0x15a1b7(%rip), %xmm0   # 0x174048
callq 0x1cfe0
movq 0x50(%rsp), %rdi
movl 0x5c(%rsp), %esi
callq 0x2ae50
movq 0xf8(%rsp), %rax
movq %rax, 0x68(%rsp)
movl 0xec(%rsp), %eax
movl %eax, 0x74(%rsp)
movq 0xd8(%rsp), %rax
movq %rax, 0x60(%rsp)
movq 0x148(%rsp), %rdi
callq 0x1f2e0
movq 0x60(%rsp), %rdi
movl %eax, %esi
movsd 0x15a15b(%rip), %xmm0   # 0x174040
callq 0x1cfe0
movq 0x68(%rsp), %rdi
movl 0x74(%rsp), %esi
callq 0x2ae50
movq 0xf0(%rsp), %rax
movq %rax, 0x80(%rsp)
movl 0xec(%rsp), %eax
movl %eax, 0x8c(%rsp)
movq 0xd8(%rsp), %rax
movq %rax, 0x78(%rsp)
movq 0x148(%rsp), %rdi
callq 0x1f2e0
movq 0x78(%rsp), %rdi
movl %eax, %esi
callq 0x1d110
movq 0x80(%rsp), %rdi
movl 0x8c(%rsp), %esi
callq 0x2ae50
movq 0xd8(%rsp), %rax
movq %rax, 0x90(%rsp)
cmpq $0x0, %rax
je 0x19f73
movq 0x90(%rsp), %rdi
callq 0x118b0
jmp 0x19f75
movl 0xec(%rsp), %eax
addl $0x1, %eax
movl %eax, 0xec(%rsp)
jmp 0x19d02
movq 0xc8(%rsp), %rdi
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x128(%rsp)
movl %eax, 0x124(%rsp)
movl $0x448, %esi            # imm = 0x448
callq 0x11690
jmp 0x1a187
movq 0xc0(%rsp), %rdi
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x128(%rsp)
movl %eax, 0x124(%rsp)
movl $0x448, %esi            # imm = 0x448
callq 0x11690
jmp 0x1a187
movq 0xb8(%rsp), %rdi
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x128(%rsp)
movl %eax, 0x124(%rsp)
movl $0x448, %esi            # imm = 0x448
callq 0x11690
jmp 0x1a187
movq 0xb0(%rsp), %rdi
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x128(%rsp)
movl %eax, 0x124(%rsp)
movl $0x448, %esi            # imm = 0x448
callq 0x11690
jmp 0x1a187
movq 0xa8(%rsp), %rdi
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x128(%rsp)
movl %eax, 0x124(%rsp)
movl $0x448, %esi            # imm = 0x448
callq 0x11690
jmp 0x1a187
movq 0xa0(%rsp), %rdi
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x128(%rsp)
movl %eax, 0x124(%rsp)
movl $0x448, %esi            # imm = 0x448
callq 0x11690
jmp 0x1a187
movq 0x130(%rsp), %rdi
movq 0x118(%rsp), %rsi
xorl %edx, %edx
callq 0x148a0
movq 0x130(%rsp), %rdi
movq 0x110(%rsp), %rsi
xorl %edx, %edx
callq 0x148a0
movq 0x130(%rsp), %rdi
movq 0x108(%rsp), %rsi
xorl %edx, %edx
callq 0x148a0
movq 0x130(%rsp), %rdi
movq 0x100(%rsp), %rsi
xorl %edx, %edx
callq 0x148a0
movq 0x130(%rsp), %rdi
movq 0xf8(%rsp), %rsi
xorl %edx, %edx
callq 0x148a0
movq 0x130(%rsp), %rdi
movq 0xf0(%rsp), %rsi
xorl %edx, %edx
callq 0x148a0
cmpl $0x0, 0x1b0622(%rip)    # 0x1ca740
je 0x1a167
leaq 0x138(%rsp), %rdi
callq 0xe99a0
leaq 0x15a0d8(%rip), %rdi    # 0x17420c
movb $0x1, %al
callq 0x11090
movq 0x130(%rsp), %rdi
callq 0x1f400
movl %eax, %esi
leaq 0x15a166(%rip), %rdi    # 0x1742b7
movb $0x0, %al
callq 0x11090
movq 0x1a6e31(%rip), %rax    # 0x1c0f90
movq (%rax), %rdi
callq 0x117f0
movq 0x130(%rsp), %rax
movq %rax, 0x150(%rsp)
movq 0x150(%rsp), %rax
addq $0x158, %rsp            # imm = 0x158
retq
movq 0x128(%rsp), %rdi
callq 0x11bb0
nopw %cs:(%rax,%rax)