// File: tomfunkhouser[P]gaps/apps/sfl2pts/sfl2pts.cpp
// Function: OpenSurfelScene(char const*, char const*)
static R3SurfelScene *
OpenSurfelScene(const char *input_scene_name, const char *input_database_name)
{
  // Start statistics
  RNTime start_time;
  start_time.Read();

  // Allocate scene
  R3SurfelScene *scene = new R3SurfelScene();
  if (!scene) {
    RNFail("Unable to allocate scene\n");
    return NULL;
  }

  // Open scene files
  if (!scene->OpenFile(input_scene_name, input_database_name, "r", "r")) {
    delete scene;
    return NULL;
  }

  // Print statistics
  if (print_verbose) {
    printf("Opened scene ...\n");
    printf("  Time = %.2f seconds\n", start_time.Elapsed());
    printf("  # Scans = %d\n", scene->NScans());
    printf("  # Objects = %d\n", scene->NObjects());
    printf("  # Labels = %d\n", scene->NLabels());
    printf("  # Assignments = %d\n", scene->NLabelAssignments());
    printf("  # Features = %d\n", scene->NFeatures());
    printf("  # Nodes = %d\n", scene->Tree()->NNodes());
    printf("  # Blocks = %d\n", scene->Tree()->Database()->NBlocks());
    printf("  # Surfels = %lld\n", scene->Tree()->Database()->NSurfels());
    fflush(stdout);
  }

  // Return scene
  return scene;
}

// Assembly:
subq $0x58, %rsp
movq %rdi, 0x48(%rsp)
movq %rsi, 0x40(%rsp)
leaq 0x30(%rsp), %rdi
movq %rdi, 0x8(%rsp)
callq 0x143310
movq 0x8(%rsp), %rdi
callq 0x18850
movl $0x1f0, %edi            # imm = 0x1F0
callq 0x13570
movq %rax, %rdi
movq %rdi, %rax
movq %rax, 0x10(%rsp)
xorl %eax, %eax
movl %eax, %esi
callq 0x34400
jmp 0x16d57
movq 0x10(%rsp), %rax
movq %rax, 0x28(%rsp)
cmpq $0x0, 0x28(%rsp)
jne 0x16da7
leaq 0x18f42b(%rip), %rdi    # 0x1a619b
movb $0x0, %al
callq 0x148290
movq $0x0, 0x50(%rsp)
jmp 0x16f3a
movq 0x10(%rsp), %rdi
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x20(%rsp)
movl %eax, 0x1c(%rsp)
movl $0x1f0, %esi            # imm = 0x1F0
callq 0x13580
jmp 0x16f44
movq 0x28(%rsp), %rdi
movq 0x48(%rsp), %rsi
movq 0x40(%rsp), %rdx
movq (%rdi), %rax
leaq 0x196793(%rip), %r8     # 0x1ad553
movq %r8, %rcx
callq *0xe8(%rax)
cmpl $0x0, %eax
jne 0x16df5
movq 0x28(%rsp), %rax
movq %rax, (%rsp)
cmpq $0x0, %rax
je 0x16de7
movq (%rsp), %rdi
movq (%rdi), %rax
callq *0x8(%rax)
movq $0x0, 0x50(%rsp)
jmp 0x16f3a
cmpl $0x0, 0x1e89cc(%rip)    # 0x1ff7c8
je 0x16f30
leaq 0x18f3ac(%rip), %rdi    # 0x1a61b5
movb $0x0, %al
callq 0x13070
leaq 0x30(%rsp), %rdi
callq 0x1433d0
leaq 0x18f3a6(%rip), %rdi    # 0x1a61c7
movb $0x1, %al
callq 0x13070
movq 0x28(%rsp), %rdi
callq 0x18870
movl %eax, %esi
leaq 0x18f3a3(%rip), %rdi    # 0x1a61de
movb $0x0, %al
callq 0x13070
movq 0x28(%rsp), %rdi
callq 0x18890
movl %eax, %esi
leaq 0x18f399(%rip), %rdi    # 0x1a61ee
movb $0x0, %al
callq 0x13070
movq 0x28(%rsp), %rdi
callq 0x188b0
movl %eax, %esi
leaq 0x18f391(%rip), %rdi    # 0x1a6200
movb $0x0, %al
callq 0x13070
movq 0x28(%rsp), %rdi
callq 0x188d0
movl %eax, %esi
leaq 0x18f388(%rip), %rdi    # 0x1a6211
movb $0x0, %al
callq 0x13070
movq 0x28(%rsp), %rdi
callq 0x188f0
movl %eax, %esi
leaq 0x18f384(%rip), %rdi    # 0x1a6227
movb $0x0, %al
callq 0x13070
movq 0x28(%rsp), %rdi
callq 0x187d0
movq %rax, %rdi
callq 0x18910
movl %eax, %esi
leaq 0x18f375(%rip), %rdi    # 0x1a623a
movb $0x0, %al
callq 0x13070
movq 0x28(%rsp), %rdi
callq 0x187d0
movq %rax, %rdi
callq 0x187e0
movq %rax, %rdi
callq 0x18930
movl %eax, %esi
leaq 0x18f35b(%rip), %rdi    # 0x1a624a
movb $0x0, %al
callq 0x13070
movq 0x28(%rsp), %rdi
callq 0x187d0
movq %rax, %rdi
callq 0x187e0
movq %rax, %rdi
callq 0x187f0
movq %rax, %rsi
leaq 0x18f341(%rip), %rdi    # 0x1a625b
movb $0x0, %al
callq 0x13070
movq 0x1df068(%rip), %rax    # 0x1f5f90
movq (%rax), %rdi
callq 0x13680
movq 0x28(%rsp), %rax
movq %rax, 0x50(%rsp)
movq 0x50(%rsp), %rax
addq $0x58, %rsp
retq
movq 0x20(%rsp), %rdi
callq 0x13970
nop