// File: /workspace/github_cpp_makefile_star2_O3/tomfunkhouser[P]gaps/apps/sflprocess/sflprocess.cpp
// Function: CreateMultiresolutionBlocks(gaps::R3SurfelScene*, char const*, double, double)
static int
CreateMultiresolutionBlocks(R3SurfelScene *scene, const char *node_name,
  RNScalar multiresolution_factor, RNScalar max_node_complexity)
{
  // Start statistics
  RNTime start_time;
  start_time.Read();

  // Get surfel tree
  R3SurfelTree *tree = scene->Tree();
  if (!tree) {
    RNFail("Scene has no surfel tree\n");
    return 0;
  }    

  // Find node
  R3SurfelNode *node = NULL;
  if (strcmp(node_name, "All")) {
    node = tree->FindNodeByName(node_name);
    if (!node) {
      RNFail("Unable to find node with name %s\n", node_name);
      return 0;
    }
  }

  // Check node
  if (node) {
    // Create multiresolution starting at node
    tree->CreateMultiresolutionBlocks(node, multiresolution_factor, max_node_complexity);

    // Print statistics
    if (print_verbose) {
      printf("Created multiresolution blocks for nodes starting at %s ...\n", node_name);
      printf("  Time = %.2f seconds\n", start_time.Elapsed());
      printf("  # Nodes = %d\n", tree->NNodes());
      printf("  # Blocks = %d\n", tree->Database()->NBlocks());
      fflush(stdout);
    }
  }
  else {
    // Create multiresolution starting at all root nodes
    tree->CreateMultiresolutionBlocks(multiresolution_factor, max_node_complexity);

    // Print statistics
    if (print_verbose) {
      printf("Created multiresolution blocks for all nodes  ...\n");
      printf("  Time = %.2f seconds\n", start_time.Elapsed());
      printf("  # Nodes = %d\n", tree->NNodes());
      printf("  # Blocks = %d\n", tree->Database()->NBlocks());
      fflush(stdout);
    }
  }

  // Return success
  return 1;
}

// Assembly:
pushq %r15
pushq %r14
pushq %r12
pushq %rbx
subq $0x28, %rsp
movsd %xmm1, 0x10(%rsp)
movsd %xmm0, 0x8(%rsp)
movq %rsi, %r15
movq %rdi, %r14
leaq 0x18(%rsp), %r12
movq %r12, %rdi
callq 0xc0cf4
xorl %ebx, %ebx
movq %r12, %rdi
xorl %esi, %esi
callq 0x15a10
movq 0x8(%r14), %r14
testq %r14, %r14
je 0x1e769
leaq 0xe93e9(%rip), %rsi     # 0x107af2
movq %r15, %rdi
callq 0x158b0
testl %eax, %eax
je 0x1e77c
movq %r14, %rdi
movq %r15, %rsi
callq 0x3a6a0
testq %rax, %rax
je 0x1e7fb
movq (%r14), %rcx
xorps %xmm2, %xmm2
movq %r14, %rdi
movq %rax, %rsi
movsd 0x8(%rsp), %xmm0
movsd 0x10(%rsp), %xmm1
callq *0x60(%rcx)
movl $0x1, %ebx
cmpl $0x0, 0x14e66c(%rip)    # 0x16cdbc
je 0x1e80e
leaq 0xe95df(%rip), %rdi     # 0x107d3c
movq %r15, %rsi
xorl %eax, %eax
callq 0x15080
jmp 0x1e7ab
leaq 0xe934b(%rip), %rdi     # 0x107abb
xorl %eax, %eax
callq 0xc3e02
jmp 0x1e80e
movq (%r14), %rax
movq %r14, %rdi
movsd 0x8(%rsp), %xmm0
movsd 0x10(%rsp), %xmm1
callq *0x68(%rax)
movl $0x1, %ebx
cmpl $0x0, 0x14e61f(%rip)    # 0x16cdbc
je 0x1e80e
leaq 0xe9749(%rip), %rdi     # 0x107eef
callq 0x15970
leaq 0x18(%rsp), %rdi
callq 0xc0d56
leaq 0xe8df6(%rip), %rdi     # 0x1075b2
movb $0x1, %al
callq 0x15080
movl 0x24(%r14), %esi
leaq 0xe8ef6(%rip), %rdi     # 0x1076c4
xorl %eax, %eax
callq 0x15080
movq 0x10(%r14), %rax
movl 0x4c(%rax), %esi
leaq 0xe8ef1(%rip), %rdi     # 0x1076d4
xorl %eax, %eax
callq 0x15080
movq 0x14d76f(%rip), %rax    # 0x16bf60
movq (%rax), %rdi
callq 0x15750
jmp 0x1e80e
leaq 0xe92f4(%rip), %rdi     # 0x107af6
xorl %ebx, %ebx
movq %r15, %rsi
xorl %eax, %eax
callq 0xc3e02
movl %ebx, %eax
addq $0x28, %rsp
popq %rbx
popq %r12
popq %r14
popq %r15
retq