// File: /workspace/github_cpp_makefile_star2_O1/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 $0x5068, %rsp           # imm = 0x5068
movl %edx, %ebp
movq %rsi, %r14
movq %rdi, %r15
leaq 0x13ccd9(%rip), %rsi    # 0x1703e3
movq %r14, %rdi
callq 0x27b30
testq %rax, %rax
je 0x338d0
movq %rax, %rbx
movq %r14, 0x20(%rsp)
leaq 0x1060(%rsp), %rdi
movl $0x4000, %esi           # imm = 0x4000
movq %rax, %rdx
callq 0x27fd0
testq %rax, %rax
movq %rbx, %r14
je 0x338c1
leaq 0x8(%r15), %rax
movq %rax, 0x38(%rsp)
leaq 0x60(%rsp), %r12
leaq 0x50(%rsp), %r13
leaq 0x40(%rsp), %rbx
xorl %eax, %eax
movq %r15, 0x30(%rsp)
movq %r14, 0x28(%rsp)
incl %eax
movl %eax, 0xc(%rsp)
movzbl 0x1060(%rsp), %eax
cmpl $0x23, %eax
je 0x3389a
testl %eax, %eax
je 0x3389a
leaq 0x1060(%rsp), %rdi
leaq 0x138955(%rip), %rsi    # 0x16c0eb
movq %r12, %rdx
xorl %eax, %eax
callq 0x27900
cmpl $0x1, %eax
jne 0x33919
movl $0x90, %edi
callq 0x27930
movq %rax, %r14
movq %rax, %rdi
movq %r12, %rsi
callq 0x37d24
movq %r15, 0x8(%r14)
movl 0x14(%r15), %edx
movl %edx, 0x10(%r14)
movq 0x38(%rsp), %rdi
movq %r14, %rsi
callq 0xfa862
movq %r14, %rdi
callq 0x384e8
testl %eax, %eax
je 0x33903
leaq 0x10(%rsp), %r12
movq %r12, %rdi
callq 0xfa7cc
movq %r14, %rdi
movq %r12, %rsi
callq 0x388ea
testl %eax, %eax
je 0x338f9
movq %r14, %rdi
leaq 0x10(%rsp), %rsi
callq 0x38b30
testl %eax, %eax
je 0x338f9
xorl %r15d, %r15d
cmpl $0x1, %r15d
je 0x3387d
movq %r13, %rdi
callq 0xfa7cc
movq %rbx, %rdi
callq 0xfa7cc
movq %r14, %rdi
movl %r15d, %esi
movq %r13, %rdx
movq %rbx, %rcx
movl %ebp, %r8d
callq 0x38fb0
testl %eax, %eax
je 0x338e5
movq %r14, %rdi
movl %r15d, %esi
movq %r13, %rdx
movq %rbx, %rcx
callq 0x39672
movl %eax, %r12d
movq %rbx, %rdi
callq 0xfa836
movq %r13, %rdi
callq 0xfa836
testl %r12d, %r12d
je 0x338f9
incl %r15d
cmpl $0x3, %r15d
jne 0x33822
leaq 0x10(%rsp), %rdi
callq 0xfa836
movq 0x30(%rsp), %r15
movq 0x28(%rsp), %r14
leaq 0x1060(%rsp), %rdi
movl $0x4000, %esi           # imm = 0x4000
movq %r14, %rdx
callq 0x27fd0
leaq 0x60(%rsp), %r12
testq %rax, %rax
movl 0xc(%rsp), %eax
jne 0x33768
movq %r14, %rdi
callq 0x27920
movl $0x1, %ebx
jmp 0x33905
leaq 0x11b21d(%rip), %rdi    # 0x14eaf4
xorl %ebx, %ebx
movq %r14, %rsi
xorl %eax, %eax
callq 0xfd64a
jmp 0x33905
leaq 0x40(%rsp), %rdi
callq 0xfa836
leaq 0x50(%rsp), %rdi
callq 0xfa836
leaq 0x10(%rsp), %rdi
callq 0xfa836
xorl %ebx, %ebx
movl %ebx, %eax
addq $0x5068, %rsp           # imm = 0x5068
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
leaq 0x11b1f7(%rip), %rdi    # 0x14eb17
movl 0xc(%rsp), %esi
movq 0x20(%rsp), %rdx
xorl %eax, %eax
callq 0xfd64a
jmp 0x33903
movq %rax, %rbx
movl $0x90, %esi
movq %r14, %rdi
callq 0x27950
jmp 0x33971
jmp 0x3394b
movq %rax, %rbx
jmp 0x3395d
movq %rax, %rbx
jmp 0x33967
movq %rax, %rbx
leaq 0x40(%rsp), %rdi
callq 0xfa836
leaq 0x50(%rsp), %rdi
callq 0xfa836
leaq 0x10(%rsp), %rdi
callq 0xfa836
movq %rbx, %rdi
callq 0x28160
nop