// File: /workspace/github_cpp_makefile_star2_O3/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 0x13af05(%rip), %rsi    # 0x16e443
movq %r14, %rdi
callq 0x27b20
testq %rax, %rax
je 0x33704
movq %rax, %rbx
movq %r14, 0x20(%rsp)
leaq 0x1060(%rsp), %rdi
movl $0x4000, %esi           # imm = 0x4000
movq %rax, %rdx
callq 0x27fc0
testq %rax, %rax
movq %rbx, %r14
je 0x336f5
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 0x336ce
testl %eax, %eax
je 0x336ce
leaq 0x1060(%rsp), %rdi
leaq 0x136b61(%rip), %rsi    # 0x16a12b
movq %r12, %rdx
xorl %eax, %eax
callq 0x27900
cmpl $0x1, %eax
jne 0x3374d
movl $0x90, %edi
callq 0x27930
movq %rax, %r14
movq %rax, %rdi
movq %r12, %rsi
callq 0x37b7c
movq %r15, 0x8(%r14)
movl 0x14(%r15), %edx
movl %edx, 0x10(%r14)
movq 0x38(%rsp), %rdi
movq %r14, %rsi
callq 0xf8c16
movq %r14, %rdi
callq 0x38328
testl %eax, %eax
je 0x33737
leaq 0x10(%rsp), %r12
movq %r12, %rdi
callq 0xf8b80
movq %r14, %rdi
movq %r12, %rsi
callq 0x38728
testl %eax, %eax
je 0x3372d
movq %r14, %rdi
leaq 0x10(%rsp), %rsi
callq 0x38980
testl %eax, %eax
je 0x3372d
xorl %r15d, %r15d
cmpl $0x1, %r15d
je 0x336b1
movq %r13, %rdi
callq 0xf8b80
movq %rbx, %rdi
callq 0xf8b80
movq %r14, %rdi
movl %r15d, %esi
movq %r13, %rdx
movq %rbx, %rcx
movl %ebp, %r8d
callq 0x38d98
testl %eax, %eax
je 0x33719
movq %r14, %rdi
movl %r15d, %esi
movq %r13, %rdx
movq %rbx, %rcx
callq 0x393a4
movl %eax, %r12d
movq %rbx, %rdi
callq 0xf8bea
movq %r13, %rdi
callq 0xf8bea
testl %r12d, %r12d
je 0x3372d
incl %r15d
cmpl $0x3, %r15d
jne 0x33656
leaq 0x10(%rsp), %rdi
callq 0xf8bea
movq 0x30(%rsp), %r15
movq 0x28(%rsp), %r14
leaq 0x1060(%rsp), %rdi
movl $0x4000, %esi           # imm = 0x4000
movq %r14, %rdx
callq 0x27fc0
leaq 0x60(%rsp), %r12
testq %rax, %rax
movl 0xc(%rsp), %eax
jne 0x3359c
movq %r14, %rdi
callq 0x27920
movl $0x1, %ebx
jmp 0x33739
leaq 0x1193f9(%rip), %rdi    # 0x14cb04
xorl %ebx, %ebx
movq %r14, %rsi
xorl %eax, %eax
callq 0xfb6f2
jmp 0x33739
leaq 0x40(%rsp), %rdi
callq 0xf8bea
leaq 0x50(%rsp), %rdi
callq 0xf8bea
leaq 0x10(%rsp), %rdi
callq 0xf8bea
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 0x1193d3(%rip), %rdi    # 0x14cb27
movl 0xc(%rsp), %esi
movq 0x20(%rsp), %rdx
xorl %eax, %eax
callq 0xfb6f2
jmp 0x33737
movq %rax, %rbx
movl $0x90, %esi
movq %r14, %rdi
callq 0x27950
jmp 0x337a5
jmp 0x3377f
movq %rax, %rbx
jmp 0x33791
movq %rax, %rbx
jmp 0x3379b
movq %rax, %rbx
leaq 0x40(%rsp), %rdi
callq 0xf8bea
leaq 0x50(%rsp), %rdi
callq 0xf8bea
leaq 0x10(%rsp), %rdi
callq 0xf8bea
movq %rbx, %rdi
callq 0x28150
nop