LLM4Binary/decompile-bench-makefile huggingface dataset:
// File: /workspace/github_cpp_makefile_star2_O1/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 0x42b2e
movq %rsi, %r12
movl 0x8(%rsi), %r13d
testl %r13d, %r13d
je 0x42b2e
movl %ecx, %ebx
movq %rdx, %r14
movq %rdi, %r15
movq 0x18(%rdi), %rdi
movl $0x2b, %esi
callq 0x131d0
testq %rax, %rax
je 0x42ae3
movq 0xa8(%r12), %rsi
testq %rsi, %rsi
je 0x42ab5
cmpl 0xb0(%r12), %r13d
jbe 0x42af5
movq %r14, %rdi
xorl %esi, %esi
movl $0x2, %edx
callq 0xad14e
movq %r14, %rdi
callq 0xad15f
movq %rax, 0xa8(%r12)
movl 0x8(%r12), %eax
movl %eax, 0xb0(%r12)
jmp 0x42aff
leaq 0x9cecc(%rip), %rdi     # 0xdf9b6
xorl %ebp, %ebp
xorl %eax, %eax
callq 0xaddb2
jmp 0x42b2e
movq %r14, %rdi
xorl %edx, %edx
callq 0xad14e
movq (%r12), %rdx
movl 0x8(%r12), %ecx
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_O1/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 0xaaf34
cmpl $0x0, 0x4c(%rbx)
jle 0x4345b
xorl %r15d, %r15d
movq %rsp, %r14
movq 0x40(%rbx), %rax
movq (%rax,%r15,8), %rsi
testb $0x2, 0x89(%rsi)
je 0x4344f
movl 0xc(%rsp), %edx
movq %r14, %rdi
callq 0xaafca
incq %r15
movslq 0x4c(%rbx), %rax
cmpq %rax, %r15
jl 0x43432
movl 0xc(%rsp), %r14d
testl %r14d, %r14d
jle 0x434ae
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)
testq %r14, %r14
je 0x434a1
movq %r14, %rdi
callq 0x2ce2e
movl $0xc8, %esi
movq %r14, %rdi
callq 0x134f0
incq %r15
movslq 0xc(%rsp), %r14
cmpq %r14, %r15
jl 0x43468
movq %rsp, %rdi
callq 0xaaf9e
movl %r14d, %eax
addq $0x10, %rsp
popq %rbx
popq %r14
popq %r15
retq
jmp 0x434c5
movq %rax, %rbx
movq %rsp, %rdi
callq 0xaaf9e
movq %rbx, %rdi
callq 0x138b0
// File: /workspace/github_cpp_makefile_star2_O1/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 0x434fb
callq 0x135e0
movq %r15, %rdi
callq 0xadc0f
movq %rax, 0x10(%rbx)
movq 0x18(%rbx), %rdi
testq %rdi, %rdi
je 0x43515
callq 0x135e0
leaq 0x9c559(%rip), %r12     # 0xdfa75
testq %r14, %r14
je 0x43555
movq %r14, %rdi
movl $0x77, %esi
callq 0x131d0
testq %rax, %rax
jne 0x43555
movq %r14, %rdi
movl $0x2b, %esi
callq 0x131d0
testq %rax, %rax
leaq 0x9ac93(%rip), %rax     # 0xde1dd
leaq 0x9c528(%rip), %r12     # 0xdfa79
cmoveq %rax, %r12
movq %r12, %rdi
callq 0xadc0f
movq %rax, 0x18(%rbx)
movq %r15, %rdi
movq %rax, %rsi
callq 0x135d0
movq %rax, 0x8(%rbx)
testq %rax, %rax
je 0x435ee
movq %rax, %r12
movq 0x18(%rbx), %rdi
leaq 0x9c4f2(%rip), %rsi     # 0xdfa75
callq 0x13710
testl %eax, %eax
je 0x43606
leaq 0xc(%rsp), %rdx
movl $0x0, (%rdx)
movq (%rbx), %rax
movq %rbx, %rdi
movq %r12, %rsi
callq *0xb0(%rax)
testl %eax, %eax
jne 0x435bb
movq 0x8(%rbx), %rdi
callq 0x134d0
movq $0x0, 0x8(%rbx)
movq (%rbx), %rax
movq 0x8(%rbx), %rsi
movl 0xc(%rsp), %edx
movl 0x28(%rbx), %ecx
movq %rbx, %rdi
callq *0xb8(%rax)
testl %eax, %eax
jne 0x435e7
movq 0x8(%rbx), %rdi
callq 0x134d0
movq $0x0, 0x8(%rbx)
movl $0x1, %ebp
jmp 0x43633
leaq 0x9c488(%rip), %rdi     # 0xdfa7d
xorl %ebp, %ebp
movq %r15, %rsi
movq %r14, %rdx
xorl %eax, %eax
callq 0xaddb2
jmp 0x43633
movq (%rbx), %rax
movq %rbx, %rdi
movq %r12, %rsi
xorl %edx, %edx
callq *0xc0(%rax)
movl $0x1, %ebp
testl %eax, %eax
jne 0x43633
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
// File: /workspace/github_cpp_makefile_star2_O1/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 %rbp
pushq %r15
pushq %r14
pushq %rbx
pushq %rax
movq %rdi, %rbx
movq 0x18(%rdi), %rdi
leaq 0x9ab86(%rip), %rsi     # 0xde1dd
callq 0x13710
testl %eax, %eax
je 0x436b7
cmpl $0x0, 0x4c(%rbx)
setg %bpl
jle 0x436cb
xorl %r15d, %r15d
movq 0x40(%rbx), %rax
movq (%rax,%r15,8), %r14
movq %r14, %rdi
callq 0x2d7c0
testl %eax, %eax
je 0x436a5
movq (%rbx), %rax
movq 0x8(%rbx), %rdx
movl 0x28(%rbx), %ecx
movq %rbx, %rdi
movq %r14, %rsi
callq *0x98(%rax)
testl %eax, %eax
je 0x436c1
movq %r14, %rdi
xorl %esi, %esi
callq 0x2d7ce
incq %r15
movslq 0x4c(%rbx), %rax
cmpq %rax, %r15
setl %bpl
jl 0x4366d
jmp 0x436cb
movl $0x1, %eax
jmp 0x4378e
testb $0x1, %bpl
jne 0x4378c
movl 0x4c(%rbx), %eax
cmpl 0x38(%rbx), %eax
jbe 0x43757
movl %eax, 0x38(%rbx)
movq $0x0, 0x30(%rbx)
testl %eax, %eax
jle 0x43733
movq 0x30(%rbx), %rsi
movq 0x40(%rbx), %rcx
movl 0x20(%rbx), %edx
addl $-0x3, %edx
xorl %edi, %edi
leaq 0x9c3ef(%rip), %r8      # 0xdfaec
movl $0x10, %r9d
cmpl $0x3, %edx
ja 0x4370c
movl (%r8,%rdx,4), %r9d
movq (%rcx,%rdi,8), %r10
imull 0xb0(%r10), %r9d
addq 0xa8(%r10), %r9
cmpq %rsi, %r9
jbe 0x4372b
movq %r9, 0x30(%rbx)
movq %r9, %rsi
incq %rdi
cmpq %rdi, %rax
jne 0x436fd
cmpq $0x0, 0x30(%rbx)
jne 0x43757
movq 0x8(%rbx), %rdi
xorl %esi, %esi
movl $0x2, %edx
callq 0xad14e
movq 0x8(%rbx), %rdi
callq 0xad15f
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 0x4378c
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 0x4378e
xorl %eax, %eax
addq $0x8, %rsp
popq %rbx
popq %r14
popq %r15
popq %rbp
retq
nop
// File: /workspace/github_cpp_makefile_star2_O1/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 0x437ec
movq 0x8(%rbx), %rdi
callq 0x134d0
movq $0x0, 0x8(%rbx)
movq 0x10(%rbx), %rdi
testq %rdi, %rdi
je 0x437c7
callq 0x135e0
movq $0x0, 0x10(%rbx)
movq 0x18(%rbx), %rdi
testq %rdi, %rdi
je 0x437dd
callq 0x135e0
movq $0x0, 0x18(%rbx)
movl $0x1, %eax
jmp 0x437ee
xorl %eax, %eax
popq %rbx
retq
// File: /workspace/github_cpp_makefile_star2_O1/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 0x43b8e
movl 0xc(%rsp), %edx
movl 0x28(%r14), %ecx
movq (%r14), %rax
movq %r14, %rdi
movq %rbx, %rsi
callq *0xb8(%rax)
testl %eax, %eax
je 0x43b8e
cmpl $0x0, 0x4c(%r14)
setle %bpl
jle 0x43b8a
movq 0x40(%r14), %rax
movq (%rax), %r15
movl 0x28(%r14), %ecx
movq (%r14), %rax
movq %r14, %rdi
movq %r15, %rsi
movq %rbx, %rdx
callq *0x88(%rax)
testl %eax, %eax
je 0x43b8a
movl $0x1, %r12d
movl $0x1, 0xb4(%r15)
movslq 0x4c(%r14), %rax
cmpq %rax, %r12
setge %bpl
jge 0x43b8a
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)
incq %r12
testl %eax, %eax
jne 0x43b4d
movzbl %bpl, %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_O1/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 0x6bc40
movl %edx, %eax
leaq 0x74a38(%rip), %rcx     # 0xe060c
movslq (%rcx,%rax,4), %rax
addq %rcx, %rax
jmpq *%rax
movq %rbx, %rdi
xorl %edx, %edx
jmp 0x6bbec
movq %rbx, %rdi
movl $0x1, %edx
xorl %ecx, %ecx
jmp 0x6bc33
movq %rbx, %rdi
xorl %edx, %edx
jmp 0x6bc2e
movq %rbx, %rdi
xorl %edx, %edx
jmp 0x6bc06
movq %rbx, %rdi
movl $0x1, %edx
movl $0x1, %ecx
jmp 0x6bc1e
movq %rbx, %rdi
xorl %edx, %edx
jmp 0x6bc1c
movq %rbx, %rdi
movl $0x1, %edx
xorl %ecx, %ecx
movl $0x1, %r8d
jmp 0x6bc36
movq %rbx, %rdi
movl $0x1, %edx
movl $0x1, %ecx
xorl %r8d, %r8d
callq 0x6bc60
movq %rbx, %rax
popq %rbx
retq
leaq 0x74a01(%rip), %rdi     # 0xe0648
xorl %eax, %eax
callq 0xadcd6
leaq 0x4caa1b(%rip), %rsi    # 0x536670
movq %rbx, %rdi
callq 0x84d8e
jmp 0x6bc3b
nop
// File: /workspace/github_cpp_makefile_star2_O1/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 0x861e6
movq %rbx, %rdi
movq %r15, %rsi
movq %r13, %rdx
callq 0x857a5
leaq 0x30(%rsp), %r15
movq %r15, %rdi
movq %r12, %rsi
movsd (%rsp), %xmm0
callq 0x861e6
movsd 0x128(%r14), %xmm0
callq 0x132d0
leaq 0x48(%rsp), %r12
movq %r12, %rdi
movq %r15, %rsi
callq 0x861e6
leaq 0x18(%rsp), %r15
movq %r15, %rdi
movq %r12, %rsi
movsd 0x8(%rsp), %xmm0
callq 0x861e6
movq %rbx, %rdi
movq %r15, %rsi
callq 0x85166
leaq 0x38(%r14), %rsi
leaq 0x30(%rsp), %r15
movq %r15, %rdi
movsd (%rsp), %xmm0
callq 0x861e6
movsd 0x130(%r14), %xmm0
callq 0x132d0
leaq 0x48(%rsp), %r14
movq %r14, %rdi
movq %r15, %rsi
callq 0x861e6
leaq 0x18(%rsp), %r15
movq %r15, %rdi
movq %r14, %rsi
movsd 0x10(%rsp), %xmm0
callq 0x861e6
movq %rbx, %rdi
movq %r15, %rsi
callq 0x85166
movq %rbx, %rax
addq $0x60, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
retq
// File: /workspace/github_cpp_makefile_star2_O1/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 $0x18, %rsp
movq %rsi, %r14
movq %rdi, %rbx
leaq 0xc9b39(%rip), %rsi     # 0x1359c8
callq 0x6df88
xorl %r12d, %r12d
movq %rsp, %r15
xorl %r13d, %r13d
xorl %ebp, %ebp
movq %r15, %rdi
movq %r14, %rsi
movl %r12d, %edx
movl %r13d, %ecx
movl %ebp, %r8d
callq 0x6bc60
movq %rbx, %rdi
movq %r15, %rsi
callq 0x6e9a6
incl %ebp
cmpl $0x1, %ebp
je 0x6be9f
leal 0x1(%r13), %eax
testl %r13d, %r13d
movl %eax, %r13d
je 0x6be9d
leal 0x1(%r12), %eax
testl %r12d, %r12d
movl %eax, %r12d
je 0x6be9a
movq %rbx, %rax
addq $0x18, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq %rax, %r14
movq %rbx, %rdi
callq 0x6ede0
movq %r14, %rdi
callq 0x138b0
nop
// File: /workspace/github_cpp_makefile_star2_O1/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 0x6bc60
movq %r15, %rdi
movq %r12, %rsi
callq 0x508bc
movq %rbx, %rdi
movq %r15, %rsi
callq 0x6c71e
movq %rbx, %rax
addq $0x38, %rsp
popq %rbx
popq %r12
popq %r14
popq %r15
retq
// File: /workspace/github_cpp_makefile_star2_O1/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 %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
movq %rdi, %rbx
addq $0x8, %rdi
leaq 0xc9cc1(%rip), %r14     # 0x135c40
movq %r14, %rsi
callq 0x850ec
leaq 0x20(%rbx), %rdi
leaq 0x18(%r14), %rsi
callq 0x85fc2
leaq 0x38(%rbx), %rdi
leaq 0x30(%r14), %rsi
callq 0x85fc2
leaq 0x50(%rbx), %rdi
addq $0x48, %r14
movq %r14, %rsi
callq 0x85fc2
leaq 0x68(%rbx), %r15
xorps %xmm0, %xmm0
movups %xmm0, 0x128(%rbx)
movups %xmm0, 0x138(%rbx)
xorl %r12d, %r12d
leaq 0x4ca1f0(%rip), %rbx    # 0x5361c0
movl $0x3, %r13d
movq %r15, %r14
movq %r14, %rdi
movq %rbx, %rsi
callq 0x85fc2
movsd 0x18(%rbx), %xmm0
movsd %xmm0, 0x18(%r14)
addq $0x20, %r14
decq %r13
jne 0x6bfd9
leaq 0x1(%r12), %rax
addq $0x60, %r15
testq %r12, %r12
movq %rax, %r12
je 0x6bfd0
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
retq
nop
// File: /workspace/github_cpp_makefile_star2_O1/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 %r15
pushq %r14
pushq %r12
pushq %rbx
pushq %rax
movq %rsi, %rbx
movq %rdi, %r14
addq $0x8, %rdi
callq 0x7160c
addq $0x68, %r14
xorl %r15d, %r15d
xorl %r12d, %r12d
leaq (%r14,%r12), %rdi
movq %rbx, %rsi
callq 0x83856
addq $0x20, %r12
cmpq $0x60, %r12
jne 0x6c035
leaq 0x1(%r15), %rax
addq $0x60, %r14
testq %r15, %r15
movq %rax, %r15
je 0x6c032
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r14
popq %r15
retq
nop
// File: /workspace/github_cpp_makefile_star2_O1/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 0x761c5
leaq 0x6a828(%rip), %rsi     # 0xe09d3
movl $0x4, %edx
movq %rax, %rdi
callq 0x13240
testl %eax, %eax
je 0x761dd
leaq 0x6a815(%rip), %rdi     # 0xe09d8
jmp 0x761cc
leaq 0x6a7dc(%rip), %rdi     # 0xe09a8
xorl %eax, %eax
callq 0xaddb2
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 0x761f0
nop
// File: /workspace/github_cpp_makefile_star2_O1/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 0x7622c
movq %rsi, %r14
leaq 0x67fd6(%rip), %rsi     # 0xde1dd
movq %r14, %rdi
callq 0x135d0
movq %rax, %r15
testq %rax, %rax
jne 0x76236
leaq 0x69b5c(%rip), %rdi     # 0xdfd7a
xorl %ebx, %ebx
movq %r14, %rsi
xorl %eax, %eax
callq 0xaddb2
jmp 0x76253
movq 0xbdd6d(%rip), %rax     # 0x133fa0
movq (%rax), %r15
movq %rbx, %rdi
movq %r15, %rsi
callq 0x76330
testl %eax, %eax
je 0x76251
movl %eax, %ebx
movq %r15, %rdi
callq 0x134d0
jmp 0x76253
xorl %ebx, %ebx
movl %ebx, %eax
popq %rbx
popq %r14
popq %r15
retq
nop
// File: /workspace/github_cpp_makefile_star2_O1/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 0x76299
leaq 0x6a754(%rip), %rsi     # 0xe09d3
movl $0x4, %edx
movq %rax, %rdi
callq 0x13240
testl %eax, %eax
je 0x762b1
leaq 0x6a741(%rip), %rdi     # 0xe09d8
jmp 0x762a0
leaq 0x6a75a(%rip), %rdi     # 0xe09fa
xorl %eax, %eax
callq 0xaddb2
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 0x762c4
nop
// File: /workspace/github_cpp_makefile_star2_O1/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 0x76300
movq %rsi, %r14
leaq 0x68d0e(%rip), %rsi     # 0xdefe9
movq %r14, %rdi
callq 0x135d0
movq %rax, %r15
testq %rax, %rax
jne 0x7630a
leaq 0x69a88(%rip), %rdi     # 0xdfd7a
xorl %ebx, %ebx
movq %r14, %rsi
xorl %eax, %eax
callq 0xaddb2
jmp 0x76327
movq 0xbdc69(%rip), %rax     # 0x133f70
movq (%rax), %r15
movq %rbx, %rdi
movq %r15, %rsi
callq 0x76496
testl %eax, %eax
je 0x76325
movl %eax, %ebx
movq %r15, %rdi
callq 0x134d0
jmp 0x76327
xorl %ebx, %ebx
movl %ebx, %eax
popq %rbx
popq %r14
popq %r15
retq
nop
// File: /workspace/github_cpp_makefile_star2_O1/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 0x9b750
testl %eax, %eax
je 0x76461
leaq 0x30(%rsp), %rdi
movl $0x8, %esi
movl $0x4, %edx
movq %r14, %rcx
callq 0x13790
cmpq $0x4, %rax
jne 0x76465
movq %rsp, %rdi
movl $0x8, %esi
movl $0x6, %edx
movq %r14, %rcx
callq 0x13790
cmpq $0x6, %rax
jne 0x7646e
leaq 0xf0(%rsp), %rdi
movl $0x8, %esi
movl $0x10, %edx
movq %r14, %rcx
callq 0x13790
cmpq $0x10, %rax
jne 0x76477
leaq 0x20(%rbx), %r14
leaq 0x70(%rsp), %r15
leaq 0xf0(%rsp), %rsi
movq %r15, %rdi
callq 0x73146
movq %r14, %rdi
movq %r15, %rsi
xorl %edx, %edx
callq 0x7136a
leaq 0x70(%rsp), %r14
leaq 0x30(%rsp), %rsi
movq %r14, %rdi
callq 0x838b8
movq %rbx, %rdi
movq %r14, %rsi
callq 0x85fc2
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 0x84d7e
movsd 0x18(%rsp), %xmm0
movsd 0x20(%rsp), %xmm1
movsd 0x28(%rsp), %xmm2
leaq 0x58(%rsp), %r15
movq %r15, %rdi
callq 0x84d7e
movq %rbx, %rdi
movq %r14, %rsi
movq %r15, %rdx
callq 0x6ed8a
movl $0x1, %ebx
jmp 0x76487
xorl %ebx, %ebx
jmp 0x76487
leaq 0x6a5ba(%rip), %rdi     # 0xe0a26
jmp 0x7647e
leaq 0x6a5d0(%rip), %rdi     # 0xe0a45
jmp 0x7647e
leaq 0x6a5ed(%rip), %rdi     # 0xe0a6b
xorl %ebx, %ebx
xorl %eax, %eax
callq 0xaddb2
movl %ebx, %eax
addq $0x170, %rsp            # imm = 0x170
popq %rbx
popq %r14
popq %r15
retq
// File: /workspace/github_cpp_makefile_star2_O1/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 0x9d95a
movq 0x40(%r15), %rdi
movq %r12, %rsi
callq 0x9da34
movq %rax, %r12
movq 0x40(%r15), %rbp
addq $0x8, %rbp
cmpq %rbp, %rax
je 0x9c5ed
movq 0xc8(%r12), %r13
jmp 0x9c5f0
xorl %r13d, %r13d
leaq 0x18(%rsp), %rax
movq -0x10(%rax), %rdi
cmpq %rax, %rdi
je 0x9c60b
movq 0x18(%rsp), %rsi
incq %rsi
callq 0x134f0
cmpq %rbp, %r12
je 0x9c649
movl $0x1, %ebp
testq %r14, %r14
je 0x9c64b
movq 0x8(%r15), %rdi
movq %r13, %rsi
xorl %edx, %edx
callq 0xad14e
movq 0x8(%r15), %rsi
movq %r14, %rdi
callq 0xa6ee2
testl %eax, %eax
jne 0x9c64b
leaq 0x4a9f1(%rip), %rdi     # 0xe7030
movq %rbx, %rsi
xorl %eax, %eax
callq 0xaddb2
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 0x9c67a
movq 0x18(%rsp), %rsi
incq %rsi
callq 0x134f0
movq %rbx, %rdi
callq 0x138b0
// File: /workspace/github_cpp_makefile_star2_O1/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 0x9d95a
movq 0x40(%rbx), %rdi
movq %r14, %rsi
callq 0x9da34
movq 0x40(%rbx), %rcx
addq $0x8, %rcx
cmpq %rcx, %rax
je 0x9c893
movl 0xc0(%rax), %ebx
jmp 0x9c898
movl $0xffffffff, %ebx       # imm = 0xFFFFFFFF
leaq 0x18(%rsp), %rax
movq -0x10(%rax), %rdi
cmpq %rax, %rdi
je 0x9c8b3
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 0x9c8db
movq 0x18(%rsp), %rsi
incq %rsi
callq 0x134f0
movq %rbx, %rdi
callq 0x138b0
nop
// File: /workspace/github_cpp_makefile_star2_O1/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 0xad14e
movq 0x8(%rbx), %rsi
movq %r12, %rdi
callq 0xa71c0
testl %eax, %eax
je 0x9ca4c
movq 0x8(%rbx), %rdi
callq 0xad15f
movq %rax, 0x38(%rbx)
subl %r15d, %eax
movl $0x0, 0xb0(%rsp)
movl %eax, 0xb4(%rsp)
movq %r15, 0xb8(%rsp)
xorps %xmm0, %xmm0
movhps 0x417f8(%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 0x9c98e
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 0x9d95a
leaq 0xd8(%rsp), %rdi
leaq 0x30(%rsp), %rsi
movl $0xa8, %edx
callq 0x133f0
movq 0x40(%rbx), %rdi
leaq 0x10(%rsp), %rsi
callq 0x9dc6a
leaq 0xd8(%rsp), %rsi
movl $0xa8, %edx
movq %rax, %rdi
callq 0x133f0
leaq 0x20(%rsp), %rax
movq -0x10(%rax), %rdi
cmpq %rax, %rdi
je 0x9c9fd
movq 0x20(%rsp), %rsi
incq %rsi
callq 0x134f0
leaq 0xd8(%rsp), %rdi
leaq 0xf(%rsp), %rdx
movq %r14, %rsi
callq 0x9d95a
leaq 0x48(%rbx), %rdi
leaq 0xd8(%rsp), %rsi
callq 0x9e714
leaq 0xe8(%rsp), %rax
movq -0x10(%rax), %rdi
cmpq %rax, %rdi
je 0x9ca44
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 0x9caa1
movq 0xe8(%rsp), %rsi
jmp 0x9ca94
jmp 0x9ca9e
movq %rax, %rbx
leaq 0x20(%rsp), %rax
movq -0x10(%rax), %rdi
cmpq %rax, %rdi
je 0x9caa1
movq 0x20(%rsp), %rsi
incq %rsi
callq 0x134f0
jmp 0x9caa1
movq %rax, %rbx
movq %rbx, %rdi
callq 0x138b0
nop
// File: /workspace/github_cpp_makefile_star2_O1/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 0x9d95a
leaq 0x40(%rbx), %rdi
movq %r14, %rsi
callq 0x9d998
leaq 0x28(%rsp), %rax
movq -0x10(%rax), %rdi
cmpq %rax, %rdi
je 0x9cdb2
movq 0x28(%rsp), %rsi
incq %rsi
callq 0x134f0
movq 0x48(%rbx), %rdi
movq 0x50(%rbx), %rsi
leaq 0x10(%rsp), %rdx
callq 0x9e9b6
cmpq 0x50(%rbx), %rax
je 0x9cdd6
leaq 0x48(%rbx), %rdi
movq %rax, %rsi
callq 0x9eaa0
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 0x9ce04
movq 0x28(%rsp), %rsi
incq %rsi
callq 0x134f0
movq %rbx, %rdi
callq 0x138b0
// File: /workspace/github_cpp_makefile_star2_O1/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 0x9ce2b
callq 0x135e0
movq %r15, %rdi
callq 0xadc0f
movq %rax, 0x18(%rbx)
movq 0x20(%rbx), %rdi
testq %rdi, %rdi
je 0x9ce45
callq 0x135e0
leaq 0x42c29(%rip), %r12     # 0xdfa75
testq %r14, %r14
je 0x9ce85
movq %r14, %rdi
movl $0x77, %esi
callq 0x131d0
testq %rax, %rax
jne 0x9ce85
movq %r14, %rdi
movl $0x2b, %esi
callq 0x131d0
testq %rax, %rax
leaq 0x41363(%rip), %rax     # 0xde1dd
leaq 0x42bf8(%rip), %r12     # 0xdfa79
cmoveq %rax, %r12
movq %r12, %rdi
callq 0xadc0f
movq %rax, 0x20(%rbx)
movq %r15, %rdi
movq %rax, %rsi
callq 0x135d0
movq %rax, 0x8(%rbx)
testq %rax, %rax
je 0x9cee4
movq %rax, %r12
movq 0x20(%rbx), %rdi
leaq 0x42bc2(%rip), %rsi     # 0xdfa75
callq 0x13710
movq (%rbx), %rcx
testl %eax, %eax
je 0x9cefc
movq %rbx, %rdi
movq %r12, %rsi
callq *0x68(%rcx)
xorl %ebp, %ebp
testl %eax, %eax
je 0x9cf1f
movq (%rbx), %rax
movq 0x8(%rbx), %rsi
movl 0x30(%rbx), %edx
movq %rbx, %rdi
callq *0x78(%rax)
testl %eax, %eax
jne 0x9cf1a
jmp 0x9cf1f
leaq 0x42b92(%rip), %rdi     # 0xdfa7d
xorl %ebp, %ebp
movq %r15, %rsi
movq %r14, %rdx
xorl %eax, %eax
callq 0xaddb2
jmp 0x9cf1f
xorl %ebp, %ebp
movq %rbx, %rdi
movq %r12, %rsi
xorl %edx, %edx
callq *0x70(%rcx)
testl %eax, %eax
je 0x9cf1f
movq 0x8(%rbx), %rdi
callq 0xad15f
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_O1/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), %rdi
leaq 0x412a2(%rip), %rsi     # 0xde1dd
callq 0x13710
testl %eax, %eax
je 0x9cf71
movq (%rbx), %rax
movq 0x8(%rbx), %rsi
movl 0x30(%rbx), %edx
movq %rbx, %rdi
callq *0x80(%rax)
xorl %ebp, %ebp
testl %eax, %eax
je 0x9cfb3
movq (%rbx), %rax
movq 0x8(%rbx), %rsi
movl 0x30(%rbx), %edx
movq %rbx, %rdi
callq *0x70(%rax)
testl %eax, %eax
je 0x9cfb3
movq 0x8(%rbx), %rdi
callq 0x134d0
movq $0x0, 0x8(%rbx)
movq 0x18(%rbx), %rdi
testq %rdi, %rdi
je 0x9cf90
callq 0x135e0
movq $0x0, 0x18(%rbx)
movq 0x20(%rbx), %rdi
testq %rdi, %rdi
je 0x9cfa6
callq 0x135e0
movq $0x0, 0x20(%rbx)
movl $0x1, %ebp
movl %ebp, %eax
addq $0x8, %rsp
popq %rbx
popq %rbp
retq
// File: /workspace/github_cpp_makefile_star2_O1/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 0x9cfdb
callq 0x135e0
leaq 0x4ced5(%rip), %rdi     # 0xe9eb7
callq 0xadc0f
movq %rax, 0x18(%r14)
movq 0x20(%r14), %rdi
testq %rdi, %rdi
je 0x9cff9
callq 0x135e0
leaq 0x42a75(%rip), %r12     # 0xdfa75
testq %r15, %r15
je 0x9d039
movq %r15, %rdi
movl $0x77, %esi
callq 0x131d0
testq %rax, %rax
jne 0x9d039
movq %r15, %rdi
movl $0x2b, %esi
callq 0x131d0
testq %rax, %rax
leaq 0x411af(%rip), %rax     # 0xde1dd
leaq 0x42a44(%rip), %r12     # 0xdfa79
cmoveq %rax, %r12
movq %r12, %rdi
callq 0xadc0f
movq %rax, 0x20(%r14)
leaq 0x42a29(%rip), %rsi     # 0xdfa75
movq %rax, %rdi
callq 0x13710
movq (%r14), %rcx
testl %eax, %eax
je 0x9d080
movq %r14, %rdi
movq %rbx, %rsi
callq *0x68(%rcx)
xorl %ebp, %ebp
testl %eax, %eax
je 0x9d0a6
movl 0x30(%r14), %edx
movq (%r14), %rax
movq %r14, %rdi
movq %rbx, %rsi
callq *0x78(%rax)
testl %eax, %eax
jne 0x9d09d
jmp 0x9d0a6
xorl %ebp, %ebp
movq %r14, %rdi
movq %rbx, %rsi
xorl %edx, %edx
callq *0x70(%rcx)
testl %eax, %eax
je 0x9d0a6
movq %rbx, %rdi
callq 0xad15f
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
// File: /workspace/github_cpp_makefile_star2_O1/tomfunkhouser[P]gaps/pkgs/R2Shapes/R2PixelDatabase.cpp
// Function: gaps::R2PixelDatabase::CloseStream()
int R2PixelDatabase::
CloseStream(void)
{
  // Check if writing file
  if (strcmp(rwaccess, "rb")) {
    // Write entries
    if (!WriteEntries(fp, swap_endian)) return 0;

    // Get position at end of stream
    unsigned long long end_of_stream = RNFileTell(fp);
    
    // Write header again (now that the seek values have been filled in)
    if (!WriteHeader(fp, swap_endian)) return 0;

    // Seek back to end of stream
    RNFileSeek(fp, end_of_stream, RN_FILE_SEEK_SET);
  }

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

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

  // Return success
  return 1;
}

// Assembly:
pushq %rbp
pushq %r14
pushq %rbx
movq %rdi, %rbx
movq 0x20(%rdi), %rdi
leaq 0x41119(%rip), %rsi     # 0xde1dd
callq 0x13710
testl %eax, %eax
je 0x9d114
movq (%rbx), %rax
movq 0x8(%rbx), %rsi
movl 0x30(%rbx), %edx
movq %rbx, %rdi
callq *0x80(%rax)
xorl %ebp, %ebp
testl %eax, %eax
je 0x9d145
movq 0x8(%rbx), %rdi
callq 0xad15f
movq %rax, %r14
movq (%rbx), %rax
movq 0x8(%rbx), %rsi
movl 0x30(%rbx), %edx
movq %rbx, %rdi
callq *0x70(%rax)
testl %eax, %eax
je 0x9d145
movq 0x8(%rbx), %rdi
movq %r14, %rsi
xorl %edx, %edx
callq 0xad14e
movq 0x18(%rbx), %rdi
testq %rdi, %rdi
je 0x9d122
callq 0x135e0
movq $0x0, 0x18(%rbx)
movq 0x20(%rbx), %rdi
testq %rdi, %rdi
je 0x9d138
callq 0x135e0
movq $0x0, 0x20(%rbx)
movl $0x1, %ebp
movl %ebp, %eax
popq %rbx
popq %r14
popq %rbp
retq
// File: /workspace/github_cpp_makefile_star2_O1/tomfunkhouser[P]gaps/pkgs/R2Shapes/R2PixelDatabase.cpp
// Function: gaps::R2PixelDatabase::ReadHeader(_IO_FILE*)
int R2PixelDatabase::
ReadHeader(FILE *fp)
{
  // Seek to beginning of file
  RNFileSeek(fp, 0, RN_FILE_SEEK_SET);

  // Read magic string
  char buffer[1024]; 
  if (!RNReadChar(fp, buffer, 32, 0)) return 0;
  if (strcmp(buffer, "R2PixelDatabase")) {
    RNFail("Incorrect header (%s) in database file %s\n", buffer, filename);
    return 0;
  }

  // Read endian test
  unsigned int endian_test1, endian_test2;
  if (!RNReadUnsignedInt(fp, &endian_test1, 1, 0)) return 0;
  if (endian_test1 != 1) swap_endian = 1;
  if (!RNReadUnsignedInt(fp, &endian_test2, 1, swap_endian)) return 0;
  if (endian_test2 != 1) {
    RNFail("Incorrect endian (%x) in database file %s\n", endian_test1, filename);
    return 0;
  }

  // Read version
  if (!RNReadUnsignedInt(fp, &major_version, 1, swap_endian)) return 0;
  if (!RNReadUnsignedInt(fp, &minor_version, 1, swap_endian)) return 0;
  
  // Read entry info
  if (!RNReadUnsignedLongLong(fp, &entries_seek, 1, swap_endian)) return 0;
  if (!RNReadUnsignedInt(fp, &entries_count, 1, swap_endian)) return 0;

  // Read extra at end of header
  if (!RNReadChar(fp, buffer, 1024, swap_endian)) return 0;
  
  // Return success
  return 1;
}

// Assembly:
pushq %r15
pushq %r14
pushq %rbx
subq $0x410, %rsp            # imm = 0x410
movq %rsi, %r14
movq %rdi, %r15
xorl %ebx, %ebx
movq %rsi, %rdi
xorl %esi, %esi
xorl %edx, %edx
callq 0xad14e
leaq 0x10(%rsp), %rsi
movq %r14, %rdi
movl $0x20, %edx
xorl %ecx, %ecx
callq 0xad164
testl %eax, %eax
je 0x9d1b6
movdqa 0x10(%rsp), %xmm0
pcmpeqb 0x49e8e(%rip), %xmm0    # 0xe7020
pmovmskb %xmm0, %eax
cmpl $0xffff, %eax           # imm = 0xFFFF
je 0x9d1c5
movq 0x18(%r15), %rdx
leaq 0x42848(%rip), %rdi     # 0xdf9f0
xorl %ebx, %ebx
leaq 0x10(%rsp), %rsi
xorl %eax, %eax
callq 0xaddb2
movl %ebx, %eax
addq $0x410, %rsp            # imm = 0x410
popq %rbx
popq %r14
popq %r15
retq
leaq 0x8(%rsp), %rsi
xorl %ebx, %ebx
movq %r14, %rdi
movl $0x1, %edx
xorl %ecx, %ecx
callq 0xad365
testl %eax, %eax
je 0x9d1b6
cmpl $0x1, 0x8(%rsp)
je 0x9d1ee
movl $0x1, 0x30(%r15)
movl 0x30(%r15), %ecx
leaq 0xc(%rsp), %rsi
movq %r14, %rdi
movl $0x1, %edx
callq 0xad365
testl %eax, %eax
je 0x9d1b6
cmpl $0x1, 0xc(%rsp)
jne 0x9d2a5
leaq 0x28(%r15), %rsi
movl 0x30(%r15), %ecx
movq %r14, %rdi
movl $0x1, %edx
callq 0xad365
testl %eax, %eax
je 0x9d1b6
leaq 0x2c(%r15), %rsi
movl 0x30(%r15), %ecx
movq %r14, %rdi
movl $0x1, %edx
callq 0xad365
testl %eax, %eax
je 0x9d1b6
leaq 0x38(%r15), %rsi
movl 0x30(%r15), %ecx
movq %r14, %rdi
movl $0x1, %edx
callq 0xad54f
testl %eax, %eax
je 0x9d1b6
leaq 0x34(%r15), %rsi
movl 0x30(%r15), %ecx
movq %r14, %rdi
movl $0x1, %edx
callq 0xad365
testl %eax, %eax
je 0x9d1b6
movl 0x30(%r15), %ecx
leaq 0x10(%rsp), %rsi
movq %r14, %rdi
movl $0x400, %edx            # imm = 0x400
callq 0xad164
xorl %ebx, %ebx
testl %eax, %eax
setne %bl
jmp 0x9d1b6
movl 0x8(%rsp), %esi
movq 0x18(%r15), %rdx
leaq 0x42767(%rip), %rdi     # 0xdfa1b
xorl %ebx, %ebx
xorl %eax, %eax
callq 0xaddb2
jmp 0x9d1b6
// File: /workspace/github_cpp_makefile_star2_O1/tomfunkhouser[P]gaps/pkgs/R2Shapes/R2PixelDatabase.cpp
// Function: gaps::R2PixelDatabase::WriteHeader(_IO_FILE*, int)
int R2PixelDatabase::
WriteHeader(FILE *fp, int swap_endian)
{
  // Seek to beginning of file
  RNFileSeek(fp, 0, RN_FILE_SEEK_SET);

  // Get convenient variables
  unsigned int endian_test = 1;
  char magic[32] = { '\0' };
  strncpy(magic, "R2PixelDatabase", 32);
  char buffer[1024] = { '\0' };

  // Write header
  if (!RNWriteChar(fp, magic, 32, swap_endian)) return 0;
  if (!RNWriteUnsignedInt(fp, &endian_test, 1, swap_endian)) return 0;
  if (!RNWriteUnsignedInt(fp, &endian_test, 1, swap_endian)) return 0;
  if (!RNWriteUnsignedInt(fp, &major_version, 1, swap_endian)) return 0;
  if (!RNWriteUnsignedInt(fp, &minor_version, 1, swap_endian)) return 0;
  if (!RNWriteUnsignedLongLong(fp, &entries_seek, 1, swap_endian)) return 0;
  if (!RNWriteUnsignedInt(fp, &entries_count, 1, swap_endian)) return 0;
  if (!RNWriteChar(fp, buffer, 1024, swap_endian)) return 0;
  
  // Return success
  return 1;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r12
pushq %rbx
subq $0x430, %rsp            # imm = 0x430
movl %edx, %ebp
movq %rsi, %r14
movq %rdi, %r15
xorl %ebx, %ebx
movq %rsi, %rdi
xorl %esi, %esi
xorl %edx, %edx
callq 0xad14e
movl $0x1, 0xc(%rsp)
movups 0x49d99(%rip), %xmm0    # 0xe708f
leaq 0x10(%rsp), %r12
movaps %xmm0, 0x10(%r12)
movups 0x49d77(%rip), %xmm0    # 0xe707f
movaps %xmm0, (%r12)
leaq 0x30(%rsp), %rdi
movl $0x400, %edx            # imm = 0x400
xorl %esi, %esi
callq 0x132a0
movq %r14, %rdi
movq %r12, %rsi
movl $0x20, %edx
movl %ebp, %ecx
callq 0xad5c4
testl %eax, %eax
je 0x9d3e6
leaq 0xc(%rsp), %rsi
movq %r14, %rdi
movl $0x1, %edx
movl %ebp, %ecx
callq 0xad80e
testl %eax, %eax
je 0x9d3e6
leaq 0xc(%rsp), %rsi
movq %r14, %rdi
movl $0x1, %edx
movl %ebp, %ecx
callq 0xad80e
testl %eax, %eax
je 0x9d3e6
leaq 0x28(%r15), %rsi
movq %r14, %rdi
movl $0x1, %edx
movl %ebp, %ecx
callq 0xad80e
testl %eax, %eax
je 0x9d3e6
leaq 0x2c(%r15), %rsi
movq %r14, %rdi
movl $0x1, %edx
movl %ebp, %ecx
callq 0xad80e
testl %eax, %eax
je 0x9d3e6
leaq 0x38(%r15), %rsi
movq %r14, %rdi
movl $0x1, %edx
movl %ebp, %ecx
callq 0xada8a
testl %eax, %eax
je 0x9d3e6
addq $0x34, %r15
movq %r14, %rdi
movq %r15, %rsi
movl $0x1, %edx
movl %ebp, %ecx
callq 0xad80e
testl %eax, %eax
je 0x9d3e6
leaq 0x30(%rsp), %rsi
movq %r14, %rdi
movl $0x400, %edx            # imm = 0x400
movl %ebp, %ecx
callq 0xad5c4
xorl %ebx, %ebx
testl %eax, %eax
setne %bl
movl %ebx, %eax
addq $0x430, %rsp            # imm = 0x430
popq %rbx
popq %r12
popq %r14
popq %r15
popq %rbp
retq