// File: /workspace/github_cpp_makefile_star2_O3/tomfunkhouser[P]gaps/pkgs/GSV/GSVScene.cpp
// Function: gaps::GSVScene::ReadLaserFile(char const*, int)
int GSVScene::
ReadLaserFile(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 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 $0x5058, %rsp           # imm = 0x5058
movl %edx, %ebp
movq %rsi, %r14
movq %rdi, %r15
leaq 0x13ac75(%rip), %rsi    # 0x16e443
movq %r14, %rdi
callq 0x27b20
testq %rax, %rax
je 0x3393d
movq %rax, %r12
movq %r14, 0x20(%rsp)
leaq 0x1050(%rsp), %rdi
movl $0x4000, %esi           # imm = 0x4000
movq %rax, %rdx
callq 0x27fc0
testq %rax, %rax
je 0x3392e
leaq 0x8(%r15), %rax
movq %rax, 0x28(%rsp)
leaq 0x1050(%rsp), %r14
leaq 0x40(%rsp), %r13
leaq 0x30(%rsp), %rbx
xorl %eax, %eax
movq %r15, 0x18(%rsp)
movq %r12, 0x10(%rsp)
incl %eax
movl %eax, 0xc(%rsp)
movzbl 0x1050(%rsp), %eax
cmpl $0x23, %eax
je 0x33911
testl %eax, %eax
je 0x33911
movq %r14, %rdi
leaq 0x1368d6(%rip), %rsi    # 0x16a12b
leaq 0x50(%rsp), %r14
movq %r14, %rdx
xorl %eax, %eax
callq 0x27900
cmpl $0x1, %eax
jne 0x3397c
movl $0x90, %edi
callq 0x27930
movq %r14, %rsi
movq %rax, %r14
movq %rax, %rdi
callq 0x37b7c
movq %r15, 0x8(%r14)
movl 0x14(%r15), %edx
movl %edx, 0x10(%r14)
movq 0x28(%rsp), %rdi
movq %r14, %rsi
callq 0xf8c16
xorl %r12d, %r12d
movq %r13, %rdi
callq 0xf8b80
movq %rbx, %rdi
callq 0xf8b80
movq %r14, %rdi
movl %r12d, %esi
movq %r13, %rdx
movq %rbx, %rcx
movl %ebp, %r8d
callq 0x38d98
testl %eax, %eax
je 0x33952
movq %r14, %rdi
movl %r12d, %esi
movq %r13, %rdx
movq %rbx, %rcx
callq 0x393a4
movl %eax, %r15d
movq %rbx, %rdi
callq 0xf8bea
movq %r13, %rdi
callq 0xf8bea
testl %r15d, %r15d
je 0x33966
incl %r12d
cmpl $0x3, %r12d
jne 0x338a1
movq 0x18(%rsp), %r15
movq 0x10(%rsp), %r12
leaq 0x1050(%rsp), %r14
movq %r14, %rdi
movl $0x4000, %esi           # imm = 0x4000
movq %r12, %rdx
callq 0x27fc0
testq %rax, %rax
movl 0xc(%rsp), %eax
jne 0x3382c
movq %r12, %rdi
callq 0x27920
movl $0x1, %ebx
jmp 0x33968
leaq 0x1191c0(%rip), %rdi    # 0x14cb04
xorl %ebx, %ebx
movq %r14, %rsi
xorl %eax, %eax
callq 0xfb6f2
jmp 0x33968
leaq 0x30(%rsp), %rdi
callq 0xf8bea
leaq 0x40(%rsp), %rdi
callq 0xf8bea
xorl %ebx, %ebx
movl %ebx, %eax
addq $0x5058, %rsp           # imm = 0x5058
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
leaq 0x1191a4(%rip), %rdi    # 0x14cb27
xorl %ebx, %ebx
movl 0xc(%rsp), %esi
movq 0x20(%rsp), %rdx
xorl %eax, %eax
callq 0xfb6f2
jmp 0x33968
movq %rax, %rbx
movl $0x90, %esi
movq %r14, %rdi
callq 0x27950
jmp 0x339c5
movq %rax, %rbx
jmp 0x339bb
movq %rax, %rbx
leaq 0x30(%rsp), %rdi
callq 0xf8bea
leaq 0x40(%rsp), %rdi
callq 0xf8bea
movq %rbx, %rdi
callq 0x28150
nop