LLM4Binary/decompile-bench-makefile huggingface dataset:
// File: /workspace/github_cpp_makefile_star2_O2/tomfunkhouser[P]gaps/pkgs/R2Shapes/R2Grid.cpp
// Function: gaps::R2Grid::DrawMesh() const
void R2Grid::
DrawMesh(void) const
{
  // Push transformation
  grid_to_world_transform.Push();

  // Draw triangle strip
  for (int j = 1; j < grid_resolution[1]; j++) {
    RNGrfxBegin(RN_GRFX_TRIANGLE_STRIP);
    for (int i = 0; i < grid_resolution[0]; i++) {
      R3LoadPoint((double) i, (double) j,     GridValue(i, j));
      R3LoadPoint((double) i, (double) (j-1), GridValue(i, j-1));
    }
    RNGrfxEnd();
  }

  // Pop transformation
  grid_to_world_transform.Pop();
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x18, %rsp
movq %rdi, %rbx
callq 0x62ea8
pushq $0x1
popq %r14
xorl %r15d, %r15d
cmpl 0xc4(%rbx), %r14d
jge 0x58110
pushq $0x5
popq %rdi
callq 0xe110
cvtsi2sd %r14d, %xmm0
movsd %xmm0, 0x8(%rsp)
leal -0x1(%r14), %eax
cvtsi2sd %eax, %xmm0
movsd %xmm0, (%rsp)
movslq %r14d, %r12
movslq %r15d, %r13
xorl %ebp, %ebp
cmpl 0xc0(%rbx), %ebp
jge 0x58100
cvtsi2sd %ebp, %xmm0
movsd %xmm0, 0x10(%rsp)
movq 0xb8(%rbx), %rax
movslq 0xc8(%rbx), %rcx
imulq %r12, %rcx
addq %rbp, %rcx
movsd (%rax,%rcx,8), %xmm2
movsd 0x8(%rsp), %xmm1
callq 0xe700
movq 0xb8(%rbx), %rax
movslq 0xc8(%rbx), %rcx
imulq %r13, %rcx
addq %rbp, %rcx
movsd (%rax,%rcx,8), %xmm2
movsd 0x10(%rsp), %xmm0
movsd (%rsp), %xmm1
callq 0xe700
incq %rbp
jmp 0x5809a
callq 0xe5f0
incl %r14d
incl %r15d
jmp 0x58065
movq %rbx, %rdi
addq $0x18, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
jmp 0x62ec0
// File: /workspace/github_cpp_makefile_star2_O2/tomfunkhouser[P]gaps/pkgs/R2Shapes/R2Grid.cpp
// Function: gaps::R2Grid::DrawImage(int, int) const
void R2Grid::
DrawImage(int x, int y) const
{
  // Set projection matrix
  glMatrixMode(GL_PROJECTION);  
  glPushMatrix();
  glLoadIdentity();
  gluOrtho2D(0, grid_resolution[0], 0, grid_resolution[1]);

  // Set model view matrix
  glMatrixMode(GL_MODELVIEW);
  glPushMatrix();
  glLoadIdentity();

  // Set position for image
  glRasterPos2i(x, y);

  // Allocate pixels
  float *pixels = new float [ grid_size ];

  // Copy pixels
  for (int i = 0; i < grid_size; i++) pixels[i] = (float) grid_values[i];

  // Draw pixels
  glDrawPixels(grid_resolution[0], grid_resolution[1], GL_LUMINANCE, GL_FLOAT, pixels); 

  // Delete pixels
  delete [] pixels;

  // Reset projection matrix
  glMatrixMode(GL_PROJECTION);
  glPopMatrix();

  // Reset model view matrix
  glMatrixMode(GL_MODELVIEW);
  glPopMatrix();
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %rbx
pushq %rax
movl %edx, %ebp
movl %esi, %r14d
movq %rdi, %rbx
movl $0x1701, %edi           # imm = 0x1701
callq 0xe640
callq 0xe770
callq 0xe5e0
cvtsi2sdl 0xc0(%rbx), %xmm1
cvtsi2sdl 0xc4(%rbx), %xmm3
xorps %xmm0, %xmm0
xorps %xmm2, %xmm2
callq 0xe2c0
movl $0x1700, %edi           # imm = 0x1700
callq 0xe640
callq 0xe770
callq 0xe5e0
movl %r14d, %edi
movl %ebp, %esi
callq 0xe180
movslq 0xcc(%rbx), %r15
leaq (,%r15,4), %rax
testq %r15, %r15
pushq $-0x1
popq %rdi
cmovnsq %rax, %rdi
callq 0xe030
movq %rax, %r14
movq 0xb8(%rbx), %rax
xorl %ecx, %ecx
testl %r15d, %r15d
movl $0x0, %edx
cmovgl %r15d, %edx
cmpq %rcx, %rdx
je 0x581cd
cvtsd2ss (%rax,%rcx,8), %xmm0
movss %xmm0, (%r14,%rcx,4)
incq %rcx
jmp 0x581b8
movl 0xc0(%rbx), %edi
movl 0xc4(%rbx), %esi
movl $0x1909, %edx           # imm = 0x1909
movl $0x1406, %ecx           # imm = 0x1406
movq %r14, %r8
callq 0xe360
movq %r14, %rdi
callq 0xe5d0
movl $0x1701, %edi           # imm = 0x1701
callq 0xe640
callq 0xe880
movl $0x1700, %edi           # imm = 0x1700
callq 0xe640
addq $0x8, %rsp
popq %rbx
popq %r14
popq %r15
popq %rbp
jmp 0xe880
nop
// File: /workspace/github_cpp_makefile_star2_O2/tomfunkhouser[P]gaps/pkgs/R2Shapes/R2Grid.cpp
// Function: gaps::R2Grid::ConnectedComponentLabelFilter(double)
void R2Grid::
ConnectedComponentLabelFilter(RNScalar isolevel)
{
  // Compute connected components
  int *components = new int [ grid_size ];
  int ncomponents = ConnectedComponents(isolevel, grid_size, NULL, NULL, components);

  // Assign component labels to grid elements
  if (ncomponents > 0) {
    // Assign component labels
    for (int i = 0; i < grid_size; i++) {
      if (grid_values[i] == R2_GRID_UNKNOWN_VALUE) continue;
      grid_values[i] = components[i];
    }
  }

  // Delete temporary memory
  delete [] components;
}

// Assembly:
pushq %r15
pushq %r14
pushq %r12
pushq %rbx
pushq %rax
movsd %xmm0, (%rsp)
movq %rdi, %r14
movslq 0xcc(%rdi), %r15
leaq (,%r15,4), %rax
testq %r15, %r15
pushq $-0x1
popq %rdi
cmovnsq %rax, %rdi
callq 0xe030
movq %rax, %rbx
xorl %r12d, %r12d
movq %r14, %rdi
movsd (%rsp), %xmm0
movl %r15d, %esi
xorl %edx, %edx
xorl %ecx, %ecx
movq %rax, %r8
callq 0x584b8
testl %eax, %eax
jle 0x584a5
movl 0xcc(%r14), %eax
movq 0xb8(%r14), %rcx
testl %eax, %eax
cmovlel %r12d, %eax
movsd 0x3bae7(%rip), %xmm0    # 0x93f68
cmpq %r12, %rax
je 0x584a5
movsd (%rcx,%r12,8), %xmm1
ucomisd %xmm0, %xmm1
jne 0x58494
jnp 0x584a0
cvtsi2sdl (%rbx,%r12,4), %xmm1
movsd %xmm1, (%rcx,%r12,8)
incq %r12
jmp 0x58481
movq %rbx, %rdi
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r14
popq %r15
jmp 0xe5d0
// File: /workspace/github_cpp_makefile_star2_O2/tomfunkhouser[P]gaps/pkgs/R2Shapes/R2Grid.cpp
// Function: gaps::R2Grid::ConnectedComponentSizeFilter(double)
void R2Grid::
ConnectedComponentSizeFilter(RNScalar isolevel)
{
  // Compute connected components
  int *sizes = new int [ grid_size ];
  int *components = new int [ grid_size ];
  int ncomponents = ConnectedComponents(isolevel, grid_size, NULL, sizes, components);

  // Assign component sizes to grid elements
  if (ncomponents > 0) {
    for (int i = 0; i < grid_size; i++) {
      if (grid_values[i] == R2_GRID_UNKNOWN_VALUE) continue;
      int component = components[i];
      if ((component < 0) || (component >= ncomponents)) grid_values[i] = 0;
      else grid_values[i] = sizes[component];
    }
  }

  // Delete temporary memory
  delete [] components;
  delete [] sizes;
}

// Assembly:
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x10, %rsp
movsd %xmm0, 0x8(%rsp)
movq %rdi, %r15
movslq 0xcc(%rdi), %r12
leaq (,%r12,4), %rax
testq %r12, %r12
pushq $-0x1
popq %r14
cmovnsq %rax, %r14
movq %r14, %rdi
callq 0xe030
movq %rax, %rbx
movq %r14, %rdi
callq 0xe030
movq %rax, %r14
xorl %r13d, %r13d
movq %r15, %rdi
movsd 0x8(%rsp), %xmm0
movl %r12d, %esi
xorl %edx, %edx
movq %rbx, %rcx
movq %rax, %r8
callq 0x584b8
testl %eax, %eax
jle 0x58a57
movl 0xcc(%r15), %ecx
movq 0xb8(%r15), %rdx
testl %ecx, %ecx
cmovlel %r13d, %ecx
movsd 0x3b540(%rip), %xmm0    # 0x93f68
cmpq %r13, %rcx
je 0x58a57
movsd (%rdx,%r13,8), %xmm1
ucomisd %xmm0, %xmm1
jne 0x58a3b
jnp 0x58a52
movl (%r14,%r13,4), %esi
xorpd %xmm1, %xmm1
cmpl %eax, %esi
jae 0x58a4c
cvtsi2sdl (%rbx,%rsi,4), %xmm1
movsd %xmm1, (%rdx,%r13,8)
incq %r13
jmp 0x58a28
movq %r14, %rdi
callq 0xe5d0
movq %rbx, %rdi
addq $0x10, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
jmp 0xe5d0
// File: /workspace/github_cpp_makefile_star2_O2/tomfunkhouser[P]gaps/pkgs/R2Shapes/R2Grid.cpp
// Function: gaps::R2Grid::ReadFile(char const*)
int R2Grid::
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, ".raw", 4)) return ReadRAWFile(filename);
  else if (!strncmp(input_extension, ".pfm", 4)) return ReadPFMFile(filename);
  else if (!strncmp(input_extension, ".pnm", 4)) return ReadPNMFile(filename);
  else if (!strncmp(input_extension, ".png", 4)) return ReadPNGFile(filename);
  else if (!strncmp(input_extension, ".grd", 4)) return ReadGridFile(filename);
  else  return ReadImageFile(filename);
}

// Assembly:
pushq %r15
pushq %r14
pushq %rbx
movq %rsi, %rbx
movq %rdi, %r14
pushq $0x2e
popq %rsi
movq %rbx, %rdi
callq 0xe4e0
testq %rax, %rax
je 0x5901e
movq %rax, %r15
leaq 0x3f7bf(%rip), %rsi     # 0x98766
pushq $0x4
popq %rdx
movq %rax, %rdi
callq 0xe220
testl %eax, %eax
je 0x59034
leaq 0x413bd(%rip), %rsi     # 0x9a37a
pushq $0x4
popq %rdx
movq %r15, %rdi
callq 0xe220
testl %eax, %eax
je 0x59044
leaq 0x413ac(%rip), %rsi     # 0x9a37f
pushq $0x4
popq %rdx
movq %r15, %rdi
callq 0xe220
testl %eax, %eax
je 0x59054
leaq 0x4139b(%rip), %rsi     # 0x9a384
pushq $0x4
popq %rdx
movq %r15, %rdi
callq 0xe220
testl %eax, %eax
je 0x59064
leaq 0x3f74e(%rip), %rsi     # 0x9874d
pushq $0x4
popq %rdx
movq %r15, %rdi
callq 0xe220
movq %r14, %rdi
movq %rbx, %rsi
testl %eax, %eax
je 0x59074
popq %rbx
popq %r14
popq %r15
jmp 0x59aca
leaq 0x4132a(%rip), %rdi     # 0x9a34f
xorl %eax, %eax
callq 0x681ca
xorl %eax, %eax
popq %rbx
popq %r14
popq %r15
retq
movq %r14, %rdi
movq %rbx, %rsi
popq %rbx
popq %r14
popq %r15
jmp 0x5907e
movq %r14, %rdi
movq %rbx, %rsi
popq %rbx
popq %r14
popq %r15
jmp 0x592b6
movq %r14, %rdi
movq %rbx, %rsi
popq %rbx
popq %r14
popq %r15
jmp 0x5968e
movq %r14, %rdi
movq %rbx, %rsi
popq %rbx
popq %r14
popq %r15
jmp 0x59a0a
popq %rbx
popq %r14
popq %r15
jmp 0x59a5e
// File: /workspace/github_cpp_makefile_star2_O2/tomfunkhouser[P]gaps/pkgs/R2Shapes/R2Grid.cpp
// Function: gaps::R2Grid::ReadPNGFile(char const*)
int R2Grid::
ReadPNGFile(const char *filename)
{
  // Open file
  FILE *fp = fopen(filename, "rb");
  if (!fp) {
    RNFail("Unable to open PNG file %s\n", filename);
    return 0;
   }

  // Read file
  if (!ReadPNGStream(fp)) {
    fclose(fp);
    return 0;
  }

  // Close the file 
  fclose(fp);

  // Return success 
  return 1;
}

// Assembly:
pushq %r15
pushq %r14
pushq %rbx
movq %rsi, %rbx
movq %rdi, %r14
leaq 0x39b3f(%rip), %rsi     # 0x9355b
movq %rbx, %rdi
callq 0xe550
testq %rax, %rax
je 0x59a45
movq %rax, %r15
movq %r14, %rdi
movq %rax, %rsi
callq 0x5a56c
movl %eax, %ebx
movq %r15, %rdi
callq 0xe440
movl %ebx, %eax
jmp 0x59a58
leaq 0x40cd3(%rip), %rdi     # 0x9a71f
movq %rbx, %rsi
xorl %eax, %eax
callq 0x681ca
xorl %eax, %eax
popq %rbx
popq %r14
popq %r15
retq
// File: /workspace/github_cpp_makefile_star2_O2/tomfunkhouser[P]gaps/pkgs/R2Shapes/R2Grid.cpp
// Function: gaps::R2Grid::ReadGridFile(char const*)
int R2Grid::
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 = ReadGridStream(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 0x59a9a
movq %rsi, %r14
leaq 0x39ae6(%rip), %rsi     # 0x9355b
movq %r14, %rdi
callq 0xe550
movq %rax, %r15
testq %rax, %rax
jne 0x59aa4
leaq 0x398de(%rip), %rdi     # 0x9336a
xorl %ebx, %ebx
movq %r14, %rsi
xorl %eax, %eax
callq 0x681ca
jmp 0x59ac1
movq 0x80507(%rip), %rax     # 0xd9fa8
movq (%rax), %r15
movq %rbx, %rdi
movq %r15, %rsi
callq 0x5a222
testl %eax, %eax
je 0x59abf
movl %eax, %ebx
movq %r15, %rdi
callq 0xe440
jmp 0x59ac1
xorl %ebx, %ebx
movl %ebx, %eax
popq %rbx
popq %r14
popq %r15
retq
nop
// File: /workspace/github_cpp_makefile_star2_O2/tomfunkhouser[P]gaps/pkgs/R2Shapes/R2Grid.cpp
// Function: gaps::R2Grid::ReadImageFile(char const*)
int R2Grid::
ReadImageFile(const char *filename)
{
  // Allocate image
  R2Image *image = new R2Image();
  if (!image) {
    RNFail("Unable to allocate image for %s\n", filename);
    return 0;
  }

  // Read image
  if (!image->Read(filename)) { 
    // RNFail("Unable to read image from %s\n", filename);
    delete image; 
    return 0; 
  }

  // Fill in grid info
  grid_resolution[0] = image->Width();
  grid_resolution[1] = image->Height();
  grid_row_size = image->Width();
  grid_size = image->Width() * image->Height();
  world_to_grid_scale_factor = 1;
  world_to_grid_transform = R2identity_affine;
  grid_to_world_transform = R2identity_affine;
  if (grid_values) delete [] grid_values;
  grid_values = new RNScalar [ grid_size ];
  for (int j = 0; j < image->Height(); j++) {
    for (int i = 0; i < image->Width(); i++) {
      SetGridValue(i, j, image->PixelRGB(i, j).Luminance());
    }
  }

  // Delete image
  delete image;

  // Return success
  return 1;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x18, %rsp
movq %rsi, %r15
movq %rdi, %r14
pushq $0x18
popq %rdi
callq 0xe450
movq %rax, %rbx
movq %rax, %rdi
callq 0x5fe14
movq %rbx, %rdi
movq %r15, %rsi
callq 0x5fe30
testl %eax, %eax
je 0x59c22
movl (%rbx), %eax
movl %eax, 0xc0(%r14)
movl 0x4(%rbx), %ecx
movl %ecx, 0xc4(%r14)
movl %eax, 0xc8(%r14)
imull %eax, %ecx
movl %ecx, 0xcc(%r14)
movabsq $0x3ff0000000000000, %rax # imm = 0x3FF0000000000000
movq %rax, 0xb0(%r14)
leaq 0x58(%r14), %rdi
leaq 0x483424(%rip), %r15    # 0x4dcf68
movq %r15, %rsi
callq 0x5ac32
movq %r14, %rdi
movq %r15, %rsi
callq 0x5ac32
movq 0xb8(%r14), %rdi
testq %rdi, %rdi
je 0x59b68
callq 0xe5d0
movslq 0xcc(%r14), %rax
leaq (,%rax,8), %rcx
testq %rax, %rax
pushq $-0x1
popq %rdi
cmovnsq %rcx, %rdi
callq 0xe030
movq %rax, 0xb8(%r14)
xorl %r15d, %r15d
movq %rsp, %r12
cmpl 0x4(%rbx), %r15d
jge 0x59c0a
movslq %r15d, %rbp
xorl %r13d, %r13d
cmpl (%rbx), %r13d
jge 0x59c05
movq %r12, %rdi
movq %rbx, %rsi
movl %r13d, %edx
movl %r15d, %ecx
callq 0x6036e
movsd 0x8(%rsp), %xmm0
mulsd 0x406dd(%rip), %xmm0    # 0x9a2a0
movsd (%rsp), %xmm1
mulsd 0x406d8(%rip), %xmm1    # 0x9a2a8
addsd %xmm0, %xmm1
movsd 0x10(%rsp), %xmm0
mulsd 0x406ce(%rip), %xmm0    # 0x9a2b0
addsd %xmm1, %xmm0
movq 0xb8(%r14), %rax
movslq 0xc8(%r14), %rcx
imulq %rbp, %rcx
addq %r13, %rcx
movsd %xmm0, (%rax,%rcx,8)
incq %r13
jmp 0x59b9f
incl %r15d
jmp 0x59b93
movq %rbx, %rdi
callq 0x60360
pushq $0x18
popq %rsi
movq %rbx, %rdi
callq 0xe460
pushq $0x1
popq %rax
jmp 0x59c37
movq %rbx, %rdi
callq 0x60360
pushq $0x18
popq %rsi
movq %rbx, %rdi
callq 0xe460
xorl %eax, %eax
addq $0x18, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq %rax, %r14
pushq $0x18
popq %rsi
movq %rbx, %rdi
callq 0xe460
movq %r14, %rdi
callq 0xe810
// File: /workspace/github_cpp_makefile_star2_O2/tomfunkhouser[P]gaps/pkgs/R2Shapes/R2Grid.cpp
// Function: gaps::R2Grid::WriteFile(char const*) const
int R2Grid::
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, ".raw", 4)) return WriteRAWFile(filename);
  else if (!strncmp(input_extension, ".pfm", 4)) return WritePFMFile(filename);
  else if (!strncmp(input_extension, ".png", 4)) return WritePNGFile(filename);
  else if (!strncmp(input_extension, ".grd", 4)) return WriteGridFile(filename);
  else return WriteImageFile(filename);
}

// Assembly:
pushq %r15
pushq %r14
pushq %rbx
movq %rsi, %rbx
movq %rdi, %r14
pushq $0x2e
popq %rsi
movq %rbx, %rdi
callq 0xe4e0
testq %rax, %rax
je 0x59ce2
movq %rax, %r15
leaq 0x3eae5(%rip), %rsi     # 0x98766
pushq $0x4
popq %rdx
movq %rax, %rdi
callq 0xe220
testl %eax, %eax
je 0x59cf8
leaq 0x406e3(%rip), %rsi     # 0x9a37a
pushq $0x4
popq %rdx
movq %r15, %rdi
callq 0xe220
testl %eax, %eax
je 0x59d08
leaq 0x406d7(%rip), %rsi     # 0x9a384
pushq $0x4
popq %rdx
movq %r15, %rdi
callq 0xe220
testl %eax, %eax
je 0x59d18
leaq 0x3ea8a(%rip), %rsi     # 0x9874d
pushq $0x4
popq %rdx
movq %r15, %rdi
callq 0xe220
movq %r14, %rdi
movq %rbx, %rsi
testl %eax, %eax
je 0x59d28
popq %rbx
popq %r14
popq %r15
jmp 0x5a088
leaq 0x406a0(%rip), %rdi     # 0x9a389
xorl %eax, %eax
callq 0x681ca
xorl %eax, %eax
popq %rbx
popq %r14
popq %r15
retq
movq %r14, %rdi
movq %rbx, %rsi
popq %rbx
popq %r14
popq %r15
jmp 0x59d32
movq %r14, %rdi
movq %rbx, %rsi
popq %rbx
popq %r14
popq %r15
jmp 0x59e7c
movq %r14, %rdi
movq %rbx, %rsi
popq %rbx
popq %r14
popq %r15
jmp 0x59fc8
popq %rbx
popq %r14
popq %r15
jmp 0x5a01c
// File: /workspace/github_cpp_makefile_star2_O2/tomfunkhouser[P]gaps/pkgs/R2Shapes/R2Grid.cpp
// Function: gaps::R2Grid::WriteRAWFile(char const*) const
int R2Grid::
WriteRAWFile(const char *filename) const
{
  // Open file
  FILE *fp = fopen(filename, "wb");
  if (!fp) {
    RNFail("Unable to open raw image file %s", filename);
    return 0;
  }

  // Write header
  const unsigned int magic = 54321;
  unsigned int xres = (unsigned int) grid_resolution[0];
  unsigned int yres = (unsigned int) grid_resolution[1];
  unsigned int header[4] = { magic, xres, yres, 1 };
  if (fwrite(header, sizeof(unsigned int), 4, fp) != 4) {
    RNFail("Unable to header to raw image file %s", filename);
    return -1;
  }

  // Allocate pixels
  float *pixels = new float [ grid_row_size ];

  // Write pixels (row by row to avoid large buffers)
  for (int i = 0; i < grid_resolution[1]; i++) {
    RNScalar *valuesp = &grid_values[i * grid_resolution[0]];
    for (int i = 0; i < grid_resolution[0]; i++) pixels[i] = (float) valuesp[i];
    if (fwrite(pixels, sizeof(float), grid_resolution[0], fp) != (unsigned int) grid_resolution[0]) {
      RNFail("Unable to write grid values to file %s\n", filename);
      return 0;
    }
  }

  // Delete pixels
  delete [] pixels;

  // Close file
  fclose(fp);

  // Return success
  return grid_size;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x18, %rsp
movq %rsi, %rbx
movq %rdi, %r14
leaq 0x39ce4(%rip), %rsi     # 0x93a31
movq %rbx, %rdi
callq 0xe550
testq %rax, %rax
je 0x59e28
movq %rax, %r15
movq %rsp, %rdi
movl $0xd431, (%rdi)         # imm = 0xD431
movq 0xc0(%r14), %rax
movq %rax, 0x4(%rdi)
movl $0x1, 0xc(%rdi)
pushq $0x4
popq %rdx
movq %rdx, %rsi
movq %r15, %rcx
callq 0xe8e0
cmpq $0x4, %rax
jne 0x59e3d
movslq 0xc8(%r14), %rax
leaq (,%rax,4), %rcx
testq %rax, %rax
pushq $-0x1
popq %rdi
cmovnsq %rcx, %rdi
callq 0xe030
movq %rax, %r12
xorl %ebp, %ebp
pushq $0x4
popq %r13
cmpl 0xc4(%r14), %ebp
jge 0x59e53
movslq 0xc0(%r14), %rdx
testl %edx, %edx
movl $0x0, %eax
cmovgl %edx, %eax
movl %edx, %ecx
imull %ebp, %ecx
movslq %ecx, %rcx
shlq $0x3, %rcx
addq 0xb8(%r14), %rcx
xorl %esi, %esi
cmpq %rsi, %rax
je 0x59e03
cvtsd2ss (%rcx,%rsi,8), %xmm0
movss %xmm0, (%r12,%rsi,4)
incq %rsi
jmp 0x59dee
movq %r12, %rdi
movq %r13, %rsi
movq %r15, %rcx
callq 0xe8e0
movl 0xc0(%r14), %ecx
incl %ebp
cmpq %rcx, %rax
je 0x59dbb
leaq 0x4064d(%rip), %rdi     # 0x9a473
jmp 0x59e2f
leaq 0x40586(%rip), %rdi     # 0x9a3b5
xorl %ebp, %ebp
movq %rbx, %rsi
xorl %eax, %eax
callq 0x681ca
jmp 0x59e6a
leaq 0x40592(%rip), %rdi     # 0x9a3d6
movq %rbx, %rsi
xorl %eax, %eax
callq 0x681ca
pushq $-0x1
popq %rbp
jmp 0x59e6a
movq %r12, %rdi
callq 0xe5d0
movq %r15, %rdi
callq 0xe440
movl 0xcc(%r14), %ebp
movl %ebp, %eax
addq $0x18, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
nop
// File: /workspace/github_cpp_makefile_star2_O2/tomfunkhouser[P]gaps/pkgs/R2Shapes/R2Grid.cpp
// Function: gaps::R2Grid::WritePFMFile(char const*) const
int R2Grid::
WritePFMFile(const char *filename) const
{
  // Open file
  FILE *fp = fopen(filename, "wb");
  if (!fp) {
    RNFail("Unable to open pfm image file %s", filename);
    return 0;
  }

  // Write header
  fprintf(fp, "Pf\n");
  fprintf(fp, "%d %d\n", grid_resolution[0], grid_resolution[1]);
  fprintf(fp, "-1.0\n");

  // Allocate pixels
  float *pixels = new float [ grid_resolution[0] ];

  // Write pixels (row by row to avoid large buffers)
  for (int i = 0; i < grid_resolution[1]; i++) {
    RNScalar *valuesp = &grid_values[i * grid_resolution[0]];
    for (int i = 0; i < grid_resolution[0]; i++) pixels[i] = valuesp[i];
    if (fwrite(pixels, sizeof(float), grid_resolution[0], fp) != (unsigned int) grid_resolution[0]) {
      RNFail("Unable to write grid values to file %s\n", filename);
      return 0;
    }
  }

  // Delete pixels
  delete [] pixels;

  // Close file
  fclose(fp);

  // Return success
  return grid_size;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
pushq %rax
movq %rsi, %rbx
movq %rdi, %r14
leaq 0x39b9d(%rip), %rsi     # 0x93a31
movq %rbx, %rdi
callq 0xe550
testq %rax, %rax
je 0x59f8b
movq %rax, %r15
movq %rbx, (%rsp)
leaq 0x40774(%rip), %rdi     # 0x9a627
pushq $0x3
popq %rsi
pushq $0x1
popq %r12
movq %r12, %rdx
movq %rax, %rcx
callq 0xe8e0
movl 0xc0(%r14), %edx
movl 0xc4(%r14), %ecx
leaq 0x39b0d(%rip), %rsi     # 0x939e7
xorl %ebp, %ebp
movq %r15, %rdi
xorl %eax, %eax
callq 0xe6a0
leaq 0x4073e(%rip), %rdi     # 0x9a62b
pushq $0x5
popq %rsi
movq %r12, %rdx
movq %r15, %rcx
callq 0xe8e0
movslq 0xc0(%r14), %rbx
leaq (,%rbx,4), %rax
testq %rbx, %rbx
pushq $-0x1
popq %rdi
cmovnsq %rax, %rdi
callq 0xe030
movq %rax, %r12
pushq $0x4
popq %r13
cmpl 0xc4(%r14), %ebp
jge 0x59fa0
testl %ebx, %ebx
movl $0x0, %eax
cmovgl %ebx, %eax
movl %ebx, %ecx
imull %ebp, %ecx
movslq %ecx, %rcx
shlq $0x3, %rcx
addq 0xb8(%r14), %rcx
xorl %edx, %edx
cmpq %rdx, %rax
je 0x59f5d
cvtsd2ss (%rcx,%rdx,8), %xmm0
movss %xmm0, (%r12,%rdx,4)
incq %rdx
jmp 0x59f48
movslq %ebx, %rdx
movq %r12, %rdi
movq %r13, %rsi
movq %r15, %rcx
callq 0xe8e0
movl 0xc0(%r14), %ebx
incl %ebp
cmpq %rbx, %rax
je 0x59f20
leaq 0x404f0(%rip), %rdi     # 0x9a473
xorl %ebp, %ebp
movq (%rsp), %rsi
jmp 0x59f97
leaq 0x40674(%rip), %rdi     # 0x9a606
xorl %ebp, %ebp
movq %rbx, %rsi
xorl %eax, %eax
callq 0x681ca
jmp 0x59fb7
movq %r12, %rdi
callq 0xe5d0
movq %r15, %rdi
callq 0xe440
movl 0xcc(%r14), %ebp
movl %ebp, %eax
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
// File: /workspace/github_cpp_makefile_star2_O2/tomfunkhouser[P]gaps/pkgs/R2Shapes/R2Grid.cpp
// Function: gaps::R2Grid::WritePNGFile(char const*) const
int R2Grid::
WritePNGFile(const char *filename) const
{
  // Open the file 
  FILE *fp = fopen(filename, "wb");
  if (fp == NULL) {
    RNFail("Unable to open PNG file %s\n", filename);
    return 0;
  }
  
  // Write the file
  if (!WritePNGStream(fp)) {
    fclose(fp);
    return 0;
  }

  // Close the file 
  fclose(fp);

  // Return success
  return 1;
}

// Assembly:
pushq %r15
pushq %r14
pushq %rbx
movq %rsi, %rbx
movq %rdi, %r14
leaq 0x39a57(%rip), %rsi     # 0x93a31
movq %rbx, %rdi
callq 0xe550
testq %rax, %rax
je 0x5a003
movq %rax, %r15
movq %r14, %rdi
movq %rax, %rsi
callq 0x5a920
movl %eax, %ebx
movq %r15, %rdi
callq 0xe440
movl %ebx, %eax
jmp 0x5a016
leaq 0x40715(%rip), %rdi     # 0x9a71f
movq %rbx, %rsi
xorl %eax, %eax
callq 0x681ca
xorl %eax, %eax
popq %rbx
popq %r14
popq %r15
retq
// File: /workspace/github_cpp_makefile_star2_O2/tomfunkhouser[P]gaps/pkgs/R2Shapes/R2Grid.cpp
// Function: gaps::R2Grid::WriteGridFile(char const*) const
int R2Grid::
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 = WriteGridStream(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 0x5a058
movq %rsi, %r14
leaq 0x399fe(%rip), %rsi     # 0x93a31
movq %r14, %rdi
callq 0xe550
movq %rax, %r15
testq %rax, %rax
jne 0x5a062
leaq 0x39320(%rip), %rdi     # 0x9336a
xorl %ebx, %ebx
movq %r14, %rsi
xorl %eax, %eax
callq 0x681ca
jmp 0x5a07f
movq 0x7ff21(%rip), %rax     # 0xd9f80
movq (%rax), %r15
movq %rbx, %rdi
movq %r15, %rsi
callq 0x5a40c
testl %eax, %eax
je 0x5a07d
movl %eax, %ebx
movq %r15, %rdi
callq 0xe440
jmp 0x5a07f
xorl %ebx, %ebx
movl %ebx, %eax
popq %rbx
popq %r14
popq %r15
retq
nop
// File: /workspace/github_cpp_makefile_star2_O2/tomfunkhouser[P]gaps/pkgs/R2Shapes/R2Grid.cpp
// Function: gaps::R2Grid::WriteImageFile(char const*) const
int R2Grid::
WriteImageFile(const char *filename) const
{
  // Allocate image
  R2Image *image = new R2Image(grid_resolution[0], grid_resolution[1], 3);
  if (!image) {
    RNFail("Unable to allocate image for %s\n", filename);
    return 0;
  }

  // Fill image pixel values
  RNInterval range = Range();
  if (range.Diameter() > 0) {
    for (int j = 0; j < image->Height(); j++) {
      for (int i = 0; i < image->Width(); i++) {
        RNScalar value = (GridValue(i, j) - range.Min()) / (range.Max() - range.Min());
        image->SetPixelRGB(i, j, RNRgb(value, value, value));
      }
    }
  }

  // Mark unknown values
  RNRgb unknown_rgb(1, 0.5, 0);
  for (int j = 0; j < image->Height(); j++) {
    for (int i = 0; i < image->Width(); i++) {
      if (GridValue(i, j) != R2_GRID_UNKNOWN_VALUE) continue;
      image->SetPixelRGB(i, j, unknown_rgb);
    }
  }

  // Write image
  if (!image->Write(filename)) { 
    // RNFail("Unable to write image to %s\n", filename);
    delete image; 
    return 0; 
  }

  // Delete image
  delete image;

  // Return success
  return 1;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x38, %rsp
movq %rsi, 0x8(%rsp)
movq %rdi, %r15
pushq $0x18
popq %rdi
callq 0xe450
movq %rax, %rbx
movl 0xc0(%r15), %esi
movl 0xc4(%r15), %edx
pushq $0x3
popq %rcx
movq %rax, %rdi
callq 0x6011e
leaq 0x10(%rsp), %r12
movq %r12, %rdi
movq %r15, %rsi
callq 0x52194
movsd 0x8(%r12), %xmm0
ucomisd (%r12), %xmm0
jbe 0x5a154
xorl %r12d, %r12d
leaq 0x20(%rsp), %r13
cmpl 0x4(%rbx), %r12d
jge 0x5a154
movslq %r12d, %r14
xorl %ebp, %ebp
cmpl (%rbx), %ebp
jge 0x5a14f
movq 0xb8(%r15), %rax
movslq 0xc8(%r15), %rcx
imulq %r14, %rcx
addq %rbp, %rcx
movsd (%rax,%rcx,8), %xmm0
movsd 0x10(%rsp), %xmm1
movsd 0x18(%rsp), %xmm2
subsd %xmm1, %xmm0
subsd %xmm1, %xmm2
divsd %xmm2, %xmm0
movq %r13, %rdi
movapd %xmm0, %xmm1
movapd %xmm0, %xmm2
callq 0x66182
movq %rbx, %rdi
movl %ebp, %esi
movl %r12d, %edx
movq %r13, %rcx
callq 0x604ac
incq %rbp
jmp 0x5a0f4
incl %r12d
jmp 0x5a0e9
leaq 0x20(%rsp), %r12
movsd 0x38ea7(%rip), %xmm0    # 0x93008
movsd 0x38ea7(%rip), %xmm1    # 0x93010
xorps %xmm2, %xmm2
movq %r12, %rdi
callq 0x66182
xorl %r13d, %r13d
movsd 0x39de9(%rip), %xmm1    # 0x93f68
cmpl 0x4(%rbx), %r13d
jge 0x5a1d2
movslq %r13d, %r14
xorl %ebp, %ebp
cmpl (%rbx), %ebp
jge 0x5a1cd
movq 0xb8(%r15), %rax
movslq 0xc8(%r15), %rcx
imulq %r14, %rcx
addq %rbp, %rcx
movsd (%rax,%rcx,8), %xmm0
ucomisd %xmm1, %xmm0
jne 0x5a1c8
jp 0x5a1c8
movq %rbx, %rdi
movl %ebp, %esi
movl %r13d, %edx
movq %r12, %rcx
callq 0x604ac
movsd 0x39da0(%rip), %xmm1    # 0x93f68
incq %rbp
jmp 0x5a18a
incl %r13d
jmp 0x5a17f
movq %rbx, %rdi
movq 0x8(%rsp), %rsi
callq 0x61d56
xorl %ebp, %ebp
testl %eax, %eax
setne %bpl
movq %rbx, %rdi
callq 0x60360
pushq $0x18
popq %rsi
movq %rbx, %rdi
callq 0xe460
movl %ebp, %eax
addq $0x38, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq %rax, %r14
pushq $0x18
popq %rsi
movq %rbx, %rdi
callq 0xe460
movq %r14, %rdi
callq 0xe810
nop
// File: /workspace/github_cpp_makefile_star2_O2/tomfunkhouser[P]gaps/pkgs/R2Shapes/R2Grid.cpp
// Function: gaps::R2Grid::WriteGridStream(_IO_FILE*) const
int R2Grid::
WriteGridStream(FILE *fp) const
{
  // Write grid resolution from file
  if (fwrite(&grid_resolution, sizeof(int), 2, fp) != 2) {
    RNFail("Unable to write resolution to file");
    return 0;
  }

  // Write world_to_grid transformation to file
  const RNScalar *m = &(world_to_grid_transform.Matrix()[0][0]);
  if (fwrite(m, sizeof(RNScalar), 9, fp) != 9) {
    RNFail("Unable to write transformation matrix to file");
    return 0;
  }

  // Write grid values (row by row to avoid large buffers)
  for (int i = 0; i < grid_resolution[1]; i++) {
    RNScalar *row_values = &grid_values[i * grid_resolution[0]];
    if (fwrite(row_values, sizeof(RNScalar), grid_resolution[0], fp) != (unsigned int) grid_resolution[0]) {
      RNFail("Unable to write grid values to grid\n");
      return 0;
    }
  }

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

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %rbx
pushq %rax
movq %rsi, %r14
movq %rdi, %rbx
leaq 0xc0(%rdi), %rdi
pushq $0x4
popq %rsi
pushq $0x2
popq %rdx
movq %r14, %rcx
callq 0xe8e0
cmpq $0x2, %rax
jne 0x5a494
leaq 0x60(%rbx), %rdi
pushq $0x8
popq %rsi
pushq $0x9
popq %rdx
movq %r14, %rcx
callq 0xe8e0
cmpq $0x9, %rax
jne 0x5a49d
xorl %ebp, %ebp
pushq $0x8
popq %r15
cmpl 0xc4(%rbx), %ebp
jge 0x5a4ba
movslq 0xc0(%rbx), %rdx
movslq %ebp, %rdi
imulq %rdx, %rdi
shlq $0x3, %rdi
addq 0xb8(%rbx), %rdi
movq %r15, %rsi
movq %r14, %rcx
callq 0xe8e0
movl 0xc0(%rbx), %ecx
incl %ebp
cmpq %rcx, %rax
je 0x5a452
leaq 0x40246(%rip), %rdi     # 0x9a6d8
jmp 0x5a4a4
leaq 0x3e3d3(%rip), %rdi     # 0x9886e
jmp 0x5a4a4
leaq 0x40206(%rip), %rdi     # 0x9a6aa
xorl %ebx, %ebx
xorl %eax, %eax
callq 0x681ca
movl %ebx, %eax
addq $0x8, %rsp
popq %rbx
popq %r14
popq %r15
popq %rbp
retq
movl 0xcc(%rbx), %ebx
jmp 0x5a4ad
// File: /workspace/github_cpp_makefile_star2_O2/tomfunkhouser[P]gaps/pkgs/R2Shapes/R2Grid.cpp
// Function: gaps::R2Grid::ReadGridBuffer(char*, unsigned long)
int R2Grid::
ReadGridBuffer(char *buffer, size_t buffer_length)
{
  // Open stream
  FILE *fp = fmemopen((void *) buffer, buffer_length, "r");
  if (!fp) {
    RNFail("Unable to open Grid stream\n");
    return 0;
   }

  // Read file
  if (!ReadGridStream(fp)) {
    fclose(fp);
    return 0;
  }

  // Close the file 
  fclose(fp);

  // Return success 
  return 1;
}

// Assembly:
pushq %r14
pushq %rbx
pushq %rax
movq %rdi, %rbx
leaq 0x42623(%rip), %rax     # 0x9caf3
movq %rsi, %rdi
movq %rdx, %rsi
movq %rax, %rdx
callq 0xe8d0
testq %rax, %rax
je 0x5a502
movq %rax, %r14
movq %rbx, %rdi
movq %rax, %rsi
callq 0x5a222
xorl %ebx, %ebx
testl %eax, %eax
setne %bl
movq %r14, %rdi
callq 0xe440
jmp 0x5a512
leaq 0x401f4(%rip), %rdi     # 0x9a6fd
xorl %ebx, %ebx
xorl %eax, %eax
callq 0x681ca
movl %ebx, %eax
addq $0x8, %rsp
popq %rbx
popq %r14
retq
// File: /workspace/github_cpp_makefile_star2_O2/tomfunkhouser[P]gaps/pkgs/R2Shapes/R2Grid.cpp
// Function: gaps::R2Grid::WriteGridBuffer(char**, unsigned long*) const
int R2Grid::
WriteGridBuffer(char **buffer, size_t *buffer_length) const
{
  // Open the file 
  FILE *fp = open_memstream(buffer, buffer_length);
  if (fp == NULL) {
    RNFail("Unable to open Grid stream\n");
    return 0;
  }
  
  // Write the file
  if (!WriteGridStream(fp)) {
    fclose(fp);
    return 0;
  }

  // Close the file 
  fclose(fp);

  // Return success
  return 1;
}

// Assembly:
pushq %r14
pushq %rbx
pushq %rax
movq %rdi, %rbx
movq %rsi, %rdi
movq %rdx, %rsi
callq 0xe4b0
testq %rax, %rax
je 0x5a552
movq %rax, %r14
movq %rbx, %rdi
movq %rax, %rsi
callq 0x5a40c
xorl %ebx, %ebx
testl %eax, %eax
setne %bl
movq %r14, %rdi
callq 0xe440
jmp 0x5a562
leaq 0x401a4(%rip), %rdi     # 0x9a6fd
xorl %ebx, %ebx
xorl %eax, %eax
callq 0x681ca
movl %ebx, %eax
addq $0x8, %rsp
popq %rbx
popq %r14
retq
// File: /workspace/github_cpp_makefile_star2_O2/tomfunkhouser[P]gaps/pkgs/R2Shapes/R2Grid.cpp
// Function: gaps::R2Grid::ReadPNGBuffer(char*, unsigned long)
int R2Grid::
ReadPNGBuffer(char *buffer, size_t buffer_length)
{
  // Open stream
  FILE *fp = fmemopen((void *) buffer, buffer_length, "r");
  if (!fp) {
    RNFail("Unable to open PNG stream\n");
    return 0;
   }

  // Read file
  if (!ReadPNGStream(fp)) {
    fclose(fp);
    return 0;
  }

  // Close the file 
  fclose(fp);

  // Return success 
  return 1;
}

// Assembly:
pushq %r14
pushq %rbx
pushq %rax
movq %rdi, %rbx
leaq 0x41fe7(%rip), %rax     # 0x9caf3
movq %rsi, %rdi
movq %rdx, %rsi
movq %rax, %rdx
callq 0xe8d0
testq %rax, %rax
je 0x5ab3b
movq %rax, %r14
movq %rbx, %rdi
movq %rax, %rsi
callq 0x5a56c
movl %eax, %ebx
movq %r14, %rdi
callq 0xe440
movl %ebx, %eax
jmp 0x5ab4b
leaq 0x3fbf9(%rip), %rdi     # 0x9a73b
xorl %eax, %eax
callq 0x681ca
xorl %eax, %eax
addq $0x8, %rsp
popq %rbx
popq %r14
retq
nop
// File: /workspace/github_cpp_makefile_star2_O2/tomfunkhouser[P]gaps/pkgs/R2Shapes/R2Grid.cpp
// Function: gaps::R2Grid::WritePNGBuffer(char**, unsigned long*) const
int R2Grid::
WritePNGBuffer(char **buffer, size_t *buffer_length) const
{
  // Open the file 
  FILE *fp = open_memstream(buffer, buffer_length);
  if (fp == NULL) {
    RNFail("Unable to open PNG stream\n");
    return 0;
  }
  
  // Write the file
  if (!WritePNGStream(fp)) {
    fclose(fp);
    return 0;
  }

  // Close the file 
  fclose(fp);

  // Return success
  return 1;
}

// Assembly:
pushq %r14
pushq %rbx
pushq %rax
movq %rdi, %rbx
movq %rsi, %rdi
movq %rdx, %rsi
callq 0xe4b0
testq %rax, %rax
je 0x5ab87
movq %rax, %r14
movq %rbx, %rdi
movq %rax, %rsi
callq 0x5a920
movl %eax, %ebx
movq %r14, %rdi
callq 0xe440
movl %ebx, %eax
jmp 0x5ab97
leaq 0x3fbad(%rip), %rdi     # 0x9a73b
xorl %eax, %eax
callq 0x681ca
xorl %eax, %eax
addq $0x8, %rsp
popq %rbx
popq %r14
retq
nop
// File: /workspace/github_cpp_makefile_star2_O2/tomfunkhouser[P]gaps/pkgs/R2Shapes/R2Grid.cpp
// Function: gaps::R2Grid::Print(_IO_FILE*) const
int R2Grid::
Print(FILE *fp) const
{
  // Check file
  if (!fp) fp = stdout;

  // Print values
  for (int j = 0; j < YResolution(); j++) {
    for (int i = 0; i < XResolution(); i++) {
      fprintf(fp, "%g ", GridValue(i, j));
    }
    fprintf(fp, "\n");
  }

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

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
pushq %rax
movq %rsi, %r14
movq %rdi, %rbx
testq %rsi, %rsi
jne 0x5abc0
movq 0x7f3c3(%rip), %rax     # 0xd9f80
movq (%rax), %r14
xorl %r12d, %r12d
leaq 0x3e929(%rip), %r15     # 0x994f3
cmpl 0xc4(%rbx), %r12d
jge 0x5ac1c
movslq %r12d, %r13
xorl %ebp, %ebp
cmpl 0xc0(%rbx), %ebp
jge 0x5ac0c
movq 0xb8(%rbx), %rax
movslq 0xc8(%rbx), %rcx
imulq %r13, %rcx
addq %rbp, %rcx
movsd (%rax,%rcx,8), %xmm0
movq %r14, %rdi
movq %r15, %rsi
movb $0x1, %al
callq 0xe6a0
incq %rbp
jmp 0x5abd8
pushq $0xa
popq %rdi
movq %r14, %rsi
callq 0xe5c0
incl %r12d
jmp 0x5abca
movl 0xcc(%rbx), %eax
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
nop
// File: /workspace/github_cpp_makefile_star2_O2/tomfunkhouser[P]gaps/pkgs/R2Shapes/./R2Grid.h
// Function: gaps::R2Grid::WorldBox() const
inline R2Box R2Grid::
WorldBox(void) const
{
  // Return bounding box in world coordinates
  R2Point p1(0, 0);
  R2Point p2(grid_resolution[0]-1, grid_resolution[1]-1);
  return R2Box(WorldPosition(p1), WorldPosition(p2));
}

// Assembly:
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x40, %rsp
movq %rsi, %r14
movq %rdi, %rbx
leaq 0x30(%rsp), %r15
xorps %xmm0, %xmm0
xorps %xmm1, %xmm1
movq %r15, %rdi
callq 0x5f58c
movl 0xc0(%r14), %eax
decl %eax
cvtsi2sd %eax, %xmm0
movl 0xc4(%r14), %eax
decl %eax
cvtsi2sd %eax, %xmm1
leaq 0x20(%rsp), %r12
movq %r12, %rdi
callq 0x5f58c
leaq 0x10(%rsp), %r13
movq %r13, %rdi
movq %r14, %rsi
movq %r15, %rdx
callq 0x5adb8
movq %rsp, %r15
movq %r15, %rdi
movq %r14, %rsi
movq %r12, %rdx
callq 0x5adb8
movq %rbx, %rdi
movq %r13, %rsi
movq %r15, %rdx
callq 0x5caa8
movq %rbx, %rax
addq $0x40, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
retq
// File: /workspace/github_cpp_makefile_star2_O2/tomfunkhouser[P]gaps/pkgs/R2Shapes/R2Polygon.cpp
// Function: gaps::R2Polygon::R2Polygon(gaps::R2Polygon const&)
R2Polygon::
R2Polygon(const R2Polygon& polygon) 
  : points(NULL),
    npoints(polygon.npoints),
    bbox(polygon.bbox),
    clockwise(polygon.clockwise)
{
  // Copy points
  if (polygon.npoints > 0) {
    points = new R2Point [ npoints ];
    for (int i = 0; i < npoints; i++) {
      points[i] = polygon.points[i];
    }
  }
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
pushq %rax
movq %rsi, %r15
movq %rdi, %rbx
callq 0x5d2e2
leaq 0x7e4df(%rip), %rax     # 0xd9320
movq %rax, (%rbx)
andq $0x0, 0x8(%rbx)
movl 0x10(%r15), %eax
movl %eax, 0x10(%rbx)
leaq 0x18(%rbx), %rdi
leaq 0x18(%r15), %rsi
movq %rdi, (%rsp)
callq 0x5ca56
movl 0x40(%r15), %eax
movl %eax, 0x40(%rbx)
cmpl $0x0, 0x10(%r15)
jle 0x5aed9
movslq 0x10(%rbx), %r14
movq %r14, %rbp
shlq $0x4, %rbp
testq %r14, %r14
pushq $-0x1
popq %r12
cmovnsq %rbp, %r12
movq %r12, %rdi
callq 0xe030
movq %rax, %r13
testl %r14d, %r14d
je 0x5aeaa
xorl %r14d, %r14d
leaq (%r14,%r13), %rdi
callq 0x5f58a
addq $0x10, %r14
cmpq %r14, %rbp
jne 0x5ae98
movq %r13, 0x8(%rbx)
xorl %r12d, %r12d
xorl %r13d, %r13d
movslq 0x10(%rbx), %rax
cmpq %rax, %r13
jge 0x5aed9
movq 0x8(%r15), %rsi
addq %r12, %rsi
movq 0x8(%rbx), %rdi
addq %r12, %rdi
callq 0x5f6c4
incq %r13
addq $0x10, %r12
jmp 0x5aeb4
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
jmp 0x5aeff
movq %rax, %r15
jmp 0x5af0b
movq %rax, %r15
movq %r13, %rdi
movq %r12, %rsi
callq 0xe8f0
jmp 0x5af02
movq %rax, %r15
movq (%rsp), %rdi
callq 0x5d2ee
movq %rbx, %rdi
callq 0x5d2ee
movq %r15, %rdi
callq 0xe810
nop
// File: /workspace/github_cpp_makefile_star2_O2/tomfunkhouser[P]gaps/pkgs/R2Shapes/R2Polygon.cpp
// Function: gaps::R2Polygon::R2Polygon(gaps::RNArray<gaps::R2Point*> const&, int)
R2Polygon::
R2Polygon(const RNArray<R2Point *>& p, RNBoolean clockwise)
  : points(NULL),
    npoints(p.NEntries()),
    bbox(R2null_box),
    clockwise(clockwise)
{
  // Copy points
  if (npoints > 0) {
    points = new R2Point [ npoints ];
    for (int i = 0; i < npoints; i++) {
      points[i] = *(p[i]);
      bbox.Union(*(p[i]));
    }
  }
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
pushq %rax
movl %edx, %ebp
movq %rsi, %r15
movq %rdi, %rbx
callq 0x5d2e2
leaq 0x7e3e5(%rip), %rax     # 0xd9320
movq %rax, (%rbx)
andq $0x0, 0x8(%rbx)
movl 0xc(%r15), %eax
movl %eax, 0x10(%rbx)
leaq 0x18(%rbx), %r14
leaq 0x481f93(%rip), %rsi    # 0x4dcee8
movq %r14, %rdi
callq 0x5ca56
movl %ebp, 0x40(%rbx)
movslq 0x10(%rbx), %r12
testq %r12, %r12
jle 0x5afcc
shlq $0x4, %r12
movq %r12, %rdi
callq 0xe030
movq %rax, %r13
xorl %ebp, %ebp
movq %r13, %rdi
addq %rbp, %rdi
callq 0x5f58a
addq $0x10, %rbp
cmpq %rbp, %r12
jne 0x5af7a
movq %r13, 0x8(%rbx)
xorl %r12d, %r12d
xorl %r13d, %r13d
movslq 0x10(%rbx), %rax
cmpq %rax, %r13
jge 0x5afcc
movq (%r15), %rax
movq (%rax,%r13,8), %rsi
movq 0x8(%rbx), %rdi
addq %r12, %rdi
callq 0x5f6c4
movq (%r15), %rax
movq (%rax,%r13,8), %rsi
movq %r14, %rdi
callq 0x5d088
incq %r13
addq $0x10, %r12
jmp 0x5af98
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
jmp 0x5aff2
movq %rax, %r15
jmp 0x5affd
movq %rax, %r15
movq %r13, %rdi
movq %r12, %rsi
callq 0xe8f0
jmp 0x5aff5
movq %rax, %r15
movq %r14, %rdi
callq 0x5d2ee
movq %rbx, %rdi
callq 0x5d2ee
movq %r15, %rdi
callq 0xe810
nop
// File: /workspace/github_cpp_makefile_star2_O2/tomfunkhouser[P]gaps/pkgs/R2Shapes/R2Polygon.cpp
// Function: gaps::R2Polygon::R2Polygon(gaps::R2Point const*, int, int)
R2Polygon::
R2Polygon(const R2Point *p, int np, RNBoolean clockwise)
  : points(NULL),
    npoints(np),
    bbox(R2null_box),
    clockwise(clockwise)
{
  // Copy points
  if (npoints > 0) {
    points = new R2Point [ npoints ];
    for (int i = 0; i < npoints; i++) {
      points[i] = p[i];
      bbox.Union(p[i]);
    }
  }
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
pushq %rax
movl %ecx, %ebp
movl %edx, %r14d
movq %rsi, %r15
movq %rdi, %rbx
callq 0x5d2e2
leaq 0x7e2f0(%rip), %rax     # 0xd9320
movq %rax, (%rbx)
andq $0x0, 0x8(%rbx)
movl %r14d, 0x10(%rbx)
leaq 0x18(%rbx), %r14
leaq 0x481ea1(%rip), %rsi    # 0x4dcee8
movq %r14, %rdi
callq 0x5ca56
movl %ebp, 0x40(%rbx)
movslq 0x10(%rbx), %r12
testq %r12, %r12
jle 0x5b0b9
shlq $0x4, %r12
movq %r12, %rdi
callq 0xe030
movq %rax, %r13
xorl %ebp, %ebp
movq %r13, %rdi
addq %rbp, %rdi
callq 0x5f58a
addq $0x10, %rbp
cmpq %rbp, %r12
jne 0x5b06c
movq %r13, 0x8(%rbx)
xorl %r13d, %r13d
xorl %ebp, %ebp
movslq 0x10(%rbx), %rax
cmpq %rax, %rbp
jge 0x5b0b9
leaq (%r15,%r13), %r12
movq 0x8(%rbx), %rdi
addq %r13, %rdi
movq %r12, %rsi
callq 0x5f6c4
movq %r14, %rdi
movq %r12, %rsi
callq 0x5d088
incq %rbp
addq $0x10, %r13
jmp 0x5b089
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
jmp 0x5b0df
movq %rax, %r15
jmp 0x5b0ea
movq %rax, %r15
movq %r13, %rdi
movq %r12, %rsi
callq 0xe8f0
jmp 0x5b0e2
movq %rax, %r15
movq %r14, %rdi
callq 0x5d2ee
movq %rbx, %rdi
callq 0x5d2ee
movq %r15, %rdi
callq 0xe810
// File: /workspace/github_cpp_makefile_star2_O2/tomfunkhouser[P]gaps/pkgs/R2Shapes/R2Polygon.cpp
// Function: gaps::R2Polygon::ClosestPoint(gaps::R2Point const&) const
const R2Point R2Polygon::
ClosestPoint(const R2Point& point) const
{
  // Return closest point on polygon
  R2Point closest_point(0,0);
  RNLength closest_squared_distance = FLT_MAX;
  for (int i = 0; i < npoints; i++) {
    const R2Point& position = points[i];
    RNLength squared_distance = R2SquaredDistance(point, position);
    if (squared_distance < closest_squared_distance) {
      closest_point = position;
      closest_squared_distance = squared_distance;
    }
  }

  // Return closest point
  return closest_point;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
pushq %rax
movq %rdx, %rbx
movq %rsi, %r15
movq %rdi, %r14
xorps %xmm0, %xmm0
xorpd %xmm1, %xmm1
callq 0x5f58c
movsd 0x37eb2(%rip), %xmm0    # 0x93018
movsd %xmm0, (%rsp)
xorl %r13d, %r13d
xorl %ebp, %ebp
movslq 0x10(%r15), %rax
cmpq %rax, %rbp
jge 0x5b1b3
movq 0x8(%r15), %r12
addq %r13, %r12
movq %rbx, %rdi
movq %r12, %rsi
callq 0x639aa
movapd %xmm0, %xmm1
movsd (%rsp), %xmm0
ucomisd %xmm1, %xmm0
jbe 0x5b1aa
movq %r14, %rdi
movq %r12, %rsi
movsd %xmm1, (%rsp)
callq 0x5f6c4
incq %rbp
addq $0x10, %r13
jmp 0x5b170
movq %r14, %rax
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
nop
// File: /workspace/github_cpp_makefile_star2_O2/tomfunkhouser[P]gaps/pkgs/R2Shapes/R2Polygon.cpp
// Function: gaps::R2Polygon::Area() const
const RNArea R2Polygon::
Area(void) const
{
  // Check number of points
  if (npoints < 3) return 0;

  // Compute twicearea by sum of cross products
  RNLength sum = 0;
  R2Point *p1 = &points[npoints-1];
  for (int i = 0; i < npoints; i++) {
    R2Point *p2 = &points[i];
    sum += p1->X()*p2->Y() - p2->X()*p1->Y();
    p1 = p2;
  }

  // Compute area
  RNArea area = 0.5 * sum;

  // Flip if clockwise
  if (clockwise) area = -area;

  // Return area
  return area;
}

// Assembly:
movslq 0x10(%rdi), %rax
xorpd %xmm0, %xmm0
cmpq $0x3, %rax
jl 0x5b251
movq 0x8(%rdi), %rdx
movq %rax, %rcx
shlq $0x4, %rcx
leaq (%rdx,%rcx), %rsi
addq $-0x10, %rsi
subq $0x1, %rax
jb 0x5b23b
movq %rdx, %rcx
movsd (%rsi), %xmm1
movsd 0x8(%rsi), %xmm2
mulsd (%rdx), %xmm2
mulsd 0x8(%rdx), %xmm1
subsd %xmm2, %xmm1
addsd %xmm1, %xmm0
addq $0x10, %rdx
movq %rcx, %rsi
jmp 0x5b20f
mulsd 0x37dcd(%rip), %xmm0    # 0x93010
cmpl $0x0, 0x40(%rdi)
je 0x5b251
xorpd 0x37ddf(%rip), %xmm0    # 0x93030
retq
// File: /workspace/github_cpp_makefile_star2_O2/tomfunkhouser[P]gaps/pkgs/R2Shapes/R2Polygon.cpp
// Function: gaps::R2Polygon::Convexity() const
const RNArea R2Polygon::
Convexity(void) const
{
  // Check number of points
  if (npoints < 3) return 0;

  // Compute area
  RNArea area = Area();

  // Compute area of convex hull
  R2Polygon convex_hull = ConvexHull();
  RNArea convex_hull_area = convex_hull.Area();
  if (convex_hull_area == 0) return 0;

  // Return ratio of areas
  return area / convex_hull_area;
}

// Assembly:
xorpd %xmm0, %xmm0
cmpl $0x3, 0x10(%rdi)
jl 0x5b2b9
pushq %r14
pushq %rbx
subq $0x58, %rsp
movq %rdi, %rbx
movq (%rdi), %rax
callq *0x30(%rax)
movapd %xmm0, (%rsp)
movq (%rbx), %rax
leaq 0x10(%rsp), %r14
movq %r14, %rdi
movq %rbx, %rsi
callq *0x68(%rax)
movq %r14, %rdi
callq 0x5b1ee
movapd (%rsp), %xmm1
divsd %xmm0, %xmm1
xorpd %xmm2, %xmm2
cmpeqsd %xmm0, %xmm2
andnpd %xmm1, %xmm2
movapd %xmm2, (%rsp)
movq %r14, %rdi
callq 0x5b0fa
movapd (%rsp), %xmm0
addq $0x58, %rsp
popq %rbx
popq %r14
retq
// File: /workspace/github_cpp_makefile_star2_O2/tomfunkhouser[P]gaps/pkgs/R2Shapes/R2Polygon.cpp
// Function: gaps::R2Polygon::Perimeter() const
const RNLength R2Polygon::
Perimeter(void) const
{
  // Check number of points
  if (npoints < 2) return 0;

  // Compute perimeter
  RNLength sum = 0;
  R2Point *p1 = &points[npoints-1];
  for (int i = 0; i < npoints; i++) {
    R2Point *p2 = &points[i];
    sum += R2Distance(*p1, *p2);
    p1 = p2;
  }

  // Return perimeter
  return sum;
}

// Assembly:
movslq 0x10(%rdi), %rax
xorpd %xmm0, %xmm0
cmpq $0x2, %rax
jl 0x5b338
pushq %r15
pushq %r14
pushq %r12
pushq %rbx
pushq %rax
movq %rdi, %rbx
movq 0x8(%rdi), %rcx
movq %rax, %rdx
shlq $0x4, %rdx
leaq (%rcx,%rdx), %rdi
addq $-0x10, %rdi
xorpd %xmm0, %xmm0
xorl %r15d, %r15d
xorl %r12d, %r12d
cltq
cmpq %rax, %r12
jge 0x5b32d
movq 0x8(%rbx), %r14
addq %r15, %r14
movq %r14, %rsi
movsd %xmm0, (%rsp)
callq 0x63469
movsd (%rsp), %xmm1
addsd %xmm0, %xmm1
movsd %xmm1, (%rsp)
movsd (%rsp), %xmm0
incq %r12
movl 0x10(%rbx), %eax
addq $0x10, %r15
movq %r14, %rdi
jmp 0x5b2f0
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r14
popq %r15
retq
nop
// File: /workspace/github_cpp_makefile_star2_O2/tomfunkhouser[P]gaps/pkgs/R2Shapes/R2Polygon.cpp
// Function: gaps::R2Polygon::Centroid() const
const R2Point R2Polygon::
Centroid(void) const
{
  // Check number of points
  if (npoints == 0) return R2zero_point;

  // Return centroid
  R2Point sum = R2zero_point;
  for (int i = 0; i < npoints; i++) sum += points[i];
  return sum / npoints;
}

// Assembly:
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x10, %rsp
movq %rdi, %rbx
cmpl $0x0, 0x10(%rsi)
je 0x5b39d
movq %rsi, %r14
leaq 0x481f36(%rip), %rsi    # 0x4dd290
movq %rsp, %r15
movq %r15, %rdi
callq 0x5f596
xorl %r12d, %r12d
xorl %r13d, %r13d
movslq 0x10(%r14), %rax
cmpq %rax, %r13
jge 0x5b38c
movq 0x8(%r14), %rsi
addq %r12, %rsi
movq %r15, %rdi
callq 0x5f6da
incq %r13
addq $0x10, %r12
jmp 0x5b36b
cvtsi2sd %eax, %xmm0
movq %rsp, %rsi
movq %rbx, %rdi
callq 0x5f847
jmp 0x5b3ac
leaq 0x481eec(%rip), %rsi    # 0x4dd290
movq %rbx, %rdi
callq 0x5f596
movq %rbx, %rax
addq $0x10, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
retq
nop
// File: /workspace/github_cpp_makefile_star2_O2/tomfunkhouser[P]gaps/pkgs/R2Shapes/R2Polygon.cpp
// Function: gaps::R2Polygon::Empty()
void R2Polygon::
Empty(void)
{
    // Empty polygon
    if (points) delete [] points;
    points = NULL;
    npoints = 0;
    bbox = R2null_box;
}

// Assembly:
pushq %rbx
movq %rdi, %rbx
movq 0x8(%rdi), %rdi
testq %rdi, %rdi
je 0x5c01a
callq 0xe5d0
andq $0x0, 0x8(%rbx)
andl $0x0, 0x10(%rbx)
addq $0x18, %rbx
leaq 0x480eba(%rip), %rsi    # 0x4dcee8
movq %rbx, %rdi
popq %rbx
jmp 0x51550
nop
// File: /workspace/github_cpp_makefile_star2_O2/tomfunkhouser[P]gaps/pkgs/R2Shapes/R2Polygon.cpp
// Function: gaps::R2Polygon::RemovePoint(int)
void R2Polygon::
RemovePoint(int k)
{
    // Copy points down one
    npoints--;
    for (int i = k; k < npoints; i++) {
      points[i] = points[i+1];
    }

    // Update bounding box
    bbox = R2null_box;
    for (int i = 0; i < npoints; i++) {
        bbox.Union(points[i]);
    }
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r12
pushq %rbx
movl %esi, %ebp
movq %rdi, %rbx
movl 0x10(%rdi), %eax
decl %eax
movl %eax, 0x10(%rdi)
movslq %esi, %r14
shlq $0x4, %r14
cmpl %ebp, %eax
jle 0x5c075
movq 0x8(%rbx), %rdi
leaq (%rdi,%r14), %rsi
addq $0x10, %rsi
addq %r14, %rdi
callq 0x5f6c4
movl 0x10(%rbx), %eax
addq $0x10, %r14
jmp 0x5c054
leaq 0x18(%rbx), %r14
leaq 0x480e68(%rip), %rsi    # 0x4dcee8
movq %r14, %rdi
callq 0x51550
xorl %r15d, %r15d
xorl %r12d, %r12d
movslq 0x10(%rbx), %rax
cmpq %rax, %r12
jge 0x5c0af
movq 0x8(%rbx), %rsi
addq %r15, %rsi
movq %r14, %rdi
callq 0x5d088
incq %r12
addq $0x10, %r15
jmp 0x5c08e
popq %rbx
popq %r12
popq %r14
popq %r15
popq %rbp
retq