// File: tomfunkhouser[P]gaps/apps/sflprocess/sflprocess.cpp
// Function: OpenScene(char const*, char const*)
static R3SurfelScene *
OpenScene(const char *scene_name, const char *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(scene_name, 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("  # Comments = %d\n", scene->NComments());
    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("  # Scans = %d\n", scene->NScans());
    printf("  # Images = %d\n", scene->NImages());
    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 0x16dd30
movq 0x8(%rsp), %rdi
callq 0x263f0
movl $0x1f0, %edi            # imm = 0x1F0
callq 0x16740
movq %rax, %rdi
movq %rdi, %rax
movq %rax, 0x10(%rsp)
xorl %eax, %eax
movl %eax, %esi
callq 0x6fe50
jmp 0x1e077
movq 0x10(%rsp), %rax
movq %rax, 0x28(%rsp)
cmpq $0x0, 0x28(%rsp)
jne 0x1e0c7
leaq 0x1da57e(%rip), %rdi    # 0x1f860e
movb $0x0, %al
callq 0x172cb0
movq $0x0, 0x50(%rsp)
jmp 0x1e28e
movq 0x10(%rsp), %rdi
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x20(%rsp)
movl %eax, 0x1c(%rsp)
movl $0x1f0, %esi            # imm = 0x1F0
callq 0x16750
jmp 0x1e298
movq 0x28(%rsp), %rdi
movq 0x48(%rsp), %rsi
movq 0x40(%rsp), %rdx
movq (%rdi), %rax
leaq 0x1da548(%rip), %r8     # 0x1f8628
movq %r8, %rcx
callq *0xe8(%rax)
cmpl $0x0, %eax
jne 0x1e115
movq 0x28(%rsp), %rax
movq %rax, (%rsp)
cmpq $0x0, %rax
je 0x1e107
movq (%rsp), %rdi
movq (%rdi), %rax
callq *0x8(%rax)
movq $0x0, 0x50(%rsp)
jmp 0x1e28e
cmpl $0x0, 0x2466a4(%rip)    # 0x2647c0
je 0x1e284
leaq 0x1da502(%rip), %rdi    # 0x1f862b
movb $0x0, %al
callq 0x16090
leaq 0x30(%rsp), %rdi
callq 0x16ddf0
leaq 0x1da43e(%rip), %rdi    # 0x1f857f
movb $0x1, %al
callq 0x16090
movq 0x28(%rsp), %rdi
callq 0x266a0
movl %eax, %esi
leaq 0x1da4e2(%rip), %rdi    # 0x1f863d
movb $0x0, %al
callq 0x16090
movq 0x28(%rsp), %rdi
callq 0x266c0
movl %eax, %esi
leaq 0x1da4db(%rip), %rdi    # 0x1f8650
movb $0x0, %al
callq 0x16090
movq 0x28(%rsp), %rdi
callq 0x266e0
movl %eax, %esi
leaq 0x1da4d3(%rip), %rdi    # 0x1f8662
movb $0x0, %al
callq 0x16090
movq 0x28(%rsp), %rdi
callq 0x26700
movl %eax, %esi
leaq 0x1da4ca(%rip), %rdi    # 0x1f8673
movb $0x0, %al
callq 0x16090
movq 0x28(%rsp), %rdi
callq 0x26720
movl %eax, %esi
leaq 0x1da4c6(%rip), %rdi    # 0x1f8689
movb $0x0, %al
callq 0x16090
movq 0x28(%rsp), %rdi
callq 0x26740
movl %eax, %esi
leaq 0x1da4bf(%rip), %rdi    # 0x1f869c
movb $0x0, %al
callq 0x16090
movq 0x28(%rsp), %rdi
callq 0x26760
movl %eax, %esi
leaq 0x1da4b5(%rip), %rdi    # 0x1f86ac
movb $0x0, %al
callq 0x16090
movq 0x28(%rsp), %rdi
callq 0x26780
movq %rax, %rdi
callq 0x26330
movl %eax, %esi
leaq 0x1da4a4(%rip), %rdi    # 0x1f86bd
movb $0x0, %al
callq 0x16090
movq 0x28(%rsp), %rdi
callq 0x26780
movq %rax, %rdi
callq 0x26790
movq %rax, %rdi
callq 0x267a0
movl %eax, %esi
leaq 0x1da48a(%rip), %rdi    # 0x1f86cd
movb $0x0, %al
callq 0x16090
movq 0x28(%rsp), %rdi
callq 0x26780
movq %rax, %rdi
callq 0x26790
movq %rax, %rdi
callq 0x267c0
movq %rax, %rsi
leaq 0x1da470(%rip), %rdi    # 0x1f86de
movb $0x0, %al
callq 0x16090
movq 0x23cd14(%rip), %rax    # 0x25af90
movq (%rax), %rdi
callq 0x168c0
movq 0x28(%rsp), %rax
movq %rax, 0x50(%rsp)
movq 0x50(%rsp), %rax
addq $0x58, %rsp
retq
movq 0x20(%rsp), %rdi
callq 0x16ca0
nopw %cs:(%rax,%rax)