// File: tomfunkhouser[P]gaps/pkgs/R3Surfels/R3SurfelPointSet.cpp
// Function: gaps::R3SurfelPointSet::Union(gaps::R3SurfelPointSet const*)
void R3SurfelPointSet::
Union(const R3SurfelPointSet *set)
{
  // Set marks in other point set
  for (int i = 0; i < set->npoints; i++) {
    set->points[i].SetMark(TRUE);
  }

  // Clear marks in this point set
  for (int i = 0; i < npoints; i++) {
    points[i].SetMark(FALSE);
  }

  // Count marked points from other point set
  int count = 0;
  for (int i = 0; i < set->npoints; i++) {
    if (!set->points[i].IsMarked()) continue;
    count++;
  }

  // Allocate space for points
  AllocatePoints(npoints + count);

  // Insert marked points from other point set
  for (int i = 0; i < set->npoints; i++) {
    if (!set->points[i].IsMarked()) continue;
    points[npoints] = set->points[i];
    npoints++;
  }

  // Update bounding box (conservatively)
  bbox.Union(set->BBox());

  // Update timestamp range (conservatively)
  timestamp_range.Union(set->TimestampRange());
}

// Assembly:
subq $0x48, %rsp
movq %rdi, 0x40(%rsp)
movq %rsi, 0x38(%rsp)
movq 0x40(%rsp), %rax
movq %rax, 0x18(%rsp)
movl $0x0, 0x34(%rsp)
movl 0x34(%rsp), %eax
movq 0x38(%rsp), %rcx
cmpl 0x10(%rcx), %eax
jge 0x5984a
movq 0x38(%rsp), %rax
movq 0x8(%rax), %rdi
movslq 0x34(%rsp), %rax
shlq $0x4, %rax
addq %rax, %rdi
movl $0x1, %esi
callq 0x55d10
movl 0x34(%rsp), %eax
addl $0x1, %eax
movl %eax, 0x34(%rsp)
jmp 0x59810
movl $0x0, 0x30(%rsp)
movq 0x18(%rsp), %rcx
movl 0x30(%rsp), %eax
cmpl 0x10(%rcx), %eax
jge 0x59889
movq 0x18(%rsp), %rax
movq 0x8(%rax), %rdi
movslq 0x30(%rsp), %rax
shlq $0x4, %rax
addq %rax, %rdi
xorl %esi, %esi
callq 0x55d10
movl 0x30(%rsp), %eax
addl $0x1, %eax
movl %eax, 0x30(%rsp)
jmp 0x59852
movl $0x0, 0x2c(%rsp)
movl $0x0, 0x28(%rsp)
movl 0x28(%rsp), %eax
movq 0x38(%rsp), %rcx
cmpl 0x10(%rcx), %eax
jge 0x598e0
movq 0x38(%rsp), %rax
movq 0x8(%rax), %rdi
movslq 0x28(%rsp), %rax
shlq $0x4, %rax
addq %rax, %rdi
callq 0x43f60
cmpl $0x0, %eax
jne 0x598c8
jmp 0x598d3
movl 0x2c(%rsp), %eax
addl $0x1, %eax
movl %eax, 0x2c(%rsp)
movl 0x28(%rsp), %eax
addl $0x1, %eax
movl %eax, 0x28(%rsp)
jmp 0x59899
movq 0x18(%rsp), %rdi
movl 0x10(%rdi), %esi
addl 0x2c(%rsp), %esi
movq (%rdi), %rax
callq *0x80(%rax)
movl $0x0, 0x24(%rsp)
movl 0x24(%rsp), %eax
movq 0x38(%rsp), %rcx
cmpl 0x10(%rcx), %eax
jge 0x59975
movq 0x38(%rsp), %rax
movq 0x8(%rax), %rdi
movslq 0x24(%rsp), %rax
shlq $0x4, %rax
addq %rax, %rdi
callq 0x43f60
cmpl $0x0, %eax
jne 0x5992c
jmp 0x59968
movq 0x18(%rsp), %rax
movq 0x38(%rsp), %rcx
movq 0x8(%rcx), %rsi
movslq 0x24(%rsp), %rcx
shlq $0x4, %rcx
addq %rcx, %rsi
movq 0x8(%rax), %rdi
movslq 0x10(%rax), %rax
shlq $0x4, %rax
addq %rax, %rdi
callq 0x55980
movq 0x18(%rsp), %rax
movl 0x10(%rax), %ecx
addl $0x1, %ecx
movl %ecx, 0x10(%rax)
movl 0x24(%rsp), %eax
addl $0x1, %eax
movl %eax, 0x24(%rsp)
jmp 0x598fd
movq 0x18(%rsp), %rax
addq $0x18, %rax
movq %rax, 0x8(%rsp)
movq 0x38(%rsp), %rdi
callq 0x435d0
movq 0x8(%rsp), %rdi
movq %rax, %rsi
callq 0xcbc30
movq 0x18(%rsp), %rax
addq $0x50, %rax
movq %rax, 0x10(%rsp)
movq 0x38(%rsp), %rdi
callq 0x4f840
movq 0x10(%rsp), %rdi
movq %rax, %rsi
callq 0x1bbc0
addq $0x48, %rsp
retq
nopw %cs:(%rax,%rax)