LLM4Binary/decompile-bench-makefile huggingface dataset:
// File: /workspace/github_cpp_makefile_star2_O3/tomfunkhouser[P]gaps/pkgs/R3Surfels/R3SurfelDatabase.cpp
// Function: gaps::R3SurfelDatabase::Print(_IO_FILE*, char const*, char const*) const
void R3SurfelDatabase::
Print(FILE *fp, const char *prefix, const char *suffix) const
{
  // Check fp
  if (!fp) fp = stdout;

  // Print name
  fprintf(fp, "%s%s%s\n", (prefix) ? prefix : "", (name) ? name : "Database", (suffix) ? suffix : "");

  // Add indent to prefix
  char indent_prefix[1024];
  sprintf(indent_prefix, "%s  ", (prefix) ? prefix : "");

  // Print blocks
  for (int i = 0; i < NBlocks(); i++) {
    blocks[i]->Print(fp, indent_prefix, suffix);
  }
}

// Assembly:
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x400, %rsp            # imm = 0x400
movq %rcx, %rbx
movq %rdx, %r12
movq %rsi, %r15
movq %rdi, %r14
testq %rsi, %rsi
jne 0x415f3
movq 0xf1980(%rip), %rax     # 0x132f70
movq (%rax), %r15
testq %r12, %r12
leaq 0x9d9f5(%rip), %r8      # 0xdeff2
cmoveq %r8, %r12
movq 0xa8(%r14), %rax
testq %rax, %rax
leaq 0x9d3d5(%rip), %rcx     # 0xde9e7
cmovneq %rax, %rcx
testq %rbx, %rbx
cmovneq %rbx, %r8
leaq 0x9d2c0(%rip), %rsi     # 0xde8e4
movq %r15, %rdi
movq %r12, %rdx
xorl %eax, %eax
callq 0x13740
leaq 0x9bde7(%rip), %rsi     # 0xdd41f
movq %rsp, %rdi
movq %r12, %rdx
xorl %eax, %eax
callq 0x130e0
cmpl $0x0, 0x4c(%r14)
jle 0x41674
xorl %r13d, %r13d
movq %rsp, %r12
movq 0x40(%r14), %rax
movq (%rax,%r13,8), %rdi
movq %r15, %rsi
movq %r12, %rdx
movq %rbx, %rcx
callq 0x2e5fa
incq %r13
movslq 0x4c(%r14), %rax
cmpq %rax, %r13
jl 0x41652
addq $0x400, %rsp            # imm = 0x400
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
retq
nop
// File: /workspace/github_cpp_makefile_star2_O3/tomfunkhouser[P]gaps/pkgs/R3Surfels/R3SurfelDatabase.cpp
// Function: gaps::R3SurfelDatabase::WriteFile(char const*)
int R3SurfelDatabase::
WriteFile(const char *filename)
{
  // Parse input filename extension
  const char *extension;
  if (!(extension = strrchr(filename, '.'))) {
    printf("Filename %s has no extension (e.g., .xyz)\n", filename);
    return 0;
  }

  // Write file of appropriate type
  if (!strncmp(extension, ".ssb", 5)) {
    // Open file
    FILE *f = fopen(filename, "wb");
    if (!f) {
      RNFail("Unable to open file %s\n", filename);
      return 0;
    }

    // Write stream
    if (!WriteStream(f)) {
      fclose(f);
      return 0;
    }

    // Close file
    fclose(f);
  }
  else if (NBlocks() == 1) {
    R3SurfelDatabase *database = (R3SurfelDatabase *) this;
    R3SurfelBlock *block = Block(0);
    if (!database->ReadBlock(block)) return 0;
    if (!block->WriteFile(filename)) return 0;
    if (!database->ReleaseBlock(block)) return 0;
  }
  else {
    RNFail("Invalid file extension %s for database with more than one block\n", extension);
    return 0;
  }

  // Return success
  return 1;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %rbx
pushq %rax
movq %rsi, %r15
movq %rdi, %rbx
movq %rsi, %rdi
movl $0x2e, %esi
callq 0x13560
testq %rax, %rax
je 0x41a17
movq %rax, %r14
leaq 0x9cfbf(%rip), %rsi     # 0xde8ec
movl $0x5, %edx
movq %rax, %rdi
callq 0x13240
testl %eax, %eax
je 0x41a2c
cmpl $0x1, 0x4c(%rbx)
jne 0x41a61
movq 0x40(%rbx), %rax
movq (%rax), %r14
movl 0xb4(%r14), %eax
testl %eax, %eax
jne 0x41983
movq (%rbx), %rax
movq 0x8(%rbx), %rdx
movl 0x28(%rbx), %ecx
movq %rbx, %rdi
movq %r14, %rsi
callq *0x88(%rax)
testl %eax, %eax
je 0x41a8f
movl 0xb4(%r14), %eax
incl %eax
movl %eax, 0xb4(%r14)
movq %r14, %rdi
movq %r15, %rsi
callq 0x2eaaa
xorl %ebp, %ebp
testl %eax, %eax
je 0x41a82
movl 0xb4(%r14), %eax
cmpl $0x1, %eax
jne 0x419d2
movq (%rbx), %rax
movq 0x8(%rbx), %rdx
movl 0x28(%rbx), %ecx
movq %rbx, %rdi
movq %r14, %rsi
callq *0x90(%rax)
testl %eax, %eax
je 0x41a82
movl 0xb4(%r14), %eax
movl $0x1, %ebp
decl %eax
movl %eax, 0xb4(%r14)
jne 0x41a82
testb $0x2, 0x89(%r14)
je 0x41a82
movq (%rbx), %rax
movq %rbx, %rdi
movq %r14, %rsi
callq *0x18(%rax)
movq %r14, %rdi
callq 0x2ca06
movl $0xc8, %esi
movq %r14, %rdi
callq 0x134f0
jmp 0x41a82
leaq 0x9ced9(%rip), %rdi     # 0xde8f7
xorl %ebp, %ebp
movq %r15, %rsi
xorl %eax, %eax
callq 0x13070
jmp 0x41a82
leaq 0x9c5b6(%rip), %rsi     # 0xddfe9
movq %r15, %rdi
callq 0x135d0
testq %rax, %rax
je 0x41a6f
movq %rax, %r14
movq (%rbx), %rax
movq %rbx, %rdi
movq %r14, %rsi
callq *0x68(%rax)
xorl %ebp, %ebp
testl %eax, %eax
setne %bpl
movq %r14, %rdi
callq 0x134d0
jmp 0x41a82
leaq 0x9ceba(%rip), %rdi     # 0xde922
xorl %ebp, %ebp
movq %r14, %rsi
jmp 0x41a7b
leaq 0x9ba5c(%rip), %rdi     # 0xdd4d2
xorl %ebp, %ebp
movq %r15, %rsi
xorl %eax, %eax
callq 0xac81a
movl %ebp, %eax
addq $0x8, %rsp
popq %rbx
popq %r14
popq %r15
popq %rbp
retq
xorl %ebp, %ebp
jmp 0x41a82
nop
// File: /workspace/github_cpp_makefile_star2_O3/tomfunkhouser[P]gaps/pkgs/R3Surfels/R3SurfelDatabase.cpp
// Function: gaps::R3SurfelDatabase::InternalSyncBlock(gaps::R3SurfelBlock*, _IO_FILE*, int)
int R3SurfelDatabase::
InternalSyncBlock(R3SurfelBlock *block, FILE *fp, int swap_endian)
{
  // Check file
  if (!fp) return 1;

  // Check number of surfels
  if (block->NSurfels() == 0) return 1;

  // Check file rwaccess
  if (!strstr(rwaccess, "+")) {
    RNFail("Unable to write block to read-only file\n");
    return 0;
  }

#if 0
  // Check database version
  if ((major_version != current_major_version) || (minor_version != current_minor_version)) {
    RNFail("Unable to write block to database with different version\n");
    return 0;
  }
#endif
  
  // Just checking
  assert(block->database == this);

  // Check if surfels can be put at original offset in file
  if ((block->file_surfels_offset > 0) && ((unsigned int) block->nsurfels <= block->file_surfels_count)) {
    // Surfels fit at original offset in file
    RNFileSeek(fp, block->file_surfels_offset, RN_FILE_SEEK_SET);
  }
  else {
    // Surfels must be put at end of file
    RNFileSeek(fp, 0, RN_FILE_SEEK_END);
    block->file_surfels_offset = RNFileTell(fp);
    block->file_surfels_count = block->nsurfels;
  }

  // Write surfels to file
  if (!WriteSurfel(fp, block->surfels, block->nsurfels, swap_endian, major_version, minor_version)) return 0;

#ifdef PRINT_DEBUG
  // Print debug message
  printf("Synced Block %6d : %6d %9ld : %9.3f %9.3f %9.3f\n", 
         block->database_index, block->nsurfels, resident_surfels,
         block->Centroid().X(), block->Centroid().Y(), block->Centroid().Z()); 
  fflush(stdout);
#endif

  // Return success
  return 1;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
pushq %rax
movl $0x1, %ebp
testq %rdx, %rdx
je 0x4279c
movq %rsi, %r12
movl 0x8(%rsi), %r13d
testl %r13d, %r13d
je 0x4279c
movl %ecx, %ebx
movq %rdx, %r14
movq %rdi, %r15
movq 0x18(%rdi), %rdi
movl $0x2b, %esi
callq 0x131d0
testq %rax, %rax
je 0x42751
movq 0xa8(%r12), %rsi
testq %rsi, %rsi
je 0x42723
cmpl 0xb0(%r12), %r13d
jbe 0x42763
movq %r14, %rdi
xorl %esi, %esi
movl $0x2, %edx
callq 0xabc5a
movq %r14, %rdi
callq 0xabc6b
movq %rax, 0xa8(%r12)
movl 0x8(%r12), %ecx
movl %ecx, 0xb0(%r12)
jmp 0x42772
leaq 0x9c25e(%rip), %rdi     # 0xde9b6
xorl %ebp, %ebp
xorl %eax, %eax
callq 0xac81a
jmp 0x4279c
movq %r14, %rdi
xorl %edx, %edx
callq 0xabc5a
movl 0x8(%r12), %ecx
movq (%r12), %rdx
movl 0x20(%r15), %r9d
movl 0x24(%r15), %eax
movq (%r15), %r10
movl %eax, (%rsp)
movq %r15, %rdi
movq %r14, %rsi
movl %ebx, %r8d
callq *0xa8(%r10)
xorl %ebp, %ebp
testl %eax, %eax
setne %bpl
movl %ebp, %eax
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
nop
// File: /workspace/github_cpp_makefile_star2_O3/tomfunkhouser[P]gaps/pkgs/R3Surfels/R3SurfelDatabase.cpp
// Function: gaps::R3SurfelDatabase::PurgeDeletedBlocks()
int R3SurfelDatabase::
PurgeDeletedBlocks(void)
{
  // Execute pending deletes
  RNArray<R3SurfelBlock *> blocks_to_delete;
  for (int i = 0; i < blocks.NEntries(); i++) {
    R3SurfelBlock *block = blocks.Kth(i);
    if (block->flags[R3_SURFEL_BLOCK_DELETE_PENDING_FLAG]) {
      blocks_to_delete.Insert(block);
    }
  }

  // Delete blocks
  for (int i = 0; i < blocks_to_delete.NEntries(); i++) {
    R3SurfelBlock *block = blocks_to_delete.Kth(i);
    block->file_read_count = 0;
    RemoveBlock(block);
    delete block;
  }

  // Return number of blocks deleted
  return blocks_to_delete.NEntries();
}

// Assembly:
pushq %r15
pushq %r14
pushq %rbx
subq $0x10, %rsp
movq %rdi, %rbx
movq %rsp, %rdi
callq 0xa9ca8
movl 0x4c(%rbx), %eax
testl %eax, %eax
jle 0x430e0
xorl %r15d, %r15d
movq %rsp, %r14
movq 0x40(%rbx), %rcx
movq (%rcx,%r15,8), %rsi
testb $0x2, 0x89(%rsi)
je 0x430d5
movl 0xc(%rsp), %edx
movq %r14, %rdi
callq 0xa9d3e
movl 0x4c(%rbx), %eax
incq %r15
movslq %eax, %rcx
cmpq %rcx, %r15
jl 0x430b5
movl 0xc(%rsp), %r14d
testl %r14d, %r14d
jle 0x4312e
xorl %r15d, %r15d
movq (%rsp), %rax
movq (%rax,%r15,8), %r14
movl $0x0, 0xb4(%r14)
movq (%rbx), %rax
movq %rbx, %rdi
movq %r14, %rsi
callq *0x18(%rax)
movq %r14, %rdi
callq 0x2ca06
movl $0xc8, %esi
movq %r14, %rdi
callq 0x134f0
incq %r15
movslq 0xc(%rsp), %r14
cmpq %r14, %r15
jl 0x430ed
movq %rsp, %rdi
callq 0xa9d12
movl %r14d, %eax
addq $0x10, %rsp
popq %rbx
popq %r14
popq %r15
retq
jmp 0x43145
movq %rax, %rbx
movq %rsp, %rdi
callq 0xa9d12
movq %rbx, %rdi
callq 0x138b0
// File: /workspace/github_cpp_makefile_star2_O3/tomfunkhouser[P]gaps/pkgs/R3Surfels/R3SurfelDatabase.cpp
// Function: gaps::R3SurfelDatabase::OpenFile(char const*, char const*)
int R3SurfelDatabase::
OpenFile(const char *filename, const char *rwaccess)
{
  // Remember file name
  if (this->filename) free(this->filename);
  this->filename = RNStrdup(filename);

  // Parse rwaccess
  if (this->rwaccess) free(this->rwaccess);
  if (!rwaccess) this->rwaccess = RNStrdup("w+b");
  else if (strstr(rwaccess, "w")) this->rwaccess = RNStrdup("w+b");
  else if (strstr(rwaccess, "+")) this->rwaccess = RNStrdup("r+b");
  else this->rwaccess = RNStrdup("rb"); 

  // Open file
  fp = fopen(filename, this->rwaccess);
  if (!fp) {
    RNFail("Unable to open database file %s with rwaccess %s\n", filename, rwaccess);
    return 0;
  }

  // Check if file is new
  if (!strcmp(this->rwaccess, "w+b")) {
    // File is new -- write header
    if (!WriteFileHeader(fp, 0)) {
      fclose(fp);
      fp = NULL;
      return 0;
    }
  }
  else {
    // Read header
    unsigned int nblocks = 0;
    if (!ReadFileHeader(fp, nblocks)) {
      fclose(fp);
      fp = NULL;
    }
    
    // Read blocks
    if (!ReadBlockHeader(fp, nblocks, swap_endian)) {
      fclose(fp);
      fp = NULL;
    }
  }

  // Return success
  return 1;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r12
pushq %rbx
subq $0x10, %rsp
movq %rdx, %r14
movq %rsi, %r15
movq %rdi, %rbx
movq 0x10(%rdi), %rdi
testq %rdi, %rdi
je 0x4317b
callq 0x135e0
movq %r15, %rdi
callq 0xac67b
movq %rax, 0x10(%rbx)
movq 0x18(%rbx), %rdi
testq %rdi, %rdi
je 0x43195
callq 0x135e0
leaq 0x9b8d9(%rip), %r12     # 0xdea75
testq %r14, %r14
je 0x431d5
movq %r14, %rdi
movl $0x77, %esi
callq 0x131d0
testq %rax, %rax
jne 0x431d5
movq %r14, %rdi
movl $0x2b, %esi
callq 0x131d0
testq %rax, %rax
leaq 0x9a00b(%rip), %rax     # 0xdd1d5
leaq 0x9b8a8(%rip), %r12     # 0xdea79
cmoveq %rax, %r12
movq %r12, %rdi
callq 0xac67b
movq %rax, 0x18(%rbx)
movq %r15, %rdi
movq %rax, %rsi
callq 0x135d0
movq %rax, 0x8(%rbx)
testq %rax, %rax
je 0x4326f
movq %rax, %r12
movq 0x18(%rbx), %rdi
leaq 0x9b872(%rip), %rsi     # 0xdea75
callq 0x13710
testl %eax, %eax
je 0x43287
leaq 0xc(%rsp), %rdx
movl $0x0, (%rdx)
movq (%rbx), %rax
movq %rbx, %rdi
movq %r12, %rsi
callq *0xb0(%rax)
movq 0x8(%rbx), %rsi
testl %eax, %eax
jne 0x43240
movq %rsi, %rdi
callq 0x134d0
movq $0x0, 0x8(%rbx)
xorl %esi, %esi
movl 0xc(%rsp), %edx
movl 0x28(%rbx), %ecx
movq (%rbx), %rax
movq %rbx, %rdi
callq *0xb8(%rax)
testl %eax, %eax
jne 0x43268
movq 0x8(%rbx), %rdi
callq 0x134d0
movq $0x0, 0x8(%rbx)
movl $0x1, %ebp
jmp 0x432b4
leaq 0x9b807(%rip), %rdi     # 0xdea7d
xorl %ebp, %ebp
movq %r15, %rsi
movq %r14, %rdx
xorl %eax, %eax
callq 0xac81a
jmp 0x432b4
movq (%rbx), %rax
movq %rbx, %rdi
movq %r12, %rsi
xorl %edx, %edx
callq *0xc0(%rax)
movl $0x1, %ebp
testl %eax, %eax
jne 0x432b4
movq 0x8(%rbx), %rdi
callq 0x134d0
movq $0x0, 0x8(%rbx)
xorl %ebp, %ebp
movl %ebp, %eax
addq $0x10, %rsp
popq %rbx
popq %r12
popq %r14
popq %r15
popq %rbp
retq
nop
// File: /workspace/github_cpp_makefile_star2_O3/tomfunkhouser[P]gaps/pkgs/R3Surfels/R3SurfelDatabase.cpp
// Function: gaps::R3SurfelDatabase::SyncFile()
int R3SurfelDatabase::
SyncFile(void)
{
  // Check if file is read-only
  if (!strcmp(rwaccess, "rb")) return 1;

  // Sync blocks
  for (int i = 0; i < blocks.NEntries(); i++) {
    R3SurfelBlock *block = blocks.Kth(i);
    if (!SyncBlock(block)) return 0;
  }

  // Update blocks offset
  unsigned int nblocks = blocks.NEntries();
  if (nblocks > file_blocks_count) {
    // Update block header size
    file_blocks_count = nblocks;

    // Update block header offset (after last block)
    file_blocks_offset = 0;
    for (int i = 0; i < blocks.NEntries(); i++) {
      R3SurfelBlock *block = blocks.Kth(i);
      unsigned long long offset = block->file_surfels_offset + block->file_surfels_count * NBytesPerSurfel();
      if (offset > file_blocks_offset) file_blocks_offset = offset;
    }

    // Double check block header offset
    if (file_blocks_offset <= 0) {
      RNFileSeek(fp, 0, RN_FILE_SEEK_END);
      file_blocks_offset = RNFileTell(fp);
    }
  }

  // Write blocks
  if (!WriteBlockHeader(fp, swap_endian)) return 0;

  // Write header again (now that the offset values have been filled in)
  if (!WriteFileHeader(fp, swap_endian)) return 0;

  // Return success
  return 1;
}

// Assembly:
pushq %r15
pushq %r14
pushq %rbx
movq %rdi, %rbx
movq 0x18(%rdi), %rax
cmpb $0x72, (%rax)
jne 0x432e5
cmpb $0x62, 0x1(%rax)
jne 0x432e5
cmpb $0x0, 0x2(%rax)
je 0x433f8
movl 0x4c(%rbx), %edx
testl %edx, %edx
jle 0x43337
xorl %r15d, %r15d
movq 0x40(%rbx), %rax
movq (%rax,%r15,8), %r14
movq %r14, %rdi
callq 0x2d3fa
testl %eax, %eax
je 0x4332b
movq (%rbx), %rax
movq 0x8(%rbx), %rdx
movl 0x28(%rbx), %ecx
movq %rbx, %rdi
movq %r14, %rsi
callq *0x98(%rax)
testl %eax, %eax
je 0x433f0
movq %r14, %rdi
xorl %esi, %esi
callq 0x2d408
incq %r15
movslq 0x4c(%rbx), %rdx
cmpq %rdx, %r15
jl 0x432ef
cmpl 0x38(%rbx), %edx
jbe 0x433bb
movl %edx, 0x38(%rbx)
movq $0x0, 0x30(%rbx)
testl %edx, %edx
jle 0x4339e
movq 0x40(%rbx), %rax
movl 0x20(%rbx), %ecx
movl %edx, %edx
addl $-0x3, %ecx
xorl %esi, %esi
leaq 0x9b78c(%rip), %rdi     # 0xdeaec
xorl %r8d, %r8d
movl $0x10, %r9d
cmpl $0x3, %ecx
ja 0x43372
movl (%rdi,%rcx,4), %r9d
movq (%rax,%rsi,8), %r10
imull 0xb0(%r10), %r9d
addq 0xa8(%r10), %r9
cmpq %r8, %r9
jbe 0x43391
movq %r9, 0x30(%rbx)
movq %r9, %r8
incq %rsi
cmpq %rsi, %rdx
jne 0x43363
testq %r8, %r8
jne 0x433bb
movq 0x8(%rbx), %rdi
xorl %esi, %esi
movl $0x2, %edx
callq 0xabc5a
movq 0x8(%rbx), %rdi
callq 0xabc6b
movq %rax, 0x30(%rbx)
movq (%rbx), %rax
movq 0x8(%rbx), %rsi
movl 0x28(%rbx), %edx
movq %rbx, %rdi
callq *0xc8(%rax)
testl %eax, %eax
je 0x433f0
movq (%rbx), %rax
movq 0x8(%rbx), %rsi
movl 0x28(%rbx), %edx
movq %rbx, %rdi
callq *0xc0(%rax)
movl %eax, %ecx
xorl %eax, %eax
testl %ecx, %ecx
setne %al
jmp 0x433f2
xorl %eax, %eax
popq %rbx
popq %r14
popq %r15
retq
movl $0x1, %eax
jmp 0x433f2
nop
// File: /workspace/github_cpp_makefile_star2_O3/tomfunkhouser[P]gaps/pkgs/R3Surfels/R3SurfelDatabase.cpp
// Function: gaps::R3SurfelDatabase::CloseFile()
int R3SurfelDatabase::
CloseFile(void)
{
  // Sync file
  if (!SyncFile()) return 0;

  // Close file
  fclose(fp);
  fp = NULL;

  // Reset filename
  if (filename) free(filename);
  filename = NULL;

  // Reset rwaccess
  if (rwaccess) free(rwaccess);
  rwaccess = NULL;

  // Return success
  return 1;
}

// Assembly:
pushq %rbx
movq %rdi, %rbx
movq (%rdi), %rax
callq *0x38(%rax)
testl %eax, %eax
je 0x43452
movq 0x8(%rbx), %rdi
callq 0x134d0
movq $0x0, 0x8(%rbx)
movq 0x10(%rbx), %rdi
testq %rdi, %rdi
je 0x4342d
callq 0x135e0
movq $0x0, 0x10(%rbx)
movq 0x18(%rbx), %rdi
testq %rdi, %rdi
je 0x43443
callq 0x135e0
movq $0x0, 0x18(%rbx)
movl $0x1, %eax
jmp 0x43454
xorl %eax, %eax
popq %rbx
retq
// File: /workspace/github_cpp_makefile_star2_O3/tomfunkhouser[P]gaps/pkgs/R3Surfels/R3SurfelDatabase.cpp
// Function: gaps::R3SurfelDatabase::ReadStream(_IO_FILE*)
int R3SurfelDatabase::
ReadStream(FILE *fp)
{
  // Read header
  unsigned int nblocks = 0;
  if (!ReadFileHeader(fp, nblocks)) return 0;
  
  // Read blocks
  if (!ReadBlockHeader(fp, nblocks, swap_endian)) return 0;

  // Read surfels
  for (int i = 0; i < blocks.NEntries(); i++) {
    R3SurfelBlock *block = blocks.Kth(i);
    if (!InternalReadBlock(block, fp, swap_endian)) return 0;
    block->file_read_count = 1;
  }

  // Return success
  return 1;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r12
pushq %rbx
subq $0x10, %rsp
movq %rsi, %rbx
movq %rdi, %r14
leaq 0xc(%rsp), %rdx
movl $0x0, (%rdx)
movq (%rdi), %rax
callq *0xb0(%rax)
xorl %ebp, %ebp
testl %eax, %eax
je 0x437f9
movl 0xc(%rsp), %edx
movl 0x28(%r14), %ecx
movq (%r14), %rax
movq %r14, %rdi
movq %rbx, %rsi
callq *0xb8(%rax)
testl %eax, %eax
je 0x437f9
cmpl $0x0, 0x4c(%r14)
jle 0x437f4
xorl %r12d, %r12d
movq 0x40(%r14), %rax
movq (%rax,%r12,8), %r15
movl 0x28(%r14), %ecx
movq (%r14), %rax
movq %r14, %rdi
movq %r15, %rsi
movq %rbx, %rdx
callq *0x88(%rax)
testl %eax, %eax
je 0x437ea
movl $0x1, 0xb4(%r15)
incq %r12
movslq 0x4c(%r14), %rcx
cmpq %rcx, %r12
jl 0x437b1
xorl %ebp, %ebp
testl %eax, %eax
setne %bpl
jmp 0x437f9
movl $0x1, %ebp
movl %ebp, %eax
addq $0x10, %rsp
popq %rbx
popq %r12
popq %r14
popq %r15
popq %rbp
retq
// File: /workspace/github_cpp_makefile_star2_O3/tomfunkhouser[P]gaps/pkgs/R3Shapes/R3Frustum.cpp
// Function: gaps::R3Frustum::Corner(int) const
const R3Point R3Frustum::
Corner (RNOctant octant) const
{
  // Return corner point 
  switch (octant) {
  case RN_NNN_OCTANT: return Corner(RN_LO, RN_LO, RN_LO);
  case RN_NNP_OCTANT: return Corner(RN_LO, RN_LO, RN_HI);
  case RN_NPN_OCTANT: return Corner(RN_LO, RN_HI, RN_LO);
  case RN_NPP_OCTANT: return Corner(RN_LO, RN_HI, RN_HI);
  case RN_PNN_OCTANT: return Corner(RN_HI, RN_LO, RN_LO);
  case RN_PNP_OCTANT: return Corner(RN_HI, RN_LO, RN_HI);
  case RN_PPN_OCTANT: return Corner(RN_HI, RN_HI, RN_LO);
  case RN_PPP_OCTANT: return Corner(RN_HI, RN_HI, RN_HI);
  default: RNAbort("Invalid octant for frustum corner"); return R3null_point;
  }
}

// Assembly:
pushq %rbx
movq %rdi, %rbx
cmpl $0x7, %edx
ja 0x6afe6
movl %edx, %eax
leaq 0x7468a(%rip), %rcx     # 0xdf604
movslq (%rcx,%rax,4), %rax
addq %rcx, %rax
jmpq *%rax
movq %rbx, %rdi
xorl %edx, %edx
jmp 0x6af92
movq %rbx, %rdi
movl $0x1, %edx
xorl %ecx, %ecx
jmp 0x6afd9
movq %rbx, %rdi
xorl %edx, %edx
jmp 0x6afd4
movq %rbx, %rdi
xorl %edx, %edx
jmp 0x6afac
movq %rbx, %rdi
movl $0x1, %edx
movl $0x1, %ecx
jmp 0x6afc4
movq %rbx, %rdi
xorl %edx, %edx
jmp 0x6afc2
movq %rbx, %rdi
movl $0x1, %edx
xorl %ecx, %ecx
movl $0x1, %r8d
jmp 0x6afdc
movq %rbx, %rdi
movl $0x1, %edx
movl $0x1, %ecx
xorl %r8d, %r8d
callq 0x6b006
movq %rbx, %rax
popq %rbx
retq
leaq 0x74653(%rip), %rdi     # 0xdf640
xorl %eax, %eax
callq 0xac73e
leaq 0x4ca675(%rip), %rsi    # 0x535670
movq %rbx, %rdi
callq 0x83dd2
jmp 0x6afe1
nop
// File: /workspace/github_cpp_makefile_star2_O3/tomfunkhouser[P]gaps/pkgs/R3Shapes/R3Frustum.cpp
// Function: gaps::R3Frustum::Corner(int, int, int) const
const R3Point R3Frustum::
Corner(int xdir, int ydir, int zdir) const
{
  // Return corner point
  double xsign = (xdir == RN_LO) ? -1 : 1;
  double ysign = (ydir == RN_LO) ? -1 : 1;
  double depth = (zdir == RN_LO) ? Near() : Far();
  R3Point corner = cs.Origin() - cs.Axes().Axis(RN_Z) * depth;
  corner += cs.Axes().Axis(RN_X) * depth * tan(xfov) * xsign;
  corner += cs.Axes().Axis(RN_Y) * depth * tan(yfov) * ysign;
  return corner;
}

// Assembly:
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x60, %rsp
xorl %eax, %eax
testl %r8d, %r8d
setne %al
xorl %r8d, %r8d
cmpl $0x1, %ecx
movl $0x0, %ecx
sbbl %ecx, %ecx
orl $0x1, %ecx
cvtsi2sd %ecx, %xmm0
movsd %xmm0, 0x10(%rsp)
movq %rsi, %r14
cmpl $0x1, %edx
sbbl %r8d, %r8d
movq %rdi, %rbx
orl $0x1, %r8d
xorps %xmm0, %xmm0
cvtsi2sd %r8d, %xmm0
movsd %xmm0, 0x8(%rsp)
movsd 0x138(%rsi,%rax,8), %xmm0
movsd %xmm0, (%rsp)
leaq 0x8(%rsi), %r15
leaq 0x20(%rsi), %r12
addq $0x50, %rsi
leaq 0x18(%rsp), %r13
movq %r13, %rdi
callq 0x851f2
movq %rbx, %rdi
movq %r15, %rsi
movq %r13, %rdx
callq 0x847e3
leaq 0x30(%rsp), %r15
movq %r15, %rdi
movq %r12, %rsi
movsd (%rsp), %xmm0
callq 0x851f2
movsd 0x128(%r14), %xmm0
callq 0x132d0
leaq 0x48(%rsp), %r12
movq %r12, %rdi
movq %r15, %rsi
callq 0x851f2
leaq 0x18(%rsp), %r15
movq %r15, %rdi
movq %r12, %rsi
movsd 0x8(%rsp), %xmm0
callq 0x851f2
movq %rbx, %rdi
movq %r15, %rsi
callq 0x841a4
leaq 0x38(%r14), %rsi
leaq 0x30(%rsp), %r15
movq %r15, %rdi
movsd (%rsp), %xmm0
callq 0x851f2
movsd 0x130(%r14), %xmm0
callq 0x132d0
leaq 0x48(%rsp), %r14
movq %r14, %rdi
movq %r15, %rsi
callq 0x851f2
leaq 0x18(%rsp), %r15
movq %r15, %rdi
movq %r14, %rsi
movsd 0x10(%rsp), %xmm0
callq 0x851f2
movq %rbx, %rdi
movq %r15, %rsi
callq 0x841a4
movq %rbx, %rax
addq $0x60, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
retq
// File: /workspace/github_cpp_makefile_star2_O3/tomfunkhouser[P]gaps/pkgs/R3Shapes/R3Frustum.cpp
// Function: gaps::R3Frustum::BBox() const
const R3Box R3Frustum::
BBox(void) const
{
  // Return bounding box
  R3Box bbox = R3null_box;
  for (int i = 0; i < 2; i++) {
    for (int j = 0; j < 2; j++) {
      for (int k = 0; k < 2; k++) {
        bbox.Union(Corner(i, j, k));
      }
    }
  }
  return bbox;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x28, %rsp
movq %rsi, %r14
movq %rdi, %rbx
leaq 0xc9793(%rip), %rsi     # 0x1349c8
callq 0x6d354
xorl %ebp, %ebp
movb $0x1, %al
leaq 0x10(%rsp), %r15
movl %eax, 0xc(%rsp)
movb $0x1, %al
movl %eax, 0x8(%rsp)
xorl %r12d, %r12d
xorl %r8d, %r8d
movb $0x1, %r13b
movq %r15, %rdi
movq %r14, %rsi
movl %ebp, %edx
movl %r12d, %ecx
callq 0x6b006
movq %rbx, %rdi
movq %r15, %rsi
callq 0x6dd46
movl $0x1, %r8d
testb $0x1, %r13b
movl $0x0, %r13d
jne 0x6b256
movl $0x1, %r12d
testb $0x1, 0x8(%rsp)
movl $0x0, 0x8(%rsp)
jne 0x6b250
movl $0x1, %ebp
testb $0x1, 0xc(%rsp)
movl $0x0, %eax
jne 0x6b243
movq %rbx, %rax
addq $0x28, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq %rax, %r14
movq %rbx, %rdi
callq 0x6e174
movq %r14, %rdi
callq 0x138b0
// File: /workspace/github_cpp_makefile_star2_O3/tomfunkhouser[P]gaps/pkgs/R3Shapes/R3Frustum.cpp
// Function: gaps::R3Frustum::BSphere() const
const R3Sphere R3Frustum::
BSphere(void) const
{
  // Return bounding sphere
  R3Point centroid = Centroid();
  R3Point corner = Corner(RN_HI, RN_HI, RN_HI);
  RNLength radius = R3Distance(centroid, corner);
  return R3Sphere(centroid, radius);
}

// Assembly:
pushq %r15
pushq %r14
pushq %r12
pushq %rbx
subq $0x38, %rsp
movq %rsi, %r14
movq %rdi, %rbx
movq (%rsi), %rax
leaq 0x20(%rsp), %r15
movq %r15, %rdi
callq *0x68(%rax)
leaq 0x8(%rsp), %r12
movq %r12, %rdi
movq %r14, %rsi
movl $0x1, %edx
movl $0x1, %ecx
movl $0x1, %r8d
callq 0x6b006
movq %r15, %rdi
movq %r12, %rsi
callq 0x4ff14
movq %rbx, %rdi
movq %r15, %rsi
callq 0x6bafa
movq %rbx, %rax
addq $0x38, %rsp
popq %rbx
popq %r12
popq %r14
popq %r15
retq
// File: /workspace/github_cpp_makefile_star2_O3/tomfunkhouser[P]gaps/pkgs/R3Shapes/R3Frustum.cpp
// Function: gaps::R3Frustum::Empty()
void R3Frustum::
Empty(void)
{
  // Reset coordinate system
  cs = R3xyz_coordinate_system;

  // Reset fovs
  xfov = 0;
  yfov = 0;

  // Reset near and far dists
  neardist = 0;
  fardist = 0;
  
  // Reset halfspaces
  for (int dir = 0; dir < 2; dir++) {
    for (int dim = 0; dim < 3; dim++) {
      halfspaces[dir][dim] = R3null_halfspace;
    }
  }
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r12
pushq %rbx
movq %rdi, %rbx
addq $0x8, %rdi
leaq 0xc98f8(%rip), %r14     # 0x134c40
movq %r14, %rsi
callq 0x8412a
leaq 0x20(%rbx), %rdi
leaq 0x18(%r14), %rsi
callq 0x84fe2
leaq 0x38(%rbx), %rdi
leaq 0x30(%r14), %rsi
callq 0x84fe2
leaq 0x50(%rbx), %rdi
addq $0x48, %r14
movq %r14, %rsi
callq 0x84fe2
xorps %xmm0, %xmm0
movups %xmm0, 0x128(%rbx)
movups %xmm0, 0x138(%rbx)
addq $0x68, %rbx
movb $0x1, %bpl
xorl %eax, %eax
leaq 0x4c9e25(%rip), %r14    # 0x5351c0
leaq (%rax,%rax,2), %r15
shlq $0x5, %r15
addq %rbx, %r15
movl $0x3, %r12d
movq %r15, %rdi
movq %r14, %rsi
callq 0x84fe2
movsd 0x18(%r14), %xmm0
movsd %xmm0, 0x18(%r15)
addq $0x20, %r15
decq %r12
jne 0x6b3ac
movl $0x1, %eax
testb $0x1, %bpl
movl $0x0, %ebp
jne 0x6b39b
popq %rbx
popq %r12
popq %r14
popq %r15
popq %rbp
retq
nop
// File: /workspace/github_cpp_makefile_star2_O3/tomfunkhouser[P]gaps/pkgs/R3Shapes/R3Frustum.cpp
// Function: gaps::R3Frustum::Transform(gaps::R3Transformation const&)
void R3Frustum::
Transform(const R3Transformation& transformation)
{
  // Assumes rigid transformation
  // xfov, yfov stay same

  // Transform coordinate system
  cs.Transform(transformation);

  // Transform halfspaces
  for (int dir = 0; dir < 2; dir++) {
    for (int dim = 0; dim < 3; dim++) {
      halfspaces[dir][dim].Transform(transformation);
    }
  }
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r12
pushq %rbx
movq %rsi, %rbx
movq %rdi, %r14
addq $0x8, %rdi
callq 0x709ac
addq $0x68, %r14
movb $0x1, %bpl
xorl %eax, %eax
leaq (%rax,%rax,2), %r15
shlq $0x5, %r15
addq %r14, %r15
xorl %r12d, %r12d
leaq (%r15,%r12), %rdi
movq %rbx, %rsi
callq 0x8289a
addq $0x20, %r12
cmpq $0x60, %r12
jne 0x6b414
movl $0x1, %eax
testb $0x1, %bpl
movl $0x0, %ebp
jne 0x6b406
popq %rbx
popq %r12
popq %r14
popq %r15
popq %rbp
retq
nop
// File: /workspace/github_cpp_makefile_star2_O3/tomfunkhouser[P]gaps/pkgs/R3Shapes/R3PlanarGrid.cpp
// Function: gaps::R3PlanarGrid::ReadFile(char const*)
int R3PlanarGrid::
ReadFile(const char *filename)
{
  // Parse input filename extension
  const char *input_extension;
  if (!(input_extension = strrchr(filename, '.'))) {
    RNFail("Input file has no extension (e.g., .pfm).\n");
    return 0;
  }
  
  // Read file of appropriate type
  if (!strncmp(input_extension, ".grd", 4)) return ReadGridFile(filename);
  
  // Should never get here
  RNFail("Unrecognized image file extension");
  return 0;
}

// Assembly:
pushq %r14
pushq %rbx
pushq %rax
movq %rsi, %rbx
movq %rdi, %r14
movq %rsi, %rdi
movl $0x2e, %esi
callq 0x13560
testq %rax, %rax
je 0x754b1
leaq 0x6a534(%rip), %rsi     # 0xdf9cb
movl $0x4, %edx
movq %rax, %rdi
callq 0x13240
testl %eax, %eax
je 0x754c9
leaq 0x6a521(%rip), %rdi     # 0xdf9d0
jmp 0x754b8
leaq 0x6a4e8(%rip), %rdi     # 0xdf9a0
xorl %eax, %eax
callq 0xac81a
xorl %eax, %eax
addq $0x8, %rsp
popq %rbx
popq %r14
retq
movq %r14, %rdi
movq %rbx, %rsi
addq $0x8, %rsp
popq %rbx
popq %r14
jmp 0x754dc
nop
// File: /workspace/github_cpp_makefile_star2_O3/tomfunkhouser[P]gaps/pkgs/R3Shapes/R3PlanarGrid.cpp
// Function: gaps::R3PlanarGrid::ReadGridFile(char const*)
int R3PlanarGrid::
ReadGridFile(const char *filename)
{
  // Open file
  FILE *fp = stdin;
  if (filename) {
    fp = fopen(filename, "rb");
    if (!fp) {
      RNFail("Unable to open file %s", filename);
      return 0;
    }
  }

  // Read file
  int status = ReadGrid(fp);
  if (!status) return 0;

  // Close file
  fclose(fp);

  // Return number of grid values read
  return status;
}

// Assembly:
pushq %r15
pushq %r14
pushq %rbx
movq %rdi, %rbx
testq %rsi, %rsi
je 0x75518
movq %rsi, %r14
leaq 0x67ce2(%rip), %rsi     # 0xdd1d5
movq %r14, %rdi
callq 0x135d0
movq %rax, %r15
testq %rax, %rax
jne 0x75522
leaq 0x6986d(%rip), %rdi     # 0xded77
xorl %ebx, %ebx
movq %r14, %rsi
xorl %eax, %eax
callq 0xac81a
jmp 0x75542
movq 0xbda81(%rip), %rax     # 0x132fa0
movq (%rax), %r15
movq %rbx, %rdi
movq %r15, %rsi
callq 0x7561e
testl %eax, %eax
je 0x75540
movq %r15, %rdi
callq 0x134d0
movl $0x1, %ebx
jmp 0x75542
xorl %ebx, %ebx
movl %ebx, %eax
popq %rbx
popq %r14
popq %r15
retq
// File: /workspace/github_cpp_makefile_star2_O3/tomfunkhouser[P]gaps/pkgs/R3Shapes/R3PlanarGrid.cpp
// Function: gaps::R3PlanarGrid::WriteFile(char const*) const
int R3PlanarGrid::
WriteFile(const char *filename) const
{
  // Parse input filename extension
  const char *input_extension;
  if (!(input_extension = strrchr(filename, '.'))) {
    RNFail("Output file has no extension (e.g., .pfm).\n");
    return 0;
  }
  
  // Write file of appropriate type
  if (!strncmp(input_extension, ".grd", 4)) return WriteGridFile(filename);

  // Should never get here
  RNFail("Unrecognized image file extension");
  return 0;
}

// Assembly:
pushq %r14
pushq %rbx
pushq %rax
movq %rsi, %rbx
movq %rdi, %r14
movq %rsi, %rdi
movl $0x2e, %esi
callq 0x13560
testq %rax, %rax
je 0x75587
leaq 0x6a45e(%rip), %rsi     # 0xdf9cb
movl $0x4, %edx
movq %rax, %rdi
callq 0x13240
testl %eax, %eax
je 0x7559f
leaq 0x6a44b(%rip), %rdi     # 0xdf9d0
jmp 0x7558e
leaq 0x6a464(%rip), %rdi     # 0xdf9f2
xorl %eax, %eax
callq 0xac81a
xorl %eax, %eax
addq $0x8, %rsp
popq %rbx
popq %r14
retq
movq %r14, %rdi
movq %rbx, %rsi
addq $0x8, %rsp
popq %rbx
popq %r14
jmp 0x755b2
nop
// File: /workspace/github_cpp_makefile_star2_O3/tomfunkhouser[P]gaps/pkgs/R3Shapes/R3PlanarGrid.cpp
// Function: gaps::R3PlanarGrid::WriteGridFile(char const*) const
int R3PlanarGrid::
WriteGridFile(const char *filename) const
{
  // Open file
  FILE *fp = stdout;
  if (filename) {
    fp = fopen(filename, "wb");
    if (!fp) {
      RNFail("Unable to open file %s", filename);
      return 0;
    }
  }

  // Write file
  int status = WriteGrid(fp);
  if (!status) return 0;

  // Close file
  fclose(fp);

  // Return number of grid values written
  return status;
}

// Assembly:
pushq %r15
pushq %r14
pushq %rbx
movq %rdi, %rbx
testq %rsi, %rsi
je 0x755ee
movq %rsi, %r14
leaq 0x68a20(%rip), %rsi     # 0xddfe9
movq %r14, %rdi
callq 0x135d0
movq %rax, %r15
testq %rax, %rax
jne 0x755f8
leaq 0x69797(%rip), %rdi     # 0xded77
xorl %ebx, %ebx
movq %r14, %rsi
xorl %eax, %eax
callq 0xac81a
jmp 0x75615
movq 0xbd97b(%rip), %rax     # 0x132f70
movq (%rax), %r15
movq %rbx, %rdi
movq %r15, %rsi
callq 0x75784
testl %eax, %eax
je 0x75613
movl %eax, %ebx
movq %r15, %rdi
callq 0x134d0
jmp 0x75615
xorl %ebx, %ebx
movl %ebx, %eax
popq %rbx
popq %r14
popq %r15
retq
nop
// File: /workspace/github_cpp_makefile_star2_O3/tomfunkhouser[P]gaps/pkgs/R3Shapes/R3PlanarGrid.cpp
// Function: gaps::R3PlanarGrid::ReadGrid(_IO_FILE*)
int R3PlanarGrid::
ReadGrid(FILE *fp)
{
  // Read grid 
  if (!grid.ReadGrid(fp)) return 0;

  // Read plane from file
  RNScalar p[4];
  if (fread(p, sizeof(RNScalar), 4, fp) != 4) {
    RNFail("Unable to read plane from file");
    return 0;
  }

  // Read bounding box from file
  RNScalar b[6];
  if (fread(b, sizeof(RNScalar), 6, fp) != 6) {
    RNFail("Unable to read bounding box from file");
    return 0;
  }

  // Read transformation from file
  RNScalar m[16];
  if (fread(m, sizeof(RNScalar), 16, fp) != 16) {
    RNFail("Unable to read transformation matrix from file");
    return 0;
  }

  // Update variables
  transformation.Reset(R4Matrix(m));
  plane = R3Plane(p);
  bbox.Reset(R3Point(b[0], b[1], b[2]), R3Point(b[3], b[4], b[5]));

  // Return success
  return 1;
}

// Assembly:
pushq %r15
pushq %r14
pushq %rbx
subq $0x170, %rsp            # imm = 0x170
movq %rsi, %r14
movq %rdi, %rbx
addq $0x130, %rdi            # imm = 0x130
callq 0x9a4cc
testl %eax, %eax
je 0x7574f
leaq 0x30(%rsp), %rdi
movl $0x8, %esi
movl $0x4, %edx
movq %r14, %rcx
callq 0x13790
cmpq $0x4, %rax
jne 0x75753
movq %rsp, %rdi
movl $0x8, %esi
movl $0x6, %edx
movq %r14, %rcx
callq 0x13790
cmpq $0x6, %rax
jne 0x7575c
leaq 0xf0(%rsp), %rdi
movl $0x8, %esi
movl $0x10, %edx
movq %r14, %rcx
callq 0x13790
cmpq $0x10, %rax
jne 0x75765
leaq 0x20(%rbx), %r14
leaq 0x70(%rsp), %r15
leaq 0xf0(%rsp), %rsi
movq %r15, %rdi
callq 0x72432
movq %r14, %rdi
movq %r15, %rsi
xorl %edx, %edx
callq 0x7070c
leaq 0x70(%rsp), %r14
leaq 0x30(%rsp), %rsi
movq %r14, %rdi
callq 0x828fc
movq %rbx, %rdi
movq %r14, %rsi
callq 0x84fe2
movsd 0x18(%r14), %xmm0
movsd %xmm0, 0x18(%rbx)
addq $0x200, %rbx            # imm = 0x200
movsd (%rsp), %xmm0
movsd 0x8(%rsp), %xmm1
movsd 0x10(%rsp), %xmm2
leaq 0x70(%rsp), %r14
movq %r14, %rdi
callq 0x83dc2
movsd 0x18(%rsp), %xmm0
movsd 0x20(%rsp), %xmm1
movsd 0x28(%rsp), %xmm2
leaq 0x58(%rsp), %r15
movq %r15, %rdi
callq 0x83dc2
movq %rbx, %rdi
movq %r14, %rsi
movq %r15, %rdx
callq 0x6e11e
movl $0x1, %ebx
jmp 0x75775
xorl %ebx, %ebx
jmp 0x75775
leaq 0x6a2c4(%rip), %rdi     # 0xdfa1e
jmp 0x7576c
leaq 0x6a2da(%rip), %rdi     # 0xdfa3d
jmp 0x7576c
leaq 0x6a2f7(%rip), %rdi     # 0xdfa63
xorl %ebx, %ebx
xorl %eax, %eax
callq 0xac81a
movl %ebx, %eax
addq $0x170, %rsp            # imm = 0x170
popq %rbx
popq %r14
popq %r15
retq
// File: /workspace/github_cpp_makefile_star2_O3/tomfunkhouser[P]gaps/pkgs/R3Shapes/R3PlanarGrid.cpp
// Function: gaps::R3PlanarGrid::WriteGrid(_IO_FILE*) const
int R3PlanarGrid::
WriteGrid(FILE *fp) const
{
  // Write grid 
  if (!grid.WriteGrid(fp)) return 0;

  // Write plane to file
  for (int i = 0; i < 4; i++) {
    RNScalar a = plane[i];
    if (fwrite(&a, sizeof(RNScalar), 1, fp) != 1) {
      RNFail("Unable to write plane to file");
      return 0;
    }
  }

  // Write bounding box to file
  for (int i = 0; i < 2; i++) {
    for (int j = 0; j < 3; j++) {
      RNScalar a = bbox[i][j];
      if (fwrite(&a, sizeof(RNScalar), 1, fp) != 1) {
        RNFail("Unable to write plane to file");
        return 0;
      }
    }
  }

  // Write transformation to file
  const R4Matrix& matrix = transformation.Matrix();
  for (int i = 0; i < 4; i++) {
    for (int j = 0; j < 4; j++) {
      RNScalar a = matrix[i][j];
      if (fwrite(&a, sizeof(RNScalar), 1, fp) != 1) {
        RNFail("Unable to write plane to file");
        return 0;
      }
    }
  }

  // Return success
  return 1;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x18, %rsp
movq %rsi, %rbx
movq %rdi, %r14
addq $0x130, %rdi            # imm = 0x130
callq 0x9a6ee
testl %eax, %eax
je 0x758d3
leaq 0x18(%r14), %r12
xorl %r13d, %r13d
movq %rsp, %r15
leaq (%r14,%r13), %rax
cmpq $0x18, %r13
cmoveq %r12, %rax
movsd (%rax), %xmm0
movsd %xmm0, (%rsp)
movl $0x8, %esi
movl $0x1, %edx
movq %r15, %rdi
movq %rbx, %rcx
callq 0x139a0
cmpq $0x1, %rax
jne 0x758c1
addq $0x8, %r13
cmpq $0x20, %r13
jne 0x757b6
leaq 0x200(%r14), %rax
movb $0x1, %bpl
leaq 0x20(%rax), %r13
addq $0x8, %rax
movq %rsp, %r15
movq %rax, 0x10(%rsp)
movq %r13, 0x8(%rsp)
testb $0x1, %bpl
cmovneq %rax, %r13
xorl %r12d, %r12d
movsd (%r13,%r12,8), %xmm0
movsd %xmm0, (%rsp)
movl $0x8, %esi
movl $0x1, %edx
movq %r15, %rdi
movq %rbx, %rcx
callq 0x139a0
cmpq $0x1, %rax
jne 0x758c1
incq %r12
cmpq $0x3, %r12
jne 0x7581e
testb $0x1, %bpl
movl $0x0, %ebp
movq 0x10(%rsp), %rax
movq 0x8(%rsp), %r13
jne 0x75813
addq $0x28, %r14
xorl %r13d, %r13d
movq %rsp, %r15
xorl %r12d, %r12d
xorl %ebp, %ebp
movsd (%r14,%rbp,8), %xmm0
movsd %xmm0, (%rsp)
movl $0x8, %esi
movl $0x1, %edx
movq %r15, %rdi
movq %rbx, %rcx
callq 0x139a0
cmpq $0x1, %rax
jne 0x758e6
incq %rbp
cmpq $0x4, %rbp
jne 0x75872
cmpq $0x3, %r13
leaq 0x1(%r13), %rax
setae %r12b
addq $0x20, %r14
movl $0x1, %ebp
movq %rax, %r13
cmpq $0x4, %rax
jne 0x75870
jmp 0x758d5
leaq 0x6a1ca(%rip), %rdi     # 0xdfa92
xorl %ebp, %ebp
xorl %eax, %eax
callq 0xac81a
jmp 0x758d5
xorl %ebp, %ebp
movl %ebp, %eax
addq $0x18, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
leaq 0x6a1a5(%rip), %rdi     # 0xdfa92
xorl %eax, %eax
callq 0xac81a
movzbl %r12b, %ebp
andl $0x1, %ebp
jmp 0x758d5
nop
// File: /workspace/github_cpp_makefile_star2_O3/tomfunkhouser[P]gaps/pkgs/R2Shapes/R2PixelDatabase.cpp
// Function: gaps::R2PixelDatabase::FindImage(char const*, gaps::R2Image*) const
int R2PixelDatabase::
FindImage(const char *key, R2Image *image) const
{
  // Find entry
  R2PixelDatabaseEntry entry;
  if (!map.Find(key, &entry)) return FALSE;

  // Read image
  if (image) {
    // Seek to start of entry
    RNFileSeek(fp, entry.seek, RN_FILE_SEEK_SET);
  
    // Read entry
    if (!image->ReadPNGStream(fp)) {
      RNFail("Error reading %s from pixel database\n", key);
      return FALSE;
    }
  }

  // Return success
  return TRUE;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x28, %rsp
movq %rdx, %r14
movq %rsi, %rbx
movq %rdi, %r15
leaq 0x8(%rsp), %r12
leaq 0x7(%rsp), %rdx
movq %r12, %rdi
callq 0x9c6a2
movq 0x40(%r15), %rdi
movq %r12, %rsi
callq 0x9c77c
movq %rax, %r12
movq 0x40(%r15), %rbp
addq $0x8, %rbp
cmpq %rbp, %rax
je 0x9b355
movq 0xc8(%r12), %r13
jmp 0x9b358
xorl %r13d, %r13d
leaq 0x18(%rsp), %rax
movq -0x10(%rax), %rdi
cmpq %rax, %rdi
je 0x9b373
movq 0x18(%rsp), %rsi
incq %rsi
callq 0x134f0
cmpq %rbp, %r12
je 0x9b3b1
movl $0x1, %ebp
testq %r14, %r14
je 0x9b3b3
movq 0x8(%r15), %rdi
movq %r13, %rsi
xorl %edx, %edx
callq 0xabc5a
movq 0x8(%r15), %rsi
movq %r14, %rdi
callq 0xa5c84
testl %eax, %eax
jne 0x9b3b3
leaq 0x4ac69(%rip), %rdi     # 0xe6010
movq %rbx, %rsi
xorl %eax, %eax
callq 0xac81a
xorl %ebp, %ebp
movl %ebp, %eax
addq $0x28, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq %rax, %rbx
leaq 0x18(%rsp), %rax
movq -0x10(%rax), %rdi
cmpq %rax, %rdi
je 0x9b3e2
movq 0x18(%rsp), %rsi
incq %rsi
callq 0x134f0
movq %rbx, %rdi
callq 0x138b0
// File: /workspace/github_cpp_makefile_star2_O3/tomfunkhouser[P]gaps/pkgs/R2Shapes/R2PixelDatabase.cpp
// Function: gaps::R2PixelDatabase::GetFormat(char const*) const
int R2PixelDatabase::
GetFormat(const char *key) const
{
  // Find entry
  R2PixelDatabaseEntry entry;
  if (!map.Find(key, &entry)) return -1;
  return entry.format;
}

// Assembly:
pushq %r14
pushq %rbx
subq $0x28, %rsp
movq %rdi, %rbx
leaq 0x8(%rsp), %r14
leaq 0x7(%rsp), %rdx
movq %r14, %rdi
callq 0x9c6a2
movq 0x40(%rbx), %rdi
movq %r14, %rsi
callq 0x9c77c
movq 0x40(%rbx), %rcx
addq $0x8, %rcx
cmpq %rcx, %rax
je 0x9b5fb
movl 0xc0(%rax), %ebx
jmp 0x9b600
movl $0xffffffff, %ebx       # imm = 0xFFFFFFFF
leaq 0x18(%rsp), %rax
movq -0x10(%rax), %rdi
cmpq %rax, %rdi
je 0x9b61b
movq 0x18(%rsp), %rsi
incq %rsi
callq 0x134f0
movl %ebx, %eax
addq $0x28, %rsp
popq %rbx
popq %r14
retq
movq %rax, %rbx
leaq 0x18(%rsp), %rax
movq -0x10(%rax), %rdi
cmpq %rax, %rdi
je 0x9b643
movq 0x18(%rsp), %rsi
incq %rsi
callq 0x134f0
movq %rbx, %rdi
callq 0x138b0
nop
// File: /workspace/github_cpp_makefile_star2_O3/tomfunkhouser[P]gaps/pkgs/R2Shapes/R2PixelDatabase.cpp
// Function: gaps::R2PixelDatabase::InsertImage(char const*, gaps::R2Image const&)
int R2PixelDatabase::
InsertImage(const char *key, const R2Image& image)
{
  // Seek to end of entries
  unsigned long long seek = entries_seek;
  RNFileSeek(fp, seek, RN_FILE_SEEK_SET);

  // Write pixels to file
  if (!image.WritePNGStream(fp)) return FALSE;

  // Update entries seek
  entries_seek = RNFileTell(fp);
  unsigned int size = entries_seek - seek;
  
  // Insert entry into map
  R2PixelDatabaseEntry entry(key, R2_PIXEL_DATABASE_3_8_PNG_FORMAT, size, seek);
  map.Insert(key, entry);

  // Insert key
  keys.push_back(key);
  
  // Increment number of entries
  entries_count++;

  // Return success
  return 1;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r12
pushq %rbx
subq $0x180, %rsp            # imm = 0x180
movq %rdx, %r12
movq %rsi, %r14
movq %rdi, %rbx
movq 0x8(%rdi), %rdi
movq 0x38(%rbx), %r15
xorl %ebp, %ebp
movq %r15, %rsi
xorl %edx, %edx
callq 0xabc5a
movq 0x8(%rbx), %rsi
movq %r12, %rdi
callq 0xa5f54
testl %eax, %eax
je 0x9b7b4
movq 0x8(%rbx), %rdi
callq 0xabc6b
movq %rax, 0x38(%rbx)
subl %r15d, %eax
movl $0x0, 0xb0(%rsp)
movl %eax, 0xb4(%rsp)
movq %r15, 0xb8(%rsp)
xorps %xmm0, %xmm0
movhps 0x41a88(%rip), %xmm0    # xmm0 = xmm0[0,1],mem[0,1]
movups %xmm0, 0xc0(%rsp)
movabsq $0x3ff0000000000000, %rax # imm = 0x3FF0000000000000
movq %rax, 0xd0(%rsp)
movb $0x0, 0x30(%rsp)
testq %r14, %r14
je 0x9b6f6
leaq 0x30(%rsp), %rdi
movl $0x7f, %edx
movq %r14, %rsi
callq 0x13280
movb $0x0, 0xaf(%rsp)
leaq 0x10(%rsp), %rdi
leaq 0xf(%rsp), %rdx
movq %r14, %rsi
callq 0x9c6a2
leaq 0xd8(%rsp), %rdi
leaq 0x30(%rsp), %rsi
movl $0xa8, %edx
callq 0x133f0
movq 0x40(%rbx), %rdi
leaq 0x10(%rsp), %rsi
callq 0x9c9a2
leaq 0xd8(%rsp), %rsi
movl $0xa8, %edx
movq %rax, %rdi
callq 0x133f0
leaq 0x20(%rsp), %rax
movq -0x10(%rax), %rdi
cmpq %rax, %rdi
je 0x9b765
movq 0x20(%rsp), %rsi
incq %rsi
callq 0x134f0
leaq 0xd8(%rsp), %rdi
leaq 0xf(%rsp), %rdx
movq %r14, %rsi
callq 0x9c6a2
leaq 0x48(%rbx), %rdi
leaq 0xd8(%rsp), %rsi
callq 0x9d416
leaq 0xe8(%rsp), %rax
movq -0x10(%rax), %rdi
cmpq %rax, %rdi
je 0x9b7ac
movq 0xe8(%rsp), %rsi
incq %rsi
callq 0x134f0
incl 0x34(%rbx)
movl $0x1, %ebp
movl %ebp, %eax
addq $0x180, %rsp            # imm = 0x180
popq %rbx
popq %r12
popq %r14
popq %r15
popq %rbp
retq
movq %rax, %rbx
leaq 0xe8(%rsp), %rax
movq -0x10(%rax), %rdi
cmpq %rax, %rdi
je 0x9b809
movq 0xe8(%rsp), %rsi
jmp 0x9b7fc
jmp 0x9b806
movq %rax, %rbx
leaq 0x20(%rsp), %rax
movq -0x10(%rax), %rdi
cmpq %rax, %rdi
je 0x9b809
movq 0x20(%rsp), %rsi
incq %rsi
callq 0x134f0
jmp 0x9b809
movq %rax, %rbx
movq %rbx, %rdi
callq 0x138b0
nop
// File: /workspace/github_cpp_makefile_star2_O3/tomfunkhouser[P]gaps/pkgs/R2Shapes/R2PixelDatabase.cpp
// Function: gaps::R2PixelDatabase::Remove(char const*)
int R2PixelDatabase::
Remove(const char *key)
{
  // Remove entry from map
  map.Remove(key);

  // Remove key
  std::vector<std::string>::iterator it = std::find(keys.begin(), keys.end(), key);
  if (it != keys.end()) keys.erase(it);
  
  // Leaves hole in file where pixels were :(

  // Decrement number of entries
  entries_count--;

  // Return success
  return 1;
}

// Assembly:
pushq %r14
pushq %rbx
subq $0x38, %rsp
movq %rdi, %rbx
movq %rsi, 0x10(%rsp)
leaq 0x18(%rsp), %r14
leaq 0xf(%rsp), %rdx
movq %r14, %rdi
callq 0x9c6a2
leaq 0x40(%rbx), %rdi
movq %r14, %rsi
callq 0x9c6e0
leaq 0x28(%rsp), %rax
movq -0x10(%rax), %rdi
cmpq %rax, %rdi
je 0x9bb1a
movq 0x28(%rsp), %rsi
incq %rsi
callq 0x134f0
movq 0x48(%rbx), %rdi
movq 0x50(%rbx), %rsi
leaq 0x10(%rsp), %rdx
callq 0x9d6c0
cmpq 0x50(%rbx), %rax
je 0x9bb3e
leaq 0x48(%rbx), %rdi
movq %rax, %rsi
callq 0x9d7b2
decl 0x34(%rbx)
movl $0x1, %eax
addq $0x38, %rsp
popq %rbx
popq %r14
retq
movq %rax, %rbx
leaq 0x28(%rsp), %rax
movq -0x10(%rax), %rdi
cmpq %rax, %rdi
je 0x9bb6c
movq 0x28(%rsp), %rsi
incq %rsi
callq 0x134f0
movq %rbx, %rdi
callq 0x138b0
// File: /workspace/github_cpp_makefile_star2_O3/tomfunkhouser[P]gaps/pkgs/R2Shapes/R2PixelDatabase.cpp
// Function: gaps::R2PixelDatabase::OpenFile(char const*, char const*)
int R2PixelDatabase::
OpenFile(const char *filename, const char *rwaccess)
{
  // Remember file name
  if (this->filename) free(this->filename);
  this->filename = RNStrdup(filename);

  // Parse rwaccess
  if (this->rwaccess) free(this->rwaccess);
  if (!rwaccess) this->rwaccess = RNStrdup("w+b");
  else if (strstr(rwaccess, "w")) this->rwaccess = RNStrdup("w+b");
  else if (strstr(rwaccess, "+")) this->rwaccess = RNStrdup("r+b");
  else this->rwaccess = RNStrdup("rb"); 

  // Open file
  fp = fopen(filename, this->rwaccess);
  if (!fp) {
    RNFail("Unable to open database file %s with rwaccess %s\n", filename, rwaccess);
    return 0;
  }

  // Check if file is new
  if (!strcmp(this->rwaccess, "w+b")) {
    // Just checking ...
    assert(entries_count == 0);

    // File is new -- write header
    if (!WriteHeader(fp, 0)) return 0;

    // Update entries info
    entries_seek = RNFileTell(fp);
  }
  else {
    // Read header
    if (!ReadHeader(fp)) return 0;

    // Read entries
    if (!ReadEntries(fp, swap_endian)) return 0;
  }

  // Return success
  return 1;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r12
pushq %rbx
movq %rdx, %r14
movq %rsi, %r15
movq %rdi, %rbx
movq 0x18(%rdi), %rdi
testq %rdi, %rdi
je 0x9bb93
callq 0x135e0
movq %r15, %rdi
callq 0xac67b
movq %rax, 0x18(%rbx)
movq 0x20(%rbx), %rdi
testq %rdi, %rdi
je 0x9bbad
callq 0x135e0
leaq 0x42ec1(%rip), %r12     # 0xdea75
testq %r14, %r14
je 0x9bbed
movq %r14, %rdi
movl $0x77, %esi
callq 0x131d0
testq %rax, %rax
jne 0x9bbed
movq %r14, %rdi
movl $0x2b, %esi
callq 0x131d0
testq %rax, %rax
leaq 0x415f3(%rip), %rax     # 0xdd1d5
leaq 0x42e90(%rip), %r12     # 0xdea79
cmoveq %rax, %r12
movq %r12, %rdi
callq 0xac67b
movq %rax, 0x20(%rbx)
movq %r15, %rdi
movq %rax, %rsi
callq 0x135d0
movq %rax, 0x8(%rbx)
testq %rax, %rax
je 0x9bc4c
movq %rax, %r12
movq 0x20(%rbx), %rdi
leaq 0x42e5a(%rip), %rsi     # 0xdea75
callq 0x13710
movq (%rbx), %rcx
testl %eax, %eax
je 0x9bc64
movq %rbx, %rdi
movq %r12, %rsi
callq *0x68(%rcx)
xorl %ebp, %ebp
testl %eax, %eax
je 0x9bc87
movq (%rbx), %rax
movq 0x8(%rbx), %rsi
movl 0x30(%rbx), %edx
movq %rbx, %rdi
callq *0x78(%rax)
testl %eax, %eax
jne 0x9bc82
jmp 0x9bc87
leaq 0x42e2a(%rip), %rdi     # 0xdea7d
xorl %ebp, %ebp
movq %r15, %rsi
movq %r14, %rdx
xorl %eax, %eax
callq 0xac81a
jmp 0x9bc87
xorl %ebp, %ebp
movq %rbx, %rdi
movq %r12, %rsi
xorl %edx, %edx
callq *0x70(%rcx)
testl %eax, %eax
je 0x9bc87
movq 0x8(%rbx), %rdi
callq 0xabc6b
movq %rax, 0x38(%rbx)
movl $0x1, %ebp
movl %ebp, %eax
popq %rbx
popq %r12
popq %r14
popq %r15
popq %rbp
retq
// File: /workspace/github_cpp_makefile_star2_O3/tomfunkhouser[P]gaps/pkgs/R2Shapes/R2PixelDatabase.cpp
// Function: gaps::R2PixelDatabase::CloseFile()
int R2PixelDatabase::
CloseFile(void)
{
  // Check if writing file
  if (strcmp(rwaccess, "rb")) {
    // Write entries
    if (!WriteEntries(fp, swap_endian)) return 0;

    // Write header again (now that the seek values have been filled in)
    if (!WriteHeader(fp, swap_endian)) return 0;
  }

  // Close file
  fclose(fp);
  fp = NULL;
  
  // Reset filename
  if (filename) free(filename);
  filename = NULL;

  // Reset rwaccess
  if (rwaccess) free(rwaccess);
  rwaccess = NULL;

  // Return success
  return 1;
}

// Assembly:
pushq %rbp
pushq %rbx
pushq %rax
movq %rdi, %rbx
movq 0x20(%rdi), %rax
cmpb $0x72, (%rax)
jne 0x9bcad
cmpb $0x62, 0x1(%rax)
jne 0x9bcad
cmpb $0x0, 0x2(%rax)
je 0x9bcda
movq (%rbx), %rax
movq 0x8(%rbx), %rsi
movl 0x30(%rbx), %edx
movq %rbx, %rdi
callq *0x80(%rax)
xorl %ebp, %ebp
testl %eax, %eax
je 0x9bd1c
movq (%rbx), %rax
movq 0x8(%rbx), %rsi
movl 0x30(%rbx), %edx
movq %rbx, %rdi
callq *0x70(%rax)
testl %eax, %eax
je 0x9bd1c
movq 0x8(%rbx), %rdi
callq 0x134d0
movq $0x0, 0x8(%rbx)
movq 0x18(%rbx), %rdi
testq %rdi, %rdi
je 0x9bcf9
callq 0x135e0
movq $0x0, 0x18(%rbx)
movq 0x20(%rbx), %rdi
testq %rdi, %rdi
je 0x9bd0f
callq 0x135e0
movq $0x0, 0x20(%rbx)
movl $0x1, %ebp
movl %ebp, %eax
addq $0x8, %rsp
popq %rbx
popq %rbp
retq
nop
// File: /workspace/github_cpp_makefile_star2_O3/tomfunkhouser[P]gaps/pkgs/R2Shapes/R2PixelDatabase.cpp
// Function: gaps::R2PixelDatabase::OpenStream(_IO_FILE*, char const*)
int R2PixelDatabase::
OpenStream(FILE *fp, const char *rwaccess)
{
  // Set dummy file name
  if (this->filename) free(this->filename);
  this->filename = RNStrdup("stream");

  // Parse rwaccess
  if (this->rwaccess) free(this->rwaccess);
  if (!rwaccess) this->rwaccess = RNStrdup("w+b");
  else if (strstr(rwaccess, "w")) this->rwaccess = RNStrdup("w+b");
  else if (strstr(rwaccess, "+")) this->rwaccess = RNStrdup("r+b");
  else this->rwaccess = RNStrdup("rb"); 

  // Check if file is new
  if (!strcmp(this->rwaccess, "w+b")) {
    // Just checking ...
    assert(entries_count == 0);

    // File is new -- write header
    if (!WriteHeader(fp, 0)) return 0;

    // Update entries info
    entries_seek = RNFileTell(fp);
  }
  else {
    // Read header
    if (!ReadHeader(fp)) return 0;

    // Read entries
    if (!ReadEntries(fp, swap_endian)) return 0;
  }

  // Remember file
  this->fp = fp;

  // Return success
  return 1;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r12
pushq %rbx
movq %rdx, %r15
movq %rsi, %rbx
movq %rdi, %r14
movq 0x18(%rdi), %rdi
testq %rdi, %rdi
je 0x9bd45
callq 0x135e0
leaq 0x4d17b(%rip), %rdi     # 0xe8ec7
callq 0xac67b
movq %rax, 0x18(%r14)
movq 0x20(%r14), %rdi
testq %rdi, %rdi
je 0x9bd63
callq 0x135e0
leaq 0x42d0b(%rip), %r12     # 0xdea75
testq %r15, %r15
je 0x9bda3
movq %r15, %rdi
movl $0x77, %esi
callq 0x131d0
testq %rax, %rax
jne 0x9bda3
movq %r15, %rdi
movl $0x2b, %esi
callq 0x131d0
testq %rax, %rax
leaq 0x4143d(%rip), %rax     # 0xdd1d5
leaq 0x42cda(%rip), %r12     # 0xdea79
cmoveq %rax, %r12
movq %r12, %rdi
callq 0xac67b
movq %rax, 0x20(%r14)
leaq 0x42cbf(%rip), %rsi     # 0xdea75
movq %rax, %rdi
callq 0x13710
movq (%r14), %rcx
testl %eax, %eax
je 0x9bdea
movq %r14, %rdi
movq %rbx, %rsi
callq *0x68(%rcx)
xorl %ebp, %ebp
testl %eax, %eax
je 0x9be10
movl 0x30(%r14), %edx
movq (%r14), %rax
movq %r14, %rdi
movq %rbx, %rsi
callq *0x78(%rax)
testl %eax, %eax
jne 0x9be07
jmp 0x9be10
xorl %ebp, %ebp
movq %r14, %rdi
movq %rbx, %rsi
xorl %edx, %edx
callq *0x70(%rcx)
testl %eax, %eax
je 0x9be10
movq %rbx, %rdi
callq 0xabc6b
movq %rax, 0x38(%r14)
movq %rbx, 0x8(%r14)
movl $0x1, %ebp
movl %ebp, %eax
popq %rbx
popq %r12
popq %r14
popq %r15
popq %rbp
retq
nop