// File: tomfunkhouser[P]gaps/apps/gapsview/gapsview.cpp
// Function: ReadGSVFile(char const*)
static GSVScene *
ReadGSVFile(const char *filename)
{
  // Start statistics
  RNTime start_time;
  start_time.Read();

  // Allocate gsv scene
  GSVScene *scene = new GSVScene();
  if (!scene) {
    RNFail("Unable to allocated gsv scene");
    return NULL;
  }

  // Read gsv 
  if (!scene->ReadFile(filename)) {
    RNFail("Unable to read gsv file %s", filename);
    return NULL;
  }

  // Print statistics
  if (print_verbose) {
    printf("Read GSV scene from %s ...\n", filename);
    printf("  Time = %.2f seconds\n", start_time.Elapsed());
    printf("  # Runs = %d\n", scene->NRuns());
    printf("  # Segments = %d\n", scene->NSegments());
    printf("  # Cameras = %d\n", scene->NCameras());
    printf("  # Tapestries = %d\n", scene->NTapestries());
    printf("  # Panoramas = %d\n", scene->NPanoramas());
    printf("  # Images = %d\n", scene->NImages());
    printf("  # Lasers = %d\n", scene->NLasers());
    printf("  # Surveys = %d\n", scene->NSurveys());
    printf("  # Scans = %d\n", scene->NScans());
    printf("  # Scanlines = %d\n", scene->NScanlines());
    printf("  # Points = %d\n", scene->NPoints());
    fflush(stdout);
  }

  // Return GSV scene
  return scene;
}

// Assembly:
subq $0x48, %rsp
movq %rdi, 0x38(%rsp)
leaq 0x28(%rsp), %rdi
movq %rdi, (%rsp)
callq 0x1c7070
movq (%rsp), %rdi
callq 0x38bc0
movl $0x180, %edi            # imm = 0x180
callq 0x292e0
movq %rax, %rdi
movq %rdi, %rax
movq %rax, 0x8(%rsp)
callq 0x3ae50
jmp 0x3789c
movq 0x8(%rsp), %rax
movq %rax, 0x20(%rsp)
cmpq $0x0, 0x20(%rsp)
jne 0x378ec
leaq 0x22f13f(%rip), %rdi    # 0x2669f4
movb $0x0, %al
callq 0x1cbff0
movq $0x0, 0x40(%rsp)
jmp 0x37a96
movq 0x8(%rsp), %rdi
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x18(%rsp)
movl %eax, 0x14(%rsp)
movl $0x180, %esi            # imm = 0x180
callq 0x291f0
jmp 0x37aa0
movq 0x20(%rsp), %rdi
movq 0x38(%rsp), %rsi
movq (%rdi), %rax
movl $0x1, %edx
callq *0x20(%rax)
cmpl $0x0, %eax
jne 0x37927
movq 0x38(%rsp), %rsi
leaq 0x22f100(%rip), %rdi    # 0x266a12
movb $0x0, %al
callq 0x1cbff0
movq $0x0, 0x40(%rsp)
jmp 0x37a96
cmpl $0x0, 0x2c738e(%rip)    # 0x2fecbc
je 0x37a8c
movq 0x38(%rsp), %rsi
leaq 0x22f0ed(%rip), %rdi    # 0x266a2d
movb $0x0, %al
callq 0x290f0
leaq 0x28(%rsp), %rdi
callq 0x1c7130
leaq 0x22ea70(%rip), %rdi    # 0x2663c8
movb $0x1, %al
callq 0x290f0
movq 0x20(%rsp), %rdi
callq 0x39f90
movl %eax, %esi
leaq 0x22f0d7(%rip), %rdi    # 0x266a49
movb $0x0, %al
callq 0x290f0
movq 0x20(%rsp), %rdi
callq 0x3b200
movl %eax, %esi
leaq 0x22f0cc(%rip), %rdi    # 0x266a58
movb $0x0, %al
callq 0x290f0
movq 0x20(%rsp), %rdi
callq 0x3b280
movl %eax, %esi
leaq 0x22f0c5(%rip), %rdi    # 0x266a6b
movb $0x0, %al
callq 0x290f0
movq 0x20(%rsp), %rdi
callq 0x3b300
movl %eax, %esi
leaq 0x22f0bd(%rip), %rdi    # 0x266a7d
movb $0x0, %al
callq 0x290f0
movq 0x20(%rsp), %rdi
callq 0x3b380
movl %eax, %esi
leaq 0x22f0b8(%rip), %rdi    # 0x266a92
movb $0x0, %al
callq 0x290f0
movq 0x20(%rsp), %rdi
callq 0x3b400
movl %eax, %esi
leaq 0x22ee69(%rip), %rdi    # 0x26685d
movb $0x0, %al
callq 0x290f0
movq 0x20(%rsp), %rdi
callq 0x3b480
movl %eax, %esi
leaq 0x22f098(%rip), %rdi    # 0x266aa6
movb $0x0, %al
callq 0x290f0
movq 0x20(%rsp), %rdi
callq 0x3b500
movl %eax, %esi
leaq 0x22f08f(%rip), %rdi    # 0x266ab7
movb $0x0, %al
callq 0x290f0
movq 0x20(%rsp), %rdi
callq 0x3b580
movl %eax, %esi
leaq 0x22f087(%rip), %rdi    # 0x266ac9
movb $0x0, %al
callq 0x290f0
movq 0x20(%rsp), %rdi
callq 0x3b600
movl %eax, %esi
leaq 0x22f07d(%rip), %rdi    # 0x266ad9
movb $0x0, %al
callq 0x290f0
movq 0x20(%rsp), %rdi
callq 0x3b680
movl %eax, %esi
leaq 0x22eb5a(%rip), %rdi    # 0x2665d0
movb $0x0, %al
callq 0x290f0
movq 0x2b7544(%rip), %rax    # 0x2eefc8
movq (%rax), %rdi
callq 0x29910
movq 0x20(%rsp), %rax
movq %rax, 0x40(%rsp)
movq 0x40(%rsp), %rax
addq $0x48, %rsp
retq
movq 0x18(%rsp), %rdi
callq 0x29c10
nopw (%rax,%rax)