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

  // Check and update bounding box (conservatively)
  R3Box intersection_box(constraint_box[0][0], constraint_box[0][1], -FLT_MAX, constraint_box[1][0], constraint_box[1][1], FLT_MAX);
  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);
    R3Point position = point->Position();
    if (!R2Intersects(constraint_box, R2Point(position.X(), position.Y()))) continue;
    points[npoints] = *point;
    npoints++;
  }
}

// Assembly:
subq $0x118, %rsp            # imm = 0x118
movq %rdi, 0x110(%rsp)
movq %rsi, 0x108(%rsp)
movq %rdx, 0x100(%rsp)
movq 0x110(%rsp), %rax
movq %rax, 0x78(%rsp)
movq 0x108(%rsp), %rdi
callq 0x18700
cmpl $0x0, %eax
jne 0x58483
jmp 0x58798
movq 0x100(%rsp), %rdi
xorl %esi, %esi
movl %esi, 0x50(%rsp)
callq 0x5b1f0
movl 0x50(%rsp), %esi
movq %rax, %rdi
callq 0x45390
movl 0x50(%rsp), %esi
movsd %xmm0, 0x68(%rsp)
movq 0x100(%rsp), %rdi
callq 0x5b1f0
movq %rax, %rdi
movl $0x1, %esi
movl %esi, 0x54(%rsp)
callq 0x45390
movl 0x54(%rsp), %esi
movsd %xmm0, 0x58(%rsp)
movq 0x100(%rsp), %rdi
callq 0x5b1f0
movl 0x50(%rsp), %esi
movq %rax, %rdi
callq 0x45390
movl 0x54(%rsp), %esi
movsd %xmm0, 0x60(%rsp)
movq 0x100(%rsp), %rdi
callq 0x5b1f0
movl 0x54(%rsp), %esi
movq %rax, %rdi
callq 0x45390
movsd 0x58(%rsp), %xmm1
movsd 0x60(%rsp), %xmm3
movaps %xmm0, %xmm4
movsd 0x68(%rsp), %xmm0
leaq 0xc8(%rsp), %rdi
movsd 0x14bc53(%rip), %xmm2   # 0x1a4188
movsd 0x14bc53(%rip), %xmm5   # 0x1a4190
callq 0xc9ee0
movq 0x108(%rsp), %rdi
callq 0x435d0
movq %rax, 0x70(%rsp)
jmp 0x58556
movq 0x70(%rsp), %rsi
leaq 0xc8(%rsp), %rdi
callq 0xcbf10
jmp 0x5856a
leaq 0xc8(%rsp), %rdi
callq 0x44290
movl %eax, 0x4c(%rsp)
jmp 0x5857d
movl 0x4c(%rsp), %eax
cmpl $0x0, %eax
je 0x585bc
movl $0x1, 0xb8(%rsp)
jmp 0x5878b
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0xc0(%rsp)
movl %eax, 0xbc(%rsp)
leaq 0xc8(%rsp), %rdi
callq 0x1b990
jmp 0x587a0
movq 0x78(%rsp), %rdi
addq $0x18, %rdi
leaq 0xc8(%rsp), %rsi
callq 0xcbc30
jmp 0x585d4
movq 0x78(%rsp), %rax
addq $0x50, %rax
movq %rax, 0x38(%rsp)
movq 0x108(%rsp), %rdi
callq 0x4f840
movq %rax, 0x40(%rsp)
jmp 0x585f6
movq 0x40(%rsp), %rsi
movq 0x38(%rsp), %rdi
callq 0x1bbc0
jmp 0x58607
movq 0x78(%rsp), %rax
movl 0x10(%rax), %eax
movl %eax, 0x30(%rsp)
movq 0x108(%rsp), %rdi
callq 0x18700
movl %eax, 0x34(%rsp)
jmp 0x58626
movq 0x78(%rsp), %rdi
movl 0x34(%rsp), %eax
movl 0x30(%rsp), %esi
addl %eax, %esi
movq (%rdi), %rax
movq 0x80(%rax), %rax
callq *%rax
jmp 0x58643
movl $0x0, 0xb4(%rsp)
movl 0xb4(%rsp), %eax
movl %eax, 0x28(%rsp)
movq 0x108(%rsp), %rdi
callq 0x18700
movl %eax, 0x2c(%rsp)
jmp 0x5866c
movl 0x28(%rsp), %eax
movl 0x2c(%rsp), %ecx
cmpl %ecx, %eax
jge 0x58780
movq 0x108(%rsp), %rdi
movl 0xb4(%rsp), %esi
callq 0x18710
movq %rax, 0x20(%rsp)
jmp 0x58697
movq 0x20(%rsp), %rax
movq %rax, 0xa8(%rsp)
movq 0xa8(%rsp), %rsi
leaq 0x90(%rsp), %rdi
callq 0x18730
jmp 0x586bb
movq 0x100(%rsp), %rax
movq %rax, 0x10(%rsp)
leaq 0x90(%rsp), %rdi
callq 0x187b0
movsd %xmm0, 0x18(%rsp)
jmp 0x586dd
leaq 0x90(%rsp), %rdi
callq 0x187c0
movsd %xmm0, 0x8(%rsp)
jmp 0x586f2
movsd 0x8(%rsp), %xmm1
movsd 0x18(%rsp), %xmm0
leaq 0x80(%rsp), %rdi
callq 0x133960
jmp 0x5870d
movq 0x10(%rsp), %rdi
leaq 0x80(%rsp), %rsi
callq 0x5b230
movl %eax, 0x4(%rsp)
jmp 0x58725
movl 0x4(%rsp), %eax
cmpl $0x0, %eax
setne %al
xorb $-0x1, %al
testb $0x1, %al
jne 0x58737
jmp 0x58739
jmp 0x5876a
movq 0x78(%rsp), %rax
movq 0xa8(%rsp), %rsi
movq 0x8(%rax), %rdi
movslq 0x10(%rax), %rax
shlq $0x4, %rax
addq %rax, %rdi
callq 0x55980
jmp 0x5875c
movq 0x78(%rsp), %rax
movl 0x10(%rax), %ecx
addl $0x1, %ecx
movl %ecx, 0x10(%rax)
movl 0xb4(%rsp), %eax
addl $0x1, %eax
movl %eax, 0xb4(%rsp)
jmp 0x5864e
movl $0x0, 0xb8(%rsp)
leaq 0xc8(%rsp), %rdi
callq 0x1b990
addq $0x118, %rsp            # imm = 0x118
retq
movq 0xc0(%rsp), %rdi
callq 0x13970
nopl (%rax)