// File: /workspace/github_cpp_makefile_star2_O1/tomfunkhouser[P]gaps/apps/sflprocess/sflprocess.cpp
// Function: CreatePlanarObjects(gaps::R3SurfelScene*, char const*, char const*, char const*, int, double, double, double, double, double, int, double, double, double)
static int
CreatePlanarObjects(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,
  RNArea min_area, RNScalar min_density, int min_points,
  RNLength grid_spacing, RNScalar accuracy_factor, RNLength chunk_size)
{
  // Start statistics
  RNTime start_time;
  start_time.Read();
  if (print_verbose) {
    printf("Creating planar 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 planar objects 
  RNArray<R3SurfelObject *> *objects = CreatePlanarObjects(scene, 
    source_node, NULL, parent_object, parent_node,
    max_neighbors, max_neighbor_distance, 
    max_offplane_distance, max_normal_angle,
    min_area, min_density, min_points, 
    grid_spacing, accuracy_factor, chunk_size);
  if (!objects) {
    RNFail("No planar 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 $0x68, %rsp
movsd %xmm7, 0x50(%rsp)
movsd %xmm6, 0x48(%rsp)
movsd %xmm5, 0x40(%rsp)
movl %r9d, %r12d
movsd %xmm4, 0x38(%rsp)
movsd %xmm3, 0x30(%rsp)
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 0x58(%rsp), %rbp
movq %rbp, %rdi
callq 0xc2368
movq %rbp, %rdi
xorl %esi, %esi
callq 0x15a20
cmpl $0x0, 0x15078a(%rip)    # 0x16edcc
je 0x1e65f
leaq 0xeb87c(%rip), %rdi     # 0x109ec7
callq 0x15980
movq 0x14f909(%rip), %rax    # 0x16df60
movq (%rax), %rdi
callq 0x15760
movq %r14, %rdi
movq %rbx, %rsi
callq 0x42dac
testq %rax, %rax
je 0x1e75c
movq %rax, %rbp
movq 0x8(%r14), %rdi
movq %r13, %rsi
callq 0x3aaf0
testq %rax, %rax
je 0x1e76b
movq %rax, %rbx
movq 0x8(%r14), %rdi
movq %r15, %rsi
callq 0x3aaf0
testq %rax, %rax
je 0x1e77a
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
movsd 0x38(%rsp), %xmm4
movsd 0x40(%rsp), %xmm5
movsd 0x48(%rsp), %xmm6
movsd 0x50(%rsp), %xmm7
callq 0x538e4
testq %rax, %rax
je 0x1e7a0
movq %rax, %rbx
cmpl $0x0, 0x1506c7(%rip)    # 0x16edcc
je 0x1e73f
leaq 0x58(%rsp), %rdi
callq 0xc23ca
leaq 0xeaea1(%rip), %rdi     # 0x1095b9
movb $0x1, %al
callq 0x15080
movl 0xc(%rbx), %esi
leaq 0xeaf35(%rip), %rdi     # 0x10965e
xorl %eax, %eax
callq 0x15080
movq 0x14f829(%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 0x1e78e
leaq 0xeb567(%rip), %rdi     # 0x109cca
xorl %r12d, %r12d
movq %rbx, %rsi
jmp 0x1e787
leaq 0xeb38d(%rip), %rdi     # 0x109aff
xorl %r12d, %r12d
movq %r13, %rsi
jmp 0x1e787
leaq 0xeb37e(%rip), %rdi     # 0x109aff
xorl %r12d, %r12d
movq %r15, %rsi
xorl %eax, %eax
callq 0xc5782
movl %r12d, %eax
addq $0x68, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
leaq 0xeb563(%rip), %rdi     # 0x109d0a
xorl %eax, %eax
callq 0xc5782
jmp 0x1e78e