LLM4Binary/decompile-bench-makefile huggingface dataset:
// File: /workspace/github_cpp_makefile_star2_O1/tomfunkhouser[P]gaps/pkgs/R3Shapes/R3Grid.cpp
// Function: gaps::R3Grid::Add(double)
void R3Grid::
Add(RNScalar value) 
{
  // Add value to all grid values 
  RNScalar *grid_valuep = grid_values;
  for (int i = 0; i < grid_size; i++) 
    *(grid_valuep++) += value;
}

// Assembly:
movl 0x24c(%rdi), %eax
testl %eax, %eax
jle 0x3259a
movq 0x230(%rdi), %rcx
xorl %edx, %edx
movsd (%rcx,%rdx,8), %xmm1
addsd %xmm0, %xmm1
movsd %xmm1, (%rcx,%rdx,8)
incq %rdx
cmpl %edx, %eax
jne 0x32585
retq
nop
// File: /workspace/github_cpp_makefile_star2_O1/tomfunkhouser[P]gaps/pkgs/R3Shapes/R3Grid.cpp
// Function: gaps::R3Grid::Multiply(double)
void R3Grid::
Multiply(RNScalar value) 
{
  // Multiply grid values by value
  RNScalar *grid_valuep = grid_values;
  for (int i = 0; i < grid_size; i++) 
    *(grid_valuep++) *= value;
}

// Assembly:
movl 0x24c(%rdi), %eax
testl %eax, %eax
jle 0x32954
movq 0x230(%rdi), %rcx
xorl %edx, %edx
movsd (%rcx,%rdx,8), %xmm1
mulsd %xmm0, %xmm1
movsd %xmm1, (%rcx,%rdx,8)
incq %rdx
cmpl %edx, %eax
jne 0x3293f
retq
nop
// File: /workspace/github_cpp_makefile_star2_O1/tomfunkhouser[P]gaps/pkgs/R3Shapes/R3Grid.cpp
// Function: gaps::R3Grid::Divide(gaps::R3Grid const&)
void R3Grid::
Divide(const R3Grid& grid) 
{
  // Resolutions must be the same (for now)
  assert(grid_resolution[0] == grid.grid_resolution[0]);
  assert(grid_resolution[1] == grid.grid_resolution[1]);
  assert(grid_resolution[2] == grid.grid_resolution[2]);

  // Divide passed grid values by corresponding entries of this grid
  for (int i = 0; i < grid_size; i++) {
    RNScalar value = grid.grid_values[i];
    if (RNIsNotZero(value, 1.0E-20)) grid_values[i] /= value;
  }
}

// Assembly:
movslq 0x24c(%rdi), %rax
testq %rax, %rax
jle 0x329df
movq 0x230(%rsi), %rcx
movq 0x230(%rdi), %rdx
xorl %esi, %esi
movapd 0x6f8c2(%rip), %xmm0    # 0xa2270
movsd 0x705ea(%rip), %xmm1    # 0xa2fa0
movsd (%rcx,%rsi,8), %xmm2
movapd %xmm2, %xmm3
andpd %xmm0, %xmm3
ucomisd %xmm1, %xmm3
jbe 0x329d7
movsd (%rdx,%rsi,8), %xmm3
divsd %xmm2, %xmm3
movsd %xmm3, (%rdx,%rsi,8)
incq %rsi
cmpq %rsi, %rax
jne 0x329b6
retq
// File: /workspace/github_cpp_makefile_star2_O1/tomfunkhouser[P]gaps/pkgs/R3Shapes/R3Grid.cpp
// Function: gaps::R3Grid::Min(gaps::R3Grid const&)
void R3Grid::
Min(const R3Grid& grid) 
{
  // Resolutions must be the same (for now)
  assert(grid_resolution[0] == grid.grid_resolution[0]);
  assert(grid_resolution[1] == grid.grid_resolution[1]);
  assert(grid_resolution[2] == grid.grid_resolution[2]);

  // Keep minimum value
  for (int i = 0; i < grid_size; i++) {
    RNScalar value0 = grid_values[i];
    RNScalar value1 = grid.grid_values[i];
    if (value1 < value0) grid_values[i] = value1;
  }
}

// Assembly:
movslq 0x24c(%rdi), %rax
testq %rax, %rax
jle 0x32a19
movq 0x230(%rdi), %rcx
movq 0x230(%rsi), %rdx
xorl %esi, %esi
movsd (%rcx,%rsi,8), %xmm1
movsd (%rdx,%rsi,8), %xmm0
ucomisd %xmm0, %xmm1
jbe 0x32a11
movsd %xmm0, (%rcx,%rsi,8)
incq %rsi
cmpq %rsi, %rax
jne 0x329fc
retq
// File: /workspace/github_cpp_makefile_star2_O1/tomfunkhouser[P]gaps/pkgs/R3Shapes/R3Grid.cpp
// Function: gaps::R3Grid::Max(gaps::R3Grid const&)
void R3Grid::
Max(const R3Grid& grid) 
{
  // Resolutions must be the same (for now)
  assert(grid_resolution[0] == grid.grid_resolution[0]);
  assert(grid_resolution[1] == grid.grid_resolution[1]);
  assert(grid_resolution[2] == grid.grid_resolution[2]);

  // Keep maximum value
  for (int i = 0; i < grid_size; i++) {
    RNScalar value0 = grid_values[i];
    RNScalar value1 = grid.grid_values[i];
    if (value1 > value0) grid_values[i] = value1;
  }
}

// Assembly:
movslq 0x24c(%rdi), %rax
testq %rax, %rax
jle 0x32a4f
movq 0x230(%rdi), %rcx
movq 0x230(%rsi), %rdx
xorl %esi, %esi
movsd (%rdx,%rsi,8), %xmm0
ucomisd (%rcx,%rsi,8), %xmm0
jbe 0x32a47
movsd %xmm0, (%rcx,%rsi,8)
incq %rsi
cmpq %rsi, %rax
jne 0x32a36
retq
// File: /workspace/github_cpp_makefile_star2_O1/tomfunkhouser[P]gaps/pkgs/R3Shapes/R3Grid.cpp
// Function: gaps::R3Grid::Pow(double)
void R3Grid::
Pow(RNScalar exponent) 
{
  // Raise each grid value to exponent
  RNScalar *grid_valuep = grid_values;
  for (int i = 0; i < grid_size; i++) {
    RNScalar value = *grid_valuep;
    if (value < 0) value = -value;
    *(grid_valuep++) = pow(value, exponent);
  }
}

// Assembly:
cmpl $0x0, 0x24c(%rdi)
jle 0x32ab5
pushq %r15
pushq %r14
pushq %rbx
subq $0x10, %rsp
movapd %xmm0, %xmm1
movq %rdi, %rbx
movq 0x230(%rdi), %r14
xorl %r15d, %r15d
movsd %xmm0, 0x8(%rsp)
movsd (%r14,%r15,8), %xmm2
movapd %xmm2, %xmm0
xorpd 0x6f595(%rip), %xmm0    # 0xa2020
maxsd %xmm2, %xmm0
callq 0xe7d0
movsd 0x8(%rsp), %xmm1
movsd %xmm0, (%r14,%r15,8)
incq %r15
cmpl 0x24c(%rbx), %r15d
jl 0x32a79
addq $0x10, %rsp
popq %rbx
popq %r14
popq %r15
retq
// File: /workspace/github_cpp_makefile_star2_O1/tomfunkhouser[P]gaps/pkgs/R3Shapes/R3Grid.cpp
// Function: gaps::R3Grid::SetWorldToGridTransformation(gaps::R3Affine const&)
void R3Grid::
SetWorldToGridTransformation(const R3Affine& affine)
{
  // Set transformations
  world_to_grid_transform = affine;
  grid_to_world_transform = affine.Inverse();
  world_to_grid_scale_factor = affine.ScaleFactor();
  grid_to_world_scale_factor = (world_to_grid_scale_factor != 0) ? 1 / world_to_grid_scale_factor : 1.0;
}

// Assembly:
pushq %r15
pushq %r14
pushq %rbx
subq $0x110, %rsp            # imm = 0x110
movq %rsi, %r14
movq %rdi, %rbx
addq $0x118, %rdi            # imm = 0x118
addq $0x8, %rsi
callq 0x2e19e
leaq 0x198(%rbx), %rdi
leaq 0x88(%r14), %rsi
callq 0x2e19e
movq 0x108(%r14), %rax
movq %rax, 0x218(%rbx)
movq %r14, %rdi
callq 0x2a29a
movl 0x108(%r14), %edx
andl $0x1, %edx
movq %rsp, %r15
movq %r15, %rdi
movq %rax, %rsi
callq 0x2a22e
leaq 0x8(%rbx), %rdi
leaq 0x8(%rsp), %rsi
callq 0x2e19e
movl $0x88, %eax
leaq (%rbx,%rax), %rdi
addq %rax, %r15
movq %r15, %rsi
callq 0x2e19e
movq %rsp, %rdi
movq 0x108(%rdi), %rax
movq %rax, 0x108(%rbx)
callq 0x2a27c
movq (%r14), %rax
movq %r14, %rdi
callq *0xc0(%rax)
movsd %xmm0, 0x220(%rbx)
movsd 0x6ec15(%rip), %xmm1    # 0xa2038
movapd %xmm1, %xmm2
divsd %xmm0, %xmm2
xorpd %xmm3, %xmm3
cmpneqsd %xmm0, %xmm3
andpd %xmm3, %xmm2
andnpd %xmm1, %xmm3
orpd %xmm2, %xmm3
movlpd %xmm3, 0x228(%rbx)
addq $0x110, %rsp            # imm = 0x110
popq %rbx
popq %r14
popq %r15
retq
movq %rax, %rbx
movq %rsp, %rdi
callq 0x2a27c
movq %rbx, %rdi
callq 0xe7e0
// File: /workspace/github_cpp_makefile_star2_O1/tomfunkhouser[P]gaps/pkgs/R3Shapes/R3Grid.cpp
// Function: gaps::R3Grid::SignedDistanceTransform()
void R3Grid::
SignedDistanceTransform(void)
{
  // Compute distance from boundary into interior (negative) and into exterior (positive)
  R3Grid copy(*this);
  SquaredDistanceTransform();
  Sqrt();
  copy.Threshold(0, 1, 0);
  copy.Substitute(R2_GRID_UNKNOWN_VALUE, 1);
  copy.SquaredDistanceTransform();
  copy.Sqrt();
  Subtract(copy);
}

// Assembly:
pushq %r15
pushq %r14
pushq %rbx
subq $0x250, %rsp            # imm = 0x250
movq %rdi, %rbx
movq %rsp, %rdi
movq %rbx, %rsi
callq 0x2f120
movq %rbx, %rdi
callq 0x305f6
cmpl $0x0, 0x24c(%rbx)
jle 0x334ce
movq 0x230(%rbx), %r14
xorl %r15d, %r15d
xorpd %xmm1, %xmm1
movsd (%r14,%r15,8), %xmm0
ucomisd %xmm1, %xmm0
jb 0x334b3
sqrtsd %xmm0, %xmm0
jmp 0x334bc
callq 0xe340
xorpd %xmm1, %xmm1
movsd %xmm0, (%r14,%r15,8)
incq %r15
cmpl 0x24c(%rbx), %r15d
jl 0x334a1
movl 0x24c(%rsp), %eax
testl %eax, %eax
jle 0x33542
movq 0x230(%rsp), %rcx
xorl %edx, %edx
xorpd %xmm0, %xmm0
movsd 0x6eb49(%rip), %xmm1    # 0xa2038
movsd (%rcx,%rdx,8), %xmm2
cmpnlesd %xmm0, %xmm2
andnpd %xmm1, %xmm2
movlpd %xmm2, (%rcx,%rdx,8)
incq %rdx
cmpl %edx, %eax
jne 0x334ef
testl %eax, %eax
jle 0x33542
movq 0x230(%rsp), %rcx
xorl %edx, %edx
movsd 0x6fa99(%rip), %xmm0    # 0xa2fb8
movabsq $0x3ff0000000000000, %rsi # imm = 0x3FF0000000000000
movsd (%rcx,%rdx,8), %xmm1
ucomisd %xmm0, %xmm1
jne 0x3353a
jp 0x3353a
movq %rsi, (%rcx,%rdx,8)
incq %rdx
cmpq %rdx, %rax
jne 0x33529
movq %rsp, %rdi
callq 0x305f6
cmpl $0x0, 0x24c(%rsp)
jle 0x33591
movq 0x230(%rsp), %r14
xorl %r15d, %r15d
xorpd %xmm1, %xmm1
movsd (%r14,%r15,8), %xmm0
ucomisd %xmm1, %xmm0
jb 0x33575
sqrtsd %xmm0, %xmm0
jmp 0x3357e
callq 0xe340
xorpd %xmm1, %xmm1
movsd %xmm0, (%r14,%r15,8)
incq %r15
cmpl 0x24c(%rsp), %r15d
jl 0x33563
movslq 0x24c(%rbx), %rax
testq %rax, %rax
jle 0x335c5
movq 0x230(%rsp), %rcx
movq 0x230(%rbx), %rdx
xorl %esi, %esi
movsd (%rdx,%rsi,8), %xmm0
subsd (%rcx,%rsi,8), %xmm0
movsd %xmm0, (%rdx,%rsi,8)
incq %rsi
cmpq %rsi, %rax
jne 0x335ae
movq %rsp, %rdi
callq 0x2f17c
addq $0x250, %rsp            # imm = 0x250
popq %rbx
popq %r14
popq %r15
retq
movq %rax, %rbx
movq %rsp, %rdi
callq 0x2f17c
movq %rbx, %rdi
callq 0xe7e0
nop
// File: /workspace/github_cpp_makefile_star2_O1/tomfunkhouser[P]gaps/pkgs/R3Shapes/R3Grid.cpp
// Function: gaps::R3Grid::Gauss(double, int)
void R3Grid::
Gauss(RNLength sigma, RNBoolean square)
{
  // Check sigma
  if (sigma == 0.0) return;    

  // Replace each grid value with Gaussian of what was there before
  const RNScalar sqrt_two_pi = sqrt(RN_TWO_PI);
  RNScalar a = sqrt_two_pi * sigma;
  RNScalar fac = 1.0 / (a * a * a);
  RNScalar denom = -2.0 * sigma * sigma;
  if (RNIsZero(denom, 1.0E-6)) return;
  for (int i = 0; i < grid_size; i++) {
    RNScalar value = grid_values[i];
    if (square) value *= value;
    grid_values[i] = fac * exp( value / denom );
  }
}

// Assembly:
xorpd %xmm1, %xmm1
ucomisd %xmm1, %xmm0
jne 0x335fb
jp 0x335fb
retq
pushq %r15
pushq %r14
pushq %rbx
subq $0x20, %rsp
movl %esi, %ebx
movapd %xmm0, %xmm3
movq %rdi, %r14
leaq 0x769b4(%rip), %rax     # 0xa9fc8
movsd (%rax), %xmm0
ucomisd %xmm1, %xmm0
jb 0x33624
sqrtsd %xmm0, %xmm0
jmp 0x33633
movsd %xmm3, (%rsp)
callq 0xe340
movsd (%rsp), %xmm3
movsd 0x6ebc5(%rip), %xmm2    # 0xa2200
mulsd %xmm3, %xmm2
mulsd %xmm3, %xmm2
movapd 0x6ec25(%rip), %xmm1    # 0xa2270
movapd %xmm2, (%rsp)
andpd %xmm2, %xmm1
movsd 0x6eb84(%rip), %xmm2    # 0xa21e0
ucomisd %xmm1, %xmm2
jae 0x336d2
cmpl $0x0, 0x24c(%r14)
jle 0x336d2
mulsd %xmm3, %xmm0
movapd %xmm0, %xmm1
mulsd %xmm0, %xmm1
mulsd %xmm0, %xmm1
movsd 0x6e9b4(%rip), %xmm0    # 0xa2038
divsd %xmm1, %xmm0
movsd %xmm0, 0x18(%rsp)
xorl %r15d, %r15d
movq 0x230(%r14), %rax
movsd (%rax,%r15,8), %xmm0
testl %ebx, %ebx
je 0x336a6
mulsd %xmm0, %xmm0
divsd (%rsp), %xmm0
callq 0xe7f0
mulsd 0x18(%rsp), %xmm0
movq 0x230(%r14), %rax
movsd %xmm0, (%rax,%r15,8)
incq %r15
movslq 0x24c(%r14), %rax
cmpq %rax, %r15
jl 0x33691
addq $0x20, %rsp
popq %rbx
popq %r14
popq %r15
retq
// File: /workspace/github_cpp_makefile_star2_O1/tomfunkhouser[P]gaps/pkgs/R3Shapes/R3Grid.cpp
// Function: gaps::R3Grid::RasterizeGridValue(int, int, int, double, int)
void R3Grid::
RasterizeGridValue(int ix, int iy, int iz, RNScalar value, int operation)
{
  // Check if within bounds
  if ((ix < 0) || (ix > grid_resolution[0]-1)) return;
  if ((iy < 0) || (iy > grid_resolution[1]-1)) return;
  if ((iz < 0) || (iz > grid_resolution[2]-1)) return;

  // Update grid based on operation
  if (operation == R3_GRID_ADD_OPERATION) AddGridValue(ix, iy, iz, value);
  else if (operation == R3_GRID_SUBTRACT_OPERATION) AddGridValue(ix, iy, iz, -value);
  else if (operation == R3_GRID_REPLACE_OPERATION) SetGridValue(ix, iy, iz, value);
  else RNAbort("Unrecognized grid rasterization operation\n");
}

// Assembly:
testl %esi, %esi
js 0x34260
testl %edx, %edx
js 0x34260
cmpl %esi, 0x238(%rdi)
jle 0x34260
testl %ecx, %ecx
js 0x34260
cmpl %edx, 0x23c(%rdi)
jle 0x34260
cmpl %ecx, 0x240(%rdi)
jle 0x34260
cmpl $0x2, %r8d
je 0x34261
cmpl $0x1, %r8d
je 0x34236
testl %r8d, %r8d
jne 0x34283
movq 0x230(%rdi), %rax
imull 0x248(%rdi), %ecx
imull 0x244(%rdi), %edx
addl %esi, %ecx
addl %edx, %ecx
movslq %ecx, %rcx
addsd (%rax,%rcx,8), %xmm0
jmp 0x3427d
movq 0x230(%rdi), %rax
imull 0x248(%rdi), %ecx
imull 0x244(%rdi), %edx
addl %esi, %ecx
addl %edx, %ecx
movslq %ecx, %rcx
movsd (%rax,%rcx,8), %xmm1
subsd %xmm0, %xmm1
movsd %xmm1, (%rax,%rcx,8)
retq
movq 0x230(%rdi), %rax
imull 0x248(%rdi), %ecx
imull 0x244(%rdi), %edx
addl %esi, %ecx
addl %edx, %ecx
movslq %ecx, %rcx
movsd %xmm0, (%rax,%rcx,8)
retq
leaq 0x734e8(%rip), %rdi     # 0xa7772
xorl %eax, %eax
jmp 0x72942
nop
// File: /workspace/github_cpp_makefile_star2_O1/tomfunkhouser[P]gaps/pkgs/R3Shapes/R3Grid.cpp
// Function: gaps::R3Grid::RasterizeGridBox(gaps::R3Box const&, double, int)
void R3Grid::
RasterizeGridBox(const R3Box& box, RNScalar value, int operation)
{
  // Get corner coordinates
  int ix1 = (int) (box.XMin() + 0.5);
  int ix2 = (int) (box.XMax() + 0.5);
  int iy1 = (int) (box.YMin() + 0.5);
  int iy2 = (int) (box.YMax() + 0.5);
  int iz1 = (int) (box.ZMin() + 0.5);
  int iz2 = (int) (box.ZMax() + 0.5);

  // Check for intersection
  if (ix1 >= XResolution()) return;
  if (iy1 >= YResolution()) return;
  if (iz1 >= ZResolution()) return;
  if (ix2 < 0) return;
  if (iy2 < 0) return;
  if (iz2 < 0) return;

  // Clip coordinates
  if (ix1 < 0) ix1 = 0;
  if (iy1 < 0) iy1 = 0;
  if (iz1 < 0) iz1 = 0;
  if (ix2 >= XResolution()) ix2 = XResolution()-1;
  if (iy2 >= YResolution()) iy2 = YResolution()-1;
  if (iz2 >= ZResolution()) iz2 = ZResolution()-1;

  // Add value to grid entries
  for (int iz = iz1; iz <= iz2; iz++) {
    for (int iy = iy1; iy <= iy2; iy++) {
      for (int ix = ix1; ix <= ix2; ix++) {
        RasterizeGridValue(ix, iy, iz, value, operation);
      }
    }
  }
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x28, %rsp
movsd 0x6c70a(%rip), %xmm1    # 0xa2030
movsd 0x8(%rsi), %xmm2
addsd %xmm1, %xmm2
cvttsd2si %xmm2, %ecx
movl 0x238(%rdi), %eax
cmpl %ecx, %eax
jle 0x35a7e
movl %edx, %ebx
movq %rdi, %r14
movl %ecx, %r11d
movsd 0x10(%rsi), %xmm2
addsd %xmm1, %xmm2
cvttsd2si %xmm2, %edx
movl 0x23c(%rdi), %ecx
cmpl %edx, %ecx
jle 0x35a7e
movl %edx, %ebp
movupd 0x20(%rsi), %xmm2
addpd 0x6c69d(%rip), %xmm2    # 0xa2010
cvttpd2dq %xmm2, %xmm3
movsd 0x18(%rsi), %xmm2
addsd %xmm1, %xmm2
cvttsd2si %xmm2, %edi
addsd 0x30(%rsi), %xmm1
cvttsd2si %xmm1, %edx
movl 0x240(%r14), %esi
cmpl %edi, %esi
setle %r8b
pshufd $0x50, %xmm3, %xmm1     # xmm1 = xmm3[0,0,1,1]
movmskpd %xmm1, %r9d
orb %r9b, %r8b
shrb %r9b
testl %edx, %edx
sets %r10b
orb %r9b, %r10b
orb %r8b, %r10b
testb $0x1, %r10b
jne 0x35a7e
xorl %r15d, %r15d
testl %r11d, %r11d
cmovlel %r15d, %r11d
movl %r11d, 0x14(%rsp)
testl %ebp, %ebp
cmovlel %r15d, %ebp
movl %ebp, 0x8(%rsp)
testl %edi, %edi
cmovgl %edi, %r15d
leal -0x1(%rsi), %edi
cmpl %edx, %esi
cmovgl %edx, %edi
movl %edi, 0x10(%rsp)
cmpl %edi, %r15d
jg 0x35a7e
pshufd $0x55, %xmm3, %xmm1     # xmm1 = xmm3[1,1,1,1]
movd %xmm1, %edx
leal -0x1(%rcx), %esi
cmpl %edx, %ecx
cmovgl %edx, %esi
movl %esi, 0xc(%rsp)
movd %xmm3, %ecx
leal -0x1(%rax), %edx
cmpl %ecx, %eax
cmovgl %ecx, %edx
movq %rdx, 0x18(%rsp)
leal 0x1(%rdx), %r13d
movsd %xmm0, 0x20(%rsp)
movl 0xc(%rsp), %eax
cmpl %eax, 0x8(%rsp)
jg 0x35a70
movl 0x8(%rsp), %eax
movl %eax, %r12d
movl 0x14(%rsp), %eax
movl %eax, %ebp
cmpl 0x18(%rsp), %eax
jg 0x35a61
movq %r14, %rdi
movl %ebp, %esi
movl %r12d, %edx
movl %r15d, %ecx
movl %ebx, %r8d
callq 0x341de
movsd 0x20(%rsp), %xmm0
incl %ebp
cmpl %ebp, %r13d
jne 0x35a41
leal 0x1(%r12), %eax
cmpl 0xc(%rsp), %r12d
movl %eax, %r12d
jne 0x35a35
leal 0x1(%r15), %eax
cmpl 0x10(%rsp), %r15d
movl %eax, %r15d
jne 0x35a24
addq $0x28, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
nop
// File: /workspace/github_cpp_makefile_star2_O1/tomfunkhouser[P]gaps/pkgs/R3Shapes/R3Grid.cpp
// Function: gaps::R3Grid::Dot(gaps::R3Grid const&) const
RNScalar R3Grid::
Dot(const R3Grid& 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]);
  assert(grid_resolution[2] == grid.grid_resolution[2]);

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

// Assembly:
movslq 0x24c(%rdi), %rax
testq %rax, %rax
jle 0x35ac5
movq 0x230(%rdi), %rcx
movq 0x230(%rsi), %rdx
xorpd %xmm0, %xmm0
xorl %esi, %esi
movsd (%rcx,%rsi,8), %xmm1
mulsd (%rdx,%rsi,8), %xmm1
addsd %xmm1, %xmm0
incq %rsi
cmpq %rsi, %rax
jne 0x35aae
retq
xorps %xmm0, %xmm0
retq
nop
// File: /workspace/github_cpp_makefile_star2_O1/tomfunkhouser[P]gaps/pkgs/R3Shapes/R3Grid.cpp
// Function: gaps::R3Grid::L1Distance(gaps::R3Grid const&) const
RNScalar R3Grid::
L1Distance(const R3Grid& grid) const
{
  // Compute distance between this and grid
  RNScalar distance = 0.0;
  for (int i = 0; i < grid_size; i++) 
    distance += fabs(grid_values[i] - grid.grid_values[i]);
  return distance;
}

// Assembly:
movslq 0x24c(%rdi), %rax
testq %rax, %rax
jle 0x35b0d
movq 0x230(%rdi), %rcx
movq 0x230(%rsi), %rdx
xorpd %xmm0, %xmm0
xorl %esi, %esi
movapd 0x6c77e(%rip), %xmm1    # 0xa2270
movsd (%rcx,%rsi,8), %xmm2
subsd (%rdx,%rsi,8), %xmm2
andpd %xmm1, %xmm2
addsd %xmm2, %xmm0
incq %rsi
cmpq %rsi, %rax
jne 0x35af2
retq
xorps %xmm0, %xmm0
retq
nop
// File: /workspace/github_cpp_makefile_star2_O1/tomfunkhouser[P]gaps/pkgs/R3Shapes/R3Grid.cpp
// Function: gaps::R3Grid::L2DistanceSquared(gaps::R3Grid const&) const
RNScalar R3Grid::
L2DistanceSquared(const R3Grid& grid) const
{
  // Compute distance between this and grid
  RNScalar distance_squared = 0.0;
  for (int i = 0; i < grid_size; i++) {
    RNScalar delta = (grid_values[i] - grid.grid_values[i]);
    distance_squared += delta * delta;
  }

  // Return result
  return distance_squared;
}

// Assembly:
movslq 0x24c(%rdi), %rax
testq %rax, %rax
jle 0x35b4d
movq 0x230(%rdi), %rcx
movq 0x230(%rsi), %rdx
xorpd %xmm0, %xmm0
xorl %esi, %esi
movsd (%rcx,%rsi,8), %xmm1
subsd (%rdx,%rsi,8), %xmm1
mulsd %xmm1, %xmm1
addsd %xmm1, %xmm0
incq %rsi
cmpq %rsi, %rax
jne 0x35b32
retq
xorps %xmm0, %xmm0
retq
nop
// File: /workspace/github_cpp_makefile_star2_O1/tomfunkhouser[P]gaps/pkgs/R3Shapes/R3Grid.cpp
// Function: gaps::R3Grid::WorldSpacing(int) const
RNScalar R3Grid::
WorldSpacing(RNDimension dim) const
{
  // Return distance between grid samples in dimension
  assert((0 <= dim) && (dim <= 2));
  RNScalar m0 = grid_to_world_transform.Matrix()[0][dim];
  RNScalar m1 = grid_to_world_transform.Matrix()[1][dim];
  RNScalar m2 = grid_to_world_transform.Matrix()[2][dim];
  RNScalar spacing_squared = m0*m0 + m1*m1 + m2*m2;
  return sqrt(spacing_squared);
}

// Assembly:
movslq %esi, %rax
movsd 0x8(%rdi,%rax,8), %xmm1
movsd 0x28(%rdi,%rax,8), %xmm2
movsd 0x48(%rdi,%rax,8), %xmm0
mulsd %xmm2, %xmm2
mulsd %xmm1, %xmm1
addsd %xmm2, %xmm1
mulsd %xmm0, %xmm0
addsd %xmm1, %xmm0
xorpd %xmm1, %xmm1
ucomisd %xmm1, %xmm0
jb 0xe340
sqrtsd %xmm0, %xmm0
retq
// File: /workspace/github_cpp_makefile_star2_O1/tomfunkhouser[P]gaps/pkgs/R3Shapes/R3Grid.cpp
// Function: gaps::R3Grid::ReadFile(char const*)
int R3Grid::
ReadFile(const char *filename)
{
  // Parse input filename extension
  const char *extension;
  if (!(extension = strrchr(filename, '.'))) {
    printf("Filename %s has no extension (e.g., .ply)\n", filename);
    return 0;
  }

  // Read file of appropriate type
  int status = 0;
  if (!strncmp(extension, ".grd", 4)) 
    status = ReadGridFile(filename);
  else if (!strncmp(extension, ".phi", 4)) 
    status = ReadDelphiFile(filename);
  else if (!strncmp(extension, ".vox", 4)) 
    status = ReadVoxelFile(filename);
  else if (!strncmp(extension, ".ins", 4)) 
    status = ReadInsightFile(filename);
  else if (!strncmp(extension, ".dx", 3)) 
    status = ReadDXFile(filename);
  else if (!strncmp(extension, ".map", 4)) 
    status = ReadCCP4File(filename);
  else if (!strncmp(extension, ".raw", 4)) 
    status = ReadRawFile(filename);
  else {
    RNFail("Unable to read file %s (unrecognized extension: %s)\n", filename, extension);
    return 0;
  }

  // Return status
  return status;
}

// 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 0x35ef2
movq %rax, %r15
leaq 0x7197e(%rip), %rsi     # 0xa779d
movl $0x4, %edx
movq %rax, %rdi
callq 0xe210
testl %eax, %eax
je 0x35f0b
leaq 0x71967(%rip), %rsi     # 0xa77a2
movl $0x4, %edx
movq %r15, %rdi
callq 0xe210
testl %eax, %eax
je 0x35f1b
leaq 0x71950(%rip), %rsi     # 0xa77a7
movl $0x4, %edx
movq %r15, %rdi
callq 0xe210
testl %eax, %eax
je 0x35f2b
leaq 0x71939(%rip), %rsi     # 0xa77ac
movl $0x4, %edx
movq %r15, %rdi
callq 0xe210
testl %eax, %eax
je 0x35f3b
leaq 0x71922(%rip), %rsi     # 0xa77b1
movl $0x3, %edx
movq %r15, %rdi
callq 0xe210
testl %eax, %eax
je 0x35f4b
leaq 0x7190a(%rip), %rsi     # 0xa77b5
movl $0x4, %edx
movq %r15, %rdi
callq 0xe210
testl %eax, %eax
je 0x35f5b
leaq 0x718f3(%rip), %rsi     # 0xa77ba
movl $0x4, %edx
movq %r15, %rdi
callq 0xe210
testl %eax, %eax
je 0x35f6b
leaq 0x6c4a5(%rip), %rdi     # 0xa2388
movq %rbx, %rsi
movq %r15, %rdx
xorl %eax, %eax
callq 0x72a1e
jmp 0x35f03
leaq 0x6c439(%rip), %rdi     # 0xa2332
movq %rbx, %rsi
xorl %eax, %eax
callq 0xe070
xorl %eax, %eax
popq %rbx
popq %r14
popq %r15
retq
movq %r14, %rdi
movq %rbx, %rsi
popq %rbx
popq %r14
popq %r15
jmp 0x35f7c
movq %r14, %rdi
movq %rbx, %rsi
popq %rbx
popq %r14
popq %r15
jmp 0x35fd0
movq %r14, %rdi
movq %rbx, %rsi
popq %rbx
popq %r14
popq %r15
jmp 0x365c2
movq %r14, %rdi
movq %rbx, %rsi
popq %rbx
popq %r14
popq %r15
jmp 0x36752
movq %r14, %rdi
movq %rbx, %rsi
popq %rbx
popq %r14
popq %r15
jmp 0x36ea0
movq %r14, %rdi
movq %rbx, %rsi
popq %rbx
popq %r14
popq %r15
jmp 0x3725a
movq %r14, %rdi
movq %rbx, %rsi
popq %rbx
popq %r14
popq %r15
jmp 0x3761e
nop
// File: /workspace/github_cpp_makefile_star2_O1/tomfunkhouser[P]gaps/pkgs/R3Shapes/R3Grid.cpp
// Function: gaps::R3Grid::ReadGridFile(char const*)
int R3Grid::
ReadGridFile(const char *filename)
{
  // Open file
  FILE *fp = fopen(filename, "rb");
  if (!fp) {
    RNFail("Unable to open voxel file %s", filename);
    return 0;
  }

  // Read 
  int status = ReadGrid(fp);

  // Close file
  fclose(fp);

  // Return status
  return status;
}

// Assembly:
pushq %r15
pushq %r14
pushq %rbx
movq %rsi, %rbx
movq %rdi, %r14
leaq 0x6c620(%rip), %rsi     # 0xa25ae
movq %rbx, %rdi
callq 0xe530
testq %rax, %rax
je 0x35fb7
movq %rax, %r15
movq %r14, %rdi
movq %rax, %rsi
callq 0x38b82
movl %eax, %ebx
movq %r15, %rdi
callq 0xe430
movl %ebx, %eax
jmp 0x35fca
leaq 0x71844(%rip), %rdi     # 0xa7802
movq %rbx, %rsi
xorl %eax, %eax
callq 0x72a1e
xorl %eax, %eax
popq %rbx
popq %r14
popq %r15
retq
// File: /workspace/github_cpp_makefile_star2_O1/tomfunkhouser[P]gaps/pkgs/R3Shapes/R3Grid.cpp
// Function: gaps::R3Grid::WriteFile(char const*) const
int R3Grid::
WriteFile(const char *filename) const
{
  // Parse input filename extension
  const char *extension;
  if (!(extension = strrchr(filename, '.'))) {
    printf("Filename %s has no extension (e.g., .ply)\n", filename);
    return 0;
  }

  // Write file of appropriate type
  int status = 0;
  if (!strncmp(extension, ".grd", 4)) 
    status = WriteGridFile(filename);
  else if (!strncmp(extension, ".dx", 3)) 
    status = WriteDXFile(filename);
  else if (!strncmp(extension, ".raw", 4)) 
    status = WriteRawFile(filename);
  else if (!strncmp(extension, ".pdb", 4)) 
    status = WritePDBFile(filename);
  else {
    RNFail("Unable to write file %s (unrecognized extension: %s)\n", filename, extension);
    return 0;
  }

  // Return status
  return status;
}

// 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 0x37fac
movq %rax, %r15
leaq 0x6f860(%rip), %rsi     # 0xa779d
movl $0x4, %edx
movq %rax, %rdi
callq 0xe210
testl %eax, %eax
je 0x37fc5
leaq 0x6f85c(%rip), %rsi     # 0xa77b1
movl $0x3, %edx
movq %r15, %rdi
callq 0xe210
testl %eax, %eax
je 0x37fd5
leaq 0x6f84d(%rip), %rsi     # 0xa77ba
movl $0x4, %edx
movq %r15, %rdi
callq 0xe210
testl %eax, %eax
je 0x37fe5
leaq 0x6f842(%rip), %rsi     # 0xa77c7
movl $0x4, %edx
movq %r15, %rdi
callq 0xe210
testl %eax, %eax
je 0x37ffc
leaq 0x6f82f(%rip), %rdi     # 0xa77cc
movq %rbx, %rsi
movq %r15, %rdx
xorl %eax, %eax
callq 0x72a1e
jmp 0x37fbd
leaq 0x6a37f(%rip), %rdi     # 0xa2332
movq %rbx, %rsi
xorl %eax, %eax
callq 0xe070
xorl %eax, %eax
popq %rbx
popq %r14
popq %r15
retq
movq %r14, %rdi
movq %rbx, %rsi
popq %rbx
popq %r14
popq %r15
jmp 0x3800c
movq %r14, %rdi
movq %rbx, %rsi
popq %rbx
popq %r14
popq %r15
jmp 0x38060
leaq 0x6f7d3(%rip), %rdx     # 0xa77bf
movq %r14, %rdi
movq %rbx, %rsi
popq %rbx
popq %r14
popq %r15
jmp 0x382e0
movq %r14, %rdi
movq %rbx, %rsi
popq %rbx
popq %r14
popq %r15
jmp 0x389aa
// File: /workspace/github_cpp_makefile_star2_O1/tomfunkhouser[P]gaps/pkgs/R3Shapes/R3Grid.cpp
// Function: gaps::R3Grid::WriteGridFile(char const*) const
int R3Grid::
WriteGridFile(const char *filename) const
{
  // Open file
  FILE *fp = fopen(filename, "wb");
  if (!fp) {
    RNFail("Unable to open voxel file %s", filename);
    return 0;
  }

  // Write
  int status = WriteGrid(fp);

  // Close file
  fclose(fp);

  // Return status
  return status;
}

// Assembly:
pushq %r15
pushq %r14
pushq %rbx
movq %rsi, %rbx
movq %rdi, %r14
leaq 0x6aa66(%rip), %rsi     # 0xa2a84
movq %rbx, %rdi
callq 0xe530
testq %rax, %rax
je 0x38047
movq %rax, %r15
movq %r14, %rdi
movq %rax, %rsi
callq 0x38e36
movl %eax, %ebx
movq %r15, %rdi
callq 0xe430
movl %ebx, %eax
jmp 0x3805a
leaq 0x6f7b4(%rip), %rdi     # 0xa7802
movq %rbx, %rsi
xorl %eax, %eax
callq 0x72a1e
xorl %eax, %eax
popq %rbx
popq %r14
popq %r15
retq
// File: /workspace/github_cpp_makefile_star2_O1/tomfunkhouser[P]gaps/pkgs/R3Shapes/R3Grid.cpp
// Function: gaps::R3Grid::WritePDBFile(char const*) const
int R3Grid::
WritePDBFile(const char *filename) const
{
  // Open file
  FILE *fp = fopen(filename, "w");
  if (!fp) {
    RNFail("Unable to open file %s", filename);
    return 0;
  }

  // Print values
  int n = 0;
  for (int k = 0; k < ZResolution(); k++) {
    for (int j = 0; j < YResolution(); j++) {
      for (int i = 0; i < XResolution(); i++) {
	if (GridValue(i,j, k) > 0){
	  R3Point world_position = WorldPosition(i, j, k);	  
	  fprintf(fp, "%-6s%5d %-4s%c%3s %1s%4d%c   %8.3f%8.3f%8.3f%6.2f%6.2f          %2s\n", "HETATM", n, "H", ' ', "POC", "1", n, ' ', world_position.X(), world_position.Y(), world_position.Z(), GridValue(i, j, k), GridValue(i, j, k), "");
	  n++;
	}
      }
    }
  }

  // Close file
  fclose(fp);

  // Return OK status
  return grid_size;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x38, %rsp
movq %rsi, %r15
movq %rdi, %rbx
leaq 0x6edf8(%rip), %rsi     # 0xa77bd
movq %r15, %rdi
callq 0xe530
movq %rax, 0x8(%rsp)
testq %rax, %rax
je 0x38b5d
cmpl $0x0, 0x240(%rbx)
jle 0x38b4b
xorl %r13d, %r13d
xorpd %xmm1, %xmm1
leaq 0x20(%rsp), %r15
xorl %r12d, %r12d
cmpl $0x0, 0x23c(%rbx)
jle 0x38b3b
xorps %xmm0, %xmm0
cvtsi2sd %r13d, %xmm0
movsd %xmm0, 0x10(%rsp)
xorl %ebp, %ebp
cmpl $0x0, 0x238(%rbx)
jle 0x38b2d
xorps %xmm0, %xmm0
cvtsi2sd %ebp, %xmm0
movsd %xmm0, 0x18(%rsp)
xorl %r14d, %r14d
movq 0x230(%rbx), %rax
movl 0x248(%rbx), %ecx
imull %r13d, %ecx
movl 0x244(%rbx), %edx
imull %ebp, %edx
addl %ecx, %edx
addl %r14d, %edx
movslq %edx, %rcx
movsd (%rax,%rcx,8), %xmm0
ucomisd %xmm1, %xmm0
jbe 0x38b1d
xorps %xmm0, %xmm0
cvtsi2sd %r14d, %xmm0
movq %r15, %rdi
movsd 0x18(%rsp), %xmm1
movsd 0x10(%rsp), %xmm2
callq 0x3ca26
movq %r15, %rdi
movq %rbx, %rsi
callq 0x3d342
movsd 0x20(%rsp), %xmm0
movsd 0x28(%rsp), %xmm1
movsd 0x30(%rsp), %xmm2
movq 0x230(%rbx), %rax
movl 0x248(%rbx), %ecx
imull %r13d, %ecx
movl 0x244(%rbx), %edx
imull %ebp, %edx
addl %ecx, %edx
addl %r14d, %edx
movslq %edx, %rcx
movsd (%rax,%rcx,8), %xmm3
subq $0x8, %rsp
movq 0x10(%rsp), %rdi
leaq 0x6f9e6(%rip), %rsi     # 0xa84b8
leaq 0x6fa24(%rip), %rdx     # 0xa84fd
movl %r12d, %ecx
leaq 0x6fa21(%rip), %r8      # 0xa8504
movl $0x20, %r9d
movaps %xmm3, %xmm4
movb $0x5, %al
leaq 0x69b67(%rip), %r10     # 0xa265c
pushq %r10
pushq $0x20
pushq %r12
leaq 0x6fa08(%rip), %r10     # 0xa850a
pushq %r10
leaq 0x6f9fb(%rip), %r10     # 0xa8506
pushq %r10
callq 0xe670
xorpd %xmm1, %xmm1
addq $0x30, %rsp
incl %r12d
incl %r14d
cmpl 0x238(%rbx), %r14d
jl 0x38a31
incl %ebp
cmpl 0x23c(%rbx), %ebp
jl 0x38a14
incl %r13d
cmpl 0x240(%rbx), %r13d
jl 0x389f7
movq 0x8(%rsp), %rdi
callq 0xe430
movl 0x24c(%rbx), %ebx
jmp 0x38b70
leaq 0x69859(%rip), %rdi     # 0xa23bd
xorl %ebx, %ebx
movq %r15, %rsi
xorl %eax, %eax
callq 0x72a1e
movl %ebx, %eax
addq $0x38, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
nop
// File: /workspace/github_cpp_makefile_star2_O1/tomfunkhouser[P]gaps/pkgs/R3Shapes/R3Grid.cpp
// Function: gaps::R3Grid::WriteGrid(_IO_FILE*) const
int R3Grid::
WriteGrid(FILE *fp) const
{
  // Check file
  if (!fp) fp = stdout;

  // Write grid resolution to file
  if (fwrite(&grid_resolution, sizeof(int), 3, fp) != 3) {
    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]);
  for (int i = 0; i < 16; i++) {
    float value = (float) *(m++);
    if (fwrite(&value, sizeof(float), 1, fp) != 1) {
      RNFail("Unable to write transformation matrix value to file");
      return 0;
    }
  }

  // Write grid values to file
  const RNScalar *grid_valuesp = grid_values;
  for (int i = 0; i < grid_size; i++) {
    float value = (float) *(grid_valuesp++);
    if (fwrite(&value, sizeof(float), 1, fp) != 1) {
      RNFail("Unable to write grid value to file");
      return 0;
    }
  }

  // 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 0x38e56
movq 0xac11d(%rip), %rax     # 0xe4f70
movq (%rax), %r14
leaq 0x238(%rbx), %rdi
movl $0x4, %esi
movl $0x3, %edx
movq %r14, %rcx
callq 0xe8b0
cmpq $0x3, %rax
jne 0x38f56
xorl %r12d, %r12d
leaq 0x4(%rsp), %r15
xorps %xmm0, %xmm0
cvtsd2ss 0x118(%rbx,%r12,8), %xmm0
movss %xmm0, 0x4(%rsp)
movl $0x4, %esi
movl $0x1, %edx
movq %r15, %rdi
movq %r14, %rcx
callq 0xe8b0
cmpq $0x1, %rax
jne 0x38f5f
incq %r12
cmpl $0x10, %r12d
jne 0x38e81
cmpl $0x0, 0x24c(%rbx)
setg %r12b
jle 0x38f47
movq 0x230(%rbx), %r13
xorps %xmm0, %xmm0
cvtsd2ss (%r13), %xmm0
movq %rsp, %rdi
movss %xmm0, (%rdi)
movl $0x1, %ebp
movl $0x4, %esi
movl $0x1, %edx
movq %r14, %rcx
callq 0xe8b0
cmpq $0x1, %rax
jne 0x38f39
movq %rsp, %r15
cmpl 0x24c(%rbx), %ebp
setl %r12b
jge 0x38f47
xorps %xmm0, %xmm0
cvtsd2ss (%r13,%rbp,8), %xmm0
movss %xmm0, (%rsp)
movl $0x4, %esi
movl $0x1, %edx
movq %r15, %rdi
movq %r14, %rcx
callq 0xe8b0
incq %rbp
cmpq $0x1, %rax
je 0x38f00
leaq 0x6e9d9(%rip), %rdi     # 0xa7919
xorl %eax, %eax
callq 0x72a1e
xorl %ebp, %ebp
testb %r12b, %r12b
jne 0x38f6f
movl 0x24c(%rbx), %ebp
jmp 0x38f6f
leaq 0x6e965(%rip), %rdi     # 0xa78c2
jmp 0x38f66
leaq 0x6e97f(%rip), %rdi     # 0xa78e5
xorl %ebp, %ebp
xorl %eax, %eax
callq 0x72a1e
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_O1/tomfunkhouser[P]gaps/pkgs/R3Shapes/R3Grid.cpp
// Function: int gaps::ReadRawValues<double>(_IO_FILE*, double*, int)
static int
ReadRawValues(FILE *fp, RNScalar *values, int nvalues)
{
  // Read values of type T into array of RNScalar
  for (int i = 0; i < nvalues; i++) {
    T value;
    if (fread(&value, sizeof(T), 1, fp) != 1) return 0;
    values[i] = (RNScalar) value;
  }
  return 1;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
pushq %rax
testl %edx, %edx
setle %r15b
jle 0x38ffe
movl %edx, %ebp
movq %rsi, %rbx
movq %rdi, %r14
movq %rsp, %rdi
movl $0x8, %esi
movl $0x1, %edx
movq %r14, %rcx
callq 0xe6c0
cmpq $0x1, %rax
jne 0x38ffe
movl %ebp, %r12d
leaq -0x1(%r12), %rbp
xorl %r13d, %r13d
movq %rsp, %r15
movsd (%rsp), %xmm0
movsd %xmm0, (%rbx,%r13,8)
cmpq %r13, %rbp
je 0x38ff4
movl $0x8, %esi
movl $0x1, %edx
movq %r15, %rdi
movq %r14, %rcx
callq 0xe6c0
incq %r13
cmpq $0x1, %rax
je 0x38fc4
jmp 0x38ff7
incq %r13
cmpq %r12, %r13
setae %r15b
movzbl %r15b, %eax
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
// File: /workspace/github_cpp_makefile_star2_O1/tomfunkhouser[P]gaps/pkgs/R3Shapes/R3Grid.cpp
// Function: int gaps::WriteRawValues<double>(_IO_FILE*, double*, int)
static int
WriteRawValues(FILE *fp, RNScalar *values, int nvalues)
{
  // Write values of type T from array of RNScalar
  for (int i = 0; i < nvalues; i++) {
    T value = (T) values[i];
    if (fwrite(&value, sizeof(T), 1, fp) != 1) return 0;
  }
  return 1;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
pushq %rax
testl %edx, %edx
setle %r15b
jle 0x39616
movl %edx, %ebp
movq %rsi, %rbx
movq %rdi, %r14
movsd (%rsi), %xmm0
movq %rsp, %rdi
movsd %xmm0, (%rdi)
movl $0x1, %r13d
movl $0x8, %esi
movl $0x1, %edx
movq %r14, %rcx
callq 0xe8b0
cmpq $0x1, %rax
jne 0x39616
movl %ebp, %r12d
movq %rsp, %r15
movq %r13, %rbp
cmpq %r13, %r12
je 0x3960f
movsd (%rbx,%rbp,8), %xmm0
movsd %xmm0, (%rsp)
movl $0x8, %esi
movl $0x1, %edx
movq %r15, %rdi
movq %r14, %rcx
callq 0xe8b0
leaq 0x1(%rbp), %r13
cmpq $0x1, %rax
je 0x395de
cmpq %r12, %rbp
setae %r15b
movzbl %r15b, %eax
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
// File: /workspace/github_cpp_makefile_star2_O1/tomfunkhouser[P]gaps/pkgs/R3Shapes/R3Grid.cpp
// Function: gaps::R3Grid::WriteASCIIFile(char const*) const
int R3Grid::
WriteASCIIFile(const char *filename) const
{
  // Open file
  FILE *fp = fopen(filename, "w");
  if (!fp) {
    RNFail("Unable to open file %s", filename);
    return 0;
  }

  // Print resolutions
  fprintf(fp, "%d %d %d\n", XResolution(), YResolution(), ZResolution());

  // Print world to grid transformation
  const R4Matrix& m = world_to_grid_transform.Matrix();
  for (int i = 0; i < 4; i++) {
    for (int j = 0; j < 4; j++) {
      fprintf(fp, "%lf ", m[i][j]);
    }
    fprintf(fp, "\n");
  }

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

  // Close file
  fclose(fp);

  // Return OK status
  return grid_size;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
pushq %rax
movq %rsi, %r15
movq %rdi, %rbx
leaq 0x6da3f(%rip), %rsi     # 0xa77bd
movq %r15, %rdi
callq 0xe530
testq %rax, %rax
je 0x39e90
movq %rax, %r14
movl 0x238(%rbx), %edx
movl 0x23c(%rbx), %ecx
movl 0x240(%rbx), %r8d
leaq 0x68c8b(%rip), %rsi     # 0xa2a37
xorl %r12d, %r12d
movq %rax, %rdi
xorl %eax, %eax
callq 0xe670
leaq 0x118(%rbx), %r13
leaq 0x6e77b(%rip), %r15     # 0xa8542
xorl %ebp, %ebp
movsd (%r13,%rbp,8), %xmm0
movq %r14, %rdi
movq %r15, %rsi
movb $0x1, %al
callq 0xe670
incq %rbp
cmpq $0x4, %rbp
jne 0x39dc9
movl $0xa, %edi
movq %r14, %rsi
callq 0xe5a0
incq %r12
addq $0x20, %r13
cmpq $0x4, %r12
jne 0x39dc7
cmpl $0x0, 0x238(%rbx)
jle 0x39e80
xorl %ebp, %ebp
leaq 0x6e62a(%rip), %r15     # 0xa843c
cmpl $0x0, 0x23c(%rbx)
jle 0x39e76
xorl %r12d, %r12d
cmpl $0x0, 0x240(%rbx)
jle 0x39e6a
xorl %r13d, %r13d
movq 0x230(%rbx), %rax
movl 0x248(%rbx), %ecx
imull %r13d, %ecx
movl 0x244(%rbx), %edx
imull %r12d, %edx
addl %ebp, %ecx
addl %edx, %ecx
movslq %ecx, %rcx
movsd (%rax,%rcx,8), %xmm0
movq %r14, %rdi
movq %r15, %rsi
movb $0x1, %al
callq 0xe670
incl %r13d
cmpl 0x240(%rbx), %r13d
jl 0x39e2a
incl %r12d
cmpl 0x23c(%rbx), %r12d
jl 0x39e1e
incl %ebp
cmpl 0x238(%rbx), %ebp
jl 0x39e12
movq %r14, %rdi
callq 0xe430
movl 0x24c(%rbx), %ebx
jmp 0x39ea3
leaq 0x68526(%rip), %rdi     # 0xa23bd
xorl %ebx, %ebx
movq %r15, %rsi
xorl %eax, %eax
callq 0x72a1e
movl %ebx, %eax
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
// File: /workspace/github_cpp_makefile_star2_O1/tomfunkhouser[P]gaps/pkgs/R3Shapes/R3Grid.cpp
// Function: gaps::R3Grid::Print(_IO_FILE*) const
int R3Grid::
Print(FILE *fp) const
{
  // Check file
  if (!fp) fp = stdout;

  // Print resolutions
  fprintf(fp, "%d %d %d\n", XResolution(), YResolution(), ZResolution());

  // Print values
  for (int k = 0; k < ZResolution(); k++) {
    for (int j = 0; j < YResolution(); j++) {
      for (int i = 0; i < XResolution(); i++) {
        fprintf(fp, "%g ", GridValue(i, j, k));
      }
      fprintf(fp, "\n");
    }
    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 0x39ed4
movq 0xab09f(%rip), %rax     # 0xe4f70
movq (%rax), %r14
movl 0x238(%rbx), %edx
movl 0x23c(%rbx), %ecx
movl 0x240(%rbx), %r8d
leaq 0x68b49(%rip), %rsi     # 0xa2a37
xorl %ebp, %ebp
movq %r14, %rdi
xorl %eax, %eax
callq 0xe670
cmpl $0x0, 0x240(%rbx)
jle 0x39f9a
leaq 0x6e639(%rip), %r15     # 0xa8547
cmpl $0x0, 0x23c(%rbx)
jle 0x39f7f
xorl %r12d, %r12d
cmpl $0x0, 0x238(%rbx)
jle 0x39f66
xorl %r13d, %r13d
movq 0x230(%rbx), %rax
movl 0x248(%rbx), %ecx
imull %ebp, %ecx
movl 0x244(%rbx), %edx
imull %r12d, %edx
addl %ecx, %edx
addl %r13d, %edx
movslq %edx, %rcx
movsd (%rax,%rcx,8), %xmm0
movq %r14, %rdi
movq %r15, %rsi
movb $0x1, %al
callq 0xe670
incl %r13d
cmpl 0x238(%rbx), %r13d
jl 0x39f26
movl $0xa, %edi
movq %r14, %rsi
callq 0xe5a0
incl %r12d
cmpl 0x23c(%rbx), %r12d
jl 0x39f1a
movl $0xa, %edi
movq %r14, %rsi
callq 0xe5a0
incl %ebp
cmpl 0x240(%rbx), %ebp
jl 0x39f0e
movl 0x24c(%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_O1/tomfunkhouser[P]gaps/pkgs/R3Shapes/R3Grid.cpp
// Function: gaps::R3Grid::DrawIsoSurface(double) const
void R3Grid::
DrawIsoSurface(RNScalar isolevel) const
{
  // Allocate storage for isosurface
  static const R3Grid *isosurface_grid = NULL;
  static RNScalar isosurface_level = -12345679;
  static const int isosurface_max_points = 8*1024*1024;
  static R3Point *isosurface_points = NULL;
  static int isosurface_npoints = 0;

  // Allocate points for isosurface
  if (!isosurface_points) { 
    isosurface_points = new R3Point [isosurface_max_points];
    assert(isosurface_points);
  }

  // Generate isosurface
  if ((this != isosurface_grid) || (isosurface_level != isolevel)) {
    isosurface_npoints = GenerateIsoSurface(isolevel, isosurface_points, isosurface_max_points);
    isosurface_grid = this;
    isosurface_level = isolevel;
  }

  // Draw isosurface
  R3Point *pointsp = isosurface_points;
  RNGrfxBegin(RN_GRFX_TRIANGLES);
  for (int i = 0; i < isosurface_npoints; i += 3) {
    R3Point p0 = *(pointsp++);
    R3Point p1 = *(pointsp++);
    R3Point p2 = *(pointsp++);
    R3Plane plane(p0, p1, p2);
    R3LoadNormal(plane.Normal());
    R3LoadPoint(p0);
    R3LoadPoint(p1);
    R3LoadPoint(p2);
  }
  RNGrfxEnd();
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x78, %rsp
movq %rdi, %rbx
cmpq $0x0, 0xab7bf(%rip)     # 0xe6650
jne 0x3aecc
movsd %xmm0, 0x8(%rsp)
movl $0xc000000, %edi        # imm = 0xC000000
callq 0xe030
movq %rax, %r14
xorl %r15d, %r15d
leaq (%r14,%r15), %rdi
callq 0x3ca24
addq $0x18, %r15
cmpq $0xc000000, %r15        # imm = 0xC000000
jne 0x3aea9
movq %r14, 0xab78a(%rip)     # 0xe6650
movsd 0x8(%rsp), %xmm0
cmpq %rbx, 0xab775(%rip)     # 0xe6648
jne 0x3aee5
movsd 0xaab23(%rip), %xmm1    # 0xe5a00
ucomisd %xmm0, %xmm1
jne 0x3aee5
jnp 0x3af1a
movq 0xab764(%rip), %rsi     # 0xe6650
movq %rbx, %rdi
movl $0x800000, %edx         # imm = 0x800000
movsd %xmm0, 0x8(%rsp)
callq 0x3ab0a
movl %eax, 0xab753(%rip)     # 0xe6658
movq %rbx, 0xab73c(%rip)     # 0xe6648
movsd 0x8(%rsp), %xmm0
movsd %xmm0, 0xaaae6(%rip)    # 0xe5a00
movq 0xab72f(%rip), %rbx     # 0xe6650
movl $0x4, %edi
callq 0xe110
cmpl $0x0, 0xab726(%rip)     # 0xe6658
jle 0x3afb3
xorl %r13d, %r13d
leaq 0x40(%rsp), %r14
leaq 0x28(%rsp), %r15
leaq 0x10(%rsp), %r12
leaq 0x18(%rbx), %rbp
movq %r14, %rdi
movq %rbx, %rsi
callq 0x3ca36
movq %r15, %rdi
movq %rbp, %rsi
callq 0x3ca36
leaq 0x30(%rbx), %rsi
movq %r12, %rdi
callq 0x3ca36
leaq 0x58(%rsp), %rbp
movq %rbp, %rdi
movq %r14, %rsi
movq %r15, %rdx
movq %r12, %rcx
callq 0x3b712
movq %rbp, %rdi
callq 0xe6b0
movq %r14, %rdi
callq 0xe130
movq %r15, %rdi
callq 0xe130
movq %r12, %rdi
callq 0xe130
addl $0x3, %r13d
addq $0x48, %rbx
cmpl 0xab6a7(%rip), %r13d    # 0xe6658
jl 0x3af46
callq 0xe5d0
addq $0x78, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq %rax, %rbx
movl $0xc000000, %esi        # imm = 0xC000000
movq %r14, %rdi
callq 0xe8c0
movq %rbx, %rdi
callq 0xe7e0
nop
// File: /workspace/github_cpp_makefile_star2_O1/tomfunkhouser[P]gaps/pkgs/R3Shapes/R3Plane.cpp
// Function: gaps::R3Plane::R3Plane(gaps::R3Point const&, gaps::R3Line const&)
R3Plane::
R3Plane(const R3Point& point, const R3Line& line)
{
    // Construct plane through point and line
    v = point - line.Point();
    v.Cross(line.Vector());
    v.Normalize();
    d = -(v[0]*point[0] + v[1]*point[1] + v[2]*point[2]);
}

// Assembly:
pushq %r15
pushq %r14
pushq %r12
pushq %rbx
subq $0x18, %rsp
movq %rdx, %r15
movq %rsi, %r14
movq %rdi, %rbx
callq 0x3d4bc
movq %rsp, %r12
movq %r12, %rdi
movq %r14, %rsi
movq %r15, %rdx
callq 0x3cc88
movq %rbx, %rdi
movq %r12, %rsi
callq 0x3dc6a
addq $0x18, %r15
movq %rbx, %rdi
movq %r15, %rsi
callq 0x3d86a
movq %rbx, %rdi
callq 0x3d7e0
movsd (%rbx), %xmm0
movsd 0x8(%rbx), %xmm1
mulsd 0x8(%r14), %xmm1
mulsd (%r14), %xmm0
addsd %xmm1, %xmm0
movsd 0x10(%rbx), %xmm1
mulsd 0x10(%r14), %xmm1
addsd %xmm0, %xmm1
xorpd 0x669a5(%rip), %xmm1    # 0xa2020
movlpd %xmm1, 0x18(%rbx)
addq $0x18, %rsp
popq %rbx
popq %r12
popq %r14
popq %r15
retq
// File: /workspace/github_cpp_makefile_star2_O1/tomfunkhouser[P]gaps/pkgs/R3Shapes/R3Plane.cpp
// Function: gaps::R3Plane::R3Plane(gaps::R3Point const&, gaps::R3Vector const&, gaps::R3Vector const&)
R3Plane::
R3Plane(const R3Point& point, const R3Vector& vector1, const R3Vector& vector2)
{
    // Construct plane through point and two vectors
    v = vector1 % vector2;
    v.Normalize();
    d = -(v[0]*point[0] + v[1]*point[1] + v[2]*point[2]);
}

// Assembly:
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x20, %rsp
movq %rcx, %r15
movq %rdx, %r12
movq %rsi, %r14
movq %rdi, %rbx
callq 0x3d4bc
leaq 0x8(%rsp), %r13
movq %r13, %rdi
movq %r12, %rsi
movq %r15, %rdx
callq 0x3de12
movq %rbx, %rdi
movq %r13, %rsi
callq 0x3dc6a
movq %rbx, %rdi
callq 0x3d7e0
movsd (%rbx), %xmm0
movsd 0x8(%rbx), %xmm1
mulsd 0x8(%r14), %xmm1
mulsd (%r14), %xmm0
addsd %xmm1, %xmm0
movsd 0x10(%rbx), %xmm1
mulsd 0x10(%r14), %xmm1
addsd %xmm0, %xmm1
xorpd 0x66921(%rip), %xmm1    # 0xa2020
movlpd %xmm1, 0x18(%rbx)
addq $0x20, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
retq
// File: /workspace/github_cpp_makefile_star2_O1/tomfunkhouser[P]gaps/pkgs/R3Shapes/R3Plane.cpp
// Function: gaps::R3Plane::R3Plane(gaps::R3Point const&, gaps::R3Point const&, gaps::R3Point const&)
R3Plane::
R3Plane(const R3Point& point1, const R3Point& point2, const R3Point& point3)
{
    // Construct plane through three points
    v = point2 - point1;
    R3Vector v3 = point3 - point1;
    v.Cross(v3);
    v.Normalize();
    d = -(v[0]*point1[0] + v[1]*point1[1] + v[2]*point1[2]);
}

// Assembly:
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x20, %rsp
movq %rcx, %r15
movq %rdx, %r12
movq %rsi, %r14
movq %rdi, %rbx
callq 0x3d4bc
leaq 0x8(%rsp), %r13
movq %r13, %rdi
movq %r12, %rsi
movq %r14, %rdx
callq 0x3cc88
movq %rbx, %rdi
movq %r13, %rsi
callq 0x3dc6a
leaq 0x8(%rsp), %r12
movq %r12, %rdi
movq %r15, %rsi
movq %r14, %rdx
callq 0x3cc88
movq %rbx, %rdi
movq %r12, %rsi
callq 0x3d86a
movq %rbx, %rdi
callq 0x3d7e0
movsd (%rbx), %xmm0
movsd 0x8(%rbx), %xmm1
mulsd 0x8(%r14), %xmm1
mulsd (%r14), %xmm0
addsd %xmm1, %xmm0
movsd 0x10(%rbx), %xmm1
mulsd 0x10(%r14), %xmm1
addsd %xmm0, %xmm1
xorpd 0x6687d(%rip), %xmm1    # 0xa2020
movlpd %xmm1, 0x18(%rbx)
addq $0x20, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
retq
// File: /workspace/github_cpp_makefile_star2_O1/tomfunkhouser[P]gaps/pkgs/R3Shapes/R3Plane.cpp
// Function: gaps::R3Plane::R3Plane(gaps::RNArray<gaps::R3Point*> const&, int)
R3Plane::
R3Plane(const RNArray<R3Point *>& points, RNBoolean polygon_vertices)
{
    // Initialize plane
    v = R3null_vector;
    d = 0;

    // Check number of points
    int npoints = points.NEntries();
    if (npoints < 3) {
      *this = R3null_plane;
      return;
    }

    // Compute centroid
    R3Point c = R3Centroid(points);

    // Check if points form (counter-clockwise) boundary of polygon
    if (polygon_vertices) {
        // Compute best normal for counter-clockwise array of points using newell's method 
        const R3Point *p1 = points[npoints-1];
        for (int i = 0; i < npoints; i++) {
            const R3Point *p2 = points[i];
            v[0] += (p1->Y() - p2->Y()) * (p1->Z() + p2->Z());
            v[1] += (p1->Z() - p2->Z()) * (p1->X() + p2->X());
            v[2] += (p1->X() - p2->X()) * (p1->Y() + p2->Y());
            p1 = p2;
        }

        // Normalize 
        v.Normalize();
    }
    else {
        // Compute principle axes
        R3Triad triad = R3PrincipleAxes(c, points);

        // Select direction of least variation
        v = triad[2];
    }

    // Compute d from centroid and normal
    d = -(v[0]*c[0] + v[1]*c[1] + v[2]*c[2]);
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %rbx
subq $0x68, %rsp
movl %edx, %ebp
movq %rsi, %r14
movq %rdi, %rbx
callq 0x3d4bc
leaq 0x6cf0c(%rip), %rsi     # 0xa86e0
movq %rbx, %rdi
callq 0x3dc6a
movq $0x0, 0x18(%rbx)
movslq 0xc(%r14), %r15
cmpq $0x2, %r15
jg 0x3b80f
leaq 0x4aae9b(%rip), %rsi    # 0x4e6690
movq %rbx, %rdi
callq 0x3dc6a
movsd 0x4aaea3(%rip), %xmm0   # 0x4e66a8
movsd %xmm0, 0x18(%rbx)
jmp 0x3b911
leaq 0x8(%rsp), %rdi
movq %r14, %rsi
xorl %edx, %edx
callq 0x4ccf0
testl %ebp, %ebp
je 0x3b8b8
movq (%r14), %rax
movsd (%rbx), %xmm0
movsd 0x8(%rbx), %xmm1
movq -0x8(%rax,%r15,8), %rsi
movsd 0x10(%rbx), %xmm2
movl %r15d, %ecx
xorl %edx, %edx
movq (%rax,%rdx,8), %rdi
movsd 0x8(%rsi), %xmm3
subsd 0x8(%rdi), %xmm3
movsd 0x10(%rsi), %xmm4
addsd 0x10(%rdi), %xmm4
mulsd %xmm3, %xmm4
addsd %xmm4, %xmm0
movsd %xmm0, (%rbx)
movsd (%rsi), %xmm3
movsd 0x10(%rsi), %xmm4
subsd 0x10(%rdi), %xmm4
addsd (%rdi), %xmm3
mulsd %xmm4, %xmm3
addsd %xmm3, %xmm1
movsd %xmm1, 0x8(%rbx)
movsd (%rsi), %xmm3
movsd 0x8(%rsi), %xmm4
subsd (%rdi), %xmm3
addsd 0x8(%rdi), %xmm4
mulsd %xmm3, %xmm4
addsd %xmm4, %xmm2
movsd %xmm2, 0x10(%rbx)
incq %rdx
movq %rdi, %rsi
cmpq %rdx, %rcx
jne 0x3b841
movq %rbx, %rdi
callq 0x3d7e0
jmp 0x3b8dc
leaq 0x20(%rsp), %rdi
leaq 0x8(%rsp), %rsi
movq %r14, %rdx
xorl %ecx, %ecx
xorl %r8d, %r8d
callq 0x4cd9c
leaq 0x50(%rsp), %rsi
movq %rbx, %rdi
callq 0x3dc6a
movsd (%rbx), %xmm0
movsd 0x8(%rbx), %xmm1
mulsd 0x10(%rsp), %xmm1
mulsd 0x8(%rsp), %xmm0
addsd %xmm1, %xmm0
movsd 0x10(%rbx), %xmm1
mulsd 0x18(%rsp), %xmm1
addsd %xmm0, %xmm1
xorpd 0x66714(%rip), %xmm1    # 0xa2020
movlpd %xmm1, 0x18(%rbx)
addq $0x68, %rsp
popq %rbx
popq %r14
popq %r15
popq %rbp
retq