// File: /workspace/github_cpp_makefile_star2_O3/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, 0x8(%rsp)
movq %rsi, %r14
movq %rdi, %r12
movapd %xmm2, %xmm0
movl %edx, %esi
callq 0x25bef
testq %rax, %rax
je 0x261e8
movq %rax, %rbx
movslq 0x24c(%rax), %rbp
testq %rbp, %rbp
je 0x261d3
movq %r14, 0x40(%rsp)
movsd 0x220(%rbx), %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, %r14
movq %r15, %rdi
callq 0x13030
movq %rax, %r13
movq %r15, %rdi
callq 0x13030
movsd 0xb724d(%rip), %xmm0    # 0xdd138
movq %rbx, %rdi
movl %ebp, %esi
movq %r13, 0x20(%rsp)
movq %r13, %rdx
movq %r14, 0x10(%rsp)
movq %r14, %rcx
movq %rax, 0x18(%rsp)
movq %rax, %r8
callq 0x813f0
testl %eax, %eax
jle 0x261b5
movl %eax, %r13d
movq %r12, 0x30(%rsp)
movsd 0x38(%rsp), %xmm1
movapd %xmm1, %xmm0
mulsd %xmm1, %xmm0
mulsd %xmm1, %xmm0
movsd 0x8(%rsp), %xmm1
mulsd %xmm0, %xmm1
cvttsd2si %xmm1, %r15d
mulsd 0x28(%rsp), %xmm0
cvttsd2si %xmm0, %r12d
movq 0x40(%rsp), %rax
movsd (%rax), %xmm0
movsd 0x8(%rax), %xmm1
movsd 0x10(%rax), %xmm2
leaq 0x48(%rsp), %r14
movq %r14, %rdi
movq %rbx, %rsi
callq 0x76f0c
movsd (%r14), %xmm0
addsd 0xb71bf(%rip), %xmm0    # 0xdd138
cvttsd2si %xmm0, %ecx
movl $0xffffffff, %eax       # imm = 0xFFFFFFFF
testl %ecx, %ecx
js 0x26033
cmpl %ecx, 0x238(%rbx)
movq 0x10(%rsp), %rdi
jle 0x26038
movsd 0x50(%rsp), %xmm0
addsd 0xb718f(%rip), %xmm0    # 0xdd138
cvttsd2si %xmm0, %edx
testl %edx, %edx
js 0x26038
cmpl %edx, 0x23c(%rbx)
jle 0x26038
movsd 0x58(%rsp), %xmm0
addsd 0xb716d(%rip), %xmm0    # 0xdd138
cvttsd2si %xmm0, %esi
testl %esi, %esi
js 0x26038
cmpl %esi, 0x240(%rbx)
jle 0x26038
imull 0x248(%rbx), %esi
imull 0x244(%rbx), %edx
addl %ecx, %esi
addl %edx, %esi
movslq %esi, %rcx
movq 0x18(%rsp), %rdx
movl (%rdx,%rcx,4), %r14d
testl %r15d, %r15d
jle 0x26013
testl %r14d, %r14d
js 0x26013
cmpl %r15d, (%rdi,%r14,4)
movl $0xffffffff, %ecx       # imm = 0xFFFFFFFF
cmovgel %r14d, %ecx
movl %ecx, %r14d
testl %r12d, %r12d
jle 0x26200
testl %r14d, %r14d
js 0x26200
movl %r14d, %ecx
cmpl %r12d, (%rdi,%rcx,4)
jg 0x26038
jmp 0x260fd
movq 0x10(%rsp), %rdi
movq %rbx, 0x8(%rsp)
movl %r13d, %r13d
movsd 0xb7120(%rip), %xmm0    # 0xdd168
xorl %ebx, %ebx
movl %eax, %r14d
testl %r15d, %r15d
jle 0x2605c
cmpl %r15d, (%rdi,%rbx,4)
jl 0x260e3
testl %r12d, %r12d
jle 0x26067
cmpl %r12d, (%rdi,%rbx,4)
jg 0x260e3
movq 0x20(%rsp), %rax
movl (%rax,%rbx,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
leaq 0x80(%rsp), %rbp
movq %rbp, %rdi
callq 0x83dc2
movq %rbp, %rdi
leaq 0x48(%rsp), %rsi
callq 0x4feeb
movq 0x10(%rsp), %rdi
movsd 0x28(%rsp), %xmm1
ucomisd %xmm0, %xmm1
cmoval %ebx, %r14d
minsd %xmm1, %xmm0
incq %rbx
cmpq %rbx, %r13
jne 0x2604d
testl %r14d, %r14d
movq 0x8(%rsp), %rbx
js 0x261b5
movslq 0x24c(%rbx), %rax
testq %rax, %rax
movq 0x30(%rsp), %r15
movq 0x18(%rsp), %r12
jle 0x2613f
movq 0x230(%rbx), %rcx
xorl %edx, %edx
movsd 0xb7024(%rip), %xmm0    # 0xdd148
movapd %xmm0, %xmm1
cmpl %r14d, (%r12,%rdx,4)
je 0x26132
xorpd %xmm1, %xmm1
movsd %xmm1, (%rcx,%rdx,8)
incq %rdx
cmpq %rdx, %rax
jne 0x26124
callq 0x13680
movq 0x20(%rsp), %rdi
callq 0x13680
movq %r12, %rdi
callq 0x13680
leaq 0x10daab(%rip), %rax    # 0x133c08
movsd (%rax), %xmm0
leaq 0x48(%rsp), %r14
xorpd %xmm1, %xmm1
xorpd %xmm2, %xmm2
movq %r14, %rdi
movq %rbx, %rsi
movl $0x4, %edx
xorl %ecx, %ecx
movl $0x1, %r8d
callq 0x3074a
movq %r15, %rdi
movq %r14, %rsi
callq 0x21f14
movq %rax, %r14
movq %rbx, %rdi
callq 0x766d6
movl $0x250, %esi            # imm = 0x250
movq %rbx, %rdi
callq 0x134f0
leaq 0x48(%rsp), %rdi
callq 0x31dba
jmp 0x261eb
movq 0x10(%rsp), %rdi
callq 0x13680
movq 0x20(%rsp), %rdi
callq 0x13680
movq 0x18(%rsp), %rdi
callq 0x13680
movq %rbx, %rdi
callq 0x766d6
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
movl %r14d, %eax
testl %r14d, %r14d
jns 0x260fd
jmp 0x26038
movq %rax, %rbx
leaq 0x48(%rsp), %rdi
callq 0x31dba
movq %rbx, %rdi
callq 0x138b0