LLM4Binary/decompile-bench-makefile huggingface dataset:
// File: /workspace/github_cpp_makefile_star2_O2/tomfunkhouser[P]gaps/pkgs/R3Surfels/R3SurfelScene.cpp
// Function: gaps::R3SurfelScene::OpenFile(char const*, char const*, char const*, char const*)
int R3SurfelScene::
OpenFile(const char *scene_filename, 
  const char *database_filename, 
  const char *scene_rwaccess,
  const char *database_rwaccess)
{
  // Remember scene file name
  if (this->filename) free(this->filename);
  this->filename = RNStrdup(scene_filename);

  // Remember scene file access mode
  if (this->rwaccess) free(this->rwaccess);
  if (!scene_rwaccess) this->rwaccess = RNStrdup("r");
  else if (!strcmp(scene_rwaccess, "w")) this->rwaccess = RNStrdup("w");
  else if (strstr(scene_rwaccess, "+")) this->rwaccess = RNStrdup("r+");
  else this->rwaccess = RNStrdup("r"); 

  // Open database file
  if (database_filename) {
    if (tree) {
      R3SurfelDatabase *database = tree->Database();
      if (!database->OpenFile(database_filename, database_rwaccess)) {
        return 0;
      }
    }
  }

  // Read scene file
  if (strcmp(this->rwaccess, "w")) {
    if (!ReadFile(scene_filename)) {
      return 0;
    }
  }

  // Return success
  return 1;
}

// Assembly:
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
movq %r8, %r15
movq %rcx, %r13
movq %rdx, %r12
movq %rsi, %rbx
movq %rdi, %r14
movq 0x1c0(%rdi), %rdi
callq 0x13600
movq %rbx, %rdi
callq 0x9cc91
movq %rax, 0x1c0(%r14)
movq 0x1c8(%r14), %rdi
callq 0x13600
testq %r13, %r13
je 0x1a0c4
cmpb $0x77, (%r13)
jne 0x1a0a2
cmpb $0x0, 0x1(%r13)
je 0x1a0cd
pushq $0x2b
popq %rsi
movq %r13, %rdi
callq 0x131d0
testq %rax, %rax
leaq 0xb94fc(%rip), %rax     # 0xd35b3
leaq 0xae366(%rip), %rdi     # 0xc8424
cmoveq %rax, %rdi
jmp 0x1a0d4
leaq 0xb94e8(%rip), %rdi     # 0xd35b3
jmp 0x1a0d4
leaq 0xb51b0(%rip), %rdi     # 0xcf284
callq 0x9cc91
movq %rax, 0x1c8(%r14)
testq %r12, %r12
je 0x1a109
movq 0x8(%r14), %rcx
testq %rcx, %rcx
je 0x1a109
movq 0x10(%rcx), %rdi
movq (%rdi), %rax
movq %r12, %rsi
movq %r15, %rdx
callq *0x30(%rax)
testl %eax, %eax
je 0x1a12c
movq 0x1c8(%r14), %rax
cmpb $0x77, (%rax)
jne 0x1a114
cmpb $0x0, 0x1(%rax)
je 0x1a127
movq (%r14), %rax
movq %r14, %rdi
movq %rbx, %rsi
callq *0x100(%rax)
testl %eax, %eax
je 0x1a12c
pushq $0x1
popq %rax
jmp 0x1a12e
xorl %eax, %eax
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
retq
// File: /workspace/github_cpp_makefile_star2_O2/tomfunkhouser[P]gaps/pkgs/R3Surfels/R3SurfelScene.cpp
// Function: gaps::R3SurfelScene::SyncFile(char const*)
int R3SurfelScene::
SyncFile(const char *output_scene_filename)
{
  // Check if nothing changed
  if (!flags[R3_SURFEL_SCENE_DIRTY_FLAG]) return 1;

  // Sync surfels
  if (tree) {
    R3SurfelDatabase *database = tree->Database();
    if (database) {
      if (!database->SyncFile()) return 0;
    }
  }

  // Write scene file
  if (output_scene_filename) {
    // Write scene to new file
    if (!WriteFile(output_scene_filename)) {
      return 0;
    }
  }
  else if (this->filename && (strcmp(this->rwaccess, "r"))) {
    // Write scene over original file
    if (!WriteFile(filename)) {
      return 0;
    }
  }

  // Return success
  return 1;
}

// Assembly:
pushq %r15
pushq %r14
pushq %rbx
pushq $0x1
popq %rbx
testb $0x1, 0x1e8(%rdi)
je 0x1a1ab
movq %rsi, %r15
movq %rdi, %r14
movq 0x8(%rdi), %rax
testq %rax, %rax
je 0x1a16b
movq 0x10(%rax), %rdi
testq %rdi, %rdi
je 0x1a16b
movq (%rdi), %rax
callq *0x38(%rax)
testl %eax, %eax
je 0x1a1a9
testq %r15, %r15
je 0x1a17b
movq (%r14), %rax
movq %r14, %rdi
movq %r15, %rsi
jmp 0x1a19f
movq 0x1c0(%r14), %rsi
testq %rsi, %rsi
je 0x1a1ab
movq 0x1c8(%r14), %rax
cmpb $0x72, (%rax)
jne 0x1a199
cmpb $0x0, 0x1(%rax)
je 0x1a1ab
movq (%r14), %rax
movq %r14, %rdi
callq *0x128(%rax)
testl %eax, %eax
jne 0x1a1ab
xorl %ebx, %ebx
movl %ebx, %eax
popq %rbx
popq %r14
popq %r15
retq
nop
// File: /workspace/github_cpp_makefile_star2_O2/tomfunkhouser[P]gaps/pkgs/R3Surfels/R3SurfelScene.cpp
// Function: gaps::R3SurfelScene::CloseFile(char const*)
int R3SurfelScene::
CloseFile(const char *output_scene_filename)
{
#if 1
  // Clean up
  if (tree) {
    R3SurfelDatabase *database = tree->Database();
    if (database) {
      if (database->PurgeDeletedBlocks()) {
        flags.Add(R3_SURFEL_SCENE_DIRTY_FLAG);
      }
    }
  }
#endif
  
  // Sync file
  if (!SyncFile(output_scene_filename)) return 0;

  // Close surfel database file
  if (tree) {
    R3SurfelDatabase *database = tree->Database();
    if (database) {
      if (!database->CloseFile()) return 0;
    }
  }

  // Return success
  return 1;
}

// Assembly:
pushq %rbp
pushq %r14
pushq %rbx
movq %rsi, %r14
movq %rdi, %rbx
movq 0x8(%rdi), %rax
testq %rax, %rax
je 0x1a1e4
movq 0x10(%rax), %rdi
testq %rdi, %rdi
je 0x1a1e4
movq (%rdi), %rax
callq *0x80(%rax)
testl %eax, %eax
je 0x1a1e4
orb $0x1, 0x1e8(%rbx)
movq (%rbx), %rax
movq %rbx, %rdi
movq %r14, %rsi
callq *0xf0(%rax)
xorl %ebp, %ebp
testl %eax, %eax
je 0x1a21a
movq 0x8(%rbx), %rax
pushq $0x1
popq %rbx
testq %rax, %rax
je 0x1a218
movq 0x10(%rax), %rdi
testq %rdi, %rdi
je 0x1a218
movq (%rdi), %rax
callq *0x40(%rax)
testl %eax, %eax
je 0x1a21a
movl %ebx, %ebp
movl %ebp, %eax
popq %rbx
popq %r14
popq %rbp
retq
nop
// File: /workspace/github_cpp_makefile_star2_O2/tomfunkhouser[P]gaps/pkgs/R3Surfels/R3SurfelScene.cpp
// Function: gaps::R3SurfelScene::ReadFile(char const*)
int R3SurfelScene::
ReadFile(const char *filename)
{
  // Parse input filename extension
  const char *extension;
  if (!(extension = strrchr(filename, '.'))) {
    printf("Filename %s has no extension (e.g., .ssa)\n", filename);
    return 0;
  }

  // Read file of appropriate type
  if (!strncmp(extension, ".ssa", 4)) {
    return ReadAsciiFile(filename);
  }
  else if (!strncmp(extension, ".ssx", 4)) {
    return ReadBinaryFile(filename);
  }
  else { 
    RNFail("Unable to read file %s (unrecognized extension: %s)\n", filename, extension); 
    return 0; 
  }

  // Should never get here
  return 0;
}

// Assembly:
pushq %r15
pushq %r14
pushq %rbx
movq %rsi, %rbx
movq %rdi, %r14
pushq $0x2e
popq %rsi
movq %rbx, %rdi
callq 0x13580
testq %rax, %rax
je 0x1a282
movq %rax, %r15
leaq 0xae20b(%rip), %rsi     # 0xc8452
pushq $0x4
popq %rdx
movq %rax, %rdi
callq 0x13250
testl %eax, %eax
je 0x1a29b
leaq 0xae1fa(%rip), %rsi     # 0xc8457
pushq $0x4
popq %rdx
movq %r15, %rdi
callq 0x13250
testl %eax, %eax
je 0x1a2a7
leaq 0xae1e9(%rip), %rdi     # 0xc845c
movq %rbx, %rsi
movq %r15, %rdx
xorl %eax, %eax
callq 0x9ce26
jmp 0x1a293
leaq 0xae19e(%rip), %rdi     # 0xc8427
movq %rbx, %rsi
xorl %eax, %eax
callq 0x13070
xorl %eax, %eax
popq %rbx
popq %r14
popq %r15
retq
movq (%r14), %rax
movq 0x108(%rax), %rax
jmp 0x1a2b1
movq (%r14), %rax
movq 0x110(%rax), %rax
movq %r14, %rdi
movq %rbx, %rsi
popq %rbx
popq %r14
popq %r15
jmpq *%rax
// File: /workspace/github_cpp_makefile_star2_O2/tomfunkhouser[P]gaps/pkgs/R3Surfels/R3SurfelScene.cpp
// Function: gaps::R3SurfelScene::WriteFile(char const*)
int R3SurfelScene::
WriteFile(const char *filename) 
{
  // Parse input filename extension
  const char *extension;
  if (!(extension = strrchr(filename, '.'))) {
    printf("Filename %s has no extension (e.g., .ssa)\n", filename);
    return 0;
  }

  // Write file of appropriate type
  if (!strncmp(extension, ".ssa", 4)) {
    return WriteAsciiFile(filename);
  }
  else if (!strncmp(extension, ".ssx", 4)) {
    return WriteBinaryFile(filename);
  }
  else if (!strncmp(extension, ".arff", 5)) {
    return WriteARFFFile(filename);
  }
  else if (!strncmp(extension, ".tqn", 4)) {
    return WriteTianqiangFile(filename);
  }
  else { 
    RNFail("Unable to write file %s (unrecognized extension: %s)\n", filename, extension); 
    return 0; 
  }

  // Should never get here
  return 0;
}

// Assembly:
pushq %r15
pushq %r14
pushq %rbx
movq %rsi, %rbx
movq %rdi, %r14
pushq $0x2e
popq %rsi
movq %rbx, %rdi
callq 0x13580
testq %rax, %rax
je 0x1a34a
movq %rax, %r15
leaq 0xae16f(%rip), %rsi     # 0xc8452
pushq $0x4
popq %rdx
movq %rax, %rdi
callq 0x13250
testl %eax, %eax
je 0x1a363
leaq 0xae15e(%rip), %rsi     # 0xc8457
pushq $0x4
popq %rdx
movq %r15, %rdi
callq 0x13250
testl %eax, %eax
je 0x1a36f
leaq 0xae182(%rip), %rsi     # 0xc8491
pushq $0x5
popq %rdx
movq %r15, %rdi
callq 0x13250
testl %eax, %eax
je 0x1a37b
leaq 0xae172(%rip), %rsi     # 0xc8497
pushq $0x4
popq %rdx
movq %r15, %rdi
callq 0x13250
testl %eax, %eax
je 0x1a387
leaq 0xae161(%rip), %rdi     # 0xc849c
movq %rbx, %rsi
movq %r15, %rdx
xorl %eax, %eax
callq 0x9ce26
jmp 0x1a35b
leaq 0xae0d6(%rip), %rdi     # 0xc8427
movq %rbx, %rsi
xorl %eax, %eax
callq 0x13070
xorl %eax, %eax
popq %rbx
popq %r14
popq %r15
retq
movq (%r14), %rax
movq 0x130(%rax), %rax
jmp 0x1a391
movq (%r14), %rax
movq 0x138(%rax), %rax
jmp 0x1a391
movq (%r14), %rax
movq 0x140(%rax), %rax
jmp 0x1a391
movq (%r14), %rax
movq 0x148(%rax), %rax
movq %r14, %rdi
movq %rbx, %rsi
popq %rbx
popq %r14
popq %r15
jmpq *%rax
// File: /workspace/github_cpp_makefile_star2_O2/tomfunkhouser[P]gaps/pkgs/R3Surfels/R3SurfelScene.cpp
// Function: gaps::R3SurfelScene::ReadAsciiFile(char const*)
int R3SurfelScene::
ReadAsciiFile(const char *filename)
{
  // Open file
  FILE *fp;
  if (!(fp = fopen(filename, "r"))) {
    RNFail("Unable to open file %s\n", filename);
    return 0;
  }

  // Read ascii stream
  int status = ReadAsciiStream(fp);

  // Close file
  fclose(fp);

  // Return status
  return status;
}

// Assembly:
pushq %r15
pushq %r14
pushq %rbx
movq %rsi, %rbx
movq %rdi, %r14
leaq 0xb9203(%rip), %rsi     # 0xd35b3
movq %rbx, %rdi
callq 0x135f0
testq %rax, %rax
je 0x1a3dd
movq %rax, %r15
movq (%r14), %rax
movq %r14, %rdi
movq %r15, %rsi
callq *0x118(%rax)
movl %eax, %ebx
movq %r15, %rdi
callq 0x134e0
movl %ebx, %eax
jmp 0x1a3f0
leaq 0xae0ee(%rip), %rdi     # 0xc84d2
movq %rbx, %rsi
xorl %eax, %eax
callq 0x9ce26
xorl %eax, %eax
popq %rbx
popq %r14
popq %r15
retq
// File: /workspace/github_cpp_makefile_star2_O2/tomfunkhouser[P]gaps/pkgs/R3Surfels/R3SurfelScene.cpp
// Function: gaps::R3SurfelScene::WriteAsciiFile(char const*)
int R3SurfelScene::
WriteAsciiFile(const char *filename)
{
  // Open file
  FILE *fp;
  if (!(fp = fopen(filename, "w"))) {
    RNFail("Unable to open file %s\n", filename);
    return 0;
  }

  // Write ascii stream
  int status = WriteAsciiStream(fp);

  // Close file
  fclose(fp);

  // Return status
  return status;
}

// Assembly:
pushq %r15
pushq %r14
pushq %rbx
movq %rsi, %rbx
movq %rdi, %r14
leaq 0xb4e7c(%rip), %rsi     # 0xcf284
movq %rbx, %rdi
callq 0x135f0
testq %rax, %rax
je 0x1a435
movq %rax, %r15
movq (%r14), %rax
movq %r14, %rdi
movq %r15, %rsi
callq *0x150(%rax)
movl %eax, %ebx
movq %r15, %rdi
callq 0x134e0
movl %ebx, %eax
jmp 0x1a448
leaq 0xae096(%rip), %rdi     # 0xc84d2
movq %rbx, %rsi
xorl %eax, %eax
callq 0x9ce26
xorl %eax, %eax
popq %rbx
popq %r14
popq %r15
retq
// File: /workspace/github_cpp_makefile_star2_O2/tomfunkhouser[P]gaps/pkgs/R3Surfels/R3SurfelScene.cpp
// Function: gaps::ReadAsciiString(_IO_FILE*, char*)
static int 
ReadAsciiString(FILE *fp, char *buffer)
{
  // Read string
  if (fscanf(fp, "%s", buffer) != (unsigned int) 1) {
    RNFail("Unable to read name\n");
    return 0;
  }

  // Restore space characters
  char *bufferp = buffer;
  while (*bufferp) {
    if (*bufferp == '^') *bufferp = '\t';
    if (*bufferp == '&') *bufferp = '\n';
    if (*bufferp == '+') *bufferp = ' ';
    bufferp++;
  }

  // Return success
  return 1;
}

// Assembly:
pushq %rbx
movq %rsi, %rbx
leaq 0xb34c6(%rip), %rsi     # 0xcf945
movq %rbx, %rdx
xorl %eax, %eax
callq 0x13970
cmpl $0x1, %eax
jne 0x1c4b5
movzbl (%rbx), %eax
cmpl $0x26, %eax
je 0x1c4ac
cmpl $0x2b, %eax
je 0x1c4a8
movb $0x9, %cl
cmpl $0x5e, %eax
je 0x1c4ae
testl %eax, %eax
jne 0x1c4b0
jmp 0x1c4c4
movb $0x20, %cl
jmp 0x1c4ae
movb $0xa, %cl
movb %cl, (%rbx)
incq %rbx
jmp 0x1c48e
leaq 0xac559(%rip), %rdi     # 0xc8a15
xorl %eax, %eax
popq %rbx
jmp 0x9ce26
popq %rbx
retq
// File: /workspace/github_cpp_makefile_star2_O2/tomfunkhouser[P]gaps/pkgs/R3Surfels/R3SurfelScene.cpp
// Function: gaps::WriteAsciiString(_IO_FILE*, char const*)
static int 
WriteAsciiString(FILE *fp, const char *name)
{
  // Copy name
  char buffer[1024];
  if (name) strncpy(buffer, name, 1023);
  else strncpy(buffer, "None", 1023);

  // Replace space characters
  char *bufferp = buffer;
  while (*bufferp) {
    if (*bufferp == '\t') *bufferp = '^';
    if (*bufferp == '\n') *bufferp = '&';
    if (*bufferp == ' ') *bufferp = '+';
    bufferp++;
  }

  // Write string
  fprintf(fp, "%s", buffer);

  // Restore space characters
  bufferp = buffer;
  while (*bufferp) {
    if (*bufferp == '^') *bufferp = '\t';
    if (*bufferp == '&') *bufferp = '\n';
    if (*bufferp == '+') *bufferp = ' ';
    bufferp++;
  }

  // Return success
  return 1;
}

// Assembly:
pushq %r14
pushq %rbx
subq $0x408, %rsp            # imm = 0x408
movq %rdi, %rbx
testq %rsi, %rsi
jne 0x1d4d8
leaq 0xab054(%rip), %rsi     # 0xc852c
movq %rsp, %rdi
movl $0x3ff, %edx            # imm = 0x3FF
callq 0x13290
movq %rsp, %rax
movzbl (%rax), %ecx
cmpl $0x9, %ecx
je 0x1d504
cmpl $0xa, %ecx
je 0x1d500
cmpl $0x20, %ecx
je 0x1d508
testl %ecx, %ecx
jne 0x1d50c
jmp 0x1d511
movb $0x26, %cl
jmp 0x1d50a
movb $0x5e, %cl
jmp 0x1d50a
movb $0x2b, %cl
movb %cl, (%rax)
incq %rax
jmp 0x1d4e8
movq %rsp, %r14
movq %r14, %rdi
movq %rbx, %rsi
callq 0x135d0
movzbl (%r14), %eax
cmpl $0x26, %eax
je 0x1d53e
cmpl $0x2b, %eax
je 0x1d53a
movb $0x9, %cl
cmpl $0x5e, %eax
je 0x1d540
testl %eax, %eax
jne 0x1d543
jmp 0x1d548
movb $0x20, %cl
jmp 0x1d540
movb $0xa, %cl
movb %cl, (%r14)
incq %r14
jmp 0x1d51f
addq $0x408, %rsp            # imm = 0x408
popq %rbx
popq %r14
retq
nop
// File: /workspace/github_cpp_makefile_star2_O2/tomfunkhouser[P]gaps/pkgs/R3Surfels/R3SurfelScene.cpp
// Function: gaps::R3SurfelScene::ReadBinaryFile(char const*)
int R3SurfelScene::
ReadBinaryFile(const char *filename)
{
  // Open file
  FILE *fp;
  if (!(fp = fopen(filename, "r"))) {
    RNFail("Unable to open file %s\n", filename);
    return 0;
  }

  // Read binary stream
  int status = ReadBinaryStream(fp);

  // Close file
  fclose(fp);

  // Return status
  return status;
}

// Assembly:
pushq %r15
pushq %r14
pushq %rbx
movq %rsi, %rbx
movq %rdi, %r14
leaq 0xb604d(%rip), %rsi     # 0xd35b3
movq %rbx, %rdi
callq 0x135f0
testq %rax, %rax
je 0x1d593
movq %rax, %r15
movq (%r14), %rax
movq %r14, %rdi
movq %r15, %rsi
callq *0x120(%rax)
movl %eax, %ebx
movq %r15, %rdi
callq 0x134e0
movl %ebx, %eax
jmp 0x1d5a6
leaq 0xaaf38(%rip), %rdi     # 0xc84d2
movq %rbx, %rsi
xorl %eax, %eax
callq 0x9ce26
xorl %eax, %eax
popq %rbx
popq %r14
popq %r15
retq
// File: /workspace/github_cpp_makefile_star2_O2/tomfunkhouser[P]gaps/pkgs/R3Surfels/R3SurfelScene.cpp
// Function: gaps::R3SurfelScene::WriteBinaryFile(char const*)
int R3SurfelScene::
WriteBinaryFile(const char *filename)
{
  // Open file
  FILE *fp;
  if (!(fp = fopen(filename, "w"))) {
    RNFail("Unable to open file %s\n", filename);
    return 0;
  }

  // Write binary stream
  int status = WriteBinaryStream(fp);

  // Close file
  fclose(fp);

  // Return status
  return status;
}

// Assembly:
pushq %r15
pushq %r14
pushq %rbx
movq %rsi, %rbx
movq %rdi, %r14
leaq 0xb1cc6(%rip), %rsi     # 0xcf284
movq %rbx, %rdi
callq 0x135f0
testq %rax, %rax
je 0x1d5eb
movq %rax, %r15
movq (%r14), %rax
movq %r14, %rdi
movq %r15, %rsi
callq *0x158(%rax)
movl %eax, %ebx
movq %r15, %rdi
callq 0x134e0
movl %ebx, %eax
jmp 0x1d5fe
leaq 0xaaee0(%rip), %rdi     # 0xc84d2
movq %rbx, %rsi
xorl %eax, %eax
callq 0x9ce26
xorl %eax, %eax
popq %rbx
popq %r14
popq %r15
retq
// File: /workspace/github_cpp_makefile_star2_O2/tomfunkhouser[P]gaps/pkgs/R3Surfels/R3SurfelScene.cpp
// Function: gaps::ReadBinaryString(_IO_FILE*, char*, int)
static int 
ReadBinaryString(FILE *fp, char *name, int size = 256)
{
  // Copy name
  if (fread(name, sizeof(char), size, fp) != (unsigned int) size) {
    RNFail("Unable to read name from binary file\n");
    return 0;
  }

  // Return success
  return 1;
}

// Assembly:
pushq %rbx
movq %rsi, %rax
movq %rdi, %rcx
movl %edx, %ebx
pushq $0x1
popq %rsi
movq %rax, %rdi
movq %rbx, %rdx
callq 0x137d0
cmpq %rbx, %rax
jne 0x1f26a
pushq $0x1
popq %rbx
jmp 0x1f27a
leaq 0xa97b9(%rip), %rdi     # 0xc8a2a
xorl %ebx, %ebx
xorl %eax, %eax
callq 0x9ce26
movl %ebx, %eax
popq %rbx
retq
// File: /workspace/github_cpp_makefile_star2_O2/tomfunkhouser[P]gaps/pkgs/R3Surfels/R3SurfelScene.cpp
// Function: gaps::WriteBinaryString(_IO_FILE*, char const*, int)
static int 
WriteBinaryString(FILE *fp, const char *name, int size = 256)
{
  // Copy name
  char buffer[1024] = { '\0' };
  if (size > 1024) size = 1024;
  if (name) strncpy(buffer, name, size-1);
  else strncpy(buffer, "None", size-1);
  if (fwrite(buffer, sizeof(char), size, fp) != (unsigned int) size) {
    RNFail("Unable to write name to binary file\n");
    return 0;
  }

  // Return success
  return 1;
}

// Assembly:
pushq %r15
pushq %r14
pushq %rbx
subq $0x400, %rsp            # imm = 0x400
movl %edx, %r14d
movq %rsi, %r15
movq %rdi, %rbx
movq %rsp, %rdi
movl $0x400, %edx            # imm = 0x400
xorl %esi, %esi
callq 0x132b0
leal -0x1(%r14), %edx
testq %r15, %r15
je 0x20045
movq %rsp, %rdi
movq %r15, %rsi
jmp 0x2004f
leaq 0xa84e0(%rip), %rsi     # 0xc852c
movq %rsp, %rdi
callq 0x13290
movl %r14d, %r14d
movq %rsp, %rdi
pushq $0x1
popq %rsi
movq %r14, %rdx
movq %rbx, %rcx
callq 0x139e0
cmpq %r14, %rax
jne 0x20072
pushq $0x1
popq %rbx
jmp 0x20082
leaq 0xa8a00(%rip), %rdi     # 0xc8a79
xorl %ebx, %ebx
xorl %eax, %eax
callq 0x9ce26
movl %ebx, %eax
addq $0x400, %rsp            # imm = 0x400
popq %rbx
popq %r14
popq %r15
retq
// File: /workspace/github_cpp_makefile_star2_O2/tomfunkhouser[P]gaps/pkgs/R3Surfels/./R3SurfelDatabase.h
// Function: gaps::R3SurfelDatabase::ReadBlock(gaps::R3SurfelBlock*)
inline int R3SurfelDatabase::
ReadBlock(R3SurfelBlock *block)
{
  // Check whether block needs to be read
  if (block->file_read_count == 0) {
    if (!InternalReadBlock(block, fp, swap_endian)) return 0;
  }

  // Increment reference count
  block->file_read_count++;

  // Return success
  return 1;
}

// Assembly:
pushq %rbx
movq %rsi, %rbx
movl 0xb4(%rsi), %eax
testl %eax, %eax
jne 0x20a8f
movq (%rdi), %rax
movq 0x8(%rdi), %rdx
movl 0x28(%rdi), %ecx
movq %rbx, %rsi
callq *0x88(%rax)
testl %eax, %eax
je 0x20a9c
movl 0xb4(%rbx), %eax
incl %eax
movl %eax, 0xb4(%rbx)
pushq $0x1
popq %rax
popq %rbx
retq
xorl %eax, %eax
jmp 0x20a9a
// File: /workspace/github_cpp_makefile_star2_O2/tomfunkhouser[P]gaps/pkgs/R3Surfels/./R3SurfelDatabase.h
// Function: gaps::R3SurfelDatabase::ReleaseBlock(gaps::R3SurfelBlock*)
inline int R3SurfelDatabase::
ReleaseBlock(R3SurfelBlock *block)
{
  // Check whether block needs to be written
  if (block->file_read_count == 1) {
    if (!InternalReleaseBlock(block, fp, swap_endian)) return 0;
  }

  // Decrement reference count
  block->file_read_count--;

  // Check if delete pending
  if (block->file_read_count == 0) {
    if (block->flags[R3_SURFEL_BLOCK_DELETE_PENDING_FLAG]) {
      RemoveBlock(block);
      delete block;
    }
  }

  // Return success
  return 1;
}

// Assembly:
pushq %rbp
pushq %r14
pushq %rbx
movq %rsi, %rbx
movq %rdi, %r14
movl 0xb4(%rsi), %eax
cmpl $0x1, %eax
jne 0x20ad6
movq (%r14), %rax
movq 0x8(%r14), %rdx
movl 0x28(%r14), %ecx
movq %r14, %rdi
movq %rbx, %rsi
callq *0x90(%rax)
testl %eax, %eax
je 0x20b0f
movl 0xb4(%rbx), %eax
pushq $0x1
popq %rbp
decl %eax
movl %eax, 0xb4(%rbx)
jne 0x20b11
testb $0x2, 0x89(%rbx)
je 0x20b11
movq (%r14), %rax
movq %r14, %rdi
movq %rbx, %rsi
callq *0x18(%rax)
movq %rbx, %rdi
callq 0x2a5a6
movl $0xc8, %esi
movq %rbx, %rdi
callq 0x13500
jmp 0x20b11
xorl %ebp, %ebp
movl %ebp, %eax
popq %rbx
popq %r14
popq %rbp
retq
// File: /workspace/github_cpp_makefile_star2_O2/tomfunkhouser[P]gaps/pkgs/R3Surfels/./R3SurfelBlock.h
// Function: gaps::R3SurfelBlock::SurfelPosition(int) const
inline R3Point R3SurfelBlock::
SurfelPosition(int surfel_index) const
{
  // Return position of kth surfel
  R3Surfel& surfel = surfels[surfel_index];
  return R3Point(position_origin.X() + surfel.PX(),
                 position_origin.Y() + surfel.PY(),
                 position_origin.Z() + surfel.PZ());
}

// Assembly:
pushq %rbx
movq %rdi, %rbx
movq (%rsi), %rax
movslq %edx, %rcx
imulq $0x30, %rcx, %rcx
cvtss2sd (%rax,%rcx), %xmm0
addsd 0x10(%rsi), %xmm0
cvtss2sd 0x4(%rax,%rcx), %xmm1
addsd 0x18(%rsi), %xmm1
cvtss2sd 0x8(%rax,%rcx), %xmm2
addsd 0x20(%rsi), %xmm2
callq 0x781bc
movq %rbx, %rax
popq %rbx
retq
// File: /workspace/github_cpp_makefile_star2_O2/tomfunkhouser[P]gaps/pkgs/R3Surfels/R3SurfelUtils.cpp
// Function: gaps::CreatePointSet(gaps::R3SurfelPointSet*, gaps::R3SurfelConstraint const*)
R3SurfelPointSet *
CreatePointSet(R3SurfelPointSet *pointset, 
  const R3SurfelConstraint *constraint)
{
  // Create point set
  R3SurfelPointSet *result = new R3SurfelPointSet();
  if (constraint) result->InsertPoints(pointset, *constraint);
  else result->InsertPoints(pointset);
  if (result->NPoints() == 0) { delete result; return NULL; }
  return result;
}

// Assembly:
pushq %r15
pushq %r14
pushq %rbx
movq %rsi, %r15
movq %rdi, %r14
pushq $0x60
popq %rdi
callq 0x134f0
movq %rax, %rbx
movq %rax, %rdi
callq 0x2f52c
movq (%rbx), %rax
movq %rbx, %rdi
movq %r14, %rsi
testq %r15, %r15
je 0x20c84
movq %r15, %rdx
callq *0x60(%rax)
jmp 0x20c87
callq *0x40(%rax)
cmpl $0x0, 0x10(%rbx)
jne 0x20c98
movq (%rbx), %rax
movq %rbx, %rdi
callq *0x8(%rax)
xorl %ebx, %ebx
movq %rbx, %rax
popq %rbx
popq %r14
popq %r15
retq
movq %rax, %r14
pushq $0x60
popq %rsi
movq %rbx, %rdi
callq 0x13500
movq %r14, %rdi
callq 0x138f0
// File: /workspace/github_cpp_makefile_star2_O2/tomfunkhouser[P]gaps/pkgs/R3Surfels/R3SurfelUtils.cpp
// Function: gaps::InsertPoints(gaps::R3SurfelPointSet*, gaps::R3SurfelTree*, gaps::R3SurfelNode*, gaps::R3SurfelConstraint const*)
static int
InsertPoints(R3SurfelPointSet *pointset, 
  R3SurfelTree *tree, R3SurfelNode *node,
  const R3SurfelConstraint *constraint)
{
  // Check node
  if (constraint && !constraint->Check(node)) return 0;

  // Check if leaf node
  if (node->NParts() == 0) {
    // Insert blocks
    for (int i = 0; i < node->NBlocks(); i++) {
      R3SurfelBlock *block = node->Block(i);
      if (constraint) pointset->InsertPoints(block, *constraint);
      else pointset->InsertPoints(block);
    }
  }
  else {
    // Consider parts
    for (int i = 0; i < node->NParts(); i++) {
      R3SurfelNode *part = node->Part(i);
      InsertPoints(pointset, tree, part, constraint);
    }
  }

  // Return success
  return 1;
}

// Assembly:
pushq %r15
pushq %r14
pushq %r12
pushq %rbx
pushq %rax
movq %rdx, %rbx
movq %rsi, %r14
movq %rdi, %r15
testq %rdx, %rdx
je 0x20d4e
movq (%rbx), %rax
movq %rbx, %rdi
movq %r14, %rsi
callq *0x18(%rax)
testl %eax, %eax
je 0x20da8
movl 0x3c(%r14), %eax
xorl %r12d, %r12d
testl %eax, %eax
jne 0x20d75
jmp 0x20d9f
movq 0x30(%r14), %rax
movq (%rax,%r12,8), %rsi
movq %r15, %rdi
movq %rbx, %rdx
callq 0x20d28
incq %r12
movl 0x3c(%r14), %eax
cltq
cmpq %rax, %r12
jl 0x20d5b
jmp 0x20da8
movq 0x40(%r14), %rax
movq (%rax,%r12,8), %rsi
movq (%r15), %rax
movq %r15, %rdi
testq %rbx, %rbx
je 0x20d99
movq %rbx, %rdx
callq *0x30(%rax)
jmp 0x20d9c
callq *0x10(%rax)
incq %r12
movslq 0x4c(%r14), %rax
cmpq %rax, %r12
jl 0x20d7e
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r14
popq %r15
retq
// File: /workspace/github_cpp_makefile_star2_O2/tomfunkhouser[P]gaps/pkgs/R3Surfels/R3SurfelUtils.cpp
// Function: gaps::CreatePointGraph(gaps::R3SurfelScene*, gaps::R3SurfelNode*, gaps::R3SurfelConstraint const*, int, double)
R3SurfelPointGraph *
CreatePointGraph(R3SurfelScene *scene, 
  R3SurfelNode *source_node, const R3SurfelConstraint *constraint, 
  int max_neighbors, RNLength max_neighbor_distance)
{
  // Create point graph with all surfels satisfying constraint
  R3SurfelPointSet *pointset = CreatePointSet(scene, source_node, constraint);
  if (!pointset) return NULL;
  R3SurfelPointGraph *graph = new R3SurfelPointGraph(*pointset, max_neighbors, max_neighbor_distance);
  delete pointset;
  return graph;
}

// Assembly:
pushq %rbp
pushq %r14
pushq %rbx
subq $0x10, %rsp
movsd %xmm0, 0x8(%rsp)
movl %ecx, %ebp
callq 0x20cb7
testq %rax, %rax
je 0x2167c
movq %rax, %r14
movl $0x80, %edi
callq 0x134f0
movq %rax, %rbx
movq %rax, %rdi
movq %r14, %rsi
movl %ebp, %edx
movsd 0x8(%rsp), %xmm0
callq 0x32a08
movq (%r14), %rax
movq %r14, %rdi
callq *0x8(%rax)
jmp 0x2167e
xorl %ebx, %ebx
movq %rbx, %rax
addq $0x10, %rsp
popq %rbx
popq %r14
popq %rbp
retq
movq %rax, %r14
movl $0x80, %esi
movq %rbx, %rdi
callq 0x13500
movq %r14, %rdi
callq 0x138f0
// File: /workspace/github_cpp_makefile_star2_O2/tomfunkhouser[P]gaps/pkgs/R3Surfels/R3SurfelUtils.cpp
// Function: gaps::VisitResidentSurfels(gaps::R3SurfelScene*, void (*)(gaps::R3SurfelBlock const*, gaps::R3Surfel const*, void*), gaps::R3SurfelNode*, gaps::R3SurfelConstraint const*, void*)
void
VisitResidentSurfels(R3SurfelScene *scene,
  void (*callback_function)(const R3SurfelBlock *block, const R3Surfel *surfel, void *callback_data),
  R3SurfelNode *source_node,
  const R3SurfelConstraint *constraint,
  void *callback_data)
{
  // Check node
  if (constraint && !constraint->Check(source_node)) return;

  // Check if leaf node
  if (source_node->NParts() == 0) {
    // Visit blocks
    for (int i = 0; i < source_node->NBlocks(); i++) {
      R3SurfelBlock *block = source_node->Block(i);
      if (block->NSurfels() == 0) continue;
      if (!constraint->Check(block->BBox())) continue;
      if (block->Database() && !block->Database()->IsBlockResident(block)) continue;

      // Visit surfels
      for (int i = 0; i < block->NSurfels(); i++) {
        const R3Surfel *surfel = block->Surfel(i);
        if (!constraint->Check(block, surfel)) continue;
        (*callback_function)(block, surfel, callback_data);
      }
    }
  }
  else {
    // Consider parts
    for (int i = 0; i < source_node->NParts(); i++) {
      R3SurfelNode *part = source_node->Part(i);
      VisitResidentSurfels(scene, callback_function, part, constraint, callback_data);
    }
  }
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x18, %rsp
movq %r8, (%rsp)
movq %rcx, %r14
movq %rdx, %r15
movq %rsi, %r12
movq %rdi, %r13
testq %rcx, %rcx
je 0x216d9
movq (%r14), %rax
movq %r14, %rdi
movq %r15, %rsi
callq *0x18(%rax)
testl %eax, %eax
je 0x217b2
movl 0x3c(%r15), %eax
testl %eax, %eax
je 0x21711
xorl %ebx, %ebx
cltq
cmpq %rax, %rbx
jge 0x217b2
movq 0x30(%r15), %rax
movq (%rax,%rbx,8), %rdx
movq %r13, %rdi
movq %r12, %rsi
movq %r14, %rcx
movq (%rsp), %r8
callq 0x216a2
incq %rbx
movl 0x3c(%r15), %eax
jmp 0x216e3
xorl %ecx, %ecx
movq %r15, 0x8(%rsp)
movslq 0x4c(%r15), %rax
cmpq %rax, %rcx
jge 0x217b2
movq 0x40(%r15), %rax
movq %rcx, 0x10(%rsp)
movq (%rax,%rcx,8), %r13
cmpl $0x0, 0x8(%r13)
je 0x217a0
movq %r13, %rdi
callq 0x2a720
movq (%r14), %rcx
movq %r14, %rdi
movq %rax, %rsi
callq *0x30(%rcx)
testl %eax, %eax
je 0x217a0
cmpq $0x0, 0x98(%r13)
je 0x21762
cmpq $0x0, (%r13)
je 0x217a0
xorl %r15d, %r15d
xorl %ebx, %ebx
movslq 0x8(%r13), %rax
cmpq %rax, %rbx
jge 0x217a0
movq (%r13), %rbp
addq %r15, %rbp
movq (%r14), %rax
movq %r14, %rdi
movq %r13, %rsi
movq %rbp, %rdx
callq *0x28(%rax)
testl %eax, %eax
je 0x21797
movq %r13, %rdi
movq %rbp, %rsi
movq (%rsp), %rdx
callq *%r12
incq %rbx
addq $0x30, %r15
jmp 0x21767
movq 0x10(%rsp), %rcx
incq %rcx
movq 0x8(%rsp), %r15
jmp 0x21718
addq $0x18, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
// File: /workspace/github_cpp_makefile_star2_O2/tomfunkhouser[P]gaps/pkgs/R3Surfels/R3SurfelUtils.cpp
// Function: gaps::CreateBlock(gaps::R3SurfelScene*, gaps::R3SurfelPointSet*, int)
R3SurfelBlock *
CreateBlock(R3SurfelScene *scene, R3SurfelPointSet *pointset, 
  RNBoolean copy_surfels)
{
  // Get convenient variables
  if (pointset->NPoints() == 0) return NULL;
  R3SurfelTree *tree = scene->Tree();
  if (!tree) return NULL;
  R3SurfelDatabase *database = tree->Database();
  if (!database) return NULL;

  // Create block with copy of points
  R3SurfelBlock *block = new R3SurfelBlock(pointset);

  // Update properties
  block->UpdateProperties();

  // Insert block into database
  database->InsertBlock(block);

  // Remove and delete pointset from other blocks ???
  // tree->RemoveAndDeletePoints(scene, pointset);

  // Return block
  return block;
}

// Assembly:
pushq %r15
pushq %r14
pushq %rbx
cmpl $0x0, 0x10(%rsi)
je 0x2180f
movq 0x8(%rdi), %rax
testq %rax, %rax
je 0x2180f
movq 0x10(%rax), %r14
testq %r14, %r14
je 0x2180f
movq %rsi, %r15
movl $0xc8, %edi
callq 0x134f0
movq %rax, %rbx
movq %rax, %rdi
movq %r15, %rsi
callq 0x297aa
movq %rbx, %rdi
callq 0x2b540
movq (%r14), %rax
movq %r14, %rdi
movq %rbx, %rsi
callq *0x10(%rax)
jmp 0x21811
xorl %ebx, %ebx
movq %rbx, %rax
popq %rbx
popq %r14
popq %r15
retq
movq %rax, %r14
movl $0xc8, %esi
movq %rbx, %rdi
callq 0x13500
movq %r14, %rdi
callq 0x138f0
// File: /workspace/github_cpp_makefile_star2_O2/tomfunkhouser[P]gaps/pkgs/R3Surfels/R3SurfelUtils.cpp
// Function: gaps::CreateBlock(gaps::R3SurfelScene*, gaps::R3SurfelNode*, gaps::R3SurfelConstraint const*, int)
R3SurfelBlock *
CreateBlock(R3SurfelScene *scene, 
  R3SurfelNode *source_node, const R3SurfelConstraint *constraint, 
  RNBoolean copy_surfels)
{
  // Create point set
  R3SurfelPointSet *pointset = CreatePointSet(scene, source_node, constraint);
  if (!pointset) return NULL;

  // Create block
  R3SurfelBlock *block = CreateBlock(scene, pointset);

  // Delete point set
  delete pointset;

  // Return block
  return block;
}

// Assembly:
pushq %r14
pushq %rbx
pushq %rax
movq %rdi, %r14
callq 0x20cb7
testq %rax, %rax
je 0x21862
movq %rax, %rbx
movq %r14, %rdi
movq %rax, %rsi
callq 0x217c1
movq %rax, %r14
movq (%rbx), %rax
movq %rbx, %rdi
callq *0x8(%rax)
movq %r14, %rax
jmp 0x21864
xorl %eax, %eax
addq $0x8, %rsp
popq %rbx
popq %r14
retq
// File: /workspace/github_cpp_makefile_star2_O2/tomfunkhouser[P]gaps/pkgs/R3Surfels/R3SurfelUtils.cpp
// Function: gaps::RemoveEmptyObjects(gaps::R3SurfelScene*)
int
RemoveEmptyObjects(R3SurfelScene *scene)
{
  // Find empty subtrees of objects
  RNArray<R3SurfelObject *> deletable_subtrees;
  for (int i = 0; i < scene->NObjects(); i++) {
    R3SurfelObject *object = scene->Object(i);
    if (object == scene->RootObject()) continue;
    R3SurfelObject *parent = object->Parent();
    if (parent && !parent->HasSurfels(TRUE)) continue;
    if (object->HasSurfels(TRUE)) continue;
    deletable_subtrees.Insert(object);
  }

  // Delete subtrees
  for (int i = 0; i < deletable_subtrees.NEntries(); i++) {
    R3SurfelObject *object = deletable_subtrees.Kth(i);
    RemoveSubtree(scene, object);
  }

  // Return success
  return 1;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r12
pushq %rbx
subq $0x10, %rsp
movq %rdi, %rbx
movq %rsp, %r14
movq %r14, %rdi
callq 0x9a7ae
xorl %r12d, %r12d
pushq $0x1
popq %rbp
movslq 0x1c(%rbx), %rax
cmpq %rax, %r12
jge 0x21baa
movq 0x10(%rbx), %rax
movq (%rax,%r12,8), %r15
cmpq (%rax), %r15
je 0x21ba5
movq 0x18(%r15), %rdi
testq %rdi, %rdi
je 0x21b8c
movl %ebp, %esi
callq 0x16c78
testl %eax, %eax
je 0x21ba5
movq %r15, %rdi
movl %ebp, %esi
callq 0x16c78
testl %eax, %eax
jne 0x21ba5
movq %r14, %rdi
movq %r15, %rsi
callq 0x1784c
incq %r12
jmp 0x21b62
xorl %r14d, %r14d
movslq 0xc(%rsp), %rax
cmpq %rax, %r14
jge 0x21bcc
movq (%rsp), %rax
movq (%rax,%r14,8), %rsi
movq %rbx, %rdi
callq 0x21bf9
incq %r14
jmp 0x21bad
movq %rsp, %rdi
callq 0x9a81c
pushq $0x1
popq %rax
addq $0x10, %rsp
popq %rbx
popq %r12
popq %r14
popq %r15
popq %rbp
retq
jmp 0x21be6
movq %rax, %rbx
movq %rsp, %rdi
callq 0x9a81c
movq %rbx, %rdi
callq 0x138f0
// File: /workspace/github_cpp_makefile_star2_O2/tomfunkhouser[P]gaps/pkgs/R3Surfels/R3SurfelUtils.cpp
// Function: gaps::RemoveSubtree(gaps::R3SurfelScene*, gaps::R3SurfelObject*)
static int
RemoveSubtree(R3SurfelScene *scene, R3SurfelObject *object)
{
  // Check object
  if (!object) return 0;
  if (object == scene->RootObject()) return 1;
  
  // Remove parts
  for (int i = 0; i < object->NParts(); i++) {
    R3SurfelObject *part = object->Part(i);
    if (!RemoveSubtree(scene, part)) return 0;
  }

  // Delete object
  scene->RemoveObject(object);
  delete object;

  // Return success
  return 1;
}

// Assembly:
pushq %r15
pushq %r14
pushq %r12
pushq %rbx
pushq %rax
testq %rsi, %rsi
je 0x21c3b
movq %rsi, %r14
movq %rdi, %r15
movq 0x10(%rdi), %rax
pushq $0x1
popq %rbx
cmpq %rsi, (%rax)
je 0x21c54
xorl %r12d, %r12d
movslq 0x2c(%r14), %rax
cmpq %rax, %r12
jge 0x21c3f
movq 0x20(%r14), %rax
movq (%rax,%r12,8), %rsi
movq %r15, %rdi
callq 0x21bf9
incq %r12
testl %eax, %eax
jne 0x21c1b
xorl %ebx, %ebx
jmp 0x21c54
movq (%r15), %rax
movq %r15, %rdi
movq %r14, %rsi
callq *0x20(%rax)
movq (%r14), %rax
movq %r14, %rdi
callq *0x8(%rax)
movl %ebx, %eax
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r14
popq %r15
retq
// File: /workspace/github_cpp_makefile_star2_O2/tomfunkhouser[P]gaps/pkgs/R3Surfels/R3SurfelUtils.cpp
// Function: gaps::RemoveDisconnectedObjects(gaps::R3SurfelScene*)
int
RemoveDisconnectedObjects(R3SurfelScene *scene)
{
  // Find subtrees of objects disconnected from root
  RNArray<R3SurfelObject *> deletable_subtrees;
  for (int i = 0; i < scene->NObjects(); i++) {
    R3SurfelObject *object = scene->Object(i);
    if (object == scene->RootObject()) continue;
    if (object->Parent()) continue;
    deletable_subtrees.Insert(object);
  }

  // Delete subtrees
  for (int i = 0; i < deletable_subtrees.NEntries(); i++) {
    R3SurfelObject *object = deletable_subtrees.Kth(i);
    RemoveSubtree(scene, object);
  }

  // Return success
  return 1;
}

// Assembly:
pushq %r15
pushq %r14
pushq %rbx
subq $0x10, %rsp
movq %rdi, %rbx
movq %rsp, %r14
movq %r14, %rdi
callq 0x9a7ae
xorl %r15d, %r15d
movslq 0x1c(%rbx), %rax
cmpq %rax, %r15
jge 0x21ca6
movq 0x10(%rbx), %rax
movq (%rax,%r15,8), %rsi
cmpq (%rax), %rsi
je 0x21ca1
cmpq $0x0, 0x18(%rsi)
jne 0x21ca1
movq %r14, %rdi
callq 0x1784c
incq %r15
jmp 0x21c7c
xorl %r14d, %r14d
movslq 0xc(%rsp), %rax
cmpq %rax, %r14
jge 0x21cc8
movq (%rsp), %rax
movq (%rax,%r14,8), %rsi
movq %rbx, %rdi
callq 0x21bf9
incq %r14
jmp 0x21ca9
movq %rsp, %rdi
callq 0x9a81c
pushq $0x1
popq %rax
addq $0x10, %rsp
popq %rbx
popq %r14
popq %r15
retq
jmp 0x21cdf
movq %rax, %rbx
movq %rsp, %rdi
callq 0x9a81c
movq %rbx, %rdi
callq 0x138f0
// File: /workspace/github_cpp_makefile_star2_O2/tomfunkhouser[P]gaps/pkgs/R3Surfels/R3SurfelUtils.cpp
// Function: gaps::RemoveEmptyNodes(gaps::R3SurfelTree*, gaps::R3SurfelNode*)
static int
RemoveEmptyNodes(R3SurfelTree *tree, R3SurfelNode *node)
{
  // Check node
  if (!node) return 0;
  if (node == tree->RootNode()) return 1;
  
  // Remove empty parts
  for (int i = 0; i < node->NParts(); i++) {
    R3SurfelNode *part = node->Part(i);
    if (!RemoveEmptyNodes(tree, part)) return 0;
  }

  // Check if node is empty
  if (node->NParts() > 0) return 1;
  if (node->NBlocks() > 0) return 1;

  // Delete node
  tree->RemoveNode(node);
  delete node;

  // Return success
  return 1;
}

// Assembly:
pushq %r15
pushq %r14
pushq %r12
pushq %rbx
pushq %rax
testq %rsi, %rsi
je 0x21d49
movq %rsi, %r14
movq %rdi, %r15
movq 0x18(%rdi), %rax
pushq $0x1
popq %rbx
cmpq %rsi, (%rax)
je 0x21d4b
xorl %r12d, %r12d
movslq 0x3c(%r14), %rax
cmpq %rax, %r12
jge 0x21d59
movq 0x30(%r14), %rax
movq (%rax,%r12,8), %rsi
movq %r15, %rdi
callq 0x21d07
incq %r12
testl %eax, %eax
jne 0x21d29
xorl %ebx, %ebx
movl %ebx, %eax
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r14
popq %r15
retq
testl %eax, %eax
jg 0x21d4b
cmpl $0x0, 0x4c(%r14)
jg 0x21d4b
movq %r15, %rdi
movq %r14, %rsi
callq 0x34fc0
movq (%r14), %rax
movq %r14, %rdi
callq *0x8(%rax)
jmp 0x21d4b
// File: /workspace/github_cpp_makefile_star2_O2/tomfunkhouser[P]gaps/pkgs/R3Surfels/R3SurfelUtils.cpp
// Function: gaps::CullScans(gaps::R3SurfelScene*, gaps::R3SurfelConstraint const*)
int
CullScans(R3SurfelScene *scene, const R3SurfelConstraint *constraint)
{
  // Check inputs
  if (!scene) return 0;
  if (!constraint) return 0;

  // Find all scans to delete
  RNArray<R3SurfelScan *> delete_scans;
  for (int i = 0; i < scene->NScans(); i++) {
    R3SurfelScan *scan = scene->Scan(i);
    if (constraint->Check(scan->Viewpoint()) != R3_SURFEL_CONSTRAINT_FAIL) continue;
    delete_scans.Insert(scan);
  }

  // Delete scans
  for (int i = 0; i < delete_scans.NEntries(); i++) {
    R3SurfelScan *scan = delete_scans.Kth(i);
    delete scan;
  }
  
  // Return success
  return 1;
}

// Assembly:
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x10, %rsp
testq %rdi, %rdi
sete %cl
testq %rsi, %rsi
sete %dl
xorl %eax, %eax
orb %cl, %dl
jne 0x21f7a
movq %rsi, %rbx
movq %rdi, %r14
movq %rsp, %r15
movq %r15, %rdi
callq 0x9a7ae
xorl %r13d, %r13d
movslq 0x8c(%r14), %rax
cmpq %rax, %r13
jge 0x21f4b
movq 0x80(%r14), %rax
movq (%rax,%r13,8), %r12
leaq 0x28(%r12), %rsi
movq (%rbx), %rax
movq %rbx, %rdi
callq *0x38(%rax)
testl %eax, %eax
jne 0x21f46
movq %r15, %rdi
movq %r12, %rsi
callq 0x1784c
incq %r13
jmp 0x21f12
xorl %ebx, %ebx
movslq 0xc(%rsp), %rax
cmpq %rax, %rbx
jge 0x21f6f
movq (%rsp), %rax
movq (%rax,%rbx,8), %rdi
testq %rdi, %rdi
je 0x21f6a
movq (%rdi), %rax
callq *0x8(%rax)
incq %rbx
jmp 0x21f4d
movq %rsp, %rdi
callq 0x9a81c
pushq $0x1
popq %rax
addq $0x10, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
retq
movq %rax, %rbx
movq %rsp, %rdi
callq 0x9a81c
movq %rbx, %rdi
callq 0x138f0
// File: /workspace/github_cpp_makefile_star2_O2/tomfunkhouser[P]gaps/pkgs/R3Surfels/R3SurfelUtils.cpp
// Function: gaps::CullImages(gaps::R3SurfelScene*, gaps::R3SurfelConstraint const*)
int
CullImages(R3SurfelScene *scene, const R3SurfelConstraint *constraint)
{
  // Check inputs
  if (!scene) return 0;
  if (!constraint) return 0;

  // Find all images to delete
  RNArray<R3SurfelImage *> delete_images;
  for (int i = 0; i < scene->NImages(); i++) {
    R3SurfelImage *image = scene->Image(i);
    if (constraint->Check(image->Viewpoint()) != R3_SURFEL_CONSTRAINT_FAIL) continue;
    delete_images.Insert(image);
  }

  // Delete images
  for (int i = 0; i < delete_images.NEntries(); i++) {
    R3SurfelImage *image = delete_images.Kth(i);
    delete image;
  }
  
  // Return success
  return 1;
}

// Assembly:
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x10, %rsp
testq %rdi, %rdi
sete %cl
testq %rsi, %rsi
sete %dl
xorl %eax, %eax
orb %cl, %dl
jne 0x22036
movq %rsi, %rbx
movq %rdi, %r14
movq %rsp, %r15
movq %r15, %rdi
callq 0x9a7ae
xorl %r13d, %r13d
movslq 0x9c(%r14), %rax
cmpq %rax, %r13
jge 0x22007
movq 0x90(%r14), %rax
movq (%rax,%r13,8), %r12
leaq 0x30(%r12), %rsi
movq (%rbx), %rax
movq %rbx, %rdi
callq *0x38(%rax)
testl %eax, %eax
jne 0x22002
movq %r15, %rdi
movq %r12, %rsi
callq 0x1784c
incq %r13
jmp 0x21fce
xorl %ebx, %ebx
movslq 0xc(%rsp), %rax
cmpq %rax, %rbx
jge 0x2202b
movq (%rsp), %rax
movq (%rax,%rbx,8), %rdi
testq %rdi, %rdi
je 0x22026
movq (%rdi), %rax
callq *0x8(%rax)
incq %rbx
jmp 0x22009
movq %rsp, %rdi
callq 0x9a81c
pushq $0x1
popq %rax
addq $0x10, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
retq
movq %rax, %rbx
movq %rsp, %rdi
callq 0x9a81c
movq %rbx, %rdi
callq 0x138f0
// File: /workspace/github_cpp_makefile_star2_O2/tomfunkhouser[P]gaps/pkgs/R3Surfels/R3SurfelUtils.cpp
// Function: gaps::CreateObject(gaps::R3SurfelScene*, gaps::R3SurfelObject*, char const*)
R3SurfelObject *
CreateObject(R3SurfelScene *scene, 
  R3SurfelObject *parent_object, const char *object_name)
{
  // Get parent object
  if (!parent_object) parent_object = scene->RootObject();

  // Create object
  R3SurfelObject *object = new R3SurfelObject(object_name);
    
  // Insert object into scene
  scene->InsertObject(object, parent_object);

  // Update properties
  object->UpdateProperties();

  // Return object
  return object;
}

// Assembly:
pushq %r15
pushq %r14
pushq %r12
pushq %rbx
pushq %rax
movq %rdx, %r12
movq %rsi, %rbx
movq %rdi, %r15
testq %rsi, %rsi
jne 0x22251
movq 0x10(%r15), %rax
movq (%rax), %rbx
movl $0xf8, %edi
callq 0x134f0
movq %rax, %r14
movq %rax, %rdi
movq %r12, %rsi
callq 0x16360
movq (%r15), %rax
movq %r15, %rdi
movq %r14, %rsi
movq %rbx, %rdx
callq *0x18(%rax)
movq %r14, %rdi
callq 0x1775a
movq %r14, %rax
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r14
popq %r15
retq
movq %rax, %rbx
movl $0xf8, %esi
movq %r14, %rdi
callq 0x13500
movq %rbx, %rdi
callq 0x138f0
// File: /workspace/github_cpp_makefile_star2_O2/tomfunkhouser[P]gaps/pkgs/R3Surfels/R3SurfelUtils.cpp
// Function: gaps::RemoveParts(gaps::R3SurfelScene*, gaps::R3SurfelObject*)
int
RemoveParts(R3SurfelScene *scene, R3SurfelObject *object)
{
  // Copy array of parts
  RNArray<R3SurfelObject *> parts;
  for (int i = 0; i < object->NParts(); i++) {
    R3SurfelObject *part = object->Part(i);
    parts.Insert(part);
  }
  
  // Delete parts
  for (int i = 0; i < parts.NEntries(); i++) {
    R3SurfelObject *part = parts.Kth(i);
    RemoveParts(scene, part);
    scene->RemoveObject(part);
    delete part;
  }

  // Return success
  return 1;
}

// Assembly:
pushq %r15
pushq %r14
pushq %r12
pushq %rbx
subq $0x18, %rsp
movq %rsi, %r14
movq %rdi, %rbx
leaq 0x8(%rsp), %r15
movq %r15, %rdi
callq 0x9a7ae
xorl %r12d, %r12d
movslq 0x2c(%r14), %rax
cmpq %rax, %r12
jge 0x2298b
movq 0x20(%r14), %rax
movq (%rax,%r12,8), %rsi
movq %r15, %rdi
callq 0x1784c
incq %r12
jmp 0x2296d
xorl %r15d, %r15d
movslq 0x14(%rsp), %rax
cmpq %rax, %r15
jge 0x229cb
movq 0x8(%rsp), %rax
movq (%rax,%r15,8), %r14
movq %rbx, %rdi
movq %r14, %rsi
callq 0x2294c
movq (%rbx), %rax
movq %rbx, %rdi
movq %r14, %rsi
callq *0x20(%rax)
testq %r14, %r14
je 0x229c6
movq (%r14), %rax
movq %r14, %rdi
callq *0x8(%rax)
incq %r15
jmp 0x2298e
leaq 0x8(%rsp), %rdi
callq 0x9a81c
pushq $0x1
popq %rax
addq $0x18, %rsp
popq %rbx
popq %r12
popq %r14
popq %r15
retq
jmp 0x229e6
movq %rax, %rbx
leaq 0x8(%rsp), %rdi
callq 0x9a81c
movq %rbx, %rdi
callq 0x138f0
// File: /workspace/github_cpp_makefile_star2_O2/tomfunkhouser[P]gaps/pkgs/R3Surfels/R3SurfelUtils.cpp
// Function: gaps::SplitObject(gaps::R3SurfelObject*, gaps::R3SurfelPointSet*, gaps::R3SurfelObject**, gaps::R3SurfelObject**)
int
SplitObject(R3SurfelObject *object, R3SurfelPointSet *pointset,
  R3SurfelObject **resultA, R3SurfelObject **resultB)
{
  // Read blocks
  object->ReadBlocks();

  // Set marks
  object->SetMarks(FALSE);
  pointset->SetMarks(TRUE);

  // Create constraint
  R3SurfelMultiConstraint constraint;
  R3SurfelMarkConstraint mark_constraint(TRUE, FALSE);
  R3SurfelObjectConstraint object_constraint(object);
  constraint.InsertConstraint(&mark_constraint);
  constraint.InsertConstraint(&object_constraint);

  // Split object
  int status = SplitObject(object, &constraint, resultA, resultB);

  // Release blocks
  object->ReleaseBlocks();

  // Return status
  return status;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r12
pushq %rbx
subq $0x40, %rsp
movq %rcx, %r14
movq %rdx, %r15
movq %rsi, %r12
movq %rdi, %rbx
xorl %esi, %esi
callq 0x1734e
movq (%rbx), %rax
movq %rbx, %rdi
xorl %esi, %esi
callq *0x40(%rax)
movq (%r12), %rax
pushq $0x1
popq %rbp
movq %r12, %rdi
movl %ebp, %esi
callq *0xa8(%rax)
leaq 0x10(%rsp), %rdi
callq 0x2ea82
movq %rsp, %rdi
movl %ebp, %esi
xorl %edx, %edx
callq 0x2ea32
leaq 0x28(%rsp), %rdi
movq %rbx, %rsi
xorl %edx, %edx
callq 0x2e782
leaq 0x10(%rsp), %rdi
movq %rsp, %rsi
callq 0x2ea96
leaq 0x10(%rsp), %rdi
leaq 0x28(%rsp), %rsi
callq 0x2ea96
leaq 0x10(%rsp), %rsi
movq %rbx, %rdi
movq %r15, %rdx
movq %r14, %rcx
callq 0x22af5
movl %eax, %ebp
movq %rbx, %rdi
xorl %esi, %esi
callq 0x1737e
leaq 0x28(%rsp), %rdi
callq 0x2ec74
movq %rsp, %rdi
callq 0x2ec74
leaq 0x10(%rsp), %rdi
callq 0x28504
movl %ebp, %eax
addq $0x40, %rsp
popq %rbx
popq %r12
popq %r14
popq %r15
popq %rbp
retq
movq %rax, %rbx
jmp 0x22adb
movq %rax, %rbx
jmp 0x22ae3
jmp 0x22ace
movq %rax, %rbx
leaq 0x28(%rsp), %rdi
callq 0x2ec74
movq %rsp, %rdi
callq 0x2ec74
leaq 0x10(%rsp), %rdi
callq 0x28504
movq %rbx, %rdi
callq 0x138f0
// File: /workspace/github_cpp_makefile_star2_O2/tomfunkhouser[P]gaps/pkgs/R3Surfels/R3SurfelUtils.cpp
// Function: gaps::GetObjectOBBProperty(gaps::R3SurfelObject*, gaps::R3OrientedBox*, double*, int*)
R3SurfelObjectProperty *
GetObjectOBBProperty(R3SurfelObject *object,
  R3OrientedBox *obb, RNScalar *confidence, int *originator)
{
  // Constants for OBB property
  static const int property_type = R3_SURFEL_OBJECT_AMODAL_OBB_PROPERTY;
  static const int noperands = 20;

  // Get object property
  R3SurfelObjectProperty *property = object->FindObjectProperty(property_type);
  if (!property) return NULL;

  // Check property operands
  if (property->NOperands() != noperands) return NULL;

  // Extract obb
  if (obb) {
    R3Point center(property->Operand(0), property->Operand(1), property->Operand(2));
    R3Vector axis0(property->Operand(3), property->Operand(4), property->Operand(5));
    R3Vector axis1(property->Operand(6), property->Operand(7), property->Operand(8));
    // R3Vector axis2(property->Operand(9), property->Operand(10), property->Operand(11));
    RNScalar radius0 = property->Operand(12);
    RNScalar radius1 = property->Operand(13);
    RNScalar radius2 = property->Operand(14);
    obb->Reset(center, axis0, axis1, radius0, radius1, radius2);
  }

  // Extract confidence and originator
  if (confidence) *confidence = property->Operand(15);
  if (originator) *originator = (int) (property->Operand(16) + 0.5);

  // Return property
  return property;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x48, %rsp
movq %rcx, %r14
movq %rdx, %r15
movq %rsi, %r12
pushq $0x2
popq %rsi
callq 0x16b78
testq %rax, %rax
je 0x22f87
movq %rax, %rbx
cmpl $0x14, 0x28(%rax)
jne 0x22f87
testq %r12, %r12
je 0x22f52
movq 0x20(%rbx), %rax
movsd (%rax), %xmm0
movsd 0x8(%rax), %xmm1
movsd 0x10(%rax), %xmm2
movq %rsp, %rdi
callq 0x781bc
movq 0x20(%rbx), %rax
movsd 0x18(%rax), %xmm0
movsd 0x20(%rax), %xmm1
movsd 0x28(%rax), %xmm2
leaq 0x30(%rsp), %rbp
movq %rbp, %rdi
callq 0x7897c
movq 0x20(%rbx), %rax
movsd 0x30(%rax), %xmm0
movsd 0x38(%rax), %xmm1
movsd 0x40(%rax), %xmm2
leaq 0x18(%rsp), %r13
movq %r13, %rdi
callq 0x7897c
movq 0x20(%rbx), %rax
movsd 0x60(%rax), %xmm0
movsd 0x68(%rax), %xmm1
movsd 0x70(%rax), %xmm2
movq (%r12), %rax
movq %r12, %rdi
movq %rsp, %rsi
movq %rbp, %rdx
movq %r13, %rcx
callq *0x268(%rax)
testq %r15, %r15
je 0x22f65
movq 0x20(%rbx), %rax
movsd 0x78(%rax), %xmm0
movsd %xmm0, (%r15)
testq %r14, %r14
je 0x22f89
movq 0x20(%rbx), %rax
movsd 0x80(%rax), %xmm0
addsd 0xa51ba(%rip), %xmm0    # 0xc8138
cvttsd2si %xmm0, %eax
movl %eax, (%r14)
jmp 0x22f89
xorl %ebx, %ebx
movq %rbx, %rax
addq $0x48, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq