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

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

  // Allocate properites
  R3MeshProperty *index = new R3MeshProperty(mesh, "Index");
  R3MeshProperty *valence = new R3MeshProperty(mesh, "Valence");
  R3MeshProperty *length = new R3MeshProperty(mesh, "AverageEdgeLength");
  R3MeshProperty *area = new R3MeshProperty(mesh, "Area");

  // Compute properties
  for (int i = 0; i < mesh->NVertices(); i++) {
    R3MeshVertex *vertex = mesh->Vertex(i);
    index->SetVertexValue(i, mesh->VertexID(vertex));
    valence->SetVertexValue(i, mesh->VertexValence(vertex));
    length->SetVertexValue(i, mesh->VertexAverageEdgeLength(vertex));
    area->SetVertexValue(i, mesh->VertexArea(vertex));
  }

  // Insert properties at multiple scales
  InsertProperty(properties, index);
  InsertProperty(properties, valence);
  InsertProperty(properties, length);
  InsertProperty(properties, area);

  // 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 $0xd8, %rsp
movq %rdi, 0xc8(%rsp)
leaq 0xb8(%rsp), %rdi
callq 0xe98e0
leaq 0xb8(%rsp), %rdi
callq 0x1f280
cmpl $0x0, 0x1b4d60(%rip)    # 0x1ca740
je 0x159ff
leaq 0x15e88f(%rip), %rdi    # 0x174278
movb $0x0, %al
callq 0x11090
movq 0x1ab599(%rip), %rax    # 0x1c0f90
movq (%rax), %rdi
callq 0x117f0
movl $0x18, %edi
callq 0x11680
movq %rax, %rdi
movq %rdi, %rax
movq %rax, 0x68(%rsp)
movq 0xc8(%rsp), %rsi
callq 0x24ce0
jmp 0x15a23
movq 0x68(%rsp), %rax
movq %rax, 0xb0(%rsp)
cmpq $0x0, 0xb0(%rsp)
jne 0x15a82
leaq 0x15e814(%rip), %rdi    # 0x174256
movb $0x0, %al
callq 0xedb00
movq $0x0, 0xd0(%rsp)
jmp 0x15dfb
movq 0x68(%rsp), %rdi
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0xa8(%rsp)
movl %eax, 0xa4(%rsp)
movl $0x18, %esi
callq 0x11690
jmp 0x15e0b
movl $0x448, %edi            # imm = 0x448
callq 0x11680
movq %rax, %rdi
movq %rdi, %rax
movq %rax, 0x60(%rsp)
movq 0xc8(%rsp), %rsi
leaq 0x15fd27(%rip), %rdx    # 0x1757cd
xorl %eax, %eax
movl %eax, %ecx
callq 0x27ef0
jmp 0x15ab1
movq 0x60(%rsp), %rax
movq %rax, 0x98(%rsp)
movl $0x448, %edi            # imm = 0x448
callq 0x11680
movq %rax, %rdi
movq %rdi, %rax
movq %rax, 0x58(%rsp)
movq 0xc8(%rsp), %rsi
leaq 0x15e7b6(%rip), %rdx    # 0x174298
xorl %eax, %eax
movl %eax, %ecx
callq 0x27ef0
jmp 0x15aed
movq 0x58(%rsp), %rax
movq %rax, 0x90(%rsp)
movl $0x448, %edi            # imm = 0x448
callq 0x11680
movq %rax, %rdi
movq %rdi, %rax
movq %rax, 0x50(%rsp)
movq 0xc8(%rsp), %rsi
leaq 0x15e782(%rip), %rdx    # 0x1742a0
xorl %eax, %eax
movl %eax, %ecx
callq 0x27ef0
jmp 0x15b29
movq 0x50(%rsp), %rax
movq %rax, 0x88(%rsp)
movl $0x448, %edi            # imm = 0x448
callq 0x11680
movq %rax, %rdi
movq %rdi, %rax
movq %rax, 0x48(%rsp)
movq 0xc8(%rsp), %rsi
leaq 0x15e758(%rip), %rdx    # 0x1742b2
xorl %eax, %eax
movl %eax, %ecx
callq 0x27ef0
jmp 0x15b65
movq 0x48(%rsp), %rax
movq %rax, 0x80(%rsp)
movl $0x0, 0x7c(%rsp)
movl 0x7c(%rsp), %eax
movl %eax, 0x44(%rsp)
movq 0xc8(%rsp), %rdi
callq 0x1f2e0
movl %eax, %ecx
movl 0x44(%rsp), %eax
cmpl %ecx, %eax
jge 0x15d3f
movq 0xc8(%rsp), %rdi
movl 0x7c(%rsp), %esi
callq 0x1f380
movq %rax, 0x70(%rsp)
movq 0x98(%rsp), %rax
movq %rax, 0x8(%rsp)
movl 0x7c(%rsp), %eax
movl %eax, 0x14(%rsp)
movq 0xc8(%rsp), %rdi
movq 0x70(%rsp), %rsi
callq 0x1f3b0
movq 0x8(%rsp), %rdi
movl 0x14(%rsp), %esi
cvtsi2sd %eax, %xmm0
callq 0x2ae50
movq 0x90(%rsp), %rax
movq %rax, 0x18(%rsp)
movl 0x7c(%rsp), %eax
movl %eax, 0x24(%rsp)
movq 0xc8(%rsp), %rdi
movq 0x70(%rsp), %rsi
callq 0x1f3d0
movq 0x18(%rsp), %rdi
movl 0x24(%rsp), %esi
cvtsi2sd %eax, %xmm0
callq 0x2ae50
movq 0x88(%rsp), %rax
movq %rax, 0x28(%rsp)
movl 0x7c(%rsp), %eax
movl %eax, 0x34(%rsp)
movq 0xc8(%rsp), %rdi
movq 0x70(%rsp), %rsi
callq 0x31660
movq 0x28(%rsp), %rdi
movl 0x34(%rsp), %esi
callq 0x2ae50
movq 0x80(%rsp), %rax
movq %rax, 0x38(%rsp)
movl 0x7c(%rsp), %eax
movl %eax, 0x40(%rsp)
movq 0xc8(%rsp), %rdi
movq 0x70(%rsp), %rsi
callq 0x31590
movq 0x38(%rsp), %rdi
movl 0x40(%rsp), %esi
callq 0x2ae50
movl 0x7c(%rsp), %eax
addl $0x1, %eax
movl %eax, 0x7c(%rsp)
jmp 0x15b7a
movq 0x60(%rsp), %rdi
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0xa8(%rsp)
movl %eax, 0xa4(%rsp)
movl $0x448, %esi            # imm = 0x448
callq 0x11690
jmp 0x15e0b
movq 0x58(%rsp), %rdi
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0xa8(%rsp)
movl %eax, 0xa4(%rsp)
movl $0x448, %esi            # imm = 0x448
callq 0x11690
jmp 0x15e0b
movq 0x50(%rsp), %rdi
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0xa8(%rsp)
movl %eax, 0xa4(%rsp)
movl $0x448, %esi            # imm = 0x448
callq 0x11690
jmp 0x15e0b
movq 0x48(%rsp), %rdi
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0xa8(%rsp)
movl %eax, 0xa4(%rsp)
movl $0x448, %esi            # imm = 0x448
callq 0x11690
jmp 0x15e0b
movq 0xb0(%rsp), %rdi
movq 0x98(%rsp), %rsi
xorl %edx, %edx
callq 0x148a0
movq 0xb0(%rsp), %rdi
movq 0x90(%rsp), %rsi
xorl %edx, %edx
callq 0x148a0
movq 0xb0(%rsp), %rdi
movq 0x88(%rsp), %rsi
xorl %edx, %edx
callq 0x148a0
movq 0xb0(%rsp), %rdi
movq 0x80(%rsp), %rsi
xorl %edx, %edx
callq 0x148a0
cmpl $0x0, 0x1b499e(%rip)    # 0x1ca740
je 0x15deb
leaq 0xb8(%rsp), %rdi
callq 0xe99a0
leaq 0x15e454(%rip), %rdi    # 0x17420c
movb $0x1, %al
callq 0x11090
movq 0xb0(%rsp), %rdi
callq 0x1f400
movl %eax, %esi
leaq 0x15e4e2(%rip), %rdi    # 0x1742b7
movb $0x0, %al
callq 0x11090
movq 0x1ab1ad(%rip), %rax    # 0x1c0f90
movq (%rax), %rdi
callq 0x117f0
movq 0xb0(%rsp), %rax
movq %rax, 0xd0(%rsp)
movq 0xd0(%rsp), %rax
addq $0xd8, %rsp
retq
movq 0xa8(%rsp), %rdi
callq 0x11bb0
nopl (%rax,%rax)