// File: /workspace/github_cpp_makefile_star2_O3/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 0x34165
movaps %xmm2, %xmm5
movapd %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, 0x8(%rsp)
addsd %xmm6, %xmm4
leaq 0x70(%rsp), %r12
movq %r12, %rdi
movsd %xmm2, 0x10(%rsp)
movsd %xmm5, 0x18(%rsp)
callq 0x6d3f4
leaq 0x20(%rsp), %rdi
movq %r12, %rsi
callq 0x6d354
leaq 0x18(%r14), %rsi
leaq 0x20(%rsp), %rdi
callq 0x6df4e
movsd 0x28(%rsp), %xmm0
ucomisd 0x40(%rsp), %xmm0
ja 0x34151
movsd 0x30(%rsp), %xmm0
ucomisd 0x48(%rsp), %xmm0
ja 0x34151
movsd 0x38(%rsp), %xmm0
ucomisd 0x50(%rsp), %xmm0
ja 0x34151
leaq 0x18(%r15), %rdi
leaq 0x20(%rsp), %rsi
callq 0x6de0c
movsd 0x50(%r14), %xmm0
movsd 0x50(%r15), %xmm1
ucomisd %xmm0, %xmm1
jbe 0x34040
movsd %xmm0, 0x50(%r15)
movsd 0x58(%r14), %xmm0
ucomisd 0x58(%r15), %xmm0
jbe 0x34054
movsd %xmm0, 0x58(%r15)
movl 0x10(%r14), %esi
addl 0x10(%r15), %esi
movq (%r15), %rax
movq %r15, %rdi
callq *0x80(%rax)
cmpl $0x0, 0x10(%r14)
jle 0x34151
movsd 0x8(%rsp), %xmm0
mulsd %xmm0, %xmm0
movsd %xmm0, 0x8(%rsp)
xorl %ebp, %ebp
xorl %r12d, %r12d
movq 0x8(%r14), %r13
movq (%r13,%rbp), %rax
movq 0x8(%r13,%rbp), %rcx
xorps %xmm0, %xmm0
cvtss2sd (%rcx), %xmm0
addsd 0x10(%rax), %xmm0
xorps %xmm1, %xmm1
cvtss2sd 0x4(%rcx), %xmm1
addsd 0x18(%rax), %xmm1
xorps %xmm2, %xmm2
cvtss2sd 0x8(%rcx), %xmm2
addsd 0x20(%rax), %xmm2
leaq 0x58(%rsp), %rdi
callq 0x83dc2
movsd 0x68(%rsp), %xmm0
movsd 0x10(%rsp), %xmm1
ucomisd %xmm0, %xmm1
movsd 0x18(%rsp), %xmm1
ja 0x3413d
ucomisd %xmm1, %xmm0
ja 0x3413d
addq %rbp, %r13
movq (%r13), %rax
movq 0x8(%r13), %rcx
xorps %xmm0, %xmm0
cvtss2sd (%rcx), %xmm0
addsd 0x10(%rax), %xmm0
xorps %xmm1, %xmm1
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 0x8(%rsp), %xmm0
ja 0x3413d
movslq 0x10(%r15), %rdi
shlq $0x4, %rdi
addq 0x8(%r15), %rdi
movq %r13, %rsi
callq 0x3230c
incl 0x10(%r15)
incq %r12
movslq 0x10(%r14), %rax
addq $0x10, %rbp
cmpq %rax, %r12
jl 0x34088
leaq 0x20(%rsp), %rdi
callq 0x6e174
leaq 0x70(%rsp), %rdi
callq 0x6e174
addq $0xa8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
jmp 0x34180
movq %rax, %rbx
jmp 0x3418d
jmp 0x34180
movq %rax, %rbx
leaq 0x20(%rsp), %rdi
callq 0x6e174
leaq 0x70(%rsp), %rdi
callq 0x6e174
movq %rbx, %rdi
callq 0x138b0
nop