// File: /workspace/github_cpp_makefile_star2_O1/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 0xe90c
movq %rsi, %r14
movl $0x138, %edi            # imm = 0x138
callq 0xc370
movq %rax, %rbx
movq %rax, %rdi
callq 0xe950
movq 0x8(%r14), %rsi
movq (%rbx), %rax
movq %rbx, %rdi
callq *0x180(%rax)
testl %eax, %eax
je 0xe91a
movslq 0x24(%rbx), %rax
testq %rax, %rax
jle 0xe755
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 0xe72c
jmp 0xe757
xorl %ebp, %ebp
movq %rbx, %rdi
callq 0xfeb6
movl %eax, %r15d
movq %rbx, %rdi
callq 0xf256
movsd %xmm0, 0x10(%rsp)
movq %rbx, %rdi
callq 0xf29a
movsd %xmm0, 0x18(%rsp)
movq %rbx, %rdi
callq 0xf0a0
movsd %xmm0, (%rsp)
movq %rbx, %rdi
callq 0xf30c
movsd %xmm0, 0x8(%rsp)
leaq 0x20(%rsp), %r14
movq %r14, %rdi
movq %rbx, %rsi
callq 0xeedc
movl 0x34(%rbx), %esi
leaq 0x42876(%rip), %rdi     # 0x51029
xorl %eax, %eax
callq 0xc070
movl 0x24(%rbx), %esi
leaq 0x42877(%rip), %rdi     # 0x5103b
xorl %eax, %eax
callq 0xc070
movl 0x14(%rbx), %esi
leaq 0x42878(%rip), %rdi     # 0x5104d
xorl %eax, %eax
callq 0xc070
xorps %xmm0, %xmm0
cvtsi2sd %ebp, %xmm0
mulsd 0x4281d(%rip), %xmm0    # 0x51008
cvtsi2sdl 0x24(%rbx), %xmm1
divsd %xmm1, %xmm0
leaq 0x42867(%rip), %rdi     # 0x51062
movl %ebp, %esi
movb $0x1, %al
callq 0xc070
leaq 0x42875(%rip), %rdi     # 0x51080
movl %r15d, %esi
xorl %eax, %eax
callq 0xc070
leaq 0x4287f(%rip), %rdi     # 0x5109b
movsd (%rsp), %xmm0
movb $0x1, %al
callq 0xc070
leaq 0x4287f(%rip), %rdi     # 0x510ae
movsd 0x10(%rsp), %xmm0
movb $0x1, %al
callq 0xc070
leaq 0x42888(%rip), %rdi     # 0x510cb
movsd 0x18(%rsp), %xmm0
movb $0x1, %al
callq 0xc070
leaq 0x4288e(%rip), %rdi     # 0x510e5
movsd 0x8(%rsp), %xmm0
movb $0x1, %al
callq 0xc070
movsd (%r14), %xmm0
movsd 0x8(%r14), %xmm1
movsd 0x10(%r14), %xmm2
leaq 0x4288b(%rip), %rdi     # 0x51107
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 0x42866(%rip), %rdi     # 0x51120
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 0x42852(%rip), %rdi     # 0x5114a
movb $0x3, %al
callq 0xc070
xorl %eax, %eax
addq $0x38, %rsp
popq %rbx
popq %r14
popq %r15
popq %rbp
retq
leaq 0x42855(%rip), %rdi     # 0x51168
callq 0xc540
jmp 0xe92c
movq 0x8(%r14), %rsi
leaq 0x426eb(%rip), %rdi     # 0x51010
xorl %eax, %eax
callq 0x50b2e
movl $0x1, %edi
callq 0xc450
movq %rax, %r14
movl $0x138, %esi            # imm = 0x138
movq %rbx, %rdi
callq 0xc380
movq %r14, %rdi
callq 0xc600
nop