// File: /workspace/github_cpp_makefile_star2_O1/tomfunkhouser[P]gaps/pkgs/GSV/GSVScene.cpp
// Function: gaps::GSVScene::ReadGSFFile(char const*, int)
int GSVScene::
ReadGSFFile(const char *filename, RNBoolean read_points)
{
  // Open file
  FILE *fp = fopen(filename, "r");
  if (!fp) {
    RNFail("Unable to open GSV scene file: %s\n", filename);
    return 0;
  }

  // Read run names from file
  int line_count = 0;
  const int buffer_size = 16*1024;
  char buffer[buffer_size];
  while (fgets(buffer, buffer_size, fp)) {
    line_count++;
    if (buffer[0] == '\0') continue;
    if (buffer[0] == '#') continue;

    // Parse command keyword
    char cmd[4096];
    if (sscanf(buffer, "%s", cmd) != (unsigned int) 1) {
      RNFail("Unable to read command from line %d of %s\n", line_count, filename);
      return 0;
    }

    // Parse rest of command
    if (!strcmp(cmd, "raw_data")) {
      // Parse directory name
      char directory_name[1024];
      if (sscanf(buffer, "%s%s", cmd, directory_name) != (unsigned int) 2) {
        RNFail("Unable to read scan_directory from line %d of %s\n", line_count, filename);
        return 0;
      }

      // Set directory name
      SetRawDataDirectoryName(directory_name);
    }
    else if (!strcmp(cmd, "cache_data")) {
      // Parse directory name
      char directory_name[1024];
      if (sscanf(buffer, "%s%s", cmd, directory_name) != (unsigned int) 2) {
        RNFail("Unable to read scan_directory from line %d of %s\n", line_count, filename);
        return 0;
      }

      // Set directory name
      SetCacheDataDirectoryName(directory_name);
    }
    else if (!strcmp(cmd, "run")) {
      // Parse run name
      char run_name[4096];
      if (sscanf(buffer, "%s%s", cmd, run_name) != (unsigned int) 2) {
        RNFail("Unable to read run name from line %d of %s\n", line_count, filename);
        return 0;
      }

      // Create run
      GSVRun *run = new GSVRun(run_name);
      InsertRun(run);
      
      // Read camera info
      if (!run->ReadCameraInfoFile()) return 0;
      
      // Read image info
      RNArray<GSVPanorama *> panoramas;
      if (!run->ReadImageSegmentFile(panoramas)) return 0;
      if (!run->ReadImagePoseFile(panoramas)) return 0;

      // Read laser stuff
      const int max_laser_index = 2;
      for (int laser_index = 0; laser_index <= max_laser_index; laser_index++) {
        RNArray<GSVScanline *> scanlines;
        RNArray<GSVScan *> scanline_scans;
        if (!run->ReadLaserObjFile(laser_index, scanlines, scanline_scans, read_points)) return 0;
        if (!run->ReadLaserPoseFile(laser_index, scanlines, scanline_scans)) return 0;
      }
    }
  }

  // Close file
  fclose(fp);

  // Return success
  return 1;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x6068, %rsp           # imm = 0x6068
movl %edx, 0x1c(%rsp)
movq %rsi, %r14
movq %rdi, 0x10(%rsp)
leaq 0x13c825(%rip), %rsi    # 0x1703e3
movq %r14, %rdi
callq 0x27b30
testq %rax, %rax
je 0x33eb8
movq %rax, %r15
movq %r14, 0x8(%rsp)
leaq 0x2060(%rsp), %rdi
movl $0x4000, %esi           # imm = 0x4000
movq %rax, %rdx
callq 0x27fd0
testq %rax, %rax
je 0x33ea9
movq 0x10(%rsp), %rax
leaq 0x8(%rax), %r14
leaq 0x50(%rsp), %rbx
xorl %ebp, %ebp
incl %ebp
movzbl 0x2060(%rsp), %eax
cmpl $0x23, %eax
je 0x33e8b
testl %eax, %eax
je 0x33e8b
leaq 0x2060(%rsp), %rdi
leaq 0x1384bc(%rip), %rsi    # 0x16c0eb
leaq 0x60(%rsp), %rdx
xorl %eax, %eax
callq 0x27900
cmpl $0x1, %eax
jne 0x33eed
movq 0x60(%rsp), %rax
movabsq $0x617461645f776172, %rcx # imm = 0x617461645F776172
xorq %rcx, %rax
movzbl 0x68(%rsp), %ecx
orq %rax, %rcx
movl %ebp, 0x4(%rsp)
je 0x33df3
movq 0x60(%rsp), %rax
movabsq $0x61645f6568636163, %rcx # imm = 0x61645F6568636163
xorq %rcx, %rax
movq 0x63(%rsp), %rcx
movabsq $0x617461645f6568, %rdx # imm = 0x617461645F6568
xorq %rdx, %rcx
orq %rax, %rcx
je 0x33e2f
cmpl $0x6e7572, 0x60(%rsp)   # imm = 0x6E7572
leaq 0x1060(%rsp), %r13
jne 0x33e87
leaq 0x2060(%rsp), %rdi
leaq 0x11ee83(%rip), %rsi    # 0x152b3d
leaq 0x60(%rsp), %rdx
movq %r13, %rcx
xorl %eax, %eax
callq 0x27900
cmpl $0x2, %eax
jne 0x33f18
movl $0x90, %edi
callq 0x27930
movq %rax, %r12
movq %rax, %rdi
movq %r13, %rsi
callq 0x37d24
movq 0x10(%rsp), %rax
movq %rax, 0x8(%r12)
movl 0x14(%rax), %edx
movl %edx, 0x10(%r12)
movq %r14, %rdi
movq %r12, %rsi
callq 0xfa862
movq %r12, %rdi
callq 0x384e8
testl %eax, %eax
je 0x33f02
leaq 0x20(%rsp), %r13
movq %r13, %rdi
callq 0xfa7cc
movq %r12, %rdi
movq %r13, %rsi
callq 0x388ea
testl %eax, %eax
je 0x33ee1
movq %r12, %rdi
leaq 0x20(%rsp), %rsi
callq 0x38b30
testl %eax, %eax
je 0x33ee1
movq %r14, 0x30(%rsp)
xorl %r13d, %r13d
movq %r15, 0x38(%rsp)
leaq 0x40(%rsp), %r14
movq %r14, %rdi
callq 0xfa7cc
movq %rbx, %rdi
callq 0xfa7cc
movq %r12, %rbp
movq %r12, %rdi
movl %r13d, %esi
movq %r14, %rdx
movq %rbx, %rcx
movl 0x1c(%rsp), %r8d
callq 0x38fb0
testl %eax, %eax
je 0x33ecd
movq %rbx, %r12
movq %rbp, %rdi
movl %r13d, %esi
leaq 0x40(%rsp), %rbx
movq %rbx, %rdx
movq %r12, %r15
movq %r12, %rcx
callq 0x39672
movl %eax, %r14d
movq %r15, %rdi
callq 0xfa836
movq %rbx, %rdi
callq 0xfa836
testl %r14d, %r14d
je 0x33ee1
incl %r13d
cmpl $0x3, %r13d
movq %r12, %rbx
movq 0x38(%rsp), %r15
movq %rbp, %r12
jne 0x33d59
leaq 0x20(%rsp), %rdi
callq 0xfa836
movq 0x30(%rsp), %r14
jmp 0x33e87
leaq 0x2060(%rsp), %rdi
leaq 0x11ed3b(%rip), %rsi    # 0x152b3d
leaq 0x60(%rsp), %rdx
leaq 0x1060(%rsp), %r13
movq %r13, %rcx
xorl %eax, %eax
callq 0x27900
movl %eax, %ebp
cmpl $0x2, %eax
jne 0x33e6b
movq 0x10(%rsp), %rdi
movq %r13, %rsi
callq 0x330c4
jmp 0x33e82
leaq 0x2060(%rsp), %rdi
leaq 0x11ecff(%rip), %rsi    # 0x152b3d
leaq 0x60(%rsp), %rdx
leaq 0x1060(%rsp), %r13
movq %r13, %rcx
xorl %eax, %eax
callq 0x27900
movl %eax, %ebp
cmpl $0x2, %eax
jne 0x33e6b
movq 0x10(%rsp), %rdi
movq %r13, %rsi
callq 0x330fa
jmp 0x33e82
leaq 0x11acfc(%rip), %rdi    # 0x14eb6e
movl 0x4(%rsp), %esi
movq 0x8(%rsp), %rdx
xorl %eax, %eax
callq 0xfd64a
cmpl $0x2, %ebp
jne 0x33f02
movl 0x4(%rsp), %ebp
leaq 0x2060(%rsp), %rdi
movl $0x4000, %esi           # imm = 0x4000
movq %r15, %rdx
callq 0x27fd0
testq %rax, %rax
jne 0x33c05
movq %r15, %rdi
callq 0x27920
movl $0x1, %ebx
jmp 0x33f04
leaq 0x11ac35(%rip), %rdi    # 0x14eaf4
xorl %ebx, %ebx
movq %r14, %rsi
xorl %eax, %eax
callq 0xfd64a
jmp 0x33f04
leaq 0x50(%rsp), %rdi
callq 0xfa836
leaq 0x40(%rsp), %rdi
callq 0xfa836
leaq 0x20(%rsp), %rdi
callq 0xfa836
jmp 0x33f02
leaq 0x11ac4f(%rip), %rdi    # 0x14eb43
movl %ebp, %esi
movq 0x8(%rsp), %rdx
xorl %eax, %eax
callq 0xfd64a
xorl %ebx, %ebx
movl %ebx, %eax
addq $0x6068, %rsp           # imm = 0x6068
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
leaq 0x11abf8(%rip), %rdi    # 0x14eb17
movl 0x4(%rsp), %esi
jmp 0x33ef6
movq %rax, %rbx
movl $0x90, %esi
movq %r12, %rdi
callq 0x27950
jmp 0x33f64
jmp 0x33f39
movq %rax, %rbx
jmp 0x33f5a
movq %rax, %rbx
jmp 0x33f50
movq %rax, %rbx
leaq 0x50(%rsp), %rdi
callq 0xfa836
leaq 0x40(%rsp), %rdi
callq 0xfa836
leaq 0x20(%rsp), %rdi
callq 0xfa836
movq %rbx, %rdi
callq 0x28160