// File: tomfunkhouser[P]gaps/apps/sflprocess/sflprocess.cpp
// Function: LoadSurfelsList(gaps::R3SurfelScene*, char const*, char const*, char const*)
static int
LoadSurfelsList(R3SurfelScene *scene, const char *list_filename, 
  const char *parent_object_name, const char *parent_node_name)
{
  // Start statistics
  RNTime start_time;
  start_time.Read();
  int saved_print_verbose = print_verbose;
  print_verbose = print_debug;

  // Open file
  FILE *fp = fopen(list_filename, "r");
  if (!fp) {
    RNFail("Unable to open %s\n", list_filename);
    return 0;
  }

  // Read objects/nodes from file with list
  int count = 0;
  char buffer[4096];
  char node_filename[512];
  while (fgets(buffer, 4096, fp)) {
    if (buffer[0] == '#') continue;
    if (sscanf(buffer, "%s", node_filename) == (unsigned int) 1) {
      char *start = strrchr(node_filename, '/');
      start = (start) ? start+1 : node_filename;
      char node_name[1024];
      strncpy(node_name, start, 1023);
      char *end = strrchr(node_name, '.');
      if (end) *end = '\0';
      if (!LoadSurfels(scene, node_filename, node_name, parent_object_name, node_name, parent_node_name)) return 0;
      count++;
    }
  }

  // Close file
  fclose(fp);

  // Print statistics
  print_verbose = saved_print_verbose;
  if (print_verbose) {
    printf("Loaded surfels from %s ...\n", list_filename);
    printf("  Time = %.2f seconds\n", start_time.Elapsed());
    printf("  # Files = %d\n", count);
    fflush(stdout);
  }

  // Return success
  return 1;
}

// Assembly:
subq $0x1678, %rsp           # imm = 0x1678
movq %rdi, 0x1668(%rsp)
movq %rsi, 0x1660(%rsp)
movq %rdx, 0x1658(%rsp)
movq %rcx, 0x1650(%rsp)
leaq 0x1640(%rsp), %rdi
callq 0x16dd30
leaq 0x1640(%rsp), %rdi
callq 0x263f0
movl 0x245999(%rip), %eax    # 0x2647c0
movl %eax, 0x163c(%rsp)
movl 0x245990(%rip), %eax    # 0x2647c4
movl %eax, 0x245986(%rip)    # 0x2647c0
movq 0x1660(%rsp), %rdi
leaq 0x1e338a(%rip), %rsi    # 0x2021d3
callq 0x168d0
movq %rax, 0x1630(%rsp)
cmpq $0x0, 0x1630(%rsp)
jne 0x1ee87
movq 0x1660(%rsp), %rsi
leaq 0x1d9a2b(%rip), %rdi    # 0x1f889b
movb $0x0, %al
callq 0x172cb0
movl $0x0, 0x1674(%rsp)
jmp 0x1f054
movl $0x0, 0x162c(%rsp)
leaq 0x620(%rsp), %rdi
movq 0x1630(%rsp), %rdx
movl $0x1000, %esi           # imm = 0x1000
callq 0x16b90
cmpq $0x0, %rax
je 0x1efd1
movsbl 0x620(%rsp), %eax
cmpl $0x23, %eax
jne 0x1eec5
jmp 0x1ee92
leaq 0x620(%rsp), %rdi
leaq 0x420(%rsp), %rdx
leaq 0x1ddfb7(%rip), %rsi    # 0x1fce93
movb $0x0, %al
callq 0x16710
cmpl $0x1, %eax
jne 0x1efcc
leaq 0x420(%rsp), %rdi
movl $0x2f, %esi
callq 0x16810
movq %rax, 0x418(%rsp)
cmpq $0x0, 0x418(%rsp)
je 0x1ef23
movq 0x418(%rsp), %rax
addq $0x1, %rax
movq %rax, (%rsp)
jmp 0x1ef2f
leaq 0x420(%rsp), %rax
movq %rax, (%rsp)
movq (%rsp), %rax
movq %rax, 0x418(%rsp)
leaq 0x10(%rsp), %rdi
movq 0x418(%rsp), %rsi
movl $0x3ff, %edx            # imm = 0x3FF
callq 0x16380
leaq 0x10(%rsp), %rdi
movl $0x2e, %esi
callq 0x16810
movq %rax, 0x8(%rsp)
cmpq $0x0, 0x8(%rsp)
je 0x1ef76
movq 0x8(%rsp), %rax
movb $0x0, (%rax)
movq 0x1668(%rsp), %rdi
leaq 0x420(%rsp), %rsi
leaq 0x10(%rsp), %rdx
movq 0x1658(%rsp), %rcx
leaq 0x10(%rsp), %r8
movq 0x1650(%rsp), %r9
callq 0x1e690
cmpq $0x0, %rax
jne 0x1efbb
movl $0x0, 0x1674(%rsp)
jmp 0x1f054
movl 0x162c(%rsp), %eax
addl $0x1, %eax
movl %eax, 0x162c(%rsp)
jmp 0x1ee92
movq 0x1630(%rsp), %rdi
callq 0x16730
movl 0x163c(%rsp), %eax
movl %eax, 0x2457d5(%rip)    # 0x2647c0
cmpl $0x0, 0x2457ce(%rip)    # 0x2647c0
je 0x1f049
movq 0x1660(%rsp), %rsi
leaq 0x1d986a(%rip), %rdi    # 0x1f886d
movb $0x0, %al
callq 0x16090
leaq 0x1640(%rsp), %rdi
callq 0x16ddf0
leaq 0x1d9561(%rip), %rdi    # 0x1f857f
movb $0x1, %al
callq 0x16090
movl 0x162c(%rsp), %esi
leaq 0x1d987b(%rip), %rdi    # 0x1f88ae
movb $0x0, %al
callq 0x16090
movq 0x23bf4f(%rip), %rax    # 0x25af90
movq (%rax), %rdi
callq 0x168c0
movl $0x1, 0x1674(%rsp)
movl 0x1674(%rsp), %eax
addq $0x1678, %rsp           # imm = 0x1678
retq
nopw %cs:(%rax,%rax)