// File: /workspace/github_cpp_makefile_star2_O2/tomfunkhouser[P]gaps/pkgs/GSV/GSVScene.cpp
// Function: gaps::GSVScene::ReadASCIIFile(char const*, int)
int GSVScene::
ReadASCIIFile(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;
    char run_name[4096];
    if (sscanf(buffer, "%s", run_name) != (unsigned int) 1) {
      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++) {
      if (laser_index == 1) continue;
      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 $0x5058, %rsp           # imm = 0x5058
movl %edx, 0x4(%rsp)
movq %rsi, %r14
movq %rdi, 0x28(%rsp)
leaq 0x11b2a3(%rip), %rsi    # 0x14d0a3
movq %r14, %rdi
callq 0x27b20
movq %rax, 0x8(%rsp)
testq %rax, %rax
je 0x31f67
movq %r14, 0x20(%rsp)
leaq 0x50(%rsp), %rbp
leaq 0x40(%rsp), %r14
leaq 0x30(%rsp), %r12
movl $0x0, (%rsp)
leaq 0x1050(%rsp), %rdi
movl $0x4000, %esi           # imm = 0x4000
movq 0x8(%rsp), %rdx
callq 0x27fe0
testq %rax, %rax
je 0x31fb0
incl (%rsp)
movzbl 0x1050(%rsp), %eax
testl %eax, %eax
je 0x31e31
cmpl $0x23, %eax
je 0x31e31
leaq 0x1050(%rsp), %rdi
leaq 0x1171b7(%rip), %rsi    # 0x14902b
movq %rbp, %rdx
xorl %eax, %eax
callq 0x27900
cmpl $0x1, %eax
jne 0x31fbf
movl $0x90, %edi
callq 0x27940
movq %rax, %rbx
movq %rax, %rdi
movq %rbp, %rsi
callq 0x35f68
movq 0x28(%rsp), %rdi
movq %rbx, %rsi
callq 0x31726
movq %rbx, %rdi
callq 0x36644
testl %eax, %eax
je 0x31f9a
leaq 0x10(%rsp), %r15
movq %r15, %rdi
callq 0xe1cd2
movq %rbx, %rdi
movq %r15, %rsi
callq 0x369ca
testl %eax, %eax
je 0x31f90
movq %rbx, %rdi
leaq 0x10(%rsp), %rsi
callq 0x36bb0
testl %eax, %eax
je 0x31f90
xorl %r15d, %r15d
cmpl $0x1, %r15d
je 0x31f53
cmpl $0x3, %r15d
je 0x31f58
movq %r14, %rdi
callq 0xe1cd2
movq %r12, %rdi
callq 0xe1cd2
movq %rbx, %rdi
movl %r15d, %esi
movq %r14, %rdx
movq %r12, %rcx
movl 0x4(%rsp), %r8d
callq 0x36f6a
testl %eax, %eax
je 0x31f7c
movq %rbx, %rdi
movl %r15d, %esi
movq %r14, %rdx
movq %r12, %rcx
callq 0x37446
movl %eax, %r13d
movq %r12, %rdi
callq 0xe1d40
movq %r14, %rdi
callq 0xe1d40
testl %r13d, %r13d
je 0x31f90
incl %r15d
jmp 0x31ef4
leaq 0x10(%rsp), %rdi
callq 0xe1d40
jmp 0x31e31
leaq 0xf9b96(%rip), %rdi     # 0x12bb04
xorl %ebx, %ebx
movq %r14, %rsi
xorl %eax, %eax
callq 0xe434a
jmp 0x31f9c
leaq 0x30(%rsp), %rdi
callq 0xe1d40
leaq 0x40(%rsp), %rdi
callq 0xe1d40
leaq 0x10(%rsp), %rdi
callq 0xe1d40
xorl %ebx, %ebx
movl %ebx, %eax
addq $0x5058, %rsp           # imm = 0x5058
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq 0x8(%rsp), %rdi
callq 0x27930
pushq $0x1
popq %rbx
jmp 0x31f9c
leaq 0xf9b61(%rip), %rdi     # 0x12bb27
movl (%rsp), %esi
movq 0x20(%rsp), %rdx
xorl %eax, %eax
callq 0xe434a
jmp 0x31f9a
movq %rax, %r14
movl $0x90, %esi
movq %rbx, %rdi
callq 0x27960
jmp 0x32016
jmp 0x31ff0
movq %rax, %r14
jmp 0x32002
movq %rax, %r14
jmp 0x3200c
movq %rax, %r14
leaq 0x30(%rsp), %rdi
callq 0xe1d40
leaq 0x40(%rsp), %rdi
callq 0xe1d40
leaq 0x10(%rsp), %rdi
callq 0xe1d40
movq %r14, %rdi
callq 0x28170