LLM4Binary/decompile-bench-makefile huggingface dataset:
// File: /workspace/github_cpp_makefile_star2_O2/tomfunkhouser[P]gaps/pkgs/GSV/GSVTapestry.cpp
// Function: gaps::GSVTapestry::FindImageBeforeTimestamp(double, int, int) const
GSVImage *GSVTapestry::
FindImageBeforeTimestamp(RNScalar timestamp, int imin, int imax) const
{
  // Binary search
  int i = (imin + imax) / 2;
  if (i == imin) return Image(imin);
  assert(i < imax);
  GSVImage *image = Image(i);
  RNScalar t = image->Timestamp();
  if (t > timestamp) return FindImageBeforeTimestamp(timestamp, imin, i);
  else if (t < timestamp) return FindImageBeforeTimestamp(timestamp, i, imax);
  else return image;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
pushq %rax
movl %edx, %r14d
movl %esi, %ebx
movsd %xmm0, (%rsp)
movq %rdi, %r15
pushq $0x2
popq %rbp
movl %r14d, %r13d
movl %r13d, %r14d
leal (%r14,%rbx), %eax
cltd
idivl %ebp
movq 0x28(%r15), %rcx
cmpl %ebx, %eax
je 0x3bd33
movl %eax, %r13d
cltq
movq (%rcx,%rax,8), %r12
movq %r12, %rdi
pushq $-0x1
popq %rsi
callq 0x3adba
ucomisd (%rsp), %xmm0
ja 0x3bcf6
movsd (%rsp), %xmm1
ucomisd %xmm0, %xmm1
movl %r13d, %ebx
ja 0x3bcf3
jmp 0x3bd3a
movslq %ebx, %rax
movq (%rcx,%rax,8), %r12
movq %r12, %rax
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
// File: /workspace/github_cpp_makefile_star2_O2/tomfunkhouser[P]gaps/pkgs/GSV/GSVTapestry.cpp
// Function: gaps::GSVTapestry::FindImageBeforeTimestamp(double) const
GSVImage *GSVTapestry::
FindImageBeforeTimestamp(RNScalar timestamp) const
{
  // Binary search
  if (NImages() == 0) return NULL;
  if (timestamp <= Image(0)->Timestamp()) return Image(0);
  if (timestamp >= Image(NImages()-1)->Timestamp()) return Image(NImages()-1);
  return FindImageBeforeTimestamp(timestamp, 0, NImages()-1);
}

// Assembly:
pushq %rbx
subq $0x10, %rsp
cmpl $0x0, 0x34(%rdi)
je 0x3bdb3
movq %rdi, %rbx
movq 0x28(%rdi), %rax
movq (%rax), %rdi
pushq $-0x1
popq %rsi
movsd %xmm0, 0x8(%rsp)
callq 0x3adba
ucomisd 0x8(%rsp), %xmm0
jae 0x3bdb7
movslq 0x34(%rbx), %rax
movq 0x28(%rbx), %rcx
movq -0x8(%rcx,%rax,8), %rdi
pushq $-0x1
popq %rsi
callq 0x3adba
movsd 0x8(%rsp), %xmm1
ucomisd %xmm0, %xmm1
movsd 0x8(%rsp), %xmm0
movslq 0x34(%rbx), %rdx
jae 0x3bdc0
decl %edx
movq %rbx, %rdi
xorl %esi, %esi
addq $0x10, %rsp
popq %rbx
jmp 0x3bcd8
xorl %eax, %eax
jmp 0x3bdc9
movq 0x28(%rbx), %rax
movq (%rax), %rax
jmp 0x3bdc9
movq 0x28(%rbx), %rax
movq -0x8(%rax,%rdx,8), %rax
addq $0x10, %rsp
popq %rbx
retq
nop
// File: /workspace/github_cpp_makefile_star2_O2/tomfunkhouser[P]gaps/pkgs/GSV/GSVTapestry.cpp
// Function: gaps::GSVTapestry::Print(_IO_FILE*, char const*, char const*) const
void GSVTapestry::
Print(FILE *fp, const char *prefix, const char *suffix) const
{
  // Check fp
  if (!fp) fp = stdout;

  // Print tapestry header
  if (prefix) fprintf(fp, "%s", prefix);
  fprintf(fp, "Tapestry %d:", segment_index);
  if (suffix) fprintf(fp, "%s", suffix);
  fprintf(fp, "\n");

  // Add indentation to prefix
  char indented_prefix[1024];
  sprintf(indented_prefix, "%s  ", prefix);

   // Print images
  for (int i = 0; i < NImages(); i++) {
    GSVImage *image = Image(i);
    image->Print(fp, indented_prefix, suffix);
  }
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x408, %rsp            # imm = 0x408
movq %rcx, %rbx
movq %rdx, %r12
movq %rsi, %r15
movq %rdi, %r14
testq %rsi, %rsi
jne 0x3c0f4
movq 0x181e4f(%rip), %rax    # 0x1bdf40
movq (%rax), %r15
testq %r12, %r12
je 0x3c104
movq %r12, %rdi
movq %r15, %rsi
callq 0x27aa0
movl 0x10(%r14), %edx
leaq 0xeffc7(%rip), %rsi     # 0x12c0d6
movq %r15, %rdi
xorl %eax, %eax
callq 0x27e20
testq %rbx, %rbx
je 0x3c129
movq %rbx, %rdi
movq %r15, %rsi
callq 0x27aa0
pushq $0xa
popq %rdi
movq %r15, %rsi
callq 0x27c30
leaq 0xef8b9(%rip), %rsi     # 0x12b9f4
xorl %ebp, %ebp
movq %rsp, %r13
movq %r13, %rdi
movq %r12, %rdx
xorl %eax, %eax
callq 0x27140
movslq 0x34(%r14), %rax
cmpq %rax, %rbp
jge 0x3c172
movq 0x28(%r14), %rax
movq (%rax,%rbp,8), %rdi
movq (%rdi), %rax
movq %r15, %rsi
movq %r13, %rdx
movq %rbx, %rcx
callq *0x18(%rax)
incq %rbp
jmp 0x3c14d
addq $0x408, %rsp            # imm = 0x408
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
// File: /workspace/github_cpp_makefile_star2_O2/tomfunkhouser[P]gaps/pkgs/GSV/GSVTapestry.cpp
// Function: gaps::GSVTapestry::UpdateBBox()
void GSVTapestry::
UpdateBBox(void) 
{
  // Update bounding box
  bbox = R3null_box;
  for (int i = 0; i < NImages(); i++) {
    bbox.Union(Image(i)->Pose().Viewpoint());
  }
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x48, %rsp
movq %rdi, %rbx
leaq 0x38(%rdi), %r14
leaq 0x18b818(%rip), %rsi    # 0x1c79b8
movq %r14, %rdi
callq 0x30d44
leaq 0x10(%rsp), %r15
xorl %r13d, %r13d
leaq 0x8(%rsp), %r12
pushq $-0x1
popq %rbp
movslq 0x34(%rbx), %rax
cmpq %rax, %r13
jge 0x3c1eb
movq 0x28(%rbx), %rax
movq (%rax,%r13,8), %rsi
movq %r12, %rdi
movl %ebp, %edx
callq 0x3acd2
movq %r14, %rdi
movq %r15, %rsi
callq 0xad308
movq %r12, %rdi
callq 0x41e6a
incq %r13
jmp 0x3c1b8
addq $0x48, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq %rax, %rbx
leaq 0x8(%rsp), %rdi
callq 0x41e6a
movq %rbx, %rdi
callq 0x28170
nop
// File: /workspace/github_cpp_makefile_star2_O2/tomfunkhouser[P]gaps/pkgs/GSV/GSVLaser.cpp
// Function: gaps::GSVLaser::GSVLaser(int)
GSVLaser::
GSVLaser(int device_type)
  : run(NULL),
    run_index(-1),
    surveys(),
    device_type(device_type),
    max_sweep_index(0),
    max_beam_index(0),
    bbox(FLT_MAX,FLT_MAX,FLT_MAX,-FLT_MAX,-FLT_MAX,-FLT_MAX),
    data(NULL)
{
  // Set max sweep and beam indices
  if (device_type == GSV_SICK_LASER) {
    max_sweep_index = 0;
    max_beam_index = 179;
  }
  else if (device_type == GSV_VLP16_LASER) {
    max_sweep_index = 1799;
    max_beam_index = 15;
  }
}

// Assembly:
pushq %rbp
pushq %r14
pushq %rbx
movl %esi, %ebp
movq %rdi, %rbx
leaq 0x179838(%rip), %rax    # 0x1b5a58
movq %rax, (%rdi)
andq $0x0, 0x8(%rdi)
orl $-0x1, 0x10(%rdi)
leaq 0x18(%rdi), %r14
movq %r14, %rdi
callq 0xe1cd2
movl %ebp, 0x28(%rbx)
andq $0x0, 0x2c(%rbx)
leaq 0x38(%rbx), %rdi
movsd 0xeeddc(%rip), %xmm0    # 0x12b028
movsd 0xeeecc(%rip), %xmm3    # 0x12b120
movaps %xmm0, %xmm1
movaps %xmm0, %xmm2
movaps %xmm3, %xmm4
movaps %xmm3, %xmm5
callq 0xaca42
andq $0x0, 0x70(%rbx)
cmpl $0x1, %ebp
je 0x3c27e
cmpl $0x2, %ebp
jne 0x3c28a
movsd 0xefe84(%rip), %xmm0    # 0x12c100
jmp 0x3c286
movsd 0xefe8a(%rip), %xmm0    # 0x12c110
movlps %xmm0, 0x2c(%rbx)
popq %rbx
popq %r14
popq %rbp
retq
movq %rax, %rbx
movq %r14, %rdi
callq 0xe1d40
movq %rbx, %rdi
callq 0x28170
// File: /workspace/github_cpp_makefile_star2_O2/tomfunkhouser[P]gaps/pkgs/GSV/GSVLaser.cpp
// Function: gaps::GSVLaser::~GSVLaser()
GSVLaser::
~GSVLaser(void)
{
  // Remove laser from run
  if (run) run->RemoveLaser(this);

  // Remove surveys from this laser
  while (NSurveys() > 0) RemoveSurvey(Survey(0));
}

// Assembly:
pushq %r14
pushq %rbx
pushq %rax
movq %rdi, %rbx
leaq 0x1797a8(%rip), %rax    # 0x1b5a58
movq %rax, (%rdi)
movq 0x8(%rdi), %rdi
testq %rdi, %rdi
je 0x3c2c4
movq %rbx, %rsi
callq 0x363e8
leaq 0x18(%rbx), %r14
cmpl $0x0, 0x24(%rbx)
jle 0x3c2df
movq 0x18(%rbx), %rax
movq (%rax), %rsi
movq %rbx, %rdi
callq 0x3c304
jmp 0x3c2c8
addq $0x38, %rbx
movq %rbx, %rdi
callq 0xad65a
movq %r14, %rdi
addq $0x8, %rsp
popq %rbx
popq %r14
jmp 0xe1d40
jmp 0x3c2fc
movq %rax, %rdi
callq 0x376d2
// File: /workspace/github_cpp_makefile_star2_O2/tomfunkhouser[P]gaps/pkgs/GSV/GSVLaser.cpp
// Function: gaps::GSVLaser::Draw(gaps::RNFlags) const
void GSVLaser::
Draw(RNFlags flags) const
{
  // Draw surveys
  for (int i = 0; i < NSurveys(); i++) {
    GSVSurvey *survey = Survey(i);
    survey->Draw(flags);
  }
}

// Assembly:
pushq %r15
pushq %r14
pushq %rbx
movq %rsi, %rbx
movq %rdi, %r14
xorl %r15d, %r15d
movslq 0x24(%r14), %rax
cmpq %rax, %r15
jge 0x3c483
movq 0x18(%r14), %rax
movq (%rax,%r15,8), %rdi
movq (%rdi), %rax
movq %rbx, %rsi
callq *0x10(%rax)
incq %r15
jmp 0x3c464
popq %rbx
popq %r14
popq %r15
retq
nop
// File: /workspace/github_cpp_makefile_star2_O2/tomfunkhouser[P]gaps/pkgs/GSV/GSVLaser.cpp
// Function: gaps::GSVLaser::Print(_IO_FILE*, char const*, char const*) const
void GSVLaser::
Print(FILE *fp, const char *prefix, const char *suffix) const
{
  // Check fp
  if (!fp) fp = stdout;

  // Print laser header
  if (prefix) fprintf(fp, "%s", prefix);
  fprintf(fp, "Laser %d:", run_index);
  if (suffix) fprintf(fp, "%s", suffix);
  fprintf(fp, "\n");

  // Add indentation to prefix
  char indented_prefix[1024];
  sprintf(indented_prefix, "%s  ", prefix);

 // Print surveys
  for (int i = 0; i < NSurveys(); i++) {
    GSVSurvey *survey = Survey(i);
    survey->Print(fp, indented_prefix, suffix);
  }
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x408, %rsp            # imm = 0x408
movq %rcx, %rbx
movq %rdx, %r12
movq %rsi, %r15
movq %rdi, %r14
testq %rsi, %rsi
jne 0x3c4b6
movq 0x181a8d(%rip), %rax    # 0x1bdf40
movq (%rax), %r15
testq %r12, %r12
je 0x3c4c6
movq %r12, %rdi
movq %r15, %rsi
callq 0x27aa0
movl 0x10(%r14), %edx
leaq 0xefc4f(%rip), %rsi     # 0x12c120
movq %r15, %rdi
xorl %eax, %eax
callq 0x27e20
testq %rbx, %rbx
je 0x3c4eb
movq %rbx, %rdi
movq %r15, %rsi
callq 0x27aa0
pushq $0xa
popq %rdi
movq %r15, %rsi
callq 0x27c30
leaq 0xef4f7(%rip), %rsi     # 0x12b9f4
xorl %ebp, %ebp
movq %rsp, %r13
movq %r13, %rdi
movq %r12, %rdx
xorl %eax, %eax
callq 0x27140
movslq 0x24(%r14), %rax
cmpq %rax, %rbp
jge 0x3c534
movq 0x18(%r14), %rax
movq (%rax,%rbp,8), %rdi
movq (%rdi), %rax
movq %r15, %rsi
movq %r13, %rdx
movq %rbx, %rcx
callq *0x18(%rax)
incq %rbp
jmp 0x3c50f
addq $0x408, %rsp            # imm = 0x408
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
// File: /workspace/github_cpp_makefile_star2_O2/tomfunkhouser[P]gaps/pkgs/GSV/GSVLaser.cpp
// Function: gaps::GSVLaser::UpdateBBox()
void GSVLaser::
UpdateBBox(void) 
{
  // Update bounding box
  bbox = R3null_box;
  for (int i = 0; i < NSurveys(); i++) {
    bbox.Union(Survey(i)->BBox());
  }
}

// Assembly:
pushq %r15
pushq %r14
pushq %rbx
movq %rdi, %rbx
leaq 0x38(%rdi), %r14
leaq 0x18b45f(%rip), %rsi    # 0x1c79b8
movq %r14, %rdi
callq 0x30d44
xorl %r15d, %r15d
movslq 0x24(%rbx), %rax
cmpq %rax, %r15
jge 0x3c58a
movq 0x18(%rbx), %rax
movq (%rax,%r15,8), %rdi
callq 0x38b16
movq %r14, %rdi
movq %rax, %rsi
callq 0xad3ba
incq %r15
jmp 0x3c564
popq %rbx
popq %r14
popq %r15
retq
// File: /workspace/github_cpp_makefile_star2_O2/tomfunkhouser[P]gaps/pkgs/GSV/GSVSurvey.cpp
// Function: gaps::GSVSurvey::~GSVSurvey()
GSVSurvey::
~GSVSurvey(void)
{
  // Remove survey from segment
  if (segment) segment->RemoveSurvey(this);

  // Remove survey from laser
  if (laser) laser->RemoveSurvey(this);

  // Delete scans
  while (NScans()) delete Scan(0);

  // Delete travel distances
  if (travel_distances) delete [] travel_distances;
}

// Assembly:
pushq %r14
pushq %rbx
pushq %rax
movq %rdi, %rbx
leaq 0x179480(%rip), %rax    # 0x1b5a98
movq %rax, (%rdi)
movq 0x8(%rdi), %rdi
testq %rdi, %rdi
je 0x3c62c
movq %rbx, %rsi
callq 0x37f24
movq 0x18(%rbx), %rdi
testq %rdi, %rdi
je 0x3c63d
movq %rbx, %rsi
callq 0x3c304
leaq 0x28(%rbx), %r14
cmpl $0x0, 0x34(%rbx)
je 0x3c65a
movq (%r14), %rax
movq (%rax), %rdi
testq %rdi, %rdi
je 0x3c641
movq (%rdi), %rax
callq *0x8(%rax)
jmp 0x3c641
movq 0x38(%rbx), %rdi
testq %rdi, %rdi
je 0x3c668
callq 0x27ca0
addq $0x40, %rbx
movq %rbx, %rdi
callq 0xad65a
movq %r14, %rdi
addq $0x8, %rsp
popq %rbx
popq %r14
jmp 0xe1d40
movq %rax, %rdi
callq 0x376d2
nop
// File: /workspace/github_cpp_makefile_star2_O2/tomfunkhouser[P]gaps/pkgs/GSV/GSVSurvey.cpp
// Function: gaps::GSVSurvey::NScanlines() const
int GSVSurvey::
NScanlines(void) const
{
  // Return number of scanlines in survey
  int count = 0;
  for (int i = 0; i < NScans(); i++) {
    GSVScan *scan = Scan(i);
    count += scan->NScanlines();
  }
  return count;
}

// Assembly:
movl 0x34(%rdi), %ecx
movq 0x28(%rdi), %rdx
xorl %esi, %esi
testl %ecx, %ecx
cmovlel %esi, %ecx
xorl %eax, %eax
cmpq %rsi, %rcx
je 0x3c77b
movq (%rdx,%rsi,8), %rdi
addl 0x34(%rdi), %eax
incq %rsi
jmp 0x3c76a
retq
// File: /workspace/github_cpp_makefile_star2_O2/tomfunkhouser[P]gaps/pkgs/GSV/GSVSurvey.cpp
// Function: gaps::GSVSurvey::Scanline(int) const
GSVScanline *GSVSurvey::
Scanline(int scanline_index) const
{
  // Return scanline
  for (int i = 0; i < NScans(); i++) {
    GSVScan *scan = Scan(i);
    if (scanline_index >= scan->NScanlines()) scanline_index -= scan->NScanlines();
    else return scan->Scanline(scanline_index);
  }

  // Index too high
  return NULL;
}

// Assembly:
movl 0x34(%rdi), %ecx
movq 0x28(%rdi), %rdx
xorl %eax, %eax
testl %ecx, %ecx
cmovlel %eax, %ecx
xorl %edi, %edi
cmpq %rdi, %rcx
je 0x3c7b1
movq (%rdx,%rdi,8), %r9
movl %esi, %r8d
subl 0x34(%r9), %r8d
jl 0x3c7a6
incq %rdi
movl %r8d, %esi
jmp 0x3c78c
movq 0x28(%r9), %rax
movslq %esi, %rcx
movq (%rax,%rcx,8), %rax
retq
// File: /workspace/github_cpp_makefile_star2_O2/tomfunkhouser[P]gaps/pkgs/GSV/GSVSurvey.cpp
// Function: gaps::GSVSurvey::FindScanBeforeTravelDistance(double, int, int) const
GSVScan *GSVSurvey::
FindScanBeforeTravelDistance(RNScalar travel_distance, int imin, int imax) const
{
  // Binary search
  int i = (imin + imax) / 2;
  if (i == imin) return Scan(imin);
  assert(i < imax);
  GSVScan *scan = Scan(i);
  RNScalar t = TravelDistance(scan->SurveyIndex());
  if (t > travel_distance) return FindScanBeforeTravelDistance(travel_distance, imin, i);
  else if (t < travel_distance) return FindScanBeforeTravelDistance(travel_distance, i, imax);
  else return scan;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
pushq %rax
movl %edx, %r14d
movl %esi, %ebx
movsd %xmm0, (%rsp)
movq %rdi, %r15
pushq $0x2
popq %r13
movl %r14d, %ebp
movl %ebp, %r14d
leal (%r14,%rbx), %eax
cltd
idivl %r13d
movq 0x28(%r15), %rcx
cmpl %ebx, %eax
je 0x3c873
movl %eax, %ebp
cltq
movq (%rcx,%rax,8), %r12
movl 0x20(%r12), %esi
movq %r15, %rdi
callq 0x3ccb0
ucomisd (%rsp), %xmm0
ja 0x3c835
movsd (%rsp), %xmm1
ucomisd %xmm0, %xmm1
movl %ebp, %ebx
ja 0x3c832
jmp 0x3c87a
movslq %ebx, %rax
movq (%rcx,%rax,8), %r12
movq %r12, %rax
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
// File: /workspace/github_cpp_makefile_star2_O2/tomfunkhouser[P]gaps/pkgs/GSV/GSVSurvey.cpp
// Function: gaps::GSVSurvey::FindScanBeforeTravelDistance(double) const
GSVScan *GSVSurvey::
FindScanBeforeTravelDistance(RNScalar travel_distance) const
{
  // Binary search
  if (NScans() == 0) return NULL;
  if (travel_distance <= TravelDistance(0)) return Scan(0);
  if (travel_distance >= TravelDistance(NScans()-1)) return Scan(NScans()-1);
  return FindScanBeforeTravelDistance(travel_distance, 0, NScans()-1);
}

// Assembly:
pushq %rbx
subq $0x10, %rsp
cmpl $0x0, 0x34(%rdi)
je 0x3c8e3
movq %rdi, %rbx
xorl %esi, %esi
movsd %xmm0, 0x8(%rsp)
callq 0x3ccb0
ucomisd 0x8(%rsp), %xmm0
jae 0x3c8e7
movl 0x34(%rbx), %esi
decl %esi
movq %rbx, %rdi
callq 0x3ccb0
movsd 0x8(%rsp), %xmm1
ucomisd %xmm0, %xmm1
movsd 0x8(%rsp), %xmm0
movslq 0x34(%rbx), %rdx
jae 0x3c8f0
decl %edx
movq %rbx, %rdi
xorl %esi, %esi
addq $0x10, %rsp
popq %rbx
jmp 0x3c816
xorl %eax, %eax
jmp 0x3c8f9
movq 0x28(%rbx), %rax
movq (%rax), %rax
jmp 0x3c8f9
movq 0x28(%rbx), %rax
movq -0x8(%rax,%rdx,8), %rax
addq $0x10, %rsp
popq %rbx
retq
nop
// File: /workspace/github_cpp_makefile_star2_O2/tomfunkhouser[P]gaps/pkgs/GSV/GSVSurvey.cpp
// Function: gaps::GSVSurvey::NPoints() const
int GSVSurvey::
NPoints(void) const
{
  // Return number of points in all scans
  int npoints = 0;
  for (int i = 0; i < NScans(); i++) 
    npoints += Scan(i)->NPoints();
  return npoints;
}

// Assembly:
pushq %rbp
pushq %r14
pushq %rbx
movq %rdi, %rbx
xorl %r14d, %r14d
xorl %ebp, %ebp
movslq 0x34(%rbx), %rax
cmpq %rax, %r14
jge 0x3c929
movq 0x28(%rbx), %rax
movq (%rax,%r14,8), %rdi
callq 0x3cf3c
addl %eax, %ebp
incq %r14
jmp 0x3c90c
movl %ebp, %eax
popq %rbx
popq %r14
popq %rbp
retq
// File: /workspace/github_cpp_makefile_star2_O2/tomfunkhouser[P]gaps/pkgs/GSV/GSVSurvey.cpp
// Function: gaps::GSVSurvey::MaxBeamIndex() const
int GSVSurvey::
MaxBeamIndex(void) const
{
  // Initialize result
  int max_beam_index = -1;

  // Find maximum beam index of any point in any scan
  for (int i = 0; i < NScans(); i++) {
    GSVScan *scan = Scan(i);
    int m = scan->MaxBeamIndex();
    if (m > max_beam_index) max_beam_index = m;
  }

  // Return result
  return max_beam_index;
}

// Assembly:
pushq %r15
pushq %r14
pushq %rbx
movq %rdi, %r14
pushq $-0x1
popq %rbx
xorl %r15d, %r15d
movslq 0x34(%r14), %rax
cmpq %rax, %r15
jge 0x3c95e
movq 0x28(%r14), %rax
movq (%rax,%r15,8), %rdi
callq 0x3cf8a
cmpl %ebx, %eax
cmovgl %eax, %ebx
incq %r15
jmp 0x3c93e
movl %ebx, %eax
popq %rbx
popq %r14
popq %r15
retq
// File: /workspace/github_cpp_makefile_star2_O2/tomfunkhouser[P]gaps/pkgs/GSV/GSVSurvey.cpp
// Function: gaps::GSVSurvey::RemoveScan(gaps::GSVScan*)
void GSVSurvey::
RemoveScan(GSVScan *scan)
{
  // Just checking
  assert(scan->survey_index >= 0);
  assert(scan->survey_index < scans.NEntries());
  assert(scan->survey == this);

  // Remove scan
  RNArrayEntry *entry = scans.KthEntry(scan->survey_index);
  GSVScan *tail = scans.Tail();
  tail->survey_index = scan->survey_index;
  scans.EntryContents(entry) = tail;
  scans.RemoveTail();
  scan->survey_index = -1;
  scan->survey = NULL;

  // Invalidate bounding box
  InvalidateBBox();
}

// Assembly:
pushq %r14
pushq %rbx
pushq %rax
movq %rsi, %rbx
movq %rdi, %r14
addq $0x28, %rdi
movslq 0x20(%rsi), %rax
movq 0x28(%r14), %rcx
movslq 0x34(%r14), %rdx
movq -0x8(%rcx,%rdx,8), %rdx
movl %eax, 0x20(%rdx)
movq %rdx, (%rcx,%rax,8)
callq 0x35d92
orl $-0x1, 0x20(%rbx)
andq $0x0, 0x18(%rbx)
movq %r14, %rdi
addq $0x8, %rsp
popq %rbx
popq %r14
jmp 0x3c986
nop
// File: /workspace/github_cpp_makefile_star2_O2/tomfunkhouser[P]gaps/pkgs/GSV/GSVSurvey.cpp
// Function: gaps::GSVSurvey::Draw(gaps::RNFlags) const
void GSVSurvey::
Draw(RNFlags flags) const
{
  // Draw scans
  for (int i = 0; i < NScans(); i++) {
    GSVScan *scan = Scan(i);
    scan->Draw(flags);
  }
}

// Assembly:
pushq %r15
pushq %r14
pushq %rbx
movq %rsi, %rbx
movq %rdi, %r14
xorl %r15d, %r15d
movslq 0x34(%r14), %rax
cmpq %rax, %r15
jge 0x3ca93
movq 0x28(%r14), %rax
movq (%rax,%r15,8), %rdi
movq (%rdi), %rax
movq %rbx, %rsi
callq *0x10(%rax)
incq %r15
jmp 0x3ca74
popq %rbx
popq %r14
popq %r15
retq
nop
// File: /workspace/github_cpp_makefile_star2_O2/tomfunkhouser[P]gaps/pkgs/GSV/GSVSurvey.cpp
// Function: gaps::GSVSurvey::Print(_IO_FILE*, char const*, char const*) const
void GSVSurvey::
Print(FILE *fp, const char *prefix, const char *suffix) const
{
  // Check fp
  if (!fp) fp = stdout;

  // Print survey header
  if (prefix) fprintf(fp, "%s", prefix);
  fprintf(fp, "Survey %d:", segment_index);
  if (suffix) fprintf(fp, "%s", suffix);
  fprintf(fp, "\n");

  // Add indentation to prefix
  char indented_prefix[1024];
  sprintf(indented_prefix, "%s  ", prefix);

   // Print scans
  for (int i = 0; i < NScans(); i++) {
    GSVScan *scan = Scan(i);
    scan->Print(fp, indented_prefix, suffix);
  }
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x408, %rsp            # imm = 0x408
movq %rcx, %rbx
movq %rdx, %r12
movq %rsi, %r15
movq %rdi, %r14
testq %rsi, %rsi
jne 0x3cac6
movq 0x18147d(%rip), %rax    # 0x1bdf40
movq (%rax), %r15
testq %r12, %r12
je 0x3cad6
movq %r12, %rdi
movq %r15, %rsi
callq 0x27aa0
movl 0x10(%r14), %edx
leaq 0xef65a(%rip), %rsi     # 0x12c13b
movq %r15, %rdi
xorl %eax, %eax
callq 0x27e20
testq %rbx, %rbx
je 0x3cafb
movq %rbx, %rdi
movq %r15, %rsi
callq 0x27aa0
pushq $0xa
popq %rdi
movq %r15, %rsi
callq 0x27c30
leaq 0xeeee7(%rip), %rsi     # 0x12b9f4
xorl %ebp, %ebp
movq %rsp, %r13
movq %r13, %rdi
movq %r12, %rdx
xorl %eax, %eax
callq 0x27140
movslq 0x34(%r14), %rax
cmpq %rax, %rbp
jge 0x3cb44
movq 0x28(%r14), %rax
movq (%rax,%rbp,8), %rdi
movq (%rdi), %rax
movq %r15, %rsi
movq %r13, %rdx
movq %rbx, %rcx
callq *0x18(%rax)
incq %rbp
jmp 0x3cb1f
addq $0x408, %rsp            # imm = 0x408
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
// File: /workspace/github_cpp_makefile_star2_O2/tomfunkhouser[P]gaps/pkgs/GSV/GSVSurvey.cpp
// Function: gaps::GSVSurvey::UpdateBBox()
void GSVSurvey::
UpdateBBox(void) 
{
  // Update bounding box
  bbox = R3null_box;
  for (int i = 0; i < NScans(); i++) {
    bbox.Union(Scan(i)->BBox());
  }
}

// Assembly:
pushq %r15
pushq %r14
pushq %rbx
movq %rdi, %rbx
leaq 0x40(%rdi), %r14
leaq 0x18ae4f(%rip), %rsi    # 0x1c79b8
movq %r14, %rdi
callq 0x30d44
xorl %r15d, %r15d
movslq 0x34(%rbx), %rax
cmpq %rax, %r15
jge 0x3cb9a
movq 0x28(%rbx), %rax
movq (%rax,%r15,8), %rdi
callq 0x35e4c
movq %r14, %rdi
movq %rax, %rsi
callq 0xad3ba
incq %r15
jmp 0x3cb74
popq %rbx
popq %r14
popq %r15
retq
// File: /workspace/github_cpp_makefile_star2_O2/tomfunkhouser[P]gaps/pkgs/GSV/GSVSurvey.cpp
// Function: gaps::GSVSurvey::UpdateTravelDistances()
void GSVSurvey::
UpdateTravelDistances(void) 
{
  // Check stuff
  if (travel_distances) return;
  if (NScans() == 0) return;

  // Allocate travel distances
  travel_distances = new RNLength [ NScans() ];
  if (!travel_distances) {
    RNFail("Unable to allocate travel distances\n");
    return;
  }

  // Compute travel distances
  RNLength travel_distance = 0;
  R3Point prev_viewpoint = Scan(0)->Viewpoint();
  for (int i = 0; i < NScans(); i++) {
    GSVScan *scan = Scan(i);
    const R3Point& viewpoint = scan->Viewpoint();
    travel_distance += R3Distance(viewpoint, prev_viewpoint);
    travel_distances[i] = travel_distance;
    prev_viewpoint = viewpoint;
  }
}

// Assembly:
cmpq $0x0, 0x38(%rdi)
je 0x3cba8
retq
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x28, %rsp
movq %rdi, %rbx
movslq 0x34(%rdi), %rax
testq %rax, %rax
je 0x3cc86
movq %rax, %rcx
shlq $0x3, %rcx
testl %eax, %eax
pushq $-0x1
popq %rdi
cmovnsq %rcx, %rdi
callq 0x27040
movq %rax, 0x38(%rbx)
movq 0x28(%rbx), %rax
movq (%rax), %rcx
movl 0x34(%rcx), %eax
leaq 0x58ba70(%rip), %r12    # 0x5c8660
pushq $0x2
popq %rbp
movq %r12, %rsi
testl %eax, %eax
je 0x3cc0b
cltd
idivl %ebp
movq 0x28(%rcx), %rcx
cltq
movq (%rcx,%rax,8), %rsi
addq $0x40, %rsi
leaq 0x10(%rsp), %r14
movq %r14, %rdi
callq 0xc0e0c
xorpd %xmm0, %xmm0
movsd %xmm0, 0x8(%rsp)
xorl %r13d, %r13d
movslq 0x34(%rbx), %rax
cmpq %rax, %r13
jge 0x3cc86
movq 0x28(%rbx), %rax
movq (%rax,%r13,8), %rcx
movl 0x34(%rcx), %eax
movq %r12, %r15
testl %eax, %eax
je 0x3cc51
cltd
idivl %ebp
movq 0x28(%rcx), %rcx
cltq
movq (%rcx,%rax,8), %r15
addq $0x40, %r15
movq %r15, %rdi
movq %r14, %rsi
callq 0x8e602
movsd 0x8(%rsp), %xmm1
addsd %xmm0, %xmm1
movq 0x38(%rbx), %rax
movsd %xmm1, 0x8(%rsp)
movsd %xmm1, (%rax,%r13,8)
movq %r14, %rdi
movq %r15, %rsi
callq 0xc10e6
incq %r13
jmp 0x3cc25
addq $0x28, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
nop
// File: /workspace/github_cpp_makefile_star2_O2/tomfunkhouser[P]gaps/pkgs/GSV/GSVScan.cpp
// Function: gaps::GSVScan::~GSVScan()
GSVScan::
~GSVScan(void)
{
  // Remove scan from survey
  if (survey) survey->RemoveScan(this);

  // Delete scanlines
  while (NScanlines()) delete Scanline(0);
}

// Assembly:
pushq %r14
pushq %rbx
pushq %rax
movq %rdi, %rbx
leaq 0x178d7e(%rip), %rax    # 0x1b5ad8
movq %rax, (%rdi)
movq 0x18(%rdi), %rdi
testq %rdi, %rdi
je 0x3cd6e
movq %rbx, %rsi
callq 0x3ca22
leaq 0x28(%rbx), %r14
cmpl $0x0, 0x34(%rbx)
je 0x3cd8b
movq (%r14), %rax
movq (%rax), %rdi
testq %rdi, %rdi
je 0x3cd72
movq (%rdi), %rax
callq *0x8(%rax)
jmp 0x3cd72
addq $0x38, %rbx
movq %rbx, %rdi
callq 0xad65a
movq %r14, %rdi
addq $0x8, %rsp
popq %rbx
popq %r14
jmp 0xe1d40
movq %rax, %rdi
callq 0x376d2
// File: /workspace/github_cpp_makefile_star2_O2/tomfunkhouser[P]gaps/pkgs/GSV/GSVScan.cpp
// Function: gaps::GSVScan::SceneIndex() const
int GSVScan::
SceneIndex(void) const
{
  // Get convenient variables
  GSVRun *run = Run();
  if (!run) return -1;
  GSVScene *scene = run->Scene();
  if (!scene) return -1;

  // Compute scene index
  int scene_index = RunIndex();
  for (int ir = 0; ir < run->SceneIndex(); ir++) {
    GSVRun *r = scene->Run(ir);
    scene_index += r->NScans();
  }

  // Return scene index
  return scene_index;
}

// Assembly:
pushq %r15
pushq %r14
pushq %r12
pushq %rbx
pushq %rax
movq %rdi, %r15
callq 0x3cdd4
pushq $-0x1
popq %rbx
testq %rax, %rax
je 0x3ce57
movq %rax, %r14
movq 0x8(%rax), %r12
testq %r12, %r12
je 0x3ce57
movq %r15, %rdi
callq 0x3ce66
movl %eax, %ebx
xorl %r15d, %r15d
movslq 0x10(%r14), %rax
cmpq %rax, %r15
jge 0x3ce57
movq 0x8(%r12), %rax
movq (%rax,%r15,8), %rdi
callq 0x361e2
addl %eax, %ebx
incq %r15
jmp 0x3ce39
movl %ebx, %eax
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r14
popq %r15
retq
nop
// File: /workspace/github_cpp_makefile_star2_O2/tomfunkhouser[P]gaps/pkgs/GSV/GSVScan.cpp
// Function: gaps::GSVScan::NPoints() const
int GSVScan::
NPoints(void) const
{
  // Return number of points in all scanlines
  int npoints = 0;
  for (int i = 0; i < NScanlines(); i++) 
    npoints += Scanline(i)->NPoints();
  return npoints;
}

// Assembly:
movl 0x34(%rdi), %ecx
movq 0x28(%rdi), %rdx
xorl %esi, %esi
testl %ecx, %ecx
cmovlel %esi, %ecx
xorl %eax, %eax
cmpq %rsi, %rcx
je 0x3cf5d
movq (%rdx,%rsi,8), %rdi
addl 0x30(%rdi), %eax
incq %rsi
jmp 0x3cf4c
retq
// File: /workspace/github_cpp_makefile_star2_O2/tomfunkhouser[P]gaps/pkgs/GSV/GSVScan.cpp
// Function: gaps::GSVScan::MaxSweepIndex() const
int GSVScan::
MaxSweepIndex(void) const
{
  // Initialize result
  int max_sweep_index = -1;

  // Find maximum sweep index of any point in any scanline
  for (int i = 0; i < NScanlines(); i++) {
    GSVScanline *scanline = Scanline(i);
    int m = scanline->SweepIndex();
    if (m > max_sweep_index) max_sweep_index = m;
  }

  // Return result
  return max_sweep_index;
}

// Assembly:
movl 0x34(%rdi), %ecx
movq 0x28(%rdi), %rdx
xorl %esi, %esi
testl %ecx, %ecx
cmovlel %esi, %ecx
pushq $-0x1
popq %rax
cmpq %rsi, %rcx
je 0x3cf88
movq (%rdx,%rsi,8), %rdi
movl 0x80(%rdi), %edi
cmpl %eax, %edi
cmovgl %edi, %eax
incq %rsi
jmp 0x3cf6f
retq
nop
// File: /workspace/github_cpp_makefile_star2_O2/tomfunkhouser[P]gaps/pkgs/GSV/GSVScan.cpp
// Function: gaps::GSVScan::MaxBeamIndex() const
int GSVScan::
MaxBeamIndex(void) const
{
  // Initialize result
  int max_beam_index = -1;

  // Find maximum beam index of any point in any scanline
  for (int i = 0; i < NScanlines(); i++) {
    GSVScanline *scanline = Scanline(i);
    int m = scanline->MaxBeamIndex();
    if (m > max_beam_index) max_beam_index = m;
  }

  // Return result
  return max_beam_index;
}

// Assembly:
pushq %r15
pushq %r14
pushq %rbx
movq %rdi, %r14
pushq $-0x1
popq %rbx
xorl %r15d, %r15d
movslq 0x34(%r14), %rax
cmpq %rax, %r15
jge 0x3cfb8
movq 0x28(%r14), %rax
movq (%rax,%r15,8), %rdi
callq 0x3e198
cmpl %ebx, %eax
cmovgl %eax, %ebx
incq %r15
jmp 0x3cf98
movl %ebx, %eax
popq %rbx
popq %r14
popq %r15
retq
// File: /workspace/github_cpp_makefile_star2_O2/tomfunkhouser[P]gaps/pkgs/GSV/GSVScan.cpp
// Function: gaps::GSVScan::FindScanlineBeforeTimestamp(double, int, int) const
GSVScanline *GSVScan::
FindScanlineBeforeTimestamp(RNScalar timestamp, int imin, int imax) const
{
  // Binary search
  int i = (imin + imax) / 2;
  if (i == imin) return Scanline(imin);
  assert(i < imax);
  GSVScanline *scanline = Scanline(i);
  RNScalar t = scanline->Timestamp();
  if (t > timestamp) return FindScanlineBeforeTimestamp(timestamp, imin, i);
  else if (t < timestamp) return FindScanlineBeforeTimestamp(timestamp, i, imax);
  else return scanline;
}

// Assembly:
movl %edx, %ecx
movq 0x28(%rdi), %rdi
pushq $0x2
popq %r8
movl %ecx, %edx
movl %edx, %ecx
leal (%rcx,%rsi), %eax
cltd
idivl %r8d
cmpl %esi, %eax
je 0x3d00d
movl %eax, %edx
cltq
movq (%rdi,%rax,8), %rax
movsd 0x78(%rax), %xmm1
ucomisd %xmm0, %xmm1
ja 0x3cfe4
ucomisd %xmm1, %xmm0
movl %edx, %esi
ja 0x3cfe2
retq
movslq %esi, %rax
movq (%rdi,%rax,8), %rax
retq
nop
// File: /workspace/github_cpp_makefile_star2_O2/tomfunkhouser[P]gaps/pkgs/GSV/GSVScan.cpp
// Function: gaps::GSVScan::Pose(double) const
GSVPose GSVScan::
Pose(RNScalar timestamp) const
{
  // Find scanlines before and after timestamp
  GSVScanline *scanline1 = FindScanlineBeforeTimestamp(timestamp);
  if (!scanline1) return GSVPose(R3zero_point, R3zero_quaternion);
  int index1 = scanline1->ScanIndex();
  if (index1 < 0) return Scanline(0)->Pose();
  if (index1 >= NScanlines()-1) return Scanline(NScanlines()-1)->Pose();
  int index2 = index1 + 1;
  GSVScanline *scanline2 = Scanline(index2);

  // Compute interpolation parameter (0 <= t <= 1)
  RNScalar timestamp1 = scanline1->Timestamp();
  RNScalar timestamp2 = scanline2->Timestamp();
  RNScalar delta_timestamp = timestamp2 - timestamp1;
  if (delta_timestamp == 0) return scanline1->Pose();
  RNScalar t = (timestamp - timestamp1) / delta_timestamp;

  // Interpolate poses (would be better with quaternions)
  const GSVPose& pose1 = scanline1->Pose();
  const GSVPose& pose2 = scanline2->Pose();
  const R3Point& viewpoint1 = pose1.Viewpoint();
  const R3Point& viewpoint2 = pose2.Viewpoint();
  const R3Quaternion& orientation1 = pose1.Orientation();
  const R3Quaternion& orientation2 = pose2.Orientation();
  R3Point viewpoint = (1-t)*viewpoint1 + t*viewpoint2;
  R3Quaternion orientation = R3QuaternionSlerp(orientation1, orientation2, t);

  // Return interpolated pose
  return GSVPose(viewpoint, orientation);
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x58, %rsp
movq %rsi, %r15
movq %rdi, %rbx
movq %rsi, %rdi
movsd %xmm0, (%rsp)
callq 0x3d016
testq %rax, %rax
je 0x3d0ba
movq %rax, %r14
movslq 0x10(%rax), %rax
testq %rax, %rax
js 0x3d0d2
movslq 0x34(%r15), %rcx
leal -0x1(%rcx), %esi
movq 0x28(%r15), %rdx
cmpl %esi, %eax
jge 0x3d0db
movq 0x8(%rdx,%rax,8), %r15
movsd 0x78(%r14), %xmm1
movsd 0x78(%r15), %xmm0
subsd %xmm1, %xmm0
xorpd %xmm2, %xmm2
ucomisd %xmm2, %xmm0
jne 0x3d0fe
jp 0x3d0fe
addq $0x38, %r14
movq %rbx, %rdi
movq %r14, %rsi
jmp 0x3d0e7
leaq 0x58b59f(%rip), %rsi    # 0x5c8660
leaq 0x18ac78(%rip), %rdx    # 0x1c7d40
movq %rbx, %rdi
callq 0x41d1e
jmp 0x3d0ec
movq 0x28(%r15), %rax
movq (%rax), %rsi
jmp 0x3d0e0
movq -0x8(%rdx,%rcx,8), %rsi
addq $0x38, %rsi
movq %rbx, %rdi
callq 0x3dd70
movq %rbx, %rax
addq $0x58, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movsd (%rsp), %xmm2
subsd %xmm1, %xmm2
divsd %xmm0, %xmm2
movsd %xmm2, (%rsp)
leaq 0x40(%r14), %rsi
leaq 0x40(%r15), %r12
addq $0x58, %r14
addq $0x58, %r15
movsd 0xedf48(%rip), %xmm0    # 0x12b070
subsd %xmm2, %xmm0
leaq 0x8(%rsp), %r13
movq %r13, %rdi
callq 0xc1570
leaq 0x28(%rsp), %rbp
movq %rbp, %rdi
movq %r12, %rsi
movsd (%rsp), %xmm0
callq 0xc1570
leaq 0x40(%rsp), %r12
movq %r12, %rdi
movq %r13, %rsi
movq %rbp, %rdx
callq 0xc152a
leaq 0x8(%rsp), %r13
movq %r13, %rdi
movq %r14, %rsi
movq %r15, %rdx
movsd (%rsp), %xmm0
callq 0xb0615
movq %rbx, %rdi
movq %r12, %rsi
movq %r13, %rdx
jmp 0x3d0cb
nop
// File: /workspace/github_cpp_makefile_star2_O2/tomfunkhouser[P]gaps/pkgs/GSV/GSVScan.cpp
// Function: gaps::GSVScan::ReadPoints()
int GSVScan::
ReadPoints(void) 
{
  // Check read counter
  if (++read_count > 1) return 1;

  // Get the scene filename
  if (NScanlines() == 0) return 1;
  GSVSegment *segment = Segment();
  if (!segment) return 0;
  GSVRun *run = segment->Run();
  if (!run) return 0;
  GSVScene *scene = run->Scene();
  if (!scene) return 0;
  const char *filename = scene->Filename();
  if (!filename) return 0;

  // Open file
  FILE *fp = fopen(filename, "rb");
  if (!fp) {
    RNFail("Unable to open GSV scene file: %s\n", filename);
    return 0;
  }

  // Read scanlines
  for (int i = 0; i < NScanlines(); i++) {
    GSVScanline *scanline = Scanline(i);
    if (!scanline->ReadPoints(fp)) return 0;
  }

  // Close file 
  fclose(fp);

  // Return success
  return 1;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r12
pushq %rbx
movl 0x24(%rdi), %eax
incl %eax
movl %eax, 0x24(%rdi)
pushq $0x1
popq %rbp
cmpl $0x1, %eax
ja 0x3d6d9
movq %rdi, %rbx
cmpl $0x0, 0x34(%rdi)
je 0x3d6d9
movq 0x18(%rbx), %rax
xorl %ebp, %ebp
testq %rax, %rax
je 0x3d6d9
movq 0x8(%rax), %rax
testq %rax, %rax
je 0x3d6d9
movq 0x10(%rax), %rax
testq %rax, %rax
je 0x3d6d9
movq 0x8(%rax), %rax
testq %rax, %rax
je 0x3d6d9
movq 0x18(%rax), %r15
testq %r15, %r15
je 0x3d6d9
leaq 0xee540(%rip), %rsi     # 0x12bbbb
movq %r15, %rdi
callq 0x27b20
testq %rax, %rax
je 0x3d6b9
movq %rax, %r14
xorl %r12d, %r12d
pushq $0x1
popq %r15
xorl %ebp, %ebp
movslq 0x34(%rbx), %rax
cmpq %rax, %r12
jge 0x3d6ce
movq 0x28(%rbx), %rax
movq (%rax,%r12,8), %rdi
movq %r14, %rsi
movl %r15d, %edx
callq 0x3f7a0
incq %r12
testl %eax, %eax
jne 0x3d694
jmp 0x3d6d9
leaq 0xee444(%rip), %rdi     # 0x12bb04
xorl %ebp, %ebp
movq %r15, %rsi
xorl %eax, %eax
callq 0xe434a
jmp 0x3d6d9
movq %r14, %rdi
callq 0x27930
movl %r15d, %ebp
movl %ebp, %eax
popq %rbx
popq %r12
popq %r14
popq %r15
popq %rbp
retq
// File: /workspace/github_cpp_makefile_star2_O2/tomfunkhouser[P]gaps/pkgs/GSV/GSVScan.cpp
// Function: gaps::GSVScan::ReleasePoints()
int GSVScan::
ReleasePoints(void) 
{
  // Check read counter
  if (--read_count > 0) return 1;

  // Release points
  for (int i = 0; i < NScanlines(); i++) {
    GSVScanline *scanline = Scanline(i);
    if (!scanline->ReleasePoints()) return 0;
  }

  // Return success
  return 1;
}

// Assembly:
decl 0x24(%rdi)
je 0x3d6ed
pushq $0x1
popq %rax
retq
pushq %r15
pushq %r14
pushq %rbx
movq %rdi, %rbx
xorl %ecx, %ecx
movq %rcx, %r14
movslq 0x34(%rbx), %r15
cmpq %r15, %rcx
jge 0x3d718
movq 0x28(%rbx), %rax
movq (%rax,%r14,8), %rdi
callq 0x3f9be
leaq 0x1(%r14), %rcx
testl %eax, %eax
jne 0x3d6f7
xorl %eax, %eax
cmpq %r15, %r14
setge %al
popq %rbx
popq %r14
popq %r15
retq
// File: /workspace/github_cpp_makefile_star2_O2/tomfunkhouser[P]gaps/pkgs/GSV/GSVScan.cpp
// Function: gaps::GSVScan::Draw(gaps::RNFlags) const
void GSVScan::
Draw(RNFlags flags) const
{
  if (flags & GSV_DRAW_POINTS_WITH_LASER_INDEX_COLOR) {
    // Draw points  colored by laser index
    const int ncolors = 3;
    GLfloat color[3][3] = { { 1, 0, 0 }, { 0, 1, 0 }, { 0, 0, 1 } };
    int laser_index = (Laser()) ? Laser()->RunIndex() : 0;
    RNLoadRgb(color[laser_index % ncolors]);
    for (int i = 0; i < NScanlines(); i++) {
      GSVScanline *scanline = Scanline(i);
      scanline->Draw(flags);
    }
  }
  else if (flags & GSV_DRAW_MESHES_WITHOUT_COLOR) {
    glEnable(GL_CULL_FACE);
    static GSVMesh *last_mesh = NULL;
    static const GSVScan *last_scan = NULL;
    if (this != last_scan) {
      if (last_mesh) delete last_mesh;
      last_mesh = Mesh();
      last_scan = this;
    }
    if (last_mesh) last_mesh->Draw();
    glDisable(GL_CULL_FACE);
  }
  else {
    // Draw scanlines
    for (int i = 0; i < NScanlines(); i++) {
      GSVScanline *scanline = Scanline(i);
      scanline->Draw(flags);
    }
  }
}

// Assembly:
pushq %r15
pushq %r14
pushq %rbx
subq $0x30, %rsp
movq %rsi, %r14
movq %rdi, %rbx
testb $0x1, %r14b
jne 0x3d85e
btl $0x10, %r14d
jb 0x3d8d5
xorl %r15d, %r15d
movslq 0x34(%rbx), %rax
cmpq %rax, %r15
jge 0x3d8cb
movq 0x28(%rbx), %rax
movq (%rax,%r15,8), %rdi
movq (%rdi), %rax
movq %r14, %rsi
callq *0x10(%rax)
incq %r15
jmp 0x3d83b
xorps %xmm0, %xmm0
movaps %xmm0, (%rsp)
movaps %xmm0, 0x10(%rsp)
movl $0x3f800000, %eax       # imm = 0x3F800000
movl %eax, (%rsp)
movl %eax, 0x10(%rsp)
movl %eax, 0x20(%rsp)
movq 0x18(%rbx), %rax
testq %rax, %rax
je 0x3d89a
movq 0x18(%rax), %rax
testq %rax, %rax
je 0x3d89a
movl 0x10(%rax), %eax
pushq $0x3
popq %rcx
cltd
idivl %ecx
movslq %edx, %rax
jmp 0x3d89c
xorl %eax, %eax
imulq $0xc, %rax, %rax
leaq (%rsp,%rax), %rdi
callq 0x27370
xorl %r15d, %r15d
movslq 0x34(%rbx), %rax
cmpq %rax, %r15
jge 0x3d8cb
movq 0x28(%rbx), %rax
movq (%rax,%r15,8), %rdi
movq (%rdi), %rax
movq %r14, %rsi
callq *0x10(%rax)
incq %r15
jmp 0x3d8ac
addq $0x30, %rsp
popq %rbx
popq %r14
popq %r15
retq
movl $0xb44, %edi            # imm = 0xB44
callq 0x27890
movq 0x186e82(%rip), %rdi    # 0x1c4768
cmpq %rbx, 0x186e83(%rip)    # 0x1c4770
je 0x3d913
testq %rdi, %rdi
je 0x3d8fa
movq (%rdi), %rax
callq *0x8(%rax)
movq %rbx, %rdi
callq 0x3d412
movq %rax, %rdi
movq %rax, 0x186e5c(%rip)    # 0x1c4768
movq %rbx, 0x186e5d(%rip)    # 0x1c4770
testq %rdi, %rdi
je 0x3d926
movq (%rdi), %rax
movl $0x772, %esi            # imm = 0x772
callq *0x120(%rax)
movl $0xb44, %edi            # imm = 0xB44
addq $0x30, %rsp
popq %rbx
popq %r14
popq %r15
jmp 0x27220
nop
// File: /workspace/github_cpp_makefile_star2_O2/tomfunkhouser[P]gaps/pkgs/GSV/GSVScan.cpp
// Function: gaps::GSVScan::Print(_IO_FILE*, char const*, char const*) const
void GSVScan::
Print(FILE *fp, const char *prefix, const char *suffix) const
{
  // Check fp
  if (!fp) fp = stdout;

  // Print scan header
  if (prefix) fprintf(fp, "%s", prefix);
  fprintf(fp, "Scan %d:", survey_index);
  if (suffix) fprintf(fp, "%s", suffix);
  fprintf(fp, "\n");

  // Add indentation to prefix
  char indented_prefix[1024];
  sprintf(indented_prefix, "%s  ", prefix);

   // Print scanlines
  for (int i = 0; i < NScanlines(); i++) {
    GSVScanline *scanline = Scanline(i);
    scanline->Print(fp, indented_prefix, suffix);
  }
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x408, %rsp            # imm = 0x408
movq %rcx, %rbx
movq %rdx, %r12
movq %rsi, %r15
movq %rdi, %r14
testq %rsi, %rsi
jne 0x3d966
movq 0x1805dd(%rip), %rax    # 0x1bdf40
movq (%rax), %r15
testq %r12, %r12
je 0x3d976
movq %r12, %rdi
movq %r15, %rsi
callq 0x27aa0
movl 0x20(%r14), %edx
leaq 0xee8c0(%rip), %rsi     # 0x12c241
movq %r15, %rdi
xorl %eax, %eax
callq 0x27e20
testq %rbx, %rbx
je 0x3d99b
movq %rbx, %rdi
movq %r15, %rsi
callq 0x27aa0
pushq $0xa
popq %rdi
movq %r15, %rsi
callq 0x27c30
leaq 0xee047(%rip), %rsi     # 0x12b9f4
xorl %ebp, %ebp
movq %rsp, %r13
movq %r13, %rdi
movq %r12, %rdx
xorl %eax, %eax
callq 0x27140
movslq 0x34(%r14), %rax
cmpq %rax, %rbp
jge 0x3d9e4
movq 0x28(%r14), %rax
movq (%rax,%rbp,8), %rdi
movq (%rdi), %rax
movq %r15, %rsi
movq %r13, %rdx
movq %rbx, %rcx
callq *0x18(%rax)
incq %rbp
jmp 0x3d9bf
addq $0x408, %rsp            # imm = 0x408
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
// File: /workspace/github_cpp_makefile_star2_O2/tomfunkhouser[P]gaps/pkgs/GSV/GSVScan.cpp
// Function: gaps::GSVScan::UpdateBBox()
void GSVScan::
UpdateBBox(void) 
{
  // Read points (assumes all scanlines are in memory or not) 
  RNBoolean read_points = FALSE;
  if (NScanlines() > 0) {
    GSVScanline *scanline = Scanline(0);
    if (scanline->DoesBBoxNeedUpdate()) {
      ReadPoints();
      read_points = TRUE;
    }
  }

  // Update bounding box
  bbox = R3null_box;
  for (int i = 0; i < NScanlines(); i++) {
    bbox.Union(Scanline(i)->BBox());
  }

  // Release points
  if (read_points) {
    ReleasePoints();
  }
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %rbx
pushq %rax
movq %rdi, %rbx
movb $0x1, %bpl
cmpl $0x0, 0x34(%rdi)
jle 0x3da23
movq 0x28(%rbx), %rax
movq (%rax), %rdi
callq 0x3f732
testl %eax, %eax
je 0x3da23
movq %rbx, %rdi
callq 0x3d614
xorl %ebp, %ebp
leaq 0x38(%rbx), %r14
leaq 0x189f8a(%rip), %rsi    # 0x1c79b8
movq %r14, %rdi
callq 0x30d44
xorl %r15d, %r15d
movslq 0x34(%rbx), %rax
cmpq %rax, %r15
jge 0x3da5f
movq 0x28(%rbx), %rax
movq (%rax,%r15,8), %rdi
callq 0x35e72
movq %r14, %rdi
movq %rax, %rsi
callq 0xad3ba
incq %r15
jmp 0x3da39
testb %bpl, %bpl
je 0x3da6f
addq $0x8, %rsp
popq %rbx
popq %r14
popq %r15
popq %rbp
retq
movq %rbx, %rdi
addq $0x8, %rsp
popq %rbx
popq %r14
popq %r15
popq %rbp
jmp 0x3d6e4
nop
// File: /workspace/github_cpp_makefile_star2_O2/tomfunkhouser[P]gaps/pkgs/GSV/GSVScanline.cpp
// Function: gaps::GSVScanline::RunIndex() const
int GSVScanline::
RunIndex(void) const
{
  // Get convenient variables
  GSVSegment *segment = Segment();
  if (!segment) return -1;
  GSVRun *run = segment->Run();
  if (!run) return -1;

  // Compute run index
  int run_index = SegmentIndex();
  for (int i = 0; i < segment->RunIndex(); i++) {
    GSVSegment *s = run->Segment(i);
    run_index += s->NScanlines();
  }

  // Return runindex
  return run_index;
}

// Assembly:
pushq %r15
pushq %r14
pushq %r12
pushq %rbx
pushq %rax
movq %rdi, %r15
callq 0x3dfc8
pushq $-0x1
popq %rbx
testq %rax, %rax
je 0x3e085
movq %rax, %r14
movq 0x10(%rax), %r12
testq %r12, %r12
je 0x3e085
movq %r15, %rdi
callq 0x3e094
movl %eax, %ebx
xorl %r15d, %r15d
movslq 0x18(%r14), %rax
cmpq %rax, %r15
jge 0x3e085
movq 0x18(%r12), %rax
movq (%rax,%r15,8), %rdi
callq 0x379c2
addl %eax, %ebx
incq %r15
jmp 0x3e067
movl %ebx, %eax
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r14
popq %r15
retq
nop
// File: /workspace/github_cpp_makefile_star2_O2/tomfunkhouser[P]gaps/pkgs/GSV/GSVScanline.cpp
// Function: gaps::GSVScanline::SegmentIndex() const
int GSVScanline::
SegmentIndex(void) const
{
  // Get convenient variables
  GSVSegment *segment = Segment();
  if (!segment) return -1;
  GSVSurvey *survey = Survey();
  if (!survey) return -1;

  // Compute segment index
  int segment_index = SurveyIndex();
  for (int i = 0; i < survey->SegmentIndex(); i++) {
    GSVSurvey *s = segment->Survey(i);
    segment_index += s->NScanlines();
  }

  // Return segment index
  return segment_index;
}

// Assembly:
pushq %r15
pushq %r14
pushq %r12
pushq %rbx
pushq %rax
movq %rdi, %r15
callq 0x3dfc8
pushq $-0x1
popq %rbx
testq %rax, %rax
je 0x3e0ec
movq %rax, %r14
movq 0x8(%r15), %rax
testq %rax, %rax
je 0x3e0ec
movq 0x18(%rax), %r12
testq %r12, %r12
je 0x3e0ec
movq %r15, %rdi
callq 0x3e160
movl %eax, %ebx
xorl %r15d, %r15d
movslq 0x10(%r12), %rax
cmpq %rax, %r15
jge 0x3e0ec
movq 0x20(%r14), %rax
movq (%rax,%r15,8), %rdi
callq 0x3c75a
addl %eax, %ebx
incq %r15
jmp 0x3e0ce
movl %ebx, %eax
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r14
popq %r15
retq
// File: /workspace/github_cpp_makefile_star2_O2/tomfunkhouser[P]gaps/pkgs/GSV/GSVScanline.cpp
// Function: gaps::GSVScanline::LaserIndex() const
int GSVScanline::
LaserIndex(void) const
{
  // Get convenient variables
  GSVLaser *laser = Laser();
  if (!laser) return -1;
  GSVSurvey *survey = Survey();
  if (!survey) return -1;

  // Compute laser index
  int laser_index = SurveyIndex();
  for (int i = 0; i < survey->LaserIndex(); i++) {
    GSVSurvey *s = laser->Survey(i);
    laser_index += s->NScanlines();
  }

  // Return laser index
  return laser_index;
}

// Assembly:
pushq %r15
pushq %r14
pushq %r12
pushq %rbx
pushq %rax
movq %rdi, %r15
callq 0x3dfa6
pushq $-0x1
popq %rbx
testq %rax, %rax
je 0x3e152
movq %rax, %r14
movq 0x8(%r15), %rax
testq %rax, %rax
je 0x3e152
movq 0x18(%rax), %r12
testq %r12, %r12
je 0x3e152
movq %r15, %rdi
callq 0x3e160
movl %eax, %ebx
xorl %r15d, %r15d
movslq 0x20(%r12), %rax
cmpq %rax, %r15
jge 0x3e152
movq 0x18(%r14), %rax
movq (%rax,%r15,8), %rdi
callq 0x3c75a
addl %eax, %ebx
incq %r15
jmp 0x3e134
movl %ebx, %eax
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r14
popq %r15
retq
// File: /workspace/github_cpp_makefile_star2_O2/tomfunkhouser[P]gaps/pkgs/GSV/GSVScanline.cpp
// Function: gaps::GSVScanline::MaxBeamIndex() const
int GSVScanline::
MaxBeamIndex(void) const
{
  // Check first and last points
  if (npoints == 0) return -1;
  int i0 = points[0].BeamIndex();
  int i1 = points[npoints-1].BeamIndex();
  return (i0 > i1) ? i0 : i1;
}

// Assembly:
movslq 0x30(%rdi), %rax
testq %rax, %rax
je 0x3e1bb
movq 0x28(%rdi), %rcx
movzbl 0x46(%rcx), %edx
imulq $0x50, %rax, %rax
movzbl -0xa(%rcx,%rax), %eax
cmpb %al, %dl
cmoval %edx, %eax
movzbl %al, %eax
retq
pushq $-0x1
popq %rax
retq
nop
// File: /workspace/github_cpp_makefile_star2_O2/tomfunkhouser[P]gaps/pkgs/GSV/GSVScanline.cpp
// Function: gaps::GSVScanline::EstimatedGroundZ() const
RNCoord GSVScanline::
EstimatedGroundZ(void) const
{
  // Get convenient variables
  GSVLaser *laser = Laser();
  const double vlp16_laser_height = 2.0;
  const int sick_scan_ground_index = 25;
  const int sick_radius = 1;

  // Check device
  if ((laser->DeviceType() == GSV_SICK_LASER) &&
      (NPoints() > 0) &&
      (NPoints() > sick_scan_ground_index+sick_radius) &&
      points) {

    // Get three points around scan_ground_index
    R3Point p0 = PointPosition(NPoints() - sick_scan_ground_index - sick_radius);
    R3Point p1 = PointPosition(NPoints() - sick_scan_ground_index);
    R3Point p2 = PointPosition(NPoints() - sick_scan_ground_index + sick_radius);

    // Find median Z coordinate
    RNCoord z;
    if (p0.Z() < p1.Z()) {
      if (p1.Z() < p2.Z()) {
        z = p1.Z();
      }
      else {
        if (p0.Z() < p2.Z()) z = p2.Z();
        else z = p0.Z();
      }
    }
    else {
      if (p0.Z() < p2.Z()) {
        z = p0.Z();
      }
      else {
        if (p1.Z() < p2.Z()) z = p2.Z();
        else z = p1.Z();
      }
    }
  
    // Return estimate of ground Z coordinate
    return z;
  }
  else {
    const GSVPose& pose = Pose();
    const R3Point& viewpoint = pose.Viewpoint();
    return viewpoint.Z() - vlp16_laser_height;
  }

  // Should not get here
  return RN_UNKNOWN;
}

// Assembly:
pushq %r15
pushq %r14
pushq %r12
pushq %rbx
subq $0x48, %rsp
movq %rdi, %rbx
callq 0x3dfa6
cmpl $0x2, 0x28(%rax)
jne 0x3e260
movl 0x30(%rbx), %edx
testl %edx, %edx
jle 0x3e260
cmpl $0x1b, %edx
jb 0x3e260
cmpq $0x0, 0x28(%rbx)
je 0x3e260
addl $-0x1a, %edx
leaq 0x30(%rsp), %r14
movq %r14, %rdi
movq %rbx, %rsi
callq 0x3f9e0
movl 0x30(%rbx), %edx
addl $-0x19, %edx
leaq 0x18(%rsp), %r15
movq %r15, %rdi
movq %rbx, %rsi
callq 0x3f9e0
movl 0x30(%rbx), %edx
addl $-0x18, %edx
movq %rsp, %r12
movq %r12, %rdi
movq %rbx, %rsi
callq 0x3f9e0
movsd 0x10(%r14), %xmm1
movsd 0x10(%r15), %xmm2
ucomisd %xmm1, %xmm2
movsd 0x10(%r12), %xmm3
jbe 0x3e279
ucomisd %xmm2, %xmm3
movapd %xmm2, %xmm0
ja 0x3e26d
ucomisd %xmm1, %xmm3
movapd %xmm3, %xmm0
ja 0x3e26d
movapd %xmm1, %xmm0
jmp 0x3e26d
movsd 0x50(%rbx), %xmm0
addsd 0xedfe3(%rip), %xmm0    # 0x12c250
addq $0x48, %rsp
popq %rbx
popq %r12
popq %r14
popq %r15
retq
ucomisd %xmm1, %xmm3
movapd %xmm1, %xmm0
ja 0x3e26d
ucomisd %xmm2, %xmm3
movapd %xmm3, %xmm0
ja 0x3e26d
movapd %xmm2, %xmm0
jmp 0x3e26d
nop
// File: /workspace/github_cpp_makefile_star2_O2/tomfunkhouser[P]gaps/pkgs/GSV/GSVScanline.cpp
// Function: gaps::GSVScanline::PointAngle(int) const
RNAngle GSVScanline::
PointAngle(int point_index) const
{
  // Return angle of laser when point was sampled (0 - PI)
  const R3Point& position = PointPosition(point_index);
  const R3Point& viewpoint = pose.Viewpoint();
  const R3Vector& towards = pose.Towards();
  const R3Vector& up = pose.Up();
  R3Vector right = towards % up;
  R3Vector v = position - viewpoint;
  RNLength distance = v.Length();
  if (RNIsZero(distance)) return 0;
  v /= distance;
  RNScalar dot = -(v.Dot(up));
  RNAngle angle = acos(dot);
  if (v.Dot(right) > 0) angle = RN_PI_OVER_TWO + angle;
  else angle = RN_PI_OVER_TWO - angle;
  return angle;
}

// Assembly:
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x90, %rsp
movl %esi, %edx
movq %rdi, %rbx
leaq 0x78(%rsp), %r14
movq %r14, %rdi
movq %rbx, %rsi
callq 0x3f9e0
leaq 0x38(%rbx), %r15
addq $0x40, %rbx
leaq 0x60(%rsp), %r12
movq %r12, %rdi
movq %r15, %rsi
callq 0x41e74
leaq 0x48(%rsp), %r13
movq %r13, %rdi
movq %r15, %rsi
callq 0x41eba
leaq 0x30(%rsp), %rdi
movq %r12, %rsi
movq %r13, %rdx
callq 0xc1c6e
leaq 0x18(%rsp), %r15
movq %r15, %rdi
movq %r14, %rsi
movq %rbx, %rdx
callq 0xc0fd9
movq %r15, %rdi
callq 0xc16c2
leaq 0x181165(%rip), %rax    # 0x1bf478
movsd (%rax), %xmm2
movapd 0xed9a1(%rip), %xmm1    # 0x12bcc0
xorpd %xmm2, %xmm1
ucomisd %xmm1, %xmm0
jb 0x3e333
xorpd %xmm1, %xmm1
ucomisd %xmm0, %xmm2
jae 0x3e39d
leaq 0x18(%rsp), %rbx
movq %rbx, %rdi
callq 0xc1eba
leaq 0x48(%rsp), %rsi
movq %rbx, %rdi
callq 0xc1836
xorpd 0xed96b(%rip), %xmm0    # 0x12bcc0
callq 0x278c0
movapd %xmm0, (%rsp)
leaq 0x30(%rsp), %rsi
movq %rbx, %rdi
callq 0xc1836
leaq 0xf8e95(%rip), %rax     # 0x137208
movapd 0xed945(%rip), %xmm2    # 0x12bcc0
movapd (%rsp), %xmm3
xorpd %xmm3, %xmm2
xorpd %xmm1, %xmm1
cmpltsd %xmm0, %xmm1
andpd %xmm1, %xmm3
andnpd %xmm2, %xmm1
orpd %xmm3, %xmm1
addsd (%rax), %xmm1
movapd %xmm1, %xmm0
addq $0x90, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
retq