// File: /workspace/github_cpp_makefile_star2_O3/tomfunkhouser[P]gaps/apps/sflprocess/sflprocess.cpp
// Function: CreateClusterObjects(gaps::R3SurfelScene*, char const*, char const*, char const*, int, double, double, double, int, double)
static int
CreateClusterObjects(R3SurfelScene *scene, 
  const char *parent_object_name, const char *parent_node_name, const char *source_node_name, 
  int max_neighbors, RNLength max_neighbor_distance, 
  RNLength max_offplane_distance, RNAngle max_normal_angle,
  int min_points_per_object, RNLength chunk_size)
{
  // Start statistics
  RNTime start_time;
  start_time.Read();
  if (print_verbose) {
    printf("Creating cluster objects ...\n");
    fflush(stdout);
  }

  // Find parent object
  R3SurfelObject *parent_object = scene->FindObjectByName(parent_object_name);
  if (!parent_object) {
    RNFail("Unable to find object with name %s\n", parent_object_name);
    return 0;
  }

  // Find parent node
  R3SurfelNode *parent_node = scene->Tree()->FindNodeByName(parent_node_name);
  if (!parent_node) {
    RNFail("Unable to find node with name %s\n", parent_node_name);
    return 0;
  }

  // Find source node
  R3SurfelNode *source_node = scene->Tree()->FindNodeByName(source_node_name);
  if (!source_node) {
    RNFail("Unable to find node with name %s\n", source_node_name);
    return 0;
  }

  // Create cluster objects 
  RNArray<R3SurfelObject *> *objects = CreateClusterObjects(scene, 
    source_node, NULL, parent_object, parent_node,                                                   
    max_neighbors, max_neighbor_distance, 
    max_offplane_distance, max_normal_angle, 
    min_points_per_object, chunk_size);
  if (!objects) {
    RNFail("No cluster objects created\n");
    return 0;
  }

  // Print statistics
  if (print_verbose) {
    printf("  Time = %.2f seconds\n", start_time.Elapsed());
    printf("  # Objects = %d\n", objects->NEntries());
    fflush(stdout);
  }

  // Delete array of objects
  delete objects;

  // Return success
  return 1;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x48, %rsp
movsd %xmm3, 0x30(%rsp)
movl %r9d, %r12d
movsd %xmm2, 0x28(%rsp)
movsd %xmm1, 0x20(%rsp)
movsd %xmm0, 0x18(%rsp)
movl %r8d, 0x14(%rsp)
movq %rcx, %r15
movq %rdx, %r13
movq %rsi, %rbx
movq %rdi, %r14
leaq 0x38(%rsp), %rbp
movq %rbp, %rdi
callq 0xc0cf4
movq %rbp, %rdi
xorl %esi, %esi
callq 0x15a10
cmpl $0x0, 0x14ebce(%rip)    # 0x16cdbc
je 0x1e20b
leaq 0xe9caa(%rip), %rdi     # 0x107ea1
callq 0x15970
movq 0x14dd5d(%rip), %rax    # 0x16bf60
movq (%rax), %rdi
callq 0x15750
movq %r14, %rdi
movq %rbx, %rsi
callq 0x428ca
testq %rax, %rax
je 0x1e2f0
movq %rax, %rbp
movq 0x8(%r14), %rdi
movq %r13, %rsi
callq 0x3a6a0
testq %rax, %rax
je 0x1e2ff
movq %rax, %rbx
movq 0x8(%r14), %rdi
movq %r15, %rsi
callq 0x3a6a0
testq %rax, %rax
je 0x1e30e
movl %r12d, (%rsp)
xorl %r12d, %r12d
movq %r14, %rdi
movq %rax, %rsi
xorl %edx, %edx
movq %rbp, %rcx
movq %rbx, %r8
movl 0x14(%rsp), %r9d
movsd 0x18(%rsp), %xmm0
movsd 0x20(%rsp), %xmm1
movsd 0x28(%rsp), %xmm2
movsd 0x30(%rsp), %xmm3
callq 0x540d1
testq %rax, %rax
je 0x1e334
movq %rax, %rbx
cmpl $0x0, 0x14eb23(%rip)    # 0x16cdbc
je 0x1e2d3
leaq 0x38(%rsp), %rdi
callq 0xc0d56
leaq 0xe9306(%rip), %rdi     # 0x1075b2
movb $0x1, %al
callq 0x15080
movl 0xc(%rbx), %esi
leaq 0xe939a(%rip), %rdi     # 0x107657
xorl %eax, %eax
callq 0x15080
movq 0x14dc95(%rip), %rax    # 0x16bf60
movq (%rax), %rdi
callq 0x15750
movq %rbx, %rdi
callq 0xc12fa
movl $0x10, %esi
movq %rbx, %rdi
callq 0x15620
movl $0x1, %r12d
jmp 0x1e322
leaq 0xe99ca(%rip), %rdi     # 0x107cc1
xorl %r12d, %r12d
movq %rbx, %rsi
jmp 0x1e31b
leaq 0xe97f0(%rip), %rdi     # 0x107af6
xorl %r12d, %r12d
movq %r13, %rsi
jmp 0x1e31b
leaq 0xe97e1(%rip), %rdi     # 0x107af6
xorl %r12d, %r12d
movq %r15, %rsi
xorl %eax, %eax
callq 0xc3e02
movl %r12d, %eax
addq $0x48, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
leaq 0xe99aa(%rip), %rdi     # 0x107ce5
xorl %eax, %eax
callq 0xc3e02
jmp 0x1e322