// File: tomfunkhouser[P]gaps/apps/sflview/sflview.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("  # Objects = %d\n", scene->NObjects());
    printf("  # Labels = %d\n", scene->NLabels());
    printf("  # Object Properties = %d\n", scene->NObjectProperties());
    printf("  # Label Properties = %d\n", scene->NLabelProperties());
    printf("  # Object Relationships = %d\n", scene->NObjectRelationships());
    printf("  # Label Relationships = %d\n", scene->NLabelRelationships());
    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()->NBlocks());
    printf("  # Surfels = %lld\n", scene->Tree()->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 0x1a20c0
movq 0x8(%rsp), %rdi
callq 0x2ef40
movl $0x1f0, %edi            # imm = 0x1F0
callq 0x28a30
movq %rax, %rdi
movq %rdi, %rax
movq %rax, 0x10(%rsp)
xorl %eax, %eax
movl %eax, %esi
callq 0x69250
jmp 0x2e777
movq 0x10(%rsp), %rax
movq %rax, 0x28(%rsp)
cmpq $0x0, 0x28(%rsp)
jne 0x2e7c7
leaq 0x212c14(%rip), %rdi    # 0x2413a4
movb $0x0, %al
callq 0x1a7770
movq $0x0, 0x50(%rsp)
jmp 0x2e9ce
movq 0x10(%rsp), %rdi
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x20(%rsp)
movl %eax, 0x1c(%rsp)
movl $0x1f0, %esi            # imm = 0x1F0
callq 0x28a50
jmp 0x2e9d8
movq 0x28(%rsp), %rdi
movq 0x48(%rsp), %rsi
movq 0x40(%rsp), %rdx
movq (%rdi), %rax
leaq 0x21d353(%rip), %r8     # 0x24bb33
movq %r8, %rcx
callq *0xe8(%rax)
cmpl $0x0, %eax
jne 0x2e815
movq 0x28(%rsp), %rax
movq %rax, (%rsp)
cmpq $0x0, %rax
je 0x2e807
movq (%rsp), %rdi
movq (%rdi), %rax
callq *0x8(%rax)
movq $0x0, 0x50(%rsp)
jmp 0x2e9ce
cmpl $0x0, 0x2a3ce4(%rip)    # 0x2d2500
je 0x2e9c4
leaq 0x212b95(%rip), %rdi    # 0x2413be
movb $0x0, %al
callq 0x28090
leaq 0x30(%rsp), %rdi
callq 0x1a2180
leaq 0x2129f7(%rip), %rdi    # 0x241238
movb $0x1, %al
callq 0x28090
movq 0x28(%rsp), %rdi
callq 0x2ef60
movl %eax, %esi
leaq 0x2129f4(%rip), %rdi    # 0x24124f
movb $0x0, %al
callq 0x28090
movq 0x28(%rsp), %rdi
callq 0x2ef80
movl %eax, %esi
leaq 0x2129ec(%rip), %rdi    # 0x241261
movb $0x0, %al
callq 0x28090
movq 0x28(%rsp), %rdi
callq 0x2f7c0
movl %eax, %esi
leaq 0x212b41(%rip), %rdi    # 0x2413d0
movb $0x0, %al
callq 0x28090
movq 0x28(%rsp), %rdi
callq 0x2f7e0
movl %eax, %esi
leaq 0x212b43(%rip), %rdi    # 0x2413ec
movb $0x0, %al
callq 0x28090
movq 0x28(%rsp), %rdi
callq 0x2f800
movl %eax, %esi
leaq 0x212b44(%rip), %rdi    # 0x241407
movb $0x0, %al
callq 0x28090
movq 0x28(%rsp), %rdi
callq 0x2f820
movl %eax, %esi
leaq 0x212b49(%rip), %rdi    # 0x241426
movb $0x0, %al
callq 0x28090
movq 0x28(%rsp), %rdi
callq 0x2efa0
movl %eax, %esi
leaq 0x21297b(%rip), %rdi    # 0x241272
movb $0x0, %al
callq 0x28090
movq 0x28(%rsp), %rdi
callq 0x2efc0
movl %eax, %esi
leaq 0x212977(%rip), %rdi    # 0x241288
movb $0x0, %al
callq 0x28090
movq 0x28(%rsp), %rdi
callq 0x2efe0
movl %eax, %esi
leaq 0x212970(%rip), %rdi    # 0x24129b
movb $0x0, %al
callq 0x28090
movq 0x28(%rsp), %rdi
callq 0x2f000
movl %eax, %esi
leaq 0x212966(%rip), %rdi    # 0x2412ab
movb $0x0, %al
callq 0x28090
movq 0x28(%rsp), %rdi
callq 0x2f020
movq %rax, %rdi
callq 0x2f030
movl %eax, %esi
leaq 0x212955(%rip), %rdi    # 0x2412bc
movb $0x0, %al
callq 0x28090
movq 0x28(%rsp), %rdi
callq 0x2f020
movq %rax, %rdi
callq 0x2f050
movl %eax, %esi
leaq 0x212943(%rip), %rdi    # 0x2412cc
movb $0x0, %al
callq 0x28090
movq 0x28(%rsp), %rdi
callq 0x2f020
movq %rax, %rdi
xorl %esi, %esi
callq 0x2f0d0
movq %rax, %rsi
leaq 0x21292f(%rip), %rdi    # 0x2412dd
movb $0x0, %al
callq 0x28090
movq 0x294554(%rip), %rax    # 0x2c2f10
movq (%rax), %rdi
callq 0x28c50
movq 0x28(%rsp), %rax
movq %rax, 0x50(%rsp)
movq 0x50(%rsp), %rax
addq $0x58, %rsp
retq
movq 0x20(%rsp), %rdi
callq 0x292e0
nopw %cs:(%rax,%rax)