// File: tomfunkhouser[P]gaps/pkgs/R3Surfels/R3SurfelPointSet.cpp
// Function: gaps::R3SurfelPointSet::InsertPoints(gaps::R3SurfelPointSet const*, gaps::R3Box const&)
void R3SurfelPointSet::
InsertPoints(const R3SurfelPointSet *set, const R3Box& constraint_box)
{
  // Check set
  if (set->NPoints() == 0) return;

  // Check and update bounding box (conservatively)
  R3Box intersection_box = constraint_box;
  intersection_box.Intersect(set->BBox());
  if (intersection_box.IsEmpty()) return;
  bbox.Union(intersection_box);

  // Check and update timestamp range (conservatively)
  timestamp_range.Union(set->TimestampRange());

  // Allocate space for points
  AllocatePoints(npoints + set->NPoints());

  // Copy points
  for (int i = 0; i < set->NPoints(); i++) {
    const R3SurfelPoint *point = set->Point(i);
    if (!R3Intersects(constraint_box, point->Position())) continue;
    points[npoints] = *point;
    npoints++;
  }
}

// Assembly:
subq $0xd8, %rsp
movq %rdi, 0xd0(%rsp)
movq %rsi, 0xc8(%rsp)
movq %rdx, 0xc0(%rsp)
movq 0xd0(%rsp), %rax
movq %rax, 0x48(%rsp)
movq 0xc8(%rsp), %rdi
callq 0x18700
cmpl $0x0, %eax
jne 0x587f3
jmp 0x589f2
movq 0xc0(%rsp), %rsi
leaq 0x88(%rsp), %rdi
callq 0xc9de0
movq 0xc8(%rsp), %rdi
callq 0x435d0
movq %rax, 0x40(%rsp)
jmp 0x5881c
movq 0x40(%rsp), %rsi
leaq 0x88(%rsp), %rdi
callq 0xcbf10
jmp 0x58830
leaq 0x88(%rsp), %rdi
callq 0x44290
movl %eax, 0x3c(%rsp)
jmp 0x58843
movl 0x3c(%rsp), %eax
cmpl $0x0, %eax
je 0x5887c
movl $0x1, 0x78(%rsp)
jmp 0x589e5
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x80(%rsp)
movl %eax, 0x7c(%rsp)
leaq 0x88(%rsp), %rdi
callq 0x1b990
jmp 0x589fa
movq 0x48(%rsp), %rdi
addq $0x18, %rdi
leaq 0x88(%rsp), %rsi
callq 0xcbc30
jmp 0x58894
movq 0x48(%rsp), %rax
addq $0x50, %rax
movq %rax, 0x28(%rsp)
movq 0xc8(%rsp), %rdi
callq 0x4f840
movq %rax, 0x30(%rsp)
jmp 0x588b6
movq 0x30(%rsp), %rsi
movq 0x28(%rsp), %rdi
callq 0x1bbc0
jmp 0x588c7
movq 0x48(%rsp), %rax
movl 0x10(%rax), %eax
movl %eax, 0x20(%rsp)
movq 0xc8(%rsp), %rdi
callq 0x18700
movl %eax, 0x24(%rsp)
jmp 0x588e6
movq 0x48(%rsp), %rdi
movl 0x24(%rsp), %eax
movl 0x20(%rsp), %esi
addl %eax, %esi
movq (%rdi), %rax
movq 0x80(%rax), %rax
callq *%rax
jmp 0x58903
movl $0x0, 0x74(%rsp)
movl 0x74(%rsp), %eax
movl %eax, 0x18(%rsp)
movq 0xc8(%rsp), %rdi
callq 0x18700
movl %eax, 0x1c(%rsp)
jmp 0x58926
movl 0x18(%rsp), %eax
movl 0x1c(%rsp), %ecx
cmpl %ecx, %eax
jge 0x589dd
movq 0xc8(%rsp), %rdi
movl 0x74(%rsp), %esi
callq 0x18710
movq %rax, 0x10(%rsp)
jmp 0x5894e
movq 0x10(%rsp), %rax
movq %rax, 0x68(%rsp)
movq 0xc0(%rsp), %rax
movq %rax, 0x8(%rsp)
movq 0x68(%rsp), %rsi
leaq 0x50(%rsp), %rdi
callq 0x18730
jmp 0x58976
movq 0x8(%rsp), %rdi
leaq 0x50(%rsp), %rsi
callq 0x441c0
movl %eax, 0x4(%rsp)
jmp 0x5898b
movl 0x4(%rsp), %eax
cmpl $0x0, %eax
setne %al
xorb $-0x1, %al
testb $0x1, %al
jne 0x5899d
jmp 0x5899f
jmp 0x589cd
movq 0x48(%rsp), %rax
movq 0x68(%rsp), %rsi
movq 0x8(%rax), %rdi
movslq 0x10(%rax), %rax
shlq $0x4, %rax
addq %rax, %rdi
callq 0x55980
jmp 0x589bf
movq 0x48(%rsp), %rax
movl 0x10(%rax), %ecx
addl $0x1, %ecx
movl %ecx, 0x10(%rax)
movl 0x74(%rsp), %eax
addl $0x1, %eax
movl %eax, 0x74(%rsp)
jmp 0x5890b
movl $0x0, 0x78(%rsp)
leaq 0x88(%rsp), %rdi
callq 0x1b990
addq $0xd8, %rsp
retq
movq 0x80(%rsp), %rdi
callq 0x13970
nopw (%rax,%rax)