// File: /workspace/github_cpp_makefile_star2_O1/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 0x13ca49(%rip), %rsi    # 0x1703e3
movq %r14, %rdi
callq 0x27b30
testq %rax, %rax
je 0x33b09
movq %rax, %r12
movq %r14, 0x20(%rsp)
leaq 0x1050(%rsp), %rdi
movl $0x4000, %esi           # imm = 0x4000
movq %rax, %rdx
callq 0x27fd0
testq %rax, %rax
je 0x33afa
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 0x33add
testl %eax, %eax
je 0x33add
movq %r14, %rdi
leaq 0x1386ca(%rip), %rsi    # 0x16c0eb
leaq 0x50(%rsp), %r14
movq %r14, %rdx
xorl %eax, %eax
callq 0x27900
cmpl $0x1, %eax
jne 0x33b48
movl $0x90, %edi
callq 0x27930
movq %r14, %rsi
movq %rax, %r14
movq %rax, %rdi
callq 0x37d24
movq %r15, 0x8(%r14)
movl 0x14(%r15), %edx
movl %edx, 0x10(%r14)
movq 0x28(%rsp), %rdi
movq %r14, %rsi
callq 0xfa862
xorl %r12d, %r12d
movq %r13, %rdi
callq 0xfa7cc
movq %rbx, %rdi
callq 0xfa7cc
movq %r14, %rdi
movl %r12d, %esi
movq %r13, %rdx
movq %rbx, %rcx
movl %ebp, %r8d
callq 0x38fb0
testl %eax, %eax
je 0x33b1e
movq %r14, %rdi
movl %r12d, %esi
movq %r13, %rdx
movq %rbx, %rcx
callq 0x39672
movl %eax, %r15d
movq %rbx, %rdi
callq 0xfa836
movq %r13, %rdi
callq 0xfa836
testl %r15d, %r15d
je 0x33b32
incl %r12d
cmpl $0x3, %r12d
jne 0x33a6d
movq 0x18(%rsp), %r15
movq 0x10(%rsp), %r12
leaq 0x1050(%rsp), %r14
movq %r14, %rdi
movl $0x4000, %esi           # imm = 0x4000
movq %r12, %rdx
callq 0x27fd0
testq %rax, %rax
movl 0xc(%rsp), %eax
jne 0x339f8
movq %r12, %rdi
callq 0x27920
movl $0x1, %ebx
jmp 0x33b34
leaq 0x11afe4(%rip), %rdi    # 0x14eaf4
xorl %ebx, %ebx
movq %r14, %rsi
xorl %eax, %eax
callq 0xfd64a
jmp 0x33b34
leaq 0x30(%rsp), %rdi
callq 0xfa836
leaq 0x40(%rsp), %rdi
callq 0xfa836
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 0x11afc8(%rip), %rdi    # 0x14eb17
xorl %ebx, %ebx
movl 0xc(%rsp), %esi
movq 0x20(%rsp), %rdx
xorl %eax, %eax
callq 0xfd64a
jmp 0x33b34
movq %rax, %rbx
movl $0x90, %esi
movq %r14, %rdi
callq 0x27950
jmp 0x33b91
movq %rax, %rbx
jmp 0x33b87
movq %rax, %rbx
leaq 0x30(%rsp), %rdi
callq 0xfa836
leaq 0x40(%rsp), %rdi
callq 0xfa836
movq %rbx, %rdi
callq 0x28160
nop