// File: /workspace/github_cpp_makefile_star2_O1/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, %rbx
movq %rdi, %r12
movapd %xmm2, %xmm0
movl %edx, %esi
callq 0x25edc
movq %rax, 0x8(%rsp)
testq %rax, %rax
je 0x26526
movq 0x8(%rsp), %rax
movslq 0x24c(%rax), %rbp
testq %rbp, %rbp
je 0x2650c
movq %rbx, 0x40(%rsp)
movq 0x8(%rsp), %r13
movsd 0x220(%r13), %xmm0
movsd %xmm0, 0x38(%rsp)
movq %rbp, %rax
shlq $0x2, %rax
testl %ebp, %ebp
movq $-0x1, %r15
cmovnsq %rax, %r15
movq %r15, %rdi
callq 0x13030
movq %rax, %rbx
movq %r15, %rdi
callq 0x13030
movq %rax, %r14
movq %r15, %rdi
callq 0x13030
movq %rax, %r15
movsd 0xb7f51(%rip), %xmm0    # 0xde140
movq %r13, %rdi
movl %ebp, %esi
movq %r14, 0x20(%rsp)
movq %r14, %rdx
movq %rbx, 0x10(%rsp)
movq %rbx, %rcx
movq %rax, %r8
callq 0x822b0
testl %eax, %eax
jle 0x264f0
movl %eax, %r13d
movq %r12, 0x30(%rsp)
movsd 0x38(%rsp), %xmm1
movapd %xmm1, %xmm0
mulsd %xmm1, %xmm0
mulsd %xmm1, %xmm0
movsd 0x18(%rsp), %xmm1
mulsd %xmm0, %xmm1
cvttsd2si %xmm1, %ebx
mulsd 0x28(%rsp), %xmm0
cvttsd2si %xmm0, %ebp
movq 0x40(%rsp), %rax
movsd (%rax), %xmm0
movsd 0x8(%rax), %xmm1
movsd 0x10(%rax), %xmm2
leaq 0x48(%rsp), %r14
movq %r14, %rdi
movq 0x8(%rsp), %rsi
callq 0x77cba
movsd (%r14), %xmm0
addsd 0xb7ec8(%rip), %xmm0    # 0xde140
cvttsd2si %xmm0, %eax
movl $0xffffffff, %r14d      # imm = 0xFFFFFFFF
testl %eax, %eax
js 0x2633e
movq 0x8(%rsp), %rcx
cmpl %eax, 0x238(%rcx)
movq 0x10(%rsp), %rdi
jle 0x26343
movsd 0x50(%rsp), %xmm0
addsd 0xb7e92(%rip), %xmm0    # 0xde140
cvttsd2si %xmm0, %ecx
testl %ecx, %ecx
js 0x26343
movq 0x8(%rsp), %rdx
cmpl %ecx, 0x23c(%rdx)
jle 0x26343
movsd 0x58(%rsp), %xmm0
addsd 0xb7e6b(%rip), %xmm0    # 0xde140
cvttsd2si %xmm0, %edx
testl %edx, %edx
js 0x26343
movq 0x8(%rsp), %rsi
cmpl %edx, 0x240(%rsi)
jle 0x26343
movq 0x8(%rsp), %rsi
imull 0x248(%rsi), %edx
imull 0x244(%rsi), %ecx
addl %eax, %edx
addl %ecx, %edx
movslq %edx, %rax
movl (%r15,%rax,4), %r14d
testl %ebx, %ebx
jle 0x26321
testl %r14d, %r14d
js 0x26321
cmpl %ebx, (%rdi,%r14,4)
movl $0xffffffff, %eax       # imm = 0xFFFFFFFF
cmovgel %r14d, %eax
movl %eax, %r14d
testl %ebp, %ebp
jle 0x26343
testl %r14d, %r14d
js 0x26343
movl %r14d, %eax
cmpl %ebp, (%rdi,%rax,4)
movl $0xffffffff, %eax       # imm = 0xFFFFFFFF
cmovlel %r14d, %eax
movl %eax, %r14d
jmp 0x26343
movq 0x10(%rsp), %rdi
movq %r15, 0x18(%rsp)
testl %r14d, %r14d
jns 0x26415
cmpl $0x2, %r13d
movl $0x1, %r15d
cmovgel %r13d, %r15d
movsd 0xb7e09(%rip), %xmm0    # 0xde170
xorl %r13d, %r13d
testl %ebx, %ebx
jle 0x26378
cmpl %ebx, (%rdi,%r13,4)
jl 0x26409
testl %ebp, %ebp
jle 0x26386
cmpl %ebp, (%rdi,%r13,4)
jg 0x26409
movq 0x20(%rsp), %rax
movl (%rax,%r13,4), %ecx
movl %ecx, %eax
cltd
movq 0x8(%rsp), %rdi
idivl 0x248(%rdi)
movl %eax, %esi
movl %edx, %eax
movl 0x244(%rdi), %r8d
cltd
idivl %r8d
movl %eax, %edi
movl %ecx, %eax
cltd
idivl %r8d
movsd %xmm0, 0x28(%rsp)
xorps %xmm0, %xmm0
cvtsi2sd %edx, %xmm0
xorps %xmm1, %xmm1
cvtsi2sd %edi, %xmm1
xorps %xmm2, %xmm2
cvtsi2sd %esi, %xmm2
movl %ebp, %r12d
leaq 0x80(%rsp), %rbp
movq %rbp, %rdi
callq 0x84d7e
movq %rbp, %rdi
movl %r12d, %ebp
leaq 0x48(%rsp), %rsi
callq 0x50893
movq 0x10(%rsp), %rdi
movsd 0x28(%rsp), %xmm1
ucomisd %xmm0, %xmm1
cmoval %r13d, %r14d
minsd %xmm1, %xmm0
incq %r13
cmpq %r13, %r15
jne 0x2636a
testl %r14d, %r14d
movq 0x18(%rsp), %r15
js 0x264f0
movq 0x8(%rsp), %rax
movslq 0x24c(%rax), %rax
testq %rax, %rax
movq 0x30(%rsp), %r12
jle 0x2646a
movq 0x8(%rsp), %rcx
movq 0x230(%rcx), %rcx
xorl %edx, %edx
movsd 0xb7d01(%rip), %xmm0    # 0xde150
movapd %xmm0, %xmm1
cmpl %r14d, (%r15,%rdx,4)
je 0x2645d
xorpd %xmm1, %xmm1
movsd %xmm1, (%rcx,%rdx,8)
incq %rdx
cmpq %rdx, %rax
jne 0x2644f
callq 0x13680
movq 0x20(%rsp), %rdi
callq 0x13680
movq %r15, %rdi
callq 0x13680
testl %r14d, %r14d
js 0x2650c
leaq 0x10e777(%rip), %rax    # 0x134c08
movsd (%rax), %xmm0
leaq 0x48(%rsp), %r14
xorpd %xmm1, %xmm1
xorpd %xmm2, %xmm2
movq %r14, %rdi
movq 0x8(%rsp), %rsi
movl $0x4, %edx
xorl %ecx, %ecx
movl $0x1, %r8d
callq 0x30b3e
movq %r12, %rdi
movq %r14, %rsi
callq 0x22118
movq %rax, %r14
movq 0x8(%rsp), %rbx
movq %rbx, %rdi
callq 0x7747c
movl $0x250, %esi            # imm = 0x250
movq %rbx, %rdi
callq 0x134f0
leaq 0x48(%rsp), %rdi
callq 0x321ae
jmp 0x26529
movq 0x10(%rsp), %rdi
callq 0x13680
movq 0x20(%rsp), %rdi
callq 0x13680
movq %r15, %rdi
callq 0x13680
movq 0x8(%rsp), %rbx
movq %rbx, %rdi
callq 0x7747c
movl $0x250, %esi            # imm = 0x250
movq %rbx, %rdi
callq 0x134f0
xorl %r14d, %r14d
movq %r14, %rax
addq $0x98, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq %rax, %rbx
leaq 0x48(%rsp), %rdi
callq 0x321ae
movq %rbx, %rdi
callq 0x138b0