// File: tomfunkhouser[P]gaps/apps/confview/confview.cpp
// Function: ReadMeshFile(gaps::RGBDConfiguration&, char const*)
static int
ReadMeshFile(RGBDConfiguration& configuration, const char *filename)
{
  // Start statistics
  RNTime start_time;
  start_time.Read();

  // Allocate mesh
  R3Mesh *mesh = new R3Mesh();
  if (!mesh) {
    RNFail("Unable to allocate mesh for %s\n", filename);
    return 0;
  }

  // Read mesh from file
  if (!mesh->ReadFile(filename)) {
    RNFail("Unable to read mesh from %s\n", filename);
    return 0;
  }

  // Create surface for mesh
  RGBDSurface *surface = new RGBDSurface(NULL, mesh, texel_spacing);
  if (!surface) {
    RNFail("Unable to allocate surface for %s\n", filename);
    return 0;
  }

  // Insert surface
  configuration.InsertSurface(surface);

  // Print statistics
  if (print_verbose) {
    printf("Read mesh from %s ...\n", filename);
    printf("  Time = %.2f seconds\n", start_time.Elapsed());
    printf("  # Faces = %d\n", mesh->NFaces());
    printf("  # Edges = %d\n", mesh->NEdges());
    printf("  # Vertices = %d\n", mesh->NVertices());
    fflush(stdout);
  }

  // Return success
  return 1;
}

// Assembly:
subq $0x68, %rsp
movq %rdi, 0x58(%rsp)
movq %rsi, 0x50(%rsp)
leaq 0x40(%rsp), %rdi
movq %rdi, 0x10(%rsp)
callq 0x127730
movq 0x10(%rsp), %rdi
callq 0x2e970
movl $0x138, %edi            # imm = 0x138
callq 0x24a00
movq %rax, %rdi
movq %rdi, %rax
movq %rax, 0x18(%rsp)
callq 0x9e6c0
jmp 0x2d4b3
movq 0x18(%rsp), %rax
movq %rax, 0x38(%rsp)
cmpq $0x0, 0x38(%rsp)
jne 0x2d507
movq 0x50(%rsp), %rsi
leaq 0x19a19b(%rip), %rdi    # 0x1c766c
movb $0x0, %al
callq 0x12c6b0
movl $0x0, 0x64(%rsp)
jmp 0x2d66d
movq 0x18(%rsp), %rdi
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x30(%rsp)
movl %eax, 0x2c(%rsp)
movl $0x138, %esi            # imm = 0x138
callq 0x24a20
jmp 0x2d676
movq 0x38(%rsp), %rdi
movq 0x50(%rsp), %rsi
movq (%rdi), %rax
callq *0x180(%rax)
cmpl $0x0, %eax
jne 0x2d53f
movq 0x50(%rsp), %rsi
leaq 0x19a161(%rip), %rdi    # 0x1c768c
movb $0x0, %al
callq 0x12c6b0
movl $0x0, 0x64(%rsp)
jmp 0x2d66d
movl $0xa0, %edi
callq 0x24a00
movq %rax, %rdi
movq %rdi, %rax
movq %rax, 0x8(%rsp)
movq 0x38(%rsp), %rdx
movsd 0x20e927(%rip), %xmm0   # 0x23be88
xorl %eax, %eax
movl %eax, %esi
callq 0x39030
jmp 0x2d56c
movq 0x8(%rsp), %rax
movq %rax, 0x20(%rsp)
cmpq $0x0, 0x20(%rsp)
jne 0x2d5c0
movq 0x50(%rsp), %rsi
leaq 0x19a11f(%rip), %rdi    # 0x1c76a9
movb $0x0, %al
callq 0x12c6b0
movl $0x0, 0x64(%rsp)
jmp 0x2d66d
movq 0x8(%rsp), %rdi
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x30(%rsp)
movl %eax, 0x2c(%rsp)
movl $0xa0, %esi
callq 0x24a20
jmp 0x2d676
movq 0x58(%rsp), %rdi
movq 0x20(%rsp), %rsi
movq (%rdi), %rax
callq *0x20(%rax)
cmpl $0x0, 0x20e7f9(%rip)    # 0x23bdd0
je 0x2d665
movq 0x50(%rsp), %rsi
leaq 0x19a0e3(%rip), %rdi    # 0x1c76cc
movb $0x0, %al
callq 0x24090
leaq 0x40(%rsp), %rdi
callq 0x1277f0
leaq 0x199d8c(%rip), %rdi    # 0x1c738d
movb $0x1, %al
callq 0x24090
movq 0x38(%rsp), %rdi
callq 0x2f7b0
movl %eax, %esi
leaq 0x19a0c8(%rip), %rdi    # 0x1c76e3
movb $0x0, %al
callq 0x24090
movq 0x38(%rsp), %rdi
callq 0x2f7d0
movl %eax, %esi
leaq 0x19a0be(%rip), %rdi    # 0x1c76f3
movb $0x0, %al
callq 0x24090
movq 0x38(%rsp), %rdi
callq 0x2f0a0
movl %eax, %esi
leaq 0x19a0b4(%rip), %rdi    # 0x1c7703
movb $0x0, %al
callq 0x24090
movq 0x207933(%rip), %rax    # 0x234f90
movq (%rax), %rdi
callq 0x24c20
movl $0x1, 0x64(%rsp)
movl 0x64(%rsp), %eax
addq $0x68, %rsp
retq
movq 0x30(%rsp), %rdi
callq 0x252b0