// File: /workspace/github_cpp_makefile_star2_O2/tomfunkhouser[P]gaps/pkgs/R3Surfels/R3SurfelPointSet.cpp
// Function: gaps::R3SurfelPointSet::InsertPoints(gaps::R3SurfelPointSet const*, gaps::R3Point const&, double, double, double)
void R3SurfelPointSet::
InsertPoints(const R3SurfelPointSet *set, const R3Point& center, RNLength radius, RNCoord zmin, RNCoord zmax)
{
  // Check set
  if (set->NPoints() == 0) return;

  // Check and update bounding box (conservatively)
  R3Box constraint_box(center[0] - radius, center[1] - radius, zmin, center[0] + radius, center[1] + radius, zmax);
  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
  RNScalar rr = radius * radius;
  for (int i = 0; i < set->NPoints(); i++) {
    const R3SurfelPoint *point = set->Point(i);
    const R3Point& position = point->Position();
    if (position.Z() < zmin) continue;
    if (position.Z() > zmax) continue;
    RNScalar dx = point->X() - center.X();
    RNScalar dy = point->Y() - center.Y();
    RNScalar dd = dx*dx + dy*dy;
    if (dd > rr) continue;
    points[npoints] = *point;
    npoints++;
  }
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0xa8, %rsp
cmpl $0x0, 0x10(%rsi)
je 0x30ae1
movaps %xmm2, %xmm5
movaps %xmm1, %xmm2
movapd %xmm0, %xmm1
movq %rdx, %rbx
movq %rsi, %r14
movq %rdi, %r15
movsd (%rdx), %xmm3
movsd 0x8(%rdx), %xmm4
movapd %xmm3, %xmm0
subsd %xmm1, %xmm0
movapd %xmm1, %xmm6
movapd %xmm4, %xmm1
subsd %xmm6, %xmm1
addsd %xmm6, %xmm3
movsd %xmm6, (%rsp)
addsd %xmm6, %xmm4
leaq 0x70(%rsp), %r12
movq %r12, %rdi
movsd %xmm2, 0x10(%rsp)
movsd %xmm5, 0x18(%rsp)
callq 0x63d86
leaq 0x20(%rsp), %rdi
movq %r12, %rsi
callq 0x63ce6
leaq 0x18(%r14), %rsi
leaq 0x20(%rsp), %rdi
callq 0x647fc
movq %r15, 0x8(%rsp)
movsd 0x28(%rsp), %xmm0
ucomisd 0x40(%rsp), %xmm0
ja 0x30acd
movsd 0x30(%rsp), %xmm0
ucomisd 0x48(%rsp), %xmm0
ja 0x30acd
movsd 0x38(%rsp), %xmm0
ucomisd 0x50(%rsp), %xmm0
ja 0x30acd
movq 0x8(%rsp), %r15
leaq 0x18(%r15), %rdi
leaq 0x20(%rsp), %rsi
callq 0x646fe
leaq 0x50(%r15), %rdi
leaq 0x50(%r14), %rsi
callq 0x177ca
movl 0x10(%r14), %esi
addl 0x10(%r15), %esi
movq (%r15), %rax
movq %r15, %rdi
callq *0x80(%rax)
movsd (%rsp), %xmm0
mulsd %xmm0, %xmm0
movsd %xmm0, (%rsp)
xorl %ebp, %ebp
xorl %r12d, %r12d
movslq 0x10(%r14), %rax
cmpq %rax, %r12
jge 0x30acd
movq 0x8(%r14), %r15
leaq (%r15,%rbp), %r13
leaq 0x58(%rsp), %rdi
movq %r13, %rsi
callq 0x16310
movsd 0x68(%rsp), %xmm0
movsd 0x10(%rsp), %xmm1
ucomisd %xmm0, %xmm1
movsd 0x18(%rsp), %xmm1
ja 0x30ac1
ucomisd %xmm1, %xmm0
ja 0x30ac1
movq (%r15,%rbp), %rax
movq 0x8(%r15,%rbp), %rcx
cvtss2sd (%rcx), %xmm0
addsd 0x10(%rax), %xmm0
cvtss2sd 0x4(%rcx), %xmm1
addsd 0x18(%rax), %xmm1
subsd (%rbx), %xmm0
subsd 0x8(%rbx), %xmm1
mulsd %xmm1, %xmm1
mulsd %xmm0, %xmm0
addsd %xmm1, %xmm0
ucomisd (%rsp), %xmm0
ja 0x30ac1
movq 0x8(%rsp), %r15
movslq 0x10(%r15), %rdi
shlq $0x4, %rdi
addq 0x8(%r15), %rdi
movq %r13, %rsi
callq 0x2f252
incl 0x10(%r15)
incq %r12
addq $0x10, %rbp
jmp 0x30a2c
leaq 0x20(%rsp), %rdi
callq 0x649ae
leaq 0x70(%rsp), %rdi
callq 0x649ae
addq $0xa8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
jmp 0x30afc
movq %rax, %rbx
jmp 0x30b09
jmp 0x30afc
movq %rax, %rbx
leaq 0x20(%rsp), %rdi
callq 0x649ae
leaq 0x70(%rsp), %rdi
callq 0x649ae
movq %rbx, %rdi
callq 0x138f0
nop