// File: /workspace/github_cpp_makefile_star2_O1/tomfunkhouser[P]gaps/pkgs/R3Surfels/R3SurfelPointSet.cpp
// Function: gaps::R3SurfelPointSet::InsertPoints(gaps::R3SurfelBlock*, gaps::R2Box const&)
void R3SurfelPointSet::
InsertPoints(R3SurfelBlock *block, const R2Box& constraint_box)
{
  // Check block
  if (block->NSurfels() == 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(block->BBox());
  if (intersection_box.IsEmpty()) return;
  bbox.Union(intersection_box);

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

  // Translate constraint by block origin (and store in floats)
  const R3Point& origin = block->PositionOrigin();
  float xmin = constraint_box[0][0] - origin[0];
  float ymin = constraint_box[0][1] - origin[1];
  float xmax = constraint_box[1][0] - origin[0];
  float ymax = constraint_box[1][1] - origin[1];

  // Allocate space for points
  AllocatePoints(npoints + block->NSurfels());

  // Read block
  if (block->database) block->database->ReadBlock(block);

  // Copy points
  for (int i = 0; i < block->NSurfels(); i++) {
    const R3Surfel *surfel = block->Surfel(i);
    if (surfel->X() < xmin) continue;
    if (surfel->Y() < ymin) continue;
    if (surfel->X() > xmax) continue;
    if (surfel->Y() > ymax) continue;
    points[npoints].Reset(block, surfel);
    npoints++;
  }

  // Release block
  if (block->database) block->database->ReleaseBlock(block);
}

// Assembly:
pushq %r15
pushq %r14
pushq %r12
pushq %rbx
subq $0x68, %rsp
cmpl $0x0, 0x8(%rsi)
je 0x3341d
movq %rdx, %r15
movq %rsi, %rbx
movq %rdi, %r14
movsd 0x8(%rdx), %xmm0
movsd 0x10(%rdx), %xmm1
movsd 0x18(%rdx), %xmm3
movsd 0x20(%rdx), %xmm4
leaq 0x30(%rsp), %rdi
movsd 0xaafb3(%rip), %xmm2    # 0xde178
movsd 0xaafa3(%rip), %xmm5    # 0xde170
callq 0x6e028
movq %rbx, %rdi
callq 0x2cfc6
leaq 0x30(%rsp), %rdi
movq %rax, %rsi
callq 0x6ebb4
movsd 0x38(%rsp), %xmm0
ucomisd 0x50(%rsp), %xmm0
ja 0x33413
movsd 0x40(%rsp), %xmm0
ucomisd 0x58(%rsp), %xmm0
ja 0x33413
movsd 0x48(%rsp), %xmm0
ucomisd 0x60(%rsp), %xmm0
ja 0x33413
leaq 0x18(%r14), %rdi
leaq 0x30(%rsp), %rsi
callq 0x6ea70
movq %rbx, %rdi
callq 0x2d262
movsd (%rax), %xmm0
movsd 0x50(%r14), %xmm1
ucomisd %xmm0, %xmm1
jbe 0x33249
movsd %xmm0, 0x50(%r14)
movsd 0x8(%rax), %xmm0
ucomisd 0x58(%r14), %xmm0
jbe 0x3325c
movsd %xmm0, 0x58(%r14)
movsd 0x10(%rbx), %xmm0
movsd %xmm0, 0x18(%rsp)
movsd 0x8(%r15), %xmm0
movsd %xmm0, 0x8(%rsp)
movsd 0x10(%r15), %xmm0
movsd %xmm0, (%rsp)
movsd 0x18(%rbx), %xmm0
movsd %xmm0, 0x10(%rsp)
movsd 0x18(%r15), %xmm0
movsd %xmm0, 0x20(%rsp)
movsd 0x20(%r15), %xmm0
movsd %xmm0, 0x28(%rsp)
movl 0x8(%rbx), %esi
addl 0x10(%r14), %esi
movq (%r14), %rax
movq %r14, %rdi
callq *0x80(%rax)
movq 0x98(%rbx), %rdi
testq %rdi, %rdi
je 0x332e6
cmpl $0x0, 0xb4(%rbx)
jne 0x332e0
movq (%rdi), %rax
movq 0x8(%rdi), %rdx
movl 0x28(%rdi), %ecx
movq %rbx, %rsi
callq *0x88(%rax)
testl %eax, %eax
je 0x332e6
incl 0xb4(%rbx)
cmpl $0x0, 0x8(%rbx)
jle 0x333b1
movsd 0x18(%rsp), %xmm0
movsd 0x8(%rsp), %xmm1
subsd %xmm0, %xmm1
cvtsd2ss %xmm1, %xmm2
movsd 0x10(%rsp), %xmm1
movsd (%rsp), %xmm3
subsd %xmm1, %xmm3
cvtsd2ss %xmm3, %xmm3
movsd 0x20(%rsp), %xmm4
subsd %xmm0, %xmm4
xorps %xmm0, %xmm0
cvtsd2ss %xmm4, %xmm0
movss %xmm0, 0x18(%rsp)
movsd 0x28(%rsp), %xmm0
subsd %xmm1, %xmm0
cvtsd2ss %xmm0, %xmm0
movss %xmm0, 0x10(%rsp)
xorl %r15d, %r15d
xorl %r12d, %r12d
movss %xmm2, 0x8(%rsp)
movss %xmm3, (%rsp)
movq (%rbx), %rdx
movss (%rdx,%r15), %xmm0
ucomiss %xmm0, %xmm2
ja 0x333a1
movss 0x4(%rdx,%r15), %xmm1
ucomiss %xmm1, %xmm3
ja 0x333a1
ucomiss 0x18(%rsp), %xmm0
ja 0x333a1
ucomiss 0x10(%rsp), %xmm1
ja 0x333a1
addq %r15, %rdx
movslq 0x10(%r14), %rdi
shlq $0x4, %rdi
addq 0x8(%r14), %rdi
movq %rbx, %rsi
callq 0x325ce
incl 0x10(%r14)
movss 0x8(%rsp), %xmm2
movss (%rsp), %xmm3
incq %r12
movslq 0x8(%rbx), %rax
addq $0x30, %r15
cmpq %rax, %r12
jl 0x33353
movq 0x98(%rbx), %r14
testq %r14, %r14
je 0x33413
cmpl $0x1, 0xb4(%rbx)
jne 0x333e1
movq (%r14), %rax
movq 0x8(%r14), %rdx
movl 0x28(%r14), %ecx
movq %r14, %rdi
movq %rbx, %rsi
callq *0x90(%rax)
testl %eax, %eax
je 0x33413
decl 0xb4(%rbx)
jne 0x33413
testb $0x2, 0x89(%rbx)
je 0x33413
movq (%r14), %rax
movq %r14, %rdi
movq %rbx, %rsi
callq *0x18(%rax)
movq %rbx, %rdi
callq 0x2ce2e
movl $0xc8, %esi
movq %rbx, %rdi
callq 0x134f0
leaq 0x30(%rsp), %rdi
callq 0x6ede0
addq $0x68, %rsp
popq %rbx
popq %r12
popq %r14
popq %r15
retq
jmp 0x3342d
jmp 0x3342d
movq %rax, %rbx
leaq 0x30(%rsp), %rdi
callq 0x6ede0
movq %rbx, %rdi
callq 0x138b0