// File: /workspace/github_cpp_makefile_star2_O3/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 0xc0cf4
movq %rbp, %rdi
xorl %esi, %esi
callq 0x15a10
cmpl $0x0, 0x14ea08(%rip)    # 0x16cdbc
je 0x1e3d1
leaq 0xe9b01(%rip), %rdi     # 0x107ebe
callq 0x15970
movq 0x14db97(%rip), %rax    # 0x16bf60
movq (%rax), %rdi
callq 0x15750
movq %r14, %rdi
movq %rbx, %rsi
callq 0x428ca
testq %rax, %rax
je 0x1e4ce
movq %rax, %rbp
movq 0x8(%r14), %rdi
movq %r13, %rsi
callq 0x3a6a0
testq %rax, %rax
je 0x1e4dd
movq %rax, %rbx
movq 0x8(%r14), %rdi
movq %r15, %rsi
callq 0x3a6a0
testq %rax, %rax
je 0x1e4ec
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 0x530f8
testq %rax, %rax
je 0x1e512
movq %rax, %rbx
cmpl $0x0, 0x14e945(%rip)    # 0x16cdbc
je 0x1e4b1
leaq 0x58(%rsp), %rdi
callq 0xc0d56
leaq 0xe9128(%rip), %rdi     # 0x1075b2
movb $0x1, %al
callq 0x15080
movl 0xc(%rbx), %esi
leaq 0xe91bc(%rip), %rdi     # 0x107657
xorl %eax, %eax
callq 0x15080
movq 0x14dab7(%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 0x1e500
leaq 0xe97ec(%rip), %rdi     # 0x107cc1
xorl %r12d, %r12d
movq %rbx, %rsi
jmp 0x1e4f9
leaq 0xe9612(%rip), %rdi     # 0x107af6
xorl %r12d, %r12d
movq %r13, %rsi
jmp 0x1e4f9
leaq 0xe9603(%rip), %rdi     # 0x107af6
xorl %r12d, %r12d
movq %r15, %rsi
xorl %eax, %eax
callq 0xc3e02
movl %r12d, %eax
addq $0x68, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
leaq 0xe97e8(%rip), %rdi     # 0x107d01
xorl %eax, %eax
callq 0xc3e02
jmp 0x1e500