LLM4Binary/decompile-bench-makefile huggingface dataset:
// File: /workspace/github_cpp_makefile_star2_O3/tomfunkhouser[P]gaps/pkgs/R2Shapes/R2Grid.cpp
// Function: gaps::R2Grid::RasterizeGridBox(int const*, int const*, double, int)
void R2Grid::
RasterizeGridBox(const int p1[2], const int p2[2], RNScalar value, int operation)
{
  // Check value
  if (value == R2_GRID_UNKNOWN_VALUE) return;

  // Clip box
  int x1 = p1[0];
  if (x1 < 0) x1 = 0;
  if (x1 > XResolution()-1) return;
  int x2 = p2[0];
  if (x2 < 0) return;
  if (x2 > XResolution()-1) x2 = XResolution()-1;
  int y1 = p1[1];
  if (y1 < 0) y1 = 0;
  if (y1 > YResolution()-1) return;
  int y2 = p2[1];
  if (y2 < 0) return;
  if (y2 > YResolution()-1) y2 = YResolution()-1;

  // Rasterize box
  for (int ix = x1; ix <= x2; ix++) {
    for (int iy = y1; iy <= y2; iy++) {
      RasterizeGridValue(ix, iy, value, operation);
    }
  }
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x18, %rsp
ucomisd 0x43fcc(%rip), %xmm0    # 0xa2fb8
jne 0x5eff4
jnp 0x5f0a2
movq %rdi, %r14
movl (%rsi), %eax
xorl %r15d, %r15d
testl %eax, %eax
cmovgl %eax, %r15d
movl 0xc0(%rdi), %eax
cmpl %eax, %r15d
jge 0x5f0a2
movl %ecx, %ebx
movl (%rdx), %ecx
testl %ecx, %ecx
js 0x5f0a2
leal -0x1(%rax), %edi
cmpl %eax, %ecx
cmovbl %ecx, %edi
movl %edi, 0x4(%rsp)
movl 0x4(%rsi), %eax
xorl %r13d, %r13d
testl %eax, %eax
cmovgl %eax, %r13d
movl 0xc4(%r14), %eax
cmpl %eax, %r13d
jge 0x5f0a2
movl 0x4(%rdx), %ecx
testl %ecx, %ecx
sets %dl
cmpl 0x4(%rsp), %r15d
seta %sil
orb %dl, %sil
jne 0x5f0a2
leal -0x1(%rax), %edx
cmpl %eax, %ecx
cmovbl %ecx, %edx
movq %rdx, 0x8(%rsp)
leal 0x1(%rdx), %r12d
movsd %xmm0, 0x10(%rsp)
movl %r13d, %ebp
cmpl 0x8(%rsp), %r13d
ja 0x5f094
movq %r14, %rdi
movl %r15d, %esi
movl %ebp, %edx
movsd 0x10(%rsp), %xmm0
movl %ebx, %ecx
callq 0x5eb14
incl %ebp
cmpl %ebp, %r12d
jne 0x5f078
leal 0x1(%r15), %eax
cmpl 0x4(%rsp), %r15d
movl %eax, %r15d
jne 0x5f06e
addq $0x18, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
nop
// File: /workspace/github_cpp_makefile_star2_O3/tomfunkhouser[P]gaps/pkgs/R2Shapes/R2Grid.cpp
// Function: gaps::CompareScanLineCrossings(void const*, void const*)
static int CompareScanLineCrossings(const void *data1, const void *data2)
{
  ScanLineCrossing *crossing1 = (ScanLineCrossing *) data1;
  ScanLineCrossing *crossing2 = (ScanLineCrossing *) data2;
  if (RNIsLess(crossing1->x, crossing2->x)) return -1;
  else if (RNIsGreater(crossing1->x, crossing2->x)) return 1;
  else if (crossing1->side < crossing2->side) return -1;
  else if (crossing1->side > crossing2->side) return 1;
  else return 0;
}

// Assembly:
movsd (%rdi), %xmm0
leaq 0x8634b(%rip), %rax     # 0xe5b98
movsd (%rax), %xmm1
subsd (%rsi), %xmm0
movapd 0x427c3(%rip), %xmm2    # 0xa2020
xorpd %xmm1, %xmm2
movl $0xffffffff, %eax       # imm = 0xFFFFFFFF
ucomisd %xmm0, %xmm2
ja 0x5f88a
movl $0x1, %eax
ucomisd %xmm1, %xmm0
ja 0x5f88a
movl 0x8(%rsi), %ecx
movl $0xffffffff, %eax       # imm = 0xFFFFFFFF
cmpl %ecx, 0x8(%rdi)
jl 0x5f88a
setg %al
movzbl %al, %eax
retq
nop
// File: /workspace/github_cpp_makefile_star2_O3/tomfunkhouser[P]gaps/pkgs/R2Shapes/R2Grid.cpp
// Function: gaps::R2Grid::RasterizeWorldPolygon(gaps::R2Polygon const&, double, int)
void R2Grid::
RasterizeWorldPolygon(const R2Polygon& polygon, RNScalar value, int operation) 
{
  // Rasterize polygon into grid coordinates
  R2Polygon transformed_polygon(polygon);
  transformed_polygon.Transform(WorldToGridTransformation());
  RasterizeGridPolygon(transformed_polygon, value, operation);
}

// Assembly:
pushq %r15
pushq %r14
pushq %rbx
subq $0x50, %rsp
movl %edx, %ebx
movsd %xmm0, (%rsp)
movq %rdi, %r14
leaq 0x8(%rsp), %r15
movq %r15, %rdi
callq 0x633f4
leaq 0x58(%r14), %rsi
movq %r15, %rdi
callq 0x64ed4
leaq 0x8(%rsp), %rsi
movq %r14, %rdi
movsd (%rsp), %xmm0
movl %ebx, %edx
callq 0x5f510
leaq 0x8(%rsp), %rdi
callq 0x636e8
addq $0x50, %rsp
popq %rbx
popq %r14
popq %r15
retq
movq %rax, %rbx
leaq 0x8(%rsp), %rdi
callq 0x636e8
movq %rbx, %rdi
callq 0xe7e0
nop
// File: /workspace/github_cpp_makefile_star2_O3/tomfunkhouser[P]gaps/pkgs/R2Shapes/R2Grid.cpp
// Function: gaps::R2Grid::Dot(gaps::R2Grid const&) const
RNScalar R2Grid::
Dot(const R2Grid& grid) const
{
  // Resolutions and transforms must be the same (for now)
  assert(grid_resolution[0] == grid.grid_resolution[0]);
  assert(grid_resolution[1] == grid.grid_resolution[1]);

  // Compute dot product between this and grid
  RNScalar dot = 0.0;
  for (int i = 0; i < grid_size; i++) {
    if (grid_values[i] == R2_GRID_UNKNOWN_VALUE) continue;
    if (grid.grid_values[i] == R2_GRID_UNKNOWN_VALUE) continue;
    dot += grid_values[i] * grid.grid_values[i];
  }
  return dot;
}

// Assembly:
movslq 0xcc(%rdi), %rax
testq %rax, %rax
jle 0x5f949
movq 0xb8(%rdi), %rcx
movq 0xb8(%rsi), %rdx
xorpd %xmm0, %xmm0
xorl %esi, %esi
movsd 0x4369a(%rip), %xmm1    # 0xa2fb8
movsd (%rcx,%rsi,8), %xmm2
ucomisd %xmm1, %xmm2
jne 0x5f92b
jnp 0x5f940
movsd (%rdx,%rsi,8), %xmm3
ucomisd %xmm1, %xmm3
jne 0x5f938
jnp 0x5f940
mulsd %xmm3, %xmm2
addsd %xmm2, %xmm0
incq %rsi
cmpq %rsi, %rax
jne 0x5f91e
retq
xorps %xmm0, %xmm0
retq
nop
// File: /workspace/github_cpp_makefile_star2_O3/tomfunkhouser[P]gaps/pkgs/R2Shapes/R2Grid.cpp
// Function: gaps::R2Grid::L1Distance(gaps::R2Grid const&) const
RNScalar R2Grid::
L1Distance(const R2Grid& grid) const
{
  // Compute distance between this and grid
  RNScalar distance = 0.0;
  for (int i = 0; i < grid_size; i++) {
    if (grid_values[i] == R2_GRID_UNKNOWN_VALUE) continue;
    if (grid.grid_values[i] == R2_GRID_UNKNOWN_VALUE) continue;
    distance += fabs(grid_values[i] - grid.grid_values[i]);
  }
  return distance;
}

// Assembly:
movslq 0xcc(%rdi), %rax
testq %rax, %rax
jle 0x5ffa9
movq 0xb8(%rdi), %rcx
movq 0xb8(%rsi), %rdx
xorpd %xmm0, %xmm0
xorl %esi, %esi
movsd 0x43046(%rip), %xmm1    # 0xa2fb8
movapd 0x422f6(%rip), %xmm2    # 0xa2270
movsd (%rcx,%rsi,8), %xmm3
ucomisd %xmm1, %xmm3
jne 0x5ff87
jnp 0x5ffa0
movsd (%rdx,%rsi,8), %xmm4
ucomisd %xmm1, %xmm4
jne 0x5ff94
jnp 0x5ffa0
subsd %xmm4, %xmm3
andpd %xmm2, %xmm3
addsd %xmm3, %xmm0
incq %rsi
cmpq %rsi, %rax
jne 0x5ff7a
retq
xorps %xmm0, %xmm0
retq
nop
// File: /workspace/github_cpp_makefile_star2_O3/tomfunkhouser[P]gaps/pkgs/R2Shapes/R2Grid.cpp
// Function: gaps::R2Grid::L2DistanceSquared(gaps::R2Grid const&) const
RNScalar R2Grid::
L2DistanceSquared(const R2Grid& grid) const
{
  // Compute distance between this and grid
  RNScalar distance_squared = 0.0;
  for (int i = 0; i < grid_size; i++) {
    if (grid_values[i] == R2_GRID_UNKNOWN_VALUE) continue;
    if (grid.grid_values[i] == R2_GRID_UNKNOWN_VALUE) continue;
    RNScalar delta = (grid_values[i] - grid.grid_values[i]);
    distance_squared += delta * delta;
  }

  // Return result
  return distance_squared;
}

// Assembly:
movslq 0xcc(%rdi), %rax
testq %rax, %rax
jle 0x60005
movq 0xb8(%rdi), %rcx
movq 0xb8(%rsi), %rdx
xorpd %xmm0, %xmm0
xorl %esi, %esi
movsd 0x42fe2(%rip), %xmm1    # 0xa2fb8
movsd (%rcx,%rsi,8), %xmm2
ucomisd %xmm1, %xmm2
jne 0x5ffe3
jnp 0x5fffc
movsd (%rdx,%rsi,8), %xmm3
ucomisd %xmm1, %xmm3
jne 0x5fff0
jnp 0x5fffc
subsd %xmm3, %xmm2
mulsd %xmm2, %xmm2
addsd %xmm2, %xmm0
incq %rsi
cmpq %rsi, %rax
jne 0x5ffd6
retq
xorps %xmm0, %xmm0
retq
nop
// File: /workspace/github_cpp_makefile_star2_O3/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 0x6bef4
cmpl $0x2, 0xc4(%rbx)
jl 0x603c6
movl $0x1, %r14d
xorl %r15d, %r15d
movl $0x5, %edi
callq 0xe110
cmpl $0x0, 0xc0(%rbx)
jle 0x603ae
xorps %xmm0, %xmm0
cvtsi2sd %r14d, %xmm0
movsd %xmm0, 0x8(%rsp)
leal -0x1(%r14), %eax
xorps %xmm0, %xmm0
cvtsi2sd %eax, %xmm0
movsd %xmm0, (%rsp)
movslq %r14d, %r12
movslq %r15d, %r13
xorl %ebp, %ebp
xorps %xmm0, %xmm0
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 0xe6d0
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 0xe6d0
incq %rbp
cmpl 0xc0(%rbx), %ebp
jl 0x60347
callq 0xe5d0
incl %r14d
incl %r15d
cmpl 0xc4(%rbx), %r14d
jl 0x6030a
movq %rbx, %rdi
addq $0x18, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
jmp 0x6bf1c
// File: /workspace/github_cpp_makefile_star2_O3/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 %rbx
subq $0x10, %rsp
movsd %xmm0, 0x8(%rsp)
movq %rdi, %r14
movslq 0xcc(%rdi), %r15
leaq (,%r15,4), %rax
testq %r15, %r15
movq $-0x1, %rdi
cmovnsq %rax, %rdi
callq 0xe030
movq %rax, %rbx
movq %r14, %rdi
movsd 0x8(%rsp), %xmm0
movl %r15d, %esi
xorl %edx, %edx
xorl %ecx, %ecx
movq %rax, %r8
callq 0x6079e
testl %eax, %eax
jle 0x6078c
movslq 0xcc(%r14), %rax
testq %rax, %rax
jle 0x6078c
movq 0xb8(%r14), %rcx
xorl %edx, %edx
movsd 0x4284e(%rip), %xmm0    # 0xa2fb8
movsd (%rcx,%rdx,8), %xmm1
ucomisd %xmm0, %xmm1
jne 0x60777
jnp 0x60784
xorps %xmm1, %xmm1
cvtsi2sdl (%rbx,%rdx,4), %xmm1
movsd %xmm1, (%rcx,%rdx,8)
incq %rdx
cmpq %rdx, %rax
jne 0x6076a
movq %rbx, %rdi
addq $0x10, %rsp
popq %rbx
popq %r14
popq %r15
jmp 0xe5b0
nop
// File: /workspace/github_cpp_makefile_star2_O3/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 %r12
pushq %rbx
pushq %rax
movsd %xmm0, (%rsp)
movq %rdi, %r15
movslq 0xcc(%rdi), %r12
leaq (,%r12,4), %rax
testq %r12, %r12
movq $-0x1, %r14
cmovnsq %rax, %r14
movq %r14, %rdi
callq 0xe030
movq %rax, %rbx
movq %r14, %rdi
callq 0xe030
movq %rax, %r14
movq %r15, %rdi
movsd (%rsp), %xmm0
movl %r12d, %esi
xorl %edx, %edx
movq %rbx, %rcx
movq %rax, %r8
callq 0x6079e
testl %eax, %eax
jle 0x60d40
movslq 0xcc(%r15), %rcx
testq %rcx, %rcx
jle 0x60d40
movq 0xb8(%r15), %rdx
xorl %esi, %esi
movsd 0x422a6(%rip), %xmm0    # 0xa2fb8
movsd (%rdx,%rsi,8), %xmm1
ucomisd %xmm0, %xmm1
jne 0x60d1f
jnp 0x60d38
movl (%r14,%rsi,4), %edi
xorpd %xmm1, %xmm1
cmpl %eax, %edi
jae 0x60d33
xorps %xmm1, %xmm1
cvtsi2sdl (%rbx,%rdi,4), %xmm1
movsd %xmm1, (%rdx,%rsi,8)
incq %rsi
cmpq %rsi, %rcx
jne 0x60d12
movq %r14, %rdi
callq 0xe5b0
movq %rbx, %rdi
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r14
popq %r15
jmp 0xe5b0
nop
// File: /workspace/github_cpp_makefile_star2_O3/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
movq %rsi, %rdi
movl $0x2e, %esi
callq 0xe4c0
testq %rax, %rax
je 0x613a6
movq %rax, %r15
leaq 0x46495(%rip), %rsi     # 0xa77b6
movl $0x4, %edx
movq %rax, %rdi
callq 0xe210
testl %eax, %eax
je 0x613bc
leaq 0x480ad(%rip), %rsi     # 0xa93ea
movl $0x4, %edx
movq %r15, %rdi
callq 0xe210
testl %eax, %eax
je 0x613cc
leaq 0x4809a(%rip), %rsi     # 0xa93ef
movl $0x4, %edx
movq %r15, %rdi
callq 0xe210
testl %eax, %eax
je 0x613dc
leaq 0x48087(%rip), %rsi     # 0xa93f4
movl $0x4, %edx
movq %r15, %rdi
callq 0xe210
testl %eax, %eax
je 0x613ec
leaq 0x46418(%rip), %rsi     # 0xa779d
movl $0x4, %edx
movq %r15, %rdi
callq 0xe210
movq %r14, %rdi
movq %rbx, %rsi
testl %eax, %eax
je 0x613fc
popq %rbx
popq %r14
popq %r15
jmp 0x61f00
leaq 0x48012(%rip), %rdi     # 0xa93bf
xorl %eax, %eax
callq 0x719d2
xorl %eax, %eax
popq %rbx
popq %r14
popq %r15
retq
movq %r14, %rdi
movq %rbx, %rsi
popq %rbx
popq %r14
popq %r15
jmp 0x61406
movq %r14, %rdi
movq %rbx, %rsi
popq %rbx
popq %r14
popq %r15
jmp 0x61652
movq %r14, %rdi
movq %rbx, %rsi
popq %rbx
popq %r14
popq %r15
jmp 0x61a6a
movq %r14, %rdi
movq %rbx, %rsi
popq %rbx
popq %r14
popq %r15
jmp 0x61e40
popq %rbx
popq %r14
popq %r15
jmp 0x61e94
// File: /workspace/github_cpp_makefile_star2_O3/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 0x40759(%rip), %rsi     # 0xa25ab
movq %rbx, %rdi
callq 0xe530
testq %rax, %rax
je 0x61e7b
movq %rax, %r15
movq %r14, %rdi
movq %rax, %rsi
callq 0x62a76
movl %eax, %ebx
movq %r15, %rdi
callq 0xe430
movl %ebx, %eax
jmp 0x61e8e
leaq 0x4790d(%rip), %rdi     # 0xa978f
movq %rbx, %rsi
xorl %eax, %eax
callq 0x719d2
xorl %eax, %eax
popq %rbx
popq %r14
popq %r15
retq
// File: /workspace/github_cpp_makefile_star2_O3/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 0x61ed0
movq %rsi, %r14
leaq 0x40700(%rip), %rsi     # 0xa25ab
movq %r14, %rdi
callq 0xe530
movq %rax, %r15
testq %rax, %rax
jne 0x61eda
leaq 0x404f8(%rip), %rdi     # 0xa23ba
xorl %ebx, %ebx
movq %r14, %rsi
xorl %eax, %eax
callq 0x719d2
jmp 0x61ef7
movq 0x830c9(%rip), %rax     # 0xe4fa0
movq (%rax), %r15
movq %rbx, %rdi
movq %r15, %rsi
callq 0x626ec
testl %eax, %eax
je 0x61ef5
movl %eax, %ebx
movq %r15, %rdi
callq 0xe430
jmp 0x61ef7
xorl %ebx, %ebx
movl %ebx, %eax
popq %rbx
popq %r14
popq %r15
retq
nop
// File: /workspace/github_cpp_makefile_star2_O3/tomfunkhouser[P]gaps/pkgs/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
movq %rsi, %rdi
movl $0x2e, %esi
callq 0xe4c0
testq %rax, %rax
je 0x6216a
movq %rax, %r15
leaq 0x456b5(%rip), %rsi     # 0xa77b6
movl $0x4, %edx
movq %rax, %rdi
callq 0xe210
testl %eax, %eax
je 0x62180
leaq 0x472d1(%rip), %rsi     # 0xa93ea
movl $0x4, %edx
movq %r15, %rdi
callq 0xe210
testl %eax, %eax
je 0x62190
leaq 0x472c3(%rip), %rsi     # 0xa93f4
movl $0x4, %edx
movq %r15, %rdi
callq 0xe210
testl %eax, %eax
je 0x621a0
leaq 0x45654(%rip), %rsi     # 0xa779d
movl $0x4, %edx
movq %r15, %rdi
callq 0xe210
movq %r14, %rdi
movq %rbx, %rsi
testl %eax, %eax
je 0x621b0
popq %rbx
popq %r14
popq %r15
jmp 0x62526
leaq 0x47288(%rip), %rdi     # 0xa93f9
xorl %eax, %eax
callq 0x719d2
xorl %eax, %eax
popq %rbx
popq %r14
popq %r15
retq
movq %r14, %rdi
movq %rbx, %rsi
popq %rbx
popq %r14
popq %r15
jmp 0x621ba
movq %r14, %rdi
movq %rbx, %rsi
popq %rbx
popq %r14
popq %r15
jmp 0x62314
movq %r14, %rdi
movq %rbx, %rsi
popq %rbx
popq %r14
popq %r15
jmp 0x62466
popq %rbx
popq %r14
popq %r15
jmp 0x624ba
// File: /workspace/github_cpp_makefile_star2_O3/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 0x408ac(%rip), %rsi     # 0xa2a81
movq %rbx, %rdi
callq 0xe530
testq %rax, %rax
je 0x622cf
movq %rax, %r15
movq %rsp, %rdi
movl $0xd431, (%rdi)         # imm = 0xD431
movq 0xc0(%r14), %rax
movq %rax, 0x4(%rdi)
movl $0x1, 0xc(%rdi)
movl $0x4, %esi
movl $0x4, %edx
movq %r15, %rcx
callq 0xe8b0
cmpq $0x4, %rax
jne 0x622d8
movslq 0xc8(%r14), %rax
leaq (,%rax,4), %rcx
testq %rax, %rax
movq $-0x1, %rdi
cmovnsq %rcx, %rdi
callq 0xe030
movq %rax, %r12
cmpl $0x0, 0xc4(%r14)
jle 0x622b6
movl 0xc0(%r14), %ecx
xorl %r13d, %r13d
testl %ecx, %ecx
jle 0x6228b
movq 0xb8(%r14), %rdx
movl %ecx, %eax
movl %ecx, %esi
imull %r13d, %esi
movslq %esi, %rsi
leaq (%rdx,%rsi,8), %rdx
xorl %esi, %esi
xorps %xmm0, %xmm0
cvtsd2ss (%rdx,%rsi,8), %xmm0
movss %xmm0, (%r12,%rsi,4)
incq %rsi
cmpq %rsi, %rax
jne 0x62275
movslq %ecx, %rdx
movl $0x4, %esi
movq %r12, %rdi
movq %r15, %rcx
callq 0xe8b0
movl 0xc0(%r14), %ecx
cmpq %rcx, %rax
jne 0x622f0
incl %r13d
cmpl 0xc4(%r14), %r13d
jl 0x62259
movq %r12, %rdi
callq 0xe5b0
movq %r15, %rdi
callq 0xe430
movl 0xcc(%r14), %ebp
jmp 0x62303
leaq 0x4714f(%rip), %rdi     # 0xa9425
jmp 0x622f7
leaq 0x47167(%rip), %rdi     # 0xa9446
movq %rbx, %rsi
xorl %eax, %eax
callq 0x719d2
movl $0xffffffff, %ebp       # imm = 0xFFFFFFFF
jmp 0x62303
leaq 0x471ec(%rip), %rdi     # 0xa94e3
xorl %ebp, %ebp
movq %rbx, %rsi
xorl %eax, %eax
callq 0x719d2
movl %ebp, %eax
addq $0x18, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
// File: /workspace/github_cpp_makefile_star2_O3/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 0x40755(%rip), %rsi     # 0xa2a81
movq %rbx, %rdi
callq 0xe530
testq %rax, %rax
je 0x62439
movq %rax, %r15
leaq 0x47350(%rip), %rdi     # 0xa9697
movl $0x3, %esi
movl $0x1, %edx
movq %rax, %rcx
callq 0xe8b0
movl 0xc0(%r14), %edx
movl 0xc4(%r14), %ecx
leaq 0x406c9(%rip), %rsi     # 0xa2a37
xorl %r13d, %r13d
movq %r15, %rdi
xorl %eax, %eax
callq 0xe670
leaq 0x47319(%rip), %rdi     # 0xa969b
movl $0x5, %esi
movl $0x1, %edx
movq %r15, %rcx
callq 0xe8b0
movslq 0xc0(%r14), %rbp
leaq (,%rbp,4), %rax
testq %rbp, %rbp
movq $-0x1, %rdi
cmovnsq %rax, %rdi
callq 0xe030
movq %rax, %r12
cmpl $0x0, 0xc4(%r14)
jle 0x62420
testl %ebp, %ebp
jle 0x623f5
movq 0xb8(%r14), %rcx
movl %ebp, %eax
movl %ebp, %edx
imull %r13d, %edx
movslq %edx, %rdx
leaq (%rcx,%rdx,8), %rcx
xorl %edx, %edx
xorps %xmm0, %xmm0
cvtsd2ss (%rcx,%rdx,8), %xmm0
movss %xmm0, (%r12,%rdx,4)
incq %rdx
cmpq %rdx, %rax
jne 0x623df
movslq %ebp, %rdx
movl $0x4, %esi
movq %r12, %rdi
movq %r15, %rcx
callq 0xe8b0
movl 0xc0(%r14), %ebp
cmpq %rbp, %rax
jne 0x62442
incl %r13d
cmpl 0xc4(%r14), %r13d
jl 0x623c3
movq %r12, %rdi
callq 0xe5b0
movq %r15, %rdi
callq 0xe430
movl 0xcc(%r14), %ebp
jmp 0x62455
leaq 0x47236(%rip), %rdi     # 0xa9676
jmp 0x62449
leaq 0x4709a(%rip), %rdi     # 0xa94e3
xorl %ebp, %ebp
movq %rbx, %rsi
xorl %eax, %eax
callq 0x719d2
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_O3/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 0x40609(%rip), %rsi     # 0xa2a81
movq %rbx, %rdi
callq 0xe530
testq %rax, %rax
je 0x624a1
movq %rax, %r15
movq %r14, %rdi
movq %rax, %rsi
callq 0x62f78
movl %eax, %ebx
movq %r15, %rdi
callq 0xe430
movl %ebx, %eax
jmp 0x624b4
leaq 0x472e7(%rip), %rdi     # 0xa978f
movq %rbx, %rsi
xorl %eax, %eax
callq 0x719d2
xorl %eax, %eax
popq %rbx
popq %r14
popq %r15
retq
// File: /workspace/github_cpp_makefile_star2_O3/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 0x624f6
movq %rsi, %r14
leaq 0x405b0(%rip), %rsi     # 0xa2a81
movq %r14, %rdi
callq 0xe530
movq %rax, %r15
testq %rax, %rax
jne 0x62500
leaq 0x3fed2(%rip), %rdi     # 0xa23ba
xorl %ebx, %ebx
movq %r14, %rsi
xorl %eax, %eax
callq 0x719d2
jmp 0x6251d
movq 0x82a73(%rip), %rax     # 0xe4f70
movq (%rax), %r15
movq %rbx, %rdi
movq %r15, %rsi
callq 0x6290e
testl %eax, %eax
je 0x6251b
movl %eax, %ebx
movq %r15, %rdi
callq 0xe430
jmp 0x6251d
xorl %ebx, %ebx
movl %ebx, %eax
popq %rbx
popq %r14
popq %r15
retq
nop
// File: /workspace/github_cpp_makefile_star2_O3/tomfunkhouser[P]gaps/pkgs/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 %r14
pushq %rbx
movq %rsi, %r14
movq %rdi, %rbx
addq $0xc0, %rdi
movl $0x4, %esi
movl $0x2, %edx
movq %r14, %rcx
callq 0xe8b0
cmpq $0x2, %rax
jne 0x629a2
leaq 0x60(%rbx), %rdi
movl $0x8, %esi
movl $0x9, %edx
movq %r14, %rcx
callq 0xe8b0
cmpq $0x9, %rax
jne 0x629ab
cmpl $0x0, 0xc4(%rbx)
jle 0x6299a
movl 0xc0(%rbx), %ecx
xorl %ebp, %ebp
movslq %ecx, %rdx
imull %ebp, %ecx
movslq %ecx, %rdi
shlq $0x3, %rdi
addq 0xb8(%rbx), %rdi
movl $0x8, %esi
movq %r14, %rcx
callq 0xe8b0
movl 0xc0(%rbx), %ecx
cmpq %rcx, %rax
jne 0x629b4
incl %ebp
cmpl 0xc4(%rbx), %ebp
jl 0x62964
movl 0xcc(%rbx), %ebx
jmp 0x629c4
leaq 0x44f15(%rip), %rdi     # 0xa78be
jmp 0x629bb
leaq 0x46d68(%rip), %rdi     # 0xa971a
jmp 0x629bb
leaq 0x46d8d(%rip), %rdi     # 0xa9748
xorl %ebx, %ebx
xorl %eax, %eax
callq 0x719d2
movl %ebx, %eax
popq %rbx
popq %r14
popq %rbp
retq
nop
// File: /workspace/github_cpp_makefile_star2_O3/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 0x493f9(%rip), %rax     # 0xabdd3
movq %rsi, %rdi
movq %rdx, %rsi
movq %rax, %rdx
callq 0xe8a0
testq %rax, %rax
je 0x62a0c
movq %rax, %r14
movq %rbx, %rdi
movq %rax, %rsi
callq 0x626ec
xorl %ebx, %ebx
testl %eax, %eax
setne %bl
movq %r14, %rdi
callq 0xe430
jmp 0x62a1c
leaq 0x46d5a(%rip), %rdi     # 0xa976d
xorl %ebx, %ebx
xorl %eax, %eax
callq 0x719d2
movl %ebx, %eax
addq $0x8, %rsp
popq %rbx
popq %r14
retq
// File: /workspace/github_cpp_makefile_star2_O3/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 0xe490
testq %rax, %rax
je 0x62a5c
movq %rax, %r14
movq %rbx, %rdi
movq %rax, %rsi
callq 0x6290e
xorl %ebx, %ebx
testl %eax, %eax
setne %bl
movq %r14, %rdi
callq 0xe430
jmp 0x62a6c
leaq 0x46d0a(%rip), %rdi     # 0xa976d
xorl %ebx, %ebx
xorl %eax, %eax
callq 0x719d2
movl %ebx, %eax
addq $0x8, %rsp
popq %rbx
popq %r14
retq
// File: /workspace/github_cpp_makefile_star2_O3/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 0x48b77(%rip), %rax     # 0xabdd3
movq %rsi, %rdi
movq %rdx, %rsi
movq %rax, %rdx
callq 0xe8a0
testq %rax, %rax
je 0x6328b
movq %rax, %r14
movq %rbx, %rdi
movq %rax, %rsi
callq 0x62a76
movl %eax, %ebx
movq %r14, %rdi
callq 0xe430
movl %ebx, %eax
jmp 0x6329b
leaq 0x46519(%rip), %rdi     # 0xa97ab
xorl %eax, %eax
callq 0x719d2
xorl %eax, %eax
addq $0x8, %rsp
popq %rbx
popq %r14
retq
nop
// File: /workspace/github_cpp_makefile_star2_O3/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 0xe490
testq %rax, %rax
je 0x632d7
movq %rax, %r14
movq %rbx, %rdi
movq %rax, %rsi
callq 0x62f78
movl %eax, %ebx
movq %r14, %rdi
callq 0xe430
movl %ebx, %eax
jmp 0x632e7
leaq 0x464cd(%rip), %rdi     # 0xa97ab
xorl %eax, %eax
callq 0x719d2
xorl %eax, %eax
addq $0x8, %rsp
popq %rbx
popq %r14
retq
nop
// File: /workspace/github_cpp_makefile_star2_O3/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 0x63310
movq 0x81c63(%rip), %rax     # 0xe4f70
movq (%rax), %r14
cmpl $0x0, 0xc4(%rbx)
jle 0x6337c
xorl %r12d, %r12d
leaq 0x45220(%rip), %r15     # 0xa8543
cmpl $0x0, 0xc0(%rbx)
jle 0x63363
movslq %r12d, %r13
xorl %ebp, %ebp
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 0xe670
incq %rbp
cmpl 0xc0(%rbx), %ebp
jl 0x63331
movl $0xa, %edi
movq %r14, %rsi
callq 0xe5a0
incl %r12d
cmpl 0xc4(%rbx), %r12d
jl 0x63323
movl 0xcc(%rbx), %eax
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
nopl (%rax)
// File: /workspace/github_cpp_makefile_star2_O3/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 0x65c08
leaq 0x80eff(%rip), %rax     # 0xe4310
movq %rax, (%rbx)
movq $0x0, 0x8(%rbx)
movl 0x10(%r15), %eax
movl %eax, 0x10(%rbx)
leaq 0x18(%rbx), %rdi
leaq 0x18(%r15), %rsi
movq %rdi, (%rsp)
callq 0x65278
movl 0x40(%r15), %eax
movl %eax, 0x40(%rbx)
cmpl $0x0, 0x10(%r15)
jle 0x634b9
movslq 0x10(%rbx), %r14
movq %r14, %rbp
shlq $0x4, %rbp
testq %r14, %r14
movq $-0x1, %r12
cmovnsq %rbp, %r12
movq %r12, %rdi
callq 0xe030
movq %rax, %r13
testl %r14d, %r14d
je 0x634b5
xorl %r14d, %r14d
leaq (%r14,%r13), %rdi
callq 0x680a4
addq $0x10, %r14
cmpq %r14, %rbp
jne 0x6346e
cmpl $0x0, 0x10(%rbx)
movq %r13, 0x8(%rbx)
jle 0x634b9
xorl %r12d, %r12d
xorl %r13d, %r13d
movq 0x8(%r15), %rsi
addq %r12, %rsi
movq 0x8(%rbx), %rdi
addq %r12, %rdi
callq 0x681de
incq %r13
movslq 0x10(%rbx), %rax
addq $0x10, %r12
cmpq %rax, %r13
jl 0x63490
jmp 0x634b9
movq %r13, 0x8(%rbx)
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
jmp 0x634cf
movq %rax, %r15
jmp 0x634eb
movq %rax, %r15
jmp 0x634e2
movq %rax, %r15
movq %r13, %rdi
movq %r12, %rsi
callq 0xe8c0
movq (%rsp), %rdi
callq 0x65c14
movq %rbx, %rdi
callq 0x65c14
movq %r15, %rdi
callq 0xe7e0
nop
// File: /workspace/github_cpp_makefile_star2_O3/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 0x65c08
leaq 0x80df5(%rip), %rax     # 0xe4310
movq %rax, (%rbx)
movq $0x0, 0x8(%rbx)
movl 0xc(%r15), %eax
movl %eax, 0x10(%rbx)
leaq 0x18(%rbx), %r14
leaq 0x4849a0(%rip), %rsi    # 0x4e7ed8
movq %r14, %rdi
callq 0x65278
movl %ebp, 0x40(%rbx)
movslq 0x10(%rbx), %r12
testq %r12, %r12
jle 0x635b3
shlq $0x4, %r12
movq %r12, %rdi
callq 0xe030
movq %rax, %r13
xorl %ebp, %ebp
movq %r13, %rdi
addq %rbp, %rdi
callq 0x680a4
addq $0x10, %rbp
cmpq %rbp, %r12
jne 0x6355d
movq %r13, 0x8(%rbx)
cmpl $0x0, 0x10(%rbx)
jle 0x635b3
xorl %r12d, %r12d
xorl %r13d, %r13d
movq (%r15), %rax
movq (%rax,%r13,8), %rsi
movq 0x8(%rbx), %rdi
addq %r12, %rdi
callq 0x681de
movq (%r15), %rax
movq (%rax,%r13,8), %rsi
movq %r14, %rdi
callq 0x65986
incq %r13
movslq 0x10(%rbx), %rax
addq $0x10, %r12
cmpq %rax, %r13
jl 0x63581
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
jmp 0x635d9
movq %rax, %r15
jmp 0x635e4
movq %rax, %r15
movq %r13, %rdi
movq %r12, %rsi
callq 0xe8c0
jmp 0x635dc
movq %rax, %r15
movq %r14, %rdi
callq 0x65c14
movq %rbx, %rdi
callq 0x65c14
movq %r15, %rdi
callq 0xe7e0
// File: /workspace/github_cpp_makefile_star2_O3/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 0x65c08
leaq 0x80cfa(%rip), %rax     # 0xe4310
movq %rax, (%rbx)
movq $0x0, 0x8(%rbx)
movl %r14d, 0x10(%rbx)
leaq 0x18(%rbx), %r14
leaq 0x4848a8(%rip), %rsi    # 0x4e7ed8
movq %r14, %rdi
callq 0x65278
movl %ebp, 0x40(%rbx)
movslq 0x10(%rbx), %r12
testq %r12, %r12
jle 0x636a6
shlq $0x4, %r12
movq %r12, %rdi
callq 0xe030
movq %rax, %r13
xorl %ebp, %ebp
movq %r13, %rdi
addq %rbp, %rdi
callq 0x680a4
addq $0x10, %rbp
cmpq %rbp, %r12
jne 0x63655
movq %r13, 0x8(%rbx)
cmpl $0x0, 0x10(%rbx)
jle 0x636a6
xorl %r13d, %r13d
xorl %ebp, %ebp
leaq (%r15,%r13), %r12
movq 0x8(%rbx), %rdi
addq %r13, %rdi
movq %r12, %rsi
callq 0x681de
movq %r14, %rdi
movq %r12, %rsi
callq 0x65986
incq %rbp
movslq 0x10(%rbx), %rax
addq $0x10, %r13
cmpq %rax, %rbp
jl 0x63678
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
jmp 0x636cc
movq %rax, %r15
jmp 0x636d7
movq %rax, %r15
movq %r13, %rdi
movq %r12, %rsi
callq 0xe8c0
jmp 0x636cf
movq %rax, %r15
movq %r14, %rdi
callq 0x65c14
movq %rbx, %rdi
callq 0x65c14
movq %r15, %rdi
callq 0xe7e0
nop
// File: /workspace/github_cpp_makefile_star2_O3/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
xorpd %xmm0, %xmm0
xorpd %xmm1, %xmm1
callq 0x680a6
cmpl $0x0, 0x10(%r15)
jle 0x637a9
movsd 0x3e8e2(%rip), %xmm0    # 0xa2040
movsd %xmm0, (%rsp)
xorl %r13d, %r13d
xorl %ebp, %ebp
movq 0x8(%r15), %r12
addq %r13, %r12
movq %rbx, %rdi
movq %r12, %rsi
callq 0x6cb1c
movapd %xmm0, %xmm1
movsd (%rsp), %xmm0
ucomisd %xmm1, %xmm0
jbe 0x63799
movq %r14, %rdi
movq %r12, %rsi
movsd %xmm1, (%rsp)
callq 0x681de
incq %rbp
movslq 0x10(%r15), %rax
addq $0x10, %r13
cmpq %rax, %rbp
jl 0x63768
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_O3/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 0x6384a
movq 0x8(%rdi), %rcx
shlq $0x4, %rax
movsd -0x10(%rcx,%rax), %xmm1
movsd -0x8(%rcx,%rax), %xmm2
xorl %edx, %edx
movsd (%rcx,%rdx), %xmm3
movsd 0x8(%rcx,%rdx), %xmm4
mulsd %xmm3, %xmm2
mulsd %xmm4, %xmm1
subsd %xmm2, %xmm1
addsd %xmm1, %xmm0
addq $0x10, %rdx
movapd %xmm4, %xmm2
movapd %xmm3, %xmm1
cmpq %rdx, %rax
jne 0x63808
mulsd 0x3e7f4(%rip), %xmm0    # 0xa2030
cmpl $0x0, 0x40(%rdi)
je 0x6384a
xorpd 0x3e7d6(%rip), %xmm0    # 0xa2020
retq
nop
// File: /workspace/github_cpp_makefile_star2_O3/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 0x638b3
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 0x637e4
movapd (%rsp), %xmm1
divsd %xmm0, %xmm1
xorpd %xmm2, %xmm2
cmpeqsd %xmm0, %xmm2
andnpd %xmm1, %xmm2
movapd %xmm2, (%rsp)
movq %r14, %rdi
callq 0x636e8
movapd (%rsp), %xmm0
addq $0x58, %rsp
popq %rbx
popq %r14
retq
// File: /workspace/github_cpp_makefile_star2_O3/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 0x6392c
pushq %r15
pushq %r14
pushq %r12
pushq %rbx
pushq %rax
movq %rdi, %rbx
movq 0x8(%rdi), %rcx
shlq $0x4, %rax
leaq (%rcx,%rax), %rdi
addq $-0x10, %rdi
xorpd %xmm0, %xmm0
xorl %r15d, %r15d
xorl %r12d, %r12d
movsd %xmm0, (%rsp)
movq 0x8(%rbx), %r14
addq %r15, %r14
movq %r14, %rsi
callq 0x6c52b
movsd (%rsp), %xmm1
addsd %xmm0, %xmm1
movsd %xmm1, (%rsp)
movsd (%rsp), %xmm0
incq %r12
movslq 0x10(%rbx), %rax
addq $0x10, %r15
movq %r14, %rdi
cmpq %rax, %r12
jl 0x638e7
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r14
popq %r15
retq
nop
// File: /workspace/github_cpp_makefile_star2_O3/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 0x63997
movq %rsi, %r14
leaq 0x484932(%rip), %rsi    # 0x4e8280
movq %rsp, %rdi
callq 0x680b0
movl 0x10(%r14), %eax
testl %eax, %eax
jle 0x63986
xorl %r12d, %r12d
movq %rsp, %r15
xorl %r13d, %r13d
movq 0x8(%r14), %rsi
addq %r12, %rsi
movq %r15, %rdi
callq 0x681f4
incq %r13
movslq 0x10(%r14), %rax
addq $0x10, %r12
cmpq %rax, %r13
jl 0x63967
cvtsi2sd %eax, %xmm0
movq %rsp, %rsi
movq %rbx, %rdi
callq 0x68361
jmp 0x639a6
leaq 0x4848e2(%rip), %rsi    # 0x4e8280
movq %rbx, %rdi
callq 0x680b0
movq %rbx, %rax
addq $0x10, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
retq
nop
// File: /workspace/github_cpp_makefile_star2_O3/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 %r14
pushq %rbx
pushq %rax
movq %rdi, %rbx
movq 0x8(%rdi), %rdi
testq %rdi, %rdi
je 0x6476b
callq 0xe5b0
movq $0x0, 0x8(%rbx)
movl $0x0, 0x10(%rbx)
leaq 0x20(%rbx), %rdi
leaq 0x483753(%rip), %r14    # 0x4e7ed8
leaq 0x8(%r14), %rsi
callq 0x681de
addq $0x30, %rbx
addq $0x18, %r14
movq %rbx, %rdi
movq %r14, %rsi
addq $0x8, %rsp
popq %rbx
popq %r14
jmp 0x681de
// File: /workspace/github_cpp_makefile_star2_O3/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
movq %rdi, %rbx
movl 0x10(%rdi), %eax
decl %eax
movl %eax, 0x10(%rdi)
cmpl %esi, %eax
jle 0x647e5
movl %esi, %ebp
movslq %esi, %r14
shlq $0x4, %r14
movq 0x8(%rbx), %rdi
leaq (%rdi,%r14), %rsi
addq $0x10, %rsi
addq %r14, %rdi
callq 0x681de
addq $0x10, %r14
cmpl %ebp, 0x10(%rbx)
jg 0x647c8
leaq 0x20(%rbx), %rdi
leaq 0x4836e8(%rip), %r14    # 0x4e7ed8
leaq 0x8(%r14), %rsi
callq 0x681de
leaq 0x30(%rbx), %rdi
addq $0x18, %r14
movq %r14, %rsi
callq 0x681de
cmpl $0x0, 0x10(%rbx)
jle 0x64838
leaq 0x18(%rbx), %r14
xorl %r15d, %r15d
xorl %r12d, %r12d
movq 0x8(%rbx), %rsi
addq %r15, %rsi
movq %r14, %rdi
callq 0x65986
incq %r12
movslq 0x10(%rbx), %rax
addq $0x10, %r15
cmpq %rax, %r12
jl 0x64819
popq %rbx
popq %r12
popq %r14
popq %r15
popq %rbp
retq
nop
// File: /workspace/github_cpp_makefile_star2_O3/tomfunkhouser[P]gaps/pkgs/R2Shapes/R2Polygon.cpp
// Function: gaps::R2Polygon::InsertPoint(int, gaps::R2Point const&)
void R2Polygon::
InsertPoint(int k, const R2Point& position)
{
    // Add point in position k, moving others starting at k+1 up to make room
    R2Point *p = new R2Point [npoints+1];
    for (int i = 0; i < k; i++) p[i] = points[i];
    p[k] = position;
    for (int i = k; i < npoints; i++) p[i+1] = points[i];
    if (points) delete [] points;
    points = p;
    npoints++;
    
    // Update bounding box
    bbox.Union(position);
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
pushq %rax
movq %rdx, (%rsp)
movl %esi, %ebp
movq %rdi, %r14
movl 0x10(%rdi), %ebx
leal 0x1(%rbx), %eax
movslq %eax, %r13
shlq $0x4, %r13
cmpl $-0x1, %ebx
movq $-0x1, %r12
cmovgeq %r13, %r12
movq %r12, %rdi
callq 0xe030
movq %rax, %r15
incl %ebx
je 0x64894
xorl %ebx, %ebx
leaq (%r15,%rbx), %rdi
callq 0x680a4
addq $0x10, %rbx
cmpq %rbx, %r13
jne 0x64882
testl %ebp, %ebp
jle 0x648bb
movl %ebp, %r12d
shlq $0x4, %r12
xorl %r13d, %r13d
movq 0x8(%r14), %rsi
addq %r13, %rsi
leaq (%r15,%r13), %rdi
callq 0x681de
addq $0x10, %r13
cmpq %r13, %r12
jne 0x648a2
movslq %ebp, %r12
movq %r12, %r13
shlq $0x4, %r13
leaq (%r15,%r13), %rdi
movq (%rsp), %rbx
movq %rbx, %rsi
callq 0x681de
movl 0x10(%r14), %eax
cmpl %ebp, %eax
jle 0x64906
movq %r15, %rbp
addq $0x10, %rbp
movq 0x8(%r14), %rsi
addq %r13, %rsi
incq %r12
movq %rbp, %rdi
addq %r13, %rdi
callq 0x681de
movslq 0x10(%r14), %rax
addq $0x10, %r13
cmpq %rax, %r12
jl 0x648e4
movq 0x8(%r14), %rdi
testq %rdi, %rdi
je 0x64918
callq 0xe5b0
movl 0x10(%r14), %eax
movq %r15, 0x8(%r14)
incl %eax
movl %eax, 0x10(%r14)
addq $0x18, %r14
movq %r14, %rdi
movq %rbx, %rsi
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
jmp 0x65986
movq %rax, %rbx
movq %r15, %rdi
movq %r12, %rsi
callq 0xe8c0
movq %rbx, %rdi
callq 0xe7e0
nop
// File: /workspace/github_cpp_makefile_star2_O3/tomfunkhouser[P]gaps/pkgs/R2Shapes/R2Polygon.cpp
// Function: gaps::R2Polygon::SetPoint(int, gaps::R2Point const&)
void R2Polygon::
SetPoint(int k, const R2Point& position)
{
    // Set point
    points[k] = position;

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

// Assembly:
pushq %r15
pushq %r14
pushq %r12
pushq %rbx
pushq %rax
movq %rdi, %rbx
movslq %esi, %rdi
shlq $0x4, %rdi
addq 0x8(%rbx), %rdi
movq %rdx, %rsi
callq 0x681de
leaq 0x20(%rbx), %rdi
leaq 0x483559(%rip), %r14    # 0x4e7ed8
leaq 0x8(%r14), %rsi
callq 0x681de
leaq 0x30(%rbx), %rdi
addq $0x18, %r14
movq %r14, %rsi
callq 0x681de
cmpl $0x0, 0x10(%rbx)
jle 0x649c7
leaq 0x18(%rbx), %r14
xorl %r15d, %r15d
xorl %r12d, %r12d
movq 0x8(%rbx), %rsi
addq %r15, %rsi
movq %r14, %rdi
callq 0x65986
incq %r12
movslq 0x10(%rbx), %rax
addq $0x10, %r15
cmpq %rax, %r12
jl 0x649a8
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r14
popq %r15
retq
nop