// File: /workspace/github_cpp_makefile_star2_O2/tomfunkhouser[P]gaps/pkgs/R3Surfels/R3SurfelUtils.cpp
// Function: gaps::CreateConnectedPointSet(gaps::R3SurfelPointSet*, gaps::R3Point const&, double, double, double, int)
R3SurfelPointSet *
CreateConnectedPointSet(R3SurfelPointSet *pointset, const R3Point &seed_position,
  RNScalar min_volume, RNScalar max_volume, RNLength grid_spacing, int max_grid_resolution)
{
  // Create grid
  R3Grid *grid = CreateGrid(pointset, grid_spacing, max_grid_resolution);
  if (!grid) return NULL;

  // Find largest connected component
  if (!MaskToSelectedConnectedComponent(grid, 0.5, seed_position, min_volume, max_volume)) { 
    delete grid; 
    return NULL; 
  }

  // Create connnected point set
  R3SurfelGridConstraint constraint(grid);
  R3SurfelPointSet *connected_pointset = CreatePointSet(pointset, &constraint);

  // Delete grid
  delete grid;

  // Return connected point set
  return connected_pointset;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x98, %rsp
movsd %xmm1, 0x28(%rsp)
movsd %xmm0, 0x18(%rsp)
movq %rsi, %r15
movq %rdi, %r14
movapd %xmm2, %xmm0
movl %edx, %esi
callq 0x242e5
testq %rax, %rax
je 0x24862
movq %rax, %rbx
movslq 0x24c(%rax), %rbp
testq %rbp, %rbp
je 0x2484d
movq %r15, 0x40(%rsp)
movq %r14, 0x30(%rsp)
movsd 0x220(%rbx), %xmm0
movsd %xmm0, 0x38(%rsp)
movq %rbp, %rax
shlq $0x2, %rax
testl %ebp, %ebp
pushq $-0x1
popq %r15
cmovnsq %rax, %r15
movq %r15, %rdi
callq 0x13030
movq %rax, %r13
movq %r15, %rdi
callq 0x13030
movq %rax, %r12
movq %r15, %rdi
callq 0x13030
movq %rax, %r14
movsd 0xa3bbc(%rip), %xmm0    # 0xc8138
movq %rbx, %rdi
movl %ebp, %esi
movq %r12, 0x20(%rsp)
movq %r12, %rdx
movq %r13, 0x8(%rsp)
movq %r13, %rcx
movq %rax, %r8
callq 0x7582c
testl %eax, %eax
jle 0x24831
movl %eax, %r13d
movq %r14, 0x10(%rsp)
movsd 0x38(%rsp), %xmm1
movapd %xmm1, %xmm0
mulsd %xmm1, %xmm0
mulsd %xmm1, %xmm0
movsd 0x18(%rsp), %xmm1
mulsd %xmm0, %xmm1
cvttsd2si %xmm1, %r15d
mulsd 0x28(%rsp), %xmm0
cvttsd2si %xmm0, %r14d
leaq 0x48(%rsp), %rbp
movq %rbp, %rdi
movq %rbx, %rsi
movq 0x40(%rsp), %rdx
callq 0x2860e
movsd (%rbp), %xmm0
addsd 0xa3b41(%rip), %xmm0    # 0xc8138
cvttsd2si %xmm0, %ecx
pushq $-0x1
popq %rax
testl %ecx, %ecx
js 0x246a3
cmpl %ecx, 0x238(%rbx)
movq 0x8(%rsp), %rdi
jle 0x246a8
movsd 0x50(%rsp), %xmm0
addsd 0xa3b13(%rip), %xmm0    # 0xc8138
cvttsd2si %xmm0, %edx
testl %edx, %edx
js 0x246a8
cmpl %edx, 0x23c(%rbx)
jle 0x246a8
movsd 0x58(%rsp), %xmm0
addsd 0xa3af5(%rip), %xmm0    # 0xc8138
cvttsd2si %xmm0, %esi
testl %esi, %esi
js 0x246a8
cmpl %esi, 0x240(%rbx)
jle 0x246a8
imull 0x248(%rbx), %esi
imull 0x244(%rbx), %edx
addl %ecx, %esi
addl %edx, %esi
movslq %esi, %rcx
movq 0x10(%rsp), %rdx
movl (%rdx,%rcx,4), %esi
testl %r15d, %r15d
jle 0x24685
testl %esi, %esi
js 0x24685
cmpl %r15d, (%rdi,%rsi,4)
pushq $-0x1
popq %rcx
cmovgel %esi, %ecx
movl %ecx, %esi
testl %r14d, %r14d
jle 0x2487a
testl %esi, %esi
js 0x2487a
movl %esi, %ecx
cmpl %r14d, (%rdi,%rcx,4)
jg 0x246a8
jmp 0x24777
movq 0x8(%rsp), %rdi
movl %r13d, %ecx
movsd 0xa3ab5(%rip), %xmm0    # 0xc8168
xorl %ebp, %ebp
movl %eax, %esi
movq %rcx, 0x18(%rsp)
cmpq %rbp, %rcx
je 0x2476f
testl %r15d, %r15d
jle 0x246d4
cmpl %r15d, (%rdi,%rbp,4)
jl 0x24767
testl %r14d, %r14d
jle 0x246e3
cmpl %r14d, (%rdi,%rbp,4)
jg 0x24767
movq 0x20(%rsp), %rax
movl (%rax,%rbp,4), %ecx
movl %ecx, %eax
cltd
idivl 0x248(%rbx)
movq %rsi, %r13
movl %eax, %esi
movl %edx, %eax
movl 0x244(%rbx), %r8d
cltd
idivl %r8d
movl %eax, %edi
movl %ecx, %eax
cltd
idivl %r8d
movsd %xmm0, 0x28(%rsp)
cvtsi2sd %edx, %xmm0
cvtsi2sd %edi, %xmm1
cvtsi2sd %esi, %xmm2
movq %rbx, %r12
movl %r14d, %ebx
leaq 0x80(%rsp), %r14
movq %r14, %rdi
callq 0x781bc
movq %r14, %rdi
movl %ebx, %r14d
movq %r12, %rbx
leaq 0x48(%rsp), %rsi
callq 0x495a1
movq 0x18(%rsp), %rcx
movq %r13, %rsi
movq 0x8(%rsp), %rdi
movsd 0x28(%rsp), %xmm1
ucomisd %xmm0, %xmm1
cmoval %ebp, %esi
minsd %xmm1, %xmm0
incq %rbp
jmp 0x246bc
testl %esi, %esi
js 0x2482c
movl 0x24c(%rbx), %eax
xorl %ecx, %ecx
testl %eax, %eax
cmovlel %ecx, %eax
movsd 0xa39bc(%rip), %xmm0    # 0xc8148
movq 0x30(%rsp), %r12
movq 0x10(%rsp), %r14
cmpq %rcx, %rax
je 0x247ba
movapd %xmm0, %xmm1
cmpl %esi, (%r14,%rcx,4)
je 0x247a9
xorpd %xmm1, %xmm1
movq 0x230(%rbx), %rdx
movsd %xmm1, (%rdx,%rcx,8)
incq %rcx
jmp 0x24796
callq 0x136a0
movq 0x20(%rsp), %rdi
callq 0x136a0
movq %r14, %rdi
callq 0x136a0
leaq 0x100450(%rip), %rax    # 0x124c28
movsd (%rax), %xmm0
leaq 0x48(%rsp), %r14
pushq $0x4
popq %rdx
pushq $0x1
popq %r8
xorpd %xmm1, %xmm1
xorpd %xmm2, %xmm2
movq %r14, %rdi
movq %rbx, %rsi
xorl %ecx, %ecx
callq 0x2d9f6
movq %r12, %rdi
movq %r14, %rsi
callq 0x20c50
movq %rax, %r14
movq %rbx, %rdi
callq 0x6c22a
movl $0x250, %esi            # imm = 0x250
movq %rbx, %rdi
callq 0x13500
leaq 0x48(%rsp), %rdi
callq 0x2ec74
jmp 0x24865
movq 0x10(%rsp), %r14
movq 0x8(%rsp), %rdi
callq 0x136a0
movq 0x20(%rsp), %rdi
callq 0x136a0
movq %r14, %rdi
callq 0x136a0
movq %rbx, %rdi
callq 0x6c22a
movl $0x250, %esi            # imm = 0x250
movq %rbx, %rdi
callq 0x13500
xorl %r14d, %r14d
movq %r14, %rax
addq $0x98, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movl %esi, %eax
testl %esi, %esi
jns 0x24777
jmp 0x246a8
movq %rax, %rbx
leaq 0x48(%rsp), %rdi
callq 0x2ec74
movq %rbx, %rdi
callq 0x138f0