// File: /workspace/github_cpp_makefile_star2_O1/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 0xc2368
movq %rbp, %rdi
xorl %esi, %esi
callq 0x15a20
cmpl $0x0, 0x150950(%rip)    # 0x16edcc
je 0x1e499
leaq 0xeba25(%rip), %rdi     # 0x109eaa
callq 0x15980
movq 0x14facf(%rip), %rax    # 0x16df60
movq (%rax), %rdi
callq 0x15760
movq %r14, %rdi
movq %rbx, %rsi
callq 0x42dac
testq %rax, %rax
je 0x1e57e
movq %rax, %rbp
movq 0x8(%r14), %rdi
movq %r13, %rsi
callq 0x3aaf0
testq %rax, %rax
je 0x1e58d
movq %rax, %rbx
movq 0x8(%r14), %rdi
movq %r15, %rsi
callq 0x3aaf0
testq %rax, %rax
je 0x1e59c
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 0x54912
testq %rax, %rax
je 0x1e5c2
movq %rax, %rbx
cmpl $0x0, 0x1508a5(%rip)    # 0x16edcc
je 0x1e561
leaq 0x38(%rsp), %rdi
callq 0xc23ca
leaq 0xeb07f(%rip), %rdi     # 0x1095b9
movb $0x1, %al
callq 0x15080
movl 0xc(%rbx), %esi
leaq 0xeb113(%rip), %rdi     # 0x10965e
xorl %eax, %eax
callq 0x15080
movq 0x14fa07(%rip), %rax    # 0x16df60
movq (%rax), %rdi
callq 0x15760
movq %rbx, %rdi
callq 0xc296e
movl $0x10, %esi
movq %rbx, %rdi
callq 0x15620
movl $0x1, %r12d
jmp 0x1e5b0
leaq 0xeb745(%rip), %rdi     # 0x109cca
xorl %r12d, %r12d
movq %rbx, %rsi
jmp 0x1e5a9
leaq 0xeb56b(%rip), %rdi     # 0x109aff
xorl %r12d, %r12d
movq %r13, %rsi
jmp 0x1e5a9
leaq 0xeb55c(%rip), %rdi     # 0x109aff
xorl %r12d, %r12d
movq %r15, %rsi
xorl %eax, %eax
callq 0xc5782
movl %r12d, %eax
addq $0x48, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
leaq 0xeb725(%rip), %rdi     # 0x109cee
xorl %eax, %eax
callq 0xc5782
jmp 0x1e5b0