// File: /workspace/github_cpp_makefile_star2_O3/tomfunkhouser[P]gaps/apps/mshinfo/mshinfo.cpp
// Function: main
int main(int argc, char **argv)
{
  // Check number of arguments
  if (argc != 2) {
    printf("Usage: meshinfo inputfile\n");
    exit(1);
  }

  // Create mesh
  R3Mesh *mesh = new R3Mesh();
  if (!mesh) {
    RNFail("Unable to allocate mesh data structure.\n");
    exit(1);
  }

  // Read mesh
  if (!mesh->ReadFile(argv[1])) {
    RNFail("Unable to read file: %s\n", argv[1]);
    exit(1);
  }

  // Compute stats
  int num_boundaries = NumBoundaryEdges(mesh);
  int num_components = mesh->ConnectedComponents();
  RNScalar avg_vertex_valence = mesh->AverageVertexValence();
  RNScalar avg_edge_length = mesh->AverageEdgeLength();
  RNArea total_face_area = mesh->Area();
  RNAngle avg_edge_interior_angle = mesh->AverageEdgeInteriorAngle();
  const R3Point& centroid = mesh->Centroid();
  const R3Box& bbox = mesh->BBox();

  // Print stats
  printf("Total faces = %d\n", mesh->NFaces());
  printf("Total edges = %d\n", mesh->NEdges());
  printf("Total vertices = %d\n", mesh->NVertices());
  printf("Boundary edges = %d ( %g%% )\n", num_boundaries, 100.0 * num_boundaries/ mesh->NEdges());
  printf("Connected components = %d\n", num_components);
  printf("Surface area = %g\n", total_face_area);
  printf("Average vertex valence = %g\n", avg_vertex_valence);
  printf("Average edge length = %g\n", avg_edge_length);
  printf("Average edge interior angle = %g\n", avg_edge_interior_angle);
  printf("Centroid = ( %g %g %g )\n", centroid[0], centroid[1], centroid[2]);
  printf("Bounding box = ( %g %g %g ) ( %g %g %g )\n", bbox[0][0], bbox[0][1], bbox[0][2], bbox[1][0], bbox[1][1], bbox[1][2]);
  printf("Axial lengths = ( %g %g %g )\n", bbox.XLength(), bbox.YLength(), bbox.ZLength());

  // Return success 
  return 0;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %rbx
subq $0x38, %rsp
cmpl $0x2, %edi
jne 0xe8ec
movq %rsi, %r14
movl $0x138, %edi            # imm = 0x138
callq 0xc370
movq %rax, %rbx
movq %rax, %rdi
callq 0xe930
movq 0x8(%r14), %rsi
movq (%rbx), %rax
movq %rbx, %rdi
callq *0x180(%rax)
testl %eax, %eax
je 0xe8fa
movslq 0x24(%rbx), %rax
testq %rax, %rax
jle 0xe735
movq 0x18(%rbx), %rcx
xorl %edx, %edx
xorl %ebp, %ebp
movq (%rcx,%rdx,8), %rsi
cmpq $0x0, 0x18(%rsi)
sete %dil
cmpq $0x0, 0x20(%rsi)
sete %sil
orb %dil, %sil
movzbl %sil, %esi
addl %esi, %ebp
incq %rdx
cmpq %rdx, %rax
jne 0xe70c
jmp 0xe737
xorl %ebp, %ebp
movq %rbx, %rdi
callq 0xff7a
movl %eax, %r15d
movq %rbx, %rdi
callq 0xf234
movsd %xmm0, 0x10(%rsp)
movq %rbx, %rdi
callq 0xf278
movsd %xmm0, 0x18(%rsp)
movq %rbx, %rdi
callq 0xf08e
movsd %xmm0, (%rsp)
movq %rbx, %rdi
callq 0xf2ee
movsd %xmm0, 0x8(%rsp)
leaq 0x20(%rsp), %r14
movq %r14, %rdi
movq %rbx, %rsi
callq 0xeecc
movl 0x34(%rbx), %esi
leaq 0x41896(%rip), %rdi     # 0x50029
xorl %eax, %eax
callq 0xc070
movl 0x24(%rbx), %esi
leaq 0x41897(%rip), %rdi     # 0x5003b
xorl %eax, %eax
callq 0xc070
movl 0x14(%rbx), %esi
leaq 0x41898(%rip), %rdi     # 0x5004d
xorl %eax, %eax
callq 0xc070
xorps %xmm0, %xmm0
cvtsi2sd %ebp, %xmm0
mulsd 0x4183d(%rip), %xmm0    # 0x50008
cvtsi2sdl 0x24(%rbx), %xmm1
divsd %xmm1, %xmm0
leaq 0x41887(%rip), %rdi     # 0x50062
movl %ebp, %esi
movb $0x1, %al
callq 0xc070
leaq 0x41895(%rip), %rdi     # 0x50080
movl %r15d, %esi
xorl %eax, %eax
callq 0xc070
leaq 0x4189f(%rip), %rdi     # 0x5009b
movsd (%rsp), %xmm0
movb $0x1, %al
callq 0xc070
leaq 0x4189f(%rip), %rdi     # 0x500ae
movsd 0x10(%rsp), %xmm0
movb $0x1, %al
callq 0xc070
leaq 0x418a8(%rip), %rdi     # 0x500cb
movsd 0x18(%rsp), %xmm0
movb $0x1, %al
callq 0xc070
leaq 0x418ae(%rip), %rdi     # 0x500e5
movsd 0x8(%rsp), %xmm0
movb $0x1, %al
callq 0xc070
movsd (%r14), %xmm0
movsd 0x8(%r14), %xmm1
movsd 0x10(%r14), %xmm2
leaq 0x418ab(%rip), %rdi     # 0x50107
movb $0x3, %al
callq 0xc070
movsd 0x100(%rbx), %xmm0
movsd 0x108(%rbx), %xmm1
movsd 0x110(%rbx), %xmm2
movsd 0x118(%rbx), %xmm3
movsd 0x120(%rbx), %xmm4
movsd 0x128(%rbx), %xmm5
leaq 0x41886(%rip), %rdi     # 0x50120
movb $0x6, %al
callq 0xc070
movsd 0x118(%rbx), %xmm0
movsd 0x120(%rbx), %xmm1
subsd 0x100(%rbx), %xmm0
subsd 0x108(%rbx), %xmm1
movsd 0x128(%rbx), %xmm2
subsd 0x110(%rbx), %xmm2
leaq 0x41872(%rip), %rdi     # 0x5014a
movb $0x3, %al
callq 0xc070
xorl %eax, %eax
addq $0x38, %rsp
popq %rbx
popq %r14
popq %r15
popq %rbp
retq
leaq 0x41875(%rip), %rdi     # 0x50168
callq 0xc540
jmp 0xe90c
movq 0x8(%r14), %rsi
leaq 0x4170b(%rip), %rdi     # 0x50010
xorl %eax, %eax
callq 0x4fd3e
movl $0x1, %edi
callq 0xc450
movq %rax, %r14
movl $0x138, %esi            # imm = 0x138
movq %rbx, %rdi
callq 0xc380
movq %r14, %rdi
callq 0xc600
nop