LLM4Binary/decompile-bench-makefile huggingface dataset:
// File: /workspace/github_cpp_makefile_star2_O3/tomfunkhouser[P]gaps/pkgs/R2Shapes/R2Grid.cpp
// Function: gaps::R2Grid::GridCentroid() const
R2Point R2Grid::
GridCentroid(void) const
{
  // Compute weighted sum
  RNScalar total_value = 0;
  R2Point centroid(0,0);
  RNScalar *grid_valuesp = grid_values;
  for (int j = 0; j < grid_resolution[1]; j++) {
    for (int i = 0; i < grid_resolution[0]; i++) {
      R2Vector position(i, j);
      RNScalar value = *(grid_valuesp++);
      centroid += value * position;
      total_value += value;
    }
  }

  // Divide by total value
  if (total_value > 0) centroid /= total_value;

  // Return centroid
  return centroid;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x48, %rsp
movq %rsi, %r14
movq %rdi, %rbx
xorpd %xmm0, %xmm0
xorpd %xmm1, %xmm1
callq 0x680a6
xorpd %xmm0, %xmm0
movl 0xc4(%r14), %ecx
testl %ecx, %ecx
jle 0x59edc
movq 0xb8(%r14), %r13
movl 0xc0(%r14), %eax
xorl %edx, %edx
leaq 0x38(%rsp), %r15
leaq 0x28(%rsp), %r12
testl %eax, %eax
jle 0x59ec0
movl %edx, 0xc(%rsp)
xorps %xmm1, %xmm1
cvtsi2sd %edx, %xmm1
movsd %xmm1, 0x10(%rsp)
xorl %ebp, %ebp
movsd %xmm0, 0x20(%rsp)
xorps %xmm0, %xmm0
cvtsi2sd %ebp, %xmm0
movq %r15, %rdi
movsd 0x10(%rsp), %xmm1
callq 0x683d2
movsd (%r13), %xmm0
movsd %xmm0, 0x18(%rsp)
addq $0x8, %r13
movq %r12, %rdi
movq %r15, %rsi
callq 0x6870c
movq %rbx, %rdi
movq %r12, %rsi
callq 0x6818c
movsd 0x20(%rsp), %xmm0
addsd 0x18(%rsp), %xmm0
incl %ebp
movl 0xc0(%r14), %eax
cmpl %eax, %ebp
jl 0x59e5b
movl 0xc4(%r14), %ecx
movl 0xc(%rsp), %edx
incl %edx
cmpl %ecx, %edx
jl 0x59e44
xorpd %xmm1, %xmm1
ucomisd %xmm1, %xmm0
jbe 0x59edc
movq %rbx, %rdi
callq 0x6828c
movq %rbx, %rax
addq $0x48, %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::Abs()
void R2Grid::
Abs(void) 
{
  // Take absolute value of every grid value
  for (int i = 0; i < grid_size; i++) {
    RNScalar value = grid_values[i];
    if (value != R2_GRID_UNKNOWN_VALUE) grid_values[i] = fabs(value);
  }
}

// Assembly:
movslq 0xcc(%rdi), %rax
testq %rax, %rax
jle 0x5a451
movq 0xb8(%rdi), %rcx
xorl %edx, %edx
movsd 0x48b8d(%rip), %xmm0    # 0xa2fb8
movapd 0x47e3d(%rip), %xmm1    # 0xa2270
movsd (%rcx,%rdx,8), %xmm2
ucomisd %xmm0, %xmm2
jne 0x5a440
jnp 0x5a449
andpd %xmm1, %xmm2
movlpd %xmm2, (%rcx,%rdx,8)
incq %rdx
cmpq %rdx, %rax
jne 0x5a433
retq
// File: /workspace/github_cpp_makefile_star2_O3/tomfunkhouser[P]gaps/pkgs/R2Shapes/R2Grid.cpp
// Function: gaps::R2Grid::Sqrt()
void R2Grid::
Sqrt(void) 
{
  // Take sqrt of every grid value
  for (int i = 0; i < grid_size; i++) {
    RNScalar value = grid_values[i];
    if (value != R2_GRID_UNKNOWN_VALUE) grid_values[i] = sqrt(value);
  }
}

// Assembly:
movl 0xcc(%rdi), %eax
testl %eax, %eax
jle 0x5a4c9
pushq %r14
pushq %rbx
pushq %rax
movq %rdi, %rbx
movq 0xb8(%rdi), %rcx
xorl %r14d, %r14d
movsd 0x48b43(%rip), %xmm1    # 0xa2fb8
xorpd %xmm2, %xmm2
movsd (%rcx,%r14,8), %xmm0
ucomisd %xmm1, %xmm0
jne 0x5a487
jnp 0x5a4b7
ucomisd %xmm2, %xmm0
jb 0x5a493
sqrtsd %xmm0, %xmm0
jmp 0x5a4a4
callq 0xe340
xorpd %xmm2, %xmm2
movsd 0x48b14(%rip), %xmm1    # 0xa2fb8
movq 0xb8(%rbx), %rcx
movsd %xmm0, (%rcx,%r14,8)
movl 0xcc(%rbx), %eax
incq %r14
movslq %eax, %rdx
cmpq %rdx, %r14
jl 0x5a479
addq $0x8, %rsp
popq %rbx
popq %r14
retq
// File: /workspace/github_cpp_makefile_star2_O3/tomfunkhouser[P]gaps/pkgs/R2Shapes/R2Grid.cpp
// Function: gaps::IsLocalExtremum(gaps::R2Grid const&, int, int, int)
void R2Grid::
Square(void) 
{
  // Square every grid value
  for (int i = 0; i < grid_size; i++) {
    RNScalar value = grid_values[i];
    if (value != R2_GRID_UNKNOWN_VALUE) grid_values[i] *= value;
  }
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r12
pushq %rbx
movq 0xb8(%rdi), %rax
movslq 0xc8(%rdi), %r8
movl %r8d, %r9d
imull %edx, %r9d
addl %esi, %r9d
movslq %r9d, %r9
movsd (%rax,%r9,8), %xmm0
movslq 0xc0(%rdi), %r9
movslq 0xc4(%rdi), %rdi
movslq %edx, %rdx
movslq %esi, %rsi
leaq -0x1(%rdx), %r10
imulq %r8, %r10
leaq (,%rsi,8), %r11
leaq (%r11,%r10,8), %r10
addq %rax, %r10
addq $-0x8, %r10
shlq $0x3, %r8
movq $-0x1, %r11
movq %r11, %rax
addq %rsi, %rax
js 0x5c90f
cmpq %r9, %rax
jge 0x5c90f
movq $-0x1, %rbx
movq %r10, %r14
movl %ebx, %eax
orl %r11d, %eax
je 0x5c903
movq %rdx, %rax
addq %rbx, %rax
js 0x5c903
cmpq %rdi, %rax
jge 0x5c903
testl %ecx, %ecx
sete %bpl
movsd (%r14), %xmm1
ucomisd %xmm1, %xmm0
seta %r12b
ucomisd %xmm0, %xmm1
setbe %r15b
xorl %eax, %eax
testb %r12b, %bpl
jne 0x5c921
orb %r15b, %bpl
je 0x5c921
incq %rbx
addq %r8, %r14
cmpq $0x2, %rbx
jne 0x5c8c8
incq %r11
addq $0x8, %r10
cmpq $0x2, %r11
jne 0x5c8b1
movl $0x1, %eax
popq %rbx
popq %r12
popq %r14
popq %r15
popq %rbp
retq
// File: /workspace/github_cpp_makefile_star2_O3/tomfunkhouser[P]gaps/pkgs/R2Shapes/R2Grid.cpp
// Function: gaps::R2Grid::Negate()
void R2Grid::
Negate(void) 
{
  // Square every grid value
  for (int i = 0; i < grid_size; i++) {
    RNScalar value = grid_values[i];
    if (value != R2_GRID_UNKNOWN_VALUE) grid_values[i] = -value;
  }
}

// Assembly:
movslq 0xcc(%rdi), %rax
testq %rax, %rax
jle 0x5a549
movq 0xb8(%rdi), %rcx
xorl %edx, %edx
movsd 0x48a95(%rip), %xmm0    # 0xa2fb8
movapd 0x47af5(%rip), %xmm1    # 0xa2020
movsd (%rcx,%rdx,8), %xmm2
ucomisd %xmm0, %xmm2
jne 0x5a538
jnp 0x5a541
xorpd %xmm1, %xmm2
movlpd %xmm2, (%rcx,%rdx,8)
incq %rdx
cmpq %rdx, %rax
jne 0x5a52b
retq
// File: /workspace/github_cpp_makefile_star2_O3/tomfunkhouser[P]gaps/pkgs/R2Shapes/R2Grid.cpp
// Function: gaps::R2Grid::Invert()
void R2Grid::
Invert(void) 
{
  // Invert every grid value
  for (int i = 0; i < grid_size; i++) {
    RNScalar value = grid_values[i];
    if ((value != R2_GRID_UNKNOWN_VALUE) && (value != 0)) {
      grid_values[i] = 1.0 / value;
    }
  }
}

// Assembly:
movslq 0xcc(%rdi), %rax
testq %rax, %rax
jle 0x5a59d
movq 0xb8(%rdi), %rcx
xorl %edx, %edx
movsd 0x48a51(%rip), %xmm0    # 0xa2fb8
xorpd %xmm1, %xmm1
movsd 0x47ac5(%rip), %xmm2    # 0xa2038
movsd (%rcx,%rdx,8), %xmm3
ucomisd %xmm0, %xmm3
jne 0x5a580
jnp 0x5a595
ucomisd %xmm1, %xmm3
jne 0x5a588
jnp 0x5a595
movapd %xmm2, %xmm4
divsd %xmm3, %xmm4
movsd %xmm4, (%rcx,%rdx,8)
incq %rdx
cmpq %rdx, %rax
jne 0x5a573
retq
// File: /workspace/github_cpp_makefile_star2_O3/tomfunkhouser[P]gaps/pkgs/R2Shapes/R2Grid.cpp
// Function: gaps::R2Grid::Transpose()
void R2Grid::
Transpose(void)
{
  // Transpose values
  R2Grid copy(*this);
  int xres = XResolution();
  int yres = YResolution();
  for (int iy = 0; iy < yres; iy++) {
    for (int ix = 0; ix < xres; ix++) {
      RNScalar value = copy.GridValue(xres-1 - ix, yres-1 - iy);
      SetGridValue(ix, iy, value);
    }
  }
}

// Assembly:
pushq %rbx
subq $0xd0, %rsp
movq %rdi, %rbx
movq %rsp, %rdi
movq %rbx, %rsi
callq 0x59934
movslq 0xc4(%rbx), %rax
testq %rax, %rax
jle 0x5a644
movl 0xc0(%rbx), %ecx
movq 0xb8(%rsp), %r8
movslq 0xc8(%rsp), %rdx
movq 0xb8(%rbx), %rsi
movslq 0xc8(%rbx), %rdi
movslq %ecx, %r9
shlq $0x3, %rdi
leaq -0x1(%rax), %r10
imulq %rdx, %r10
shlq $0x3, %r9
leaq (%r9,%r10,8), %r9
addq %r9, %r8
addq $-0x8, %r8
shlq $0x3, %rdx
negq %rdx
movq %rcx, %r9
negq %r9
xorl %r10d, %r10d
testl %ecx, %ecx
jle 0x5a636
xorl %r11d, %r11d
movq %rsi, %rbx
movsd (%r8,%r11,8), %xmm0
movsd %xmm0, (%rbx)
addq $0x8, %rbx
decq %r11
cmpq %r11, %r9
jne 0x5a620
incq %r10
addq %rdi, %rsi
addq %rdx, %r8
cmpq %rax, %r10
jne 0x5a616
movq %rsp, %rdi
callq 0x59b0c
addq $0xd0, %rsp
popq %rbx
retq
nop
// File: /workspace/github_cpp_makefile_star2_O3/tomfunkhouser[P]gaps/pkgs/R2Shapes/R2Grid.cpp
// Function: gaps::R2Grid::Divide(double)
void R2Grid::
Divide(RNScalar value) 
{
  // Just checking
  if (RNIsZero(value)) return;

  // Multiply by recipricol
  Multiply(1.0 / value);
}

// Assembly:
leaq 0x8b4c5(%rip), %rax     # 0xe5b98
movsd (%rax), %xmm1
movapd 0x47941(%rip), %xmm2    # 0xa2020
xorpd %xmm1, %xmm2
ucomisd %xmm2, %xmm0
jb 0x5a6ef
ucomisd %xmm0, %xmm1
jae 0x5a736
movslq 0xcc(%rdi), %rax
testq %rax, %rax
jle 0x5a736
movsd 0x47935(%rip), %xmm1    # 0xa2038
divsd %xmm0, %xmm1
movq 0xb8(%rdi), %rcx
xorl %edx, %edx
movsd 0x488a0(%rip), %xmm0    # 0xa2fb8
movsd (%rcx,%rdx,8), %xmm2
ucomisd %xmm0, %xmm2
jne 0x5a725
jnp 0x5a72e
mulsd %xmm1, %xmm2
movsd %xmm2, (%rcx,%rdx,8)
incq %rdx
cmpq %rdx, %rax
jne 0x5a718
retq
nop
// File: /workspace/github_cpp_makefile_star2_O3/tomfunkhouser[P]gaps/pkgs/R2Shapes/R2Grid.cpp
// Function: gaps::R2Grid::Clear(double)
void R2Grid::
Clear(RNScalar value) 
{
  // Set all grid values to value
  for (int i = 0; i < grid_size; i++) {
    if (grid_values[i] == R2_GRID_UNKNOWN_VALUE) continue;
    grid_values[i] = value;
  }
}

// Assembly:
movslq 0xcc(%rdi), %rax
testq %rax, %rax
jle 0x5b08f
movq 0xb8(%rdi), %rcx
xorl %edx, %edx
movsd 0x47f43(%rip), %xmm1    # 0xa2fb8
movsd (%rcx,%rdx,8), %xmm2
ucomisd %xmm1, %xmm2
jne 0x5b082
jnp 0x5b087
movsd %xmm0, (%rcx,%rdx,8)
incq %rdx
cmpq %rdx, %rax
jne 0x5b075
retq
// File: /workspace/github_cpp_makefile_star2_O3/tomfunkhouser[P]gaps/pkgs/R2Shapes/R2Grid.cpp
// Function: gaps::R2Grid::Dilate(double)
void R2Grid::
Dilate(RNLength grid_distance) 
{
  // Make copy so that can restore unknown values
  R2Grid copy(*this);

  // Set pixels (to one) within grid_distance from some non-zero pixel
  SquaredDistanceTransform();
  Threshold(grid_distance * grid_distance, 1, 0);

  // Restore unknown values
  for (int i = 0; i < grid_size; i++) {
    if (copy.grid_values[i] == R2_GRID_UNKNOWN_VALUE) {
      grid_values[i] = R2_GRID_UNKNOWN_VALUE;
    }
  }
}

// Assembly:
pushq %rbx
subq $0xe0, %rsp
movsd %xmm0, 0x8(%rsp)
movq %rdi, %rbx
leaq 0x10(%rsp), %rdi
movq %rbx, %rsi
callq 0x59934
movq %rbx, %rdi
callq 0x5b168
movslq 0xcc(%rbx), %rax
testq %rax, %rax
jle 0x5b140
movsd 0x8(%rsp), %xmm3
mulsd %xmm3, %xmm3
movq 0xb8(%rbx), %rcx
xorl %edx, %edx
movsd 0x47edb(%rip), %xmm0    # 0xa2fb8
movsd 0x46f53(%rip), %xmm1    # 0xa2038
movsd (%rcx,%rdx,8), %xmm2
ucomisd %xmm0, %xmm2
jne 0x5b0f2
jnp 0x5b100
cmpnlesd %xmm3, %xmm2
andnpd %xmm1, %xmm2
movlpd %xmm2, (%rcx,%rdx,8)
incq %rdx
cmpq %rdx, %rax
jne 0x5b0e5
testl %eax, %eax
jle 0x5b140
movq 0xc8(%rsp), %rcx
movq 0xb8(%rbx), %rdx
xorl %esi, %esi
movabsq $-0x3f8bf00000000000, %rdi # imm = 0xC074100000000000
movsd (%rcx,%rsi,8), %xmm1
ucomisd %xmm0, %xmm1
jne 0x5b138
jp 0x5b138
movq %rdi, (%rdx,%rsi,8)
incq %rsi
cmpq %rsi, %rax
jne 0x5b127
leaq 0x10(%rsp), %rdi
callq 0x59b0c
addq $0xe0, %rsp
popq %rbx
retq
movq %rax, %rbx
leaq 0x10(%rsp), %rdi
callq 0x59b0c
movq %rbx, %rdi
callq 0xe7e0
// File: /workspace/github_cpp_makefile_star2_O3/tomfunkhouser[P]gaps/pkgs/R2Shapes/R2Grid.cpp
// Function: gaps::R2Grid::Threshold(double, double, double)
void R2Grid::
Threshold(RNScalar threshold, RNScalar low, RNScalar high) 
{
  // Set grid value to low (high) if less/equal (greater) than threshold
  for (int i = 0; i < grid_size; i++) {
    if (grid_values[i] != R2_GRID_UNKNOWN_VALUE) {
      if (grid_values[i] <= threshold) {
        if (low != R2_GRID_KEEP_VALUE) grid_values[i] = low;
      }
      else {
        if (high != R2_GRID_KEEP_VALUE) grid_values[i] = high;
      }
    }
  }
}

// Assembly:
movslq 0xcc(%rdi), %rax
testq %rax, %rax
jle 0x5b549
movq 0xb8(%rdi), %rcx
xorl %edx, %edx
movsd 0x47aad(%rip), %xmm3    # 0xa2fb8
movsd 0x47a95(%rip), %xmm4    # 0xa2fa8
movsd (%rcx,%rdx,8), %xmm5
ucomisd %xmm3, %xmm5
jne 0x5b520
jnp 0x5b541
ucomisd %xmm5, %xmm0
jae 0x5b530
ucomisd %xmm4, %xmm2
movapd %xmm2, %xmm5
jmp 0x5b538
ucomisd %xmm4, %xmm1
movapd %xmm1, %xmm5
jne 0x5b53c
jnp 0x5b541
movsd %xmm5, (%rcx,%rdx,8)
incq %rdx
cmpq %rdx, %rax
jne 0x5b513
retq
// File: /workspace/github_cpp_makefile_star2_O3/tomfunkhouser[P]gaps/pkgs/R2Shapes/R2Grid.cpp
// Function: gaps::R2Grid::Erode(double)
void R2Grid::
Erode(RNLength grid_distance) 
{
  // Make copy so that can restore unknown values
  R2Grid copy(*this);

  // Keep only pixels at least distance from some zero pixel
  Threshold(1.0E-20, 1, 0);
  SquaredDistanceTransform();
  Threshold(grid_distance * grid_distance, 0, 1);

  // Restore unknown values
  for (int i = 0; i < grid_size; i++) {
    if (copy.grid_values[i] == R2_GRID_UNKNOWN_VALUE) {
      grid_values[i] = R2_GRID_UNKNOWN_VALUE;
    }
  }
}

// Assembly:
pushq %rbx
subq $0xe0, %rsp
movsd %xmm0, 0x8(%rsp)
movq %rdi, %rbx
leaq 0x10(%rsp), %rdi
movq %rbx, %rsi
callq 0x59934
movslq 0xcc(%rbx), %rax
testq %rax, %rax
jle 0x5b5b8
movq 0xb8(%rbx), %rcx
xorl %edx, %edx
movsd 0x47a33(%rip), %xmm0    # 0xa2fb8
movsd 0x47a13(%rip), %xmm1    # 0xa2fa0
movsd 0x46aa3(%rip), %xmm2    # 0xa2038
movsd (%rcx,%rdx,8), %xmm3
ucomisd %xmm0, %xmm3
jne 0x5b5a2
jnp 0x5b5b0
cmpnlesd %xmm1, %xmm3
andnpd %xmm2, %xmm3
movlpd %xmm3, (%rcx,%rdx,8)
incq %rdx
cmpq %rdx, %rax
jne 0x5b595
movq %rbx, %rdi
callq 0x5b168
movslq 0xcc(%rbx), %rax
testq %rax, %rax
jle 0x5b656
movsd 0x8(%rsp), %xmm0
mulsd %xmm0, %xmm0
movsd %xmm0, 0x8(%rsp)
movq 0xb8(%rbx), %rcx
xorl %edx, %edx
movsd 0x479c7(%rip), %xmm0    # 0xa2fb8
movsd 0x46a3f(%rip), %xmm1    # 0xa2038
movsd (%rcx,%rdx,8), %xmm2
ucomisd %xmm0, %xmm2
jne 0x5b606
jnp 0x5b616
cmpnlesd 0x8(%rsp), %xmm2
andpd %xmm1, %xmm2
movlpd %xmm2, (%rcx,%rdx,8)
incq %rdx
cmpq %rdx, %rax
jne 0x5b5f9
testl %eax, %eax
jle 0x5b656
movq 0xc8(%rsp), %rcx
movq 0xb8(%rbx), %rdx
xorl %esi, %esi
movabsq $-0x3f8bf00000000000, %rdi # imm = 0xC074100000000000
movsd (%rcx,%rsi,8), %xmm1
ucomisd %xmm0, %xmm1
jne 0x5b64e
jp 0x5b64e
movq %rdi, (%rdx,%rsi,8)
incq %rsi
cmpq %rsi, %rax
jne 0x5b63d
leaq 0x10(%rsp), %rdi
callq 0x59b0c
addq $0xe0, %rsp
popq %rbx
retq
movq %rax, %rbx
leaq 0x10(%rsp), %rdi
callq 0x59b0c
movq %rbx, %rdi
callq 0xe7e0
// File: /workspace/github_cpp_makefile_star2_O3/tomfunkhouser[P]gaps/pkgs/R2Shapes/R2Grid.cpp
// Function: gaps::R2Grid::AddNoise(double)
void R2Grid::
AddNoise(RNScalar sigma_fraction)
{
  // Add noise to every grid entry
  if (sigma_fraction == 0) return;
  for (int i = 0; i < grid_size; i++) {
    if (grid_values[i] == R2_GRID_UNKNOWN_VALUE) continue;
    RNScalar r = RNRandomScalar();
    RNScalar sign = (RNRandomScalar() < 0.5) ? -1.0 : 1.0;
    RNScalar sigma = sigma_fraction * grid_values[i];
    RNScalar magnitude = sigma * (1.0 - exp(-0.5 * r * r));
    grid_values[i] += sign * magnitude;
  }
}

// Assembly:
pushq %r15
pushq %r14
pushq %r12
pushq %rbx
subq $0x18, %rsp
xorpd %xmm1, %xmm1
movsd %xmm0, (%rsp)
ucomisd %xmm1, %xmm0
jne 0x5bdc6
jnp 0x5bea0
movq %rdi, %rbx
movl 0xcc(%rdi), %ecx
testl %ecx, %ecx
jle 0x5bea0
movq 0xb8(%rbx), %rax
xorl %r14d, %r14d
movsd 0x471cf(%rip), %xmm1    # 0xa2fb8
leaq 0x4d540(%rip), %r15     # 0xa9330
movsd (%rax,%r14,8), %xmm0
ucomisd %xmm1, %xmm0
jne 0x5be02
jnp 0x5be91
callq 0x715e8
movsd %xmm0, 0x10(%rsp)
callq 0x715e8
xorl %r12d, %r12d
movsd 0x46213(%rip), %xmm1    # 0xa2030
ucomisd %xmm0, %xmm1
seta %r12b
movq 0xb8(%rbx), %rax
movsd (%rax,%r14,8), %xmm0
mulsd (%rsp), %xmm0
movsd %xmm0, 0x8(%rsp)
movsd 0x10(%rsp), %xmm1
movapd %xmm1, %xmm0
mulsd 0x46411(%rip), %xmm0    # 0xa2260
mulsd %xmm1, %xmm0
callq 0xe7f0
movsd 0x461d8(%rip), %xmm1    # 0xa2038
subsd %xmm0, %xmm1
mulsd 0x8(%rsp), %xmm1
movq 0xb8(%rbx), %rax
mulsd (%r15,%r12,8), %xmm1
addsd (%rax,%r14,8), %xmm1
movsd %xmm1, (%rax,%r14,8)
movsd 0x4712d(%rip), %xmm1    # 0xa2fb8
movl 0xcc(%rbx), %ecx
incq %r14
movslq %ecx, %rdx
cmpq %rdx, %r14
jl 0x5bdf0
addq $0x18, %rsp
popq %rbx
popq %r12
popq %r14
popq %r15
retq
// File: /workspace/github_cpp_makefile_star2_O3/tomfunkhouser[P]gaps/pkgs/R2Shapes/R2Grid.cpp
// Function: gaps::R2Grid::Gradient(int)
void R2Grid::
Gradient(RNDimension dim)
{
  // Set up xfilter
  const RNScalar xfilter[3][3] = { 
    { -0.25, 0, 0.25 }, 
    { -0.5,  0, 0.5}, 
    { -0.25, 0, 0.25 } 
  };
  const RNScalar yfilter[3][3] = { 
    { -0.25, -0.5, -0.25 }, 
    {  0,     0,    0 }, 
    {  0.25,  0.5,  0.25 } 
  };

  // Convolve with filter
  if (dim == RN_X) Convolve(xfilter);
  else if (dim == RN_Y) Convolve(yfilter);
  else RNAbort("Invalid dimension");
}

// Assembly:
subq $0x98, %rsp
xorps %xmm0, %xmm0
movaps %xmm0, (%rsp)
movaps %xmm0, 0x30(%rsp)
movaps %xmm0, 0x20(%rsp)
movabsq $-0x4030000000000000, %rax # imm = 0xBFD0000000000000
movq %rax, (%rsp)
movaps 0x4c3f7(%rip), %xmm1    # 0xa9340
movaps %xmm1, 0x10(%rsp)
movaps 0x4c3fb(%rip), %xmm1    # 0xa9350
movups %xmm1, 0x28(%rsp)
movabsq $0x3fd0000000000000, %rcx # imm = 0x3FD0000000000000
movq %rcx, 0x40(%rsp)
movaps %xmm0, 0x60(%rsp)
movaps %xmm0, 0x70(%rsp)
movaps 0x4c3e6(%rip), %xmm0    # 0xa9360
movaps %xmm0, 0x50(%rsp)
movq %rax, 0x60(%rsp)
movaps 0x4c3e5(%rip), %xmm0    # 0xa9370
movaps %xmm0, 0x80(%rsp)
movq %rcx, 0x90(%rsp)
cmpl $0x1, %esi
je 0x5cfa9
testl %esi, %esi
jne 0x5cfbb
movq %rsp, %rsi
jmp 0x5cfae
leaq 0x50(%rsp), %rsi
callq 0x5cd4c
addq $0x98, %rsp
retq
leaq 0x4a79e(%rip), %rdi     # 0xa7760
xorl %eax, %eax
addq $0x98, %rsp
jmp 0x718f6
// File: /workspace/github_cpp_makefile_star2_O3/tomfunkhouser[P]gaps/pkgs/R2Shapes/R2Grid.cpp
// Function: gaps::R2Grid::GradientAngle()
void R2Grid::
GradientAngle(void)
{
  // Compute direction of gradient
  R2Grid gx(*this); gx.Gradient(RN_X);
  R2Grid gy(*this); gy.Gradient(RN_Y);
  for (int i = 0; i < grid_size; i++) {
    if (grid_values[i] == R2_GRID_UNKNOWN_VALUE) {
      continue;
    }
    RNScalar x = gx.GridValue(i);
    if (x == R2_GRID_UNKNOWN_VALUE) {
      grid_values[i] = R2_GRID_UNKNOWN_VALUE;
      continue;
    }
    RNScalar y = gy.GridValue(i);
    if (y == R2_GRID_UNKNOWN_VALUE) {
      grid_values[i] = R2_GRID_UNKNOWN_VALUE;
      continue;
     }
    if (x == 0) {
      grid_values[i] = RN_PI_OVER_TWO;
      continue;
    }
    grid_values[i] = atan(y/x);
  }
}

// Assembly:
pushq %r15
pushq %r14
pushq %rbx
subq $0x1b0, %rsp            # imm = 0x1B0
movq %rdi, %rbx
leaq 0xe0(%rsp), %r14
movq %r14, %rdi
movq %rbx, %rsi
callq 0x59934
movq %r14, %rdi
xorl %esi, %esi
callq 0x5cf1c
leaq 0x10(%rsp), %rdi
movq %rbx, %rsi
callq 0x59934
leaq 0x10(%rsp), %rdi
movl $0x1, %esi
callq 0x5cf1c
movl 0xcc(%rbx), %eax
testl %eax, %eax
jle 0x5d102
leaq 0x4cf8b(%rip), %rcx     # 0xa9fd8
movsd (%rcx), %xmm2
movq 0xb8(%rbx), %rcx
xorl %r14d, %r14d
movsd 0x45f55(%rip), %xmm3    # 0xa2fb8
movabsq $-0x3f8bf00000000000, %r15 # imm = 0xC074100000000000
xorpd %xmm4, %xmm4
movsd (%rcx,%r14,8), %xmm0
ucomisd %xmm3, %xmm0
jne 0x5d07f
jnp 0x5d0af
movq 0x198(%rsp), %rdx
movsd (%rdx,%r14,8), %xmm1
ucomisd %xmm3, %xmm1
jne 0x5d095
jnp 0x5d0ab
movq 0xc8(%rsp), %rdx
movsd (%rdx,%r14,8), %xmm0
ucomisd %xmm3, %xmm0
jne 0x5d0bc
jp 0x5d0bc
movq %r15, (%rcx,%r14,8)
incq %r14
movslq %eax, %rdx
cmpq %rdx, %r14
jl 0x5d071
jmp 0x5d102
ucomisd %xmm4, %xmm1
jne 0x5d0cc
jp 0x5d0cc
movsd %xmm2, (%rcx,%r14,8)
jmp 0x5d0af
divsd %xmm1, %xmm0
movsd %xmm2, 0x8(%rsp)
callq 0xe380
xorpd %xmm4, %xmm4
movsd 0x45ed1(%rip), %xmm3    # 0xa2fb8
movsd 0x8(%rsp), %xmm2
movq 0xb8(%rbx), %rcx
movsd %xmm0, (%rcx,%r14,8)
movl 0xcc(%rbx), %eax
jmp 0x5d0af
leaq 0x10(%rsp), %rdi
callq 0x59b0c
leaq 0xe0(%rsp), %rdi
callq 0x59b0c
addq $0x1b0, %rsp            # imm = 0x1B0
popq %rbx
popq %r14
popq %r15
retq
movq %rax, %rbx
leaq 0x10(%rsp), %rdi
callq 0x59b0c
jmp 0x5d13a
jmp 0x5d137
movq %rax, %rbx
leaq 0xe0(%rsp), %rdi
callq 0x59b0c
movq %rbx, %rdi
callq 0xe7e0
nop
// File: /workspace/github_cpp_makefile_star2_O3/tomfunkhouser[P]gaps/pkgs/R2Shapes/R2Grid.cpp
// Function: gaps::R2Grid::GradientMagnitude()
void R2Grid::
GradientMagnitude(void)
{
  // Compute magnitude of gradient (Sobel operator)
  R2Grid gx(*this); gx.Gradient(RN_X);
  R2Grid gy(*this); gy.Gradient(RN_Y);
  for (int i = 0; i < grid_size; i++) {
    if (grid_values[i] == R2_GRID_UNKNOWN_VALUE) {
      continue;
    }
    RNScalar x = gx.GridValue(i);
    if (x == R2_GRID_UNKNOWN_VALUE) {
      grid_values[i] = R2_GRID_UNKNOWN_VALUE;
      continue;
    }
    RNScalar y = gy.GridValue(i);
    if (y == R2_GRID_UNKNOWN_VALUE) {
      grid_values[i] = R2_GRID_UNKNOWN_VALUE;
      continue;
    }
    grid_values[i] = sqrt(x*x + y*y);
  }
}

// Assembly:
pushq %r14
pushq %rbx
subq $0x1a8, %rsp            # imm = 0x1A8
movq %rdi, %rbx
leaq 0xd8(%rsp), %r14
movq %r14, %rdi
movq %rbx, %rsi
callq 0x59934
movq %r14, %rdi
xorl %esi, %esi
callq 0x5cf1c
leaq 0x8(%rsp), %rdi
movq %rbx, %rsi
callq 0x59934
leaq 0x8(%rsp), %rdi
movl $0x1, %esi
callq 0x5cf1c
movslq 0xcc(%rbx), %rax
testq %rax, %rax
jle 0x5d212
movq 0xb8(%rbx), %rcx
movq 0x190(%rsp), %rdx
movq 0xc0(%rsp), %rsi
xorl %edi, %edi
movsd 0x45df5(%rip), %xmm0    # 0xa2fb8
movsd (%rcx,%rdi,8), %xmm1
ucomisd %xmm0, %xmm1
jne 0x5d1d0
jnp 0x5d20a
movsd (%rdx,%rdi,8), %xmm1
ucomisd %xmm0, %xmm1
movapd %xmm0, %xmm3
jne 0x5d1e1
jnp 0x5d205
movsd (%rsi,%rdi,8), %xmm2
ucomisd %xmm0, %xmm2
movapd %xmm0, %xmm3
jne 0x5d1f2
jnp 0x5d205
mulsd %xmm2, %xmm2
mulsd %xmm1, %xmm1
addsd %xmm2, %xmm1
xorps %xmm3, %xmm3
sqrtsd %xmm1, %xmm3
movsd %xmm3, (%rcx,%rdi,8)
incq %rdi
cmpq %rdi, %rax
jne 0x5d1c3
leaq 0x8(%rsp), %rdi
callq 0x59b0c
leaq 0xd8(%rsp), %rdi
callq 0x59b0c
addq $0x1a8, %rsp            # imm = 0x1A8
popq %rbx
popq %r14
retq
movq %rax, %rbx
leaq 0x8(%rsp), %rdi
callq 0x59b0c
jmp 0x5d248
jmp 0x5d245
movq %rax, %rbx
leaq 0xd8(%rsp), %rdi
callq 0x59b0c
movq %rbx, %rdi
callq 0xe7e0
nop
// File: /workspace/github_cpp_makefile_star2_O3/tomfunkhouser[P]gaps/pkgs/R2Shapes/R2Grid.cpp
// Function: gaps::R2Grid::Substitute(double, double)
void R2Grid::
Substitute(RNScalar old_value, RNScalar new_value) 
{
  // Replace all instances of old_value with new_value
  for (int i = 0; i < grid_size; i++) {
    if (grid_values[i] == old_value) {
      grid_values[i] = new_value;
    }
  }
}

// Assembly:
movslq 0xcc(%rdi), %rax
testq %rax, %rax
jle 0x5d7d7
movq 0xb8(%rdi), %rcx
xorl %edx, %edx
movsd (%rcx,%rdx,8), %xmm2
ucomisd %xmm0, %xmm2
jne 0x5d7cf
jp 0x5d7cf
movsd %xmm1, (%rcx,%rdx,8)
incq %rdx
cmpq %rdx, %rax
jne 0x5d7bd
retq
// File: /workspace/github_cpp_makefile_star2_O3/tomfunkhouser[P]gaps/pkgs/R2Shapes/R2Grid.cpp
// Function: gaps::R2Grid::Add(double)
void R2Grid::
Add(RNScalar value) 
{
  // Add value to all grid values 
  for (int i = 0; i < grid_size; i++) {
    if (grid_values[i] != R2_GRID_UNKNOWN_VALUE) {
      grid_values[i] += value;
    }
  }
}

// Assembly:
movslq 0xcc(%rdi), %rax
testq %rax, %rax
jle 0x5d813
movq 0xb8(%rdi), %rcx
xorl %edx, %edx
movsd 0x457c3(%rip), %xmm1    # 0xa2fb8
movsd (%rcx,%rdx,8), %xmm2
ucomisd %xmm1, %xmm2
jne 0x5d802
jnp 0x5d80b
addsd %xmm0, %xmm2
movsd %xmm2, (%rcx,%rdx,8)
incq %rdx
cmpq %rdx, %rax
jne 0x5d7f5
retq
// File: /workspace/github_cpp_makefile_star2_O3/tomfunkhouser[P]gaps/pkgs/R2Shapes/R2Grid.cpp
// Function: gaps::R2Grid::Add(gaps::R2Grid const&)
void R2Grid::
Add(const R2Grid& grid) 
{
  // Resolutions must be the same (for now)
  assert(grid_resolution[0] == grid.grid_resolution[0]);
  assert(grid_resolution[1] == grid.grid_resolution[1]);

  // Add passed grid values to corresponding entries of this grid
  for (int i = 0; i < grid_size; i++) {
    if (grid_values[i] != R2_GRID_UNKNOWN_VALUE) {
      if (grid.grid_values[i] == R2_GRID_UNKNOWN_VALUE) grid_values[i] = R2_GRID_UNKNOWN_VALUE;
      else grid_values[i] += grid.grid_values[i];
    }
  }
}

// Assembly:
movslq 0xcc(%rdi), %rax
testq %rax, %rax
jle 0x5d870
movq 0xb8(%rdi), %rcx
movq 0xb8(%rsi), %rdx
xorl %esi, %esi
movsd 0x45780(%rip), %xmm0    # 0xa2fb8
movsd (%rcx,%rsi,8), %xmm1
ucomisd %xmm0, %xmm1
jne 0x5d845
jnp 0x5d868
movsd (%rdx,%rsi,8), %xmm2
addsd %xmm2, %xmm1
cmpeqsd %xmm0, %xmm2
movapd %xmm2, %xmm3
andnpd %xmm1, %xmm3
andpd %xmm0, %xmm2
orpd %xmm3, %xmm2
movlpd %xmm2, (%rcx,%rsi,8)
incq %rsi
cmpq %rsi, %rax
jne 0x5d838
retq
nop
// File: /workspace/github_cpp_makefile_star2_O3/tomfunkhouser[P]gaps/pkgs/R2Shapes/R2Grid.cpp
// Function: gaps::R2Grid::Subtract(gaps::R2Grid const&)
void R2Grid::
Subtract(const R2Grid& grid) 
{
  // Resolutions must be the same (for now)
  assert(grid_resolution[0] == grid.grid_resolution[0]);
  assert(grid_resolution[1] == grid.grid_resolution[1]);

  // Subtract passed grid values from corresponding entries of this grid
  for (int i = 0; i < grid_size; i++) {
    if (grid_values[i] != R2_GRID_UNKNOWN_VALUE) {
      if (grid.grid_values[i] == R2_GRID_UNKNOWN_VALUE) grid_values[i] = R2_GRID_UNKNOWN_VALUE;
      else grid_values[i] -= grid.grid_values[i];
    }
  }
}

// Assembly:
movslq 0xcc(%rdi), %rax
testq %rax, %rax
jle 0x5d90a
movq 0xb8(%rdi), %rcx
movq 0xb8(%rsi), %rdx
xorl %esi, %esi
movsd 0x456e6(%rip), %xmm0    # 0xa2fb8
movsd (%rcx,%rsi,8), %xmm1
ucomisd %xmm0, %xmm1
jne 0x5d8df
jnp 0x5d902
movsd (%rdx,%rsi,8), %xmm2
subsd %xmm2, %xmm1
cmpeqsd %xmm0, %xmm2
movapd %xmm2, %xmm3
andnpd %xmm1, %xmm3
andpd %xmm0, %xmm2
orpd %xmm3, %xmm2
movlpd %xmm2, (%rcx,%rsi,8)
incq %rsi
cmpq %rsi, %rax
jne 0x5d8d2
retq
nop
// File: /workspace/github_cpp_makefile_star2_O3/tomfunkhouser[P]gaps/pkgs/R2Shapes/R2Grid.cpp
// Function: gaps::R2Grid::Multiply(double)
void R2Grid::
Multiply(RNScalar value) 
{
  // Multiply grid values by value
  for (int i = 0; i < grid_size; i++) {
    if (grid_values[i] != R2_GRID_UNKNOWN_VALUE) {
      grid_values[i] *= value;
    }
  }
}

// Assembly:
movslq 0xcc(%rdi), %rax
testq %rax, %rax
jle 0x5d947
movq 0xb8(%rdi), %rcx
xorl %edx, %edx
movsd 0x4568f(%rip), %xmm1    # 0xa2fb8
movsd (%rcx,%rdx,8), %xmm2
ucomisd %xmm1, %xmm2
jne 0x5d936
jnp 0x5d93f
mulsd %xmm0, %xmm2
movsd %xmm2, (%rcx,%rdx,8)
incq %rdx
cmpq %rdx, %rax
jne 0x5d929
retq
// File: /workspace/github_cpp_makefile_star2_O3/tomfunkhouser[P]gaps/pkgs/R2Shapes/R2Grid.cpp
// Function: gaps::R2Grid::Multiply(gaps::R2Grid const&)
void R2Grid::
Multiply(const R2Grid& grid) 
{
  // Resolutions must be the same (for now)
  assert(grid_resolution[0] == grid.grid_resolution[0]);
  assert(grid_resolution[1] == grid.grid_resolution[1]);

  // Multiply passed grid values by corresponding entries of this grid
  for (int i = 0; i < grid_size; i++) {
    if (grid_values[i] != R2_GRID_UNKNOWN_VALUE) {
      if (grid.grid_values[i] == R2_GRID_UNKNOWN_VALUE) grid_values[i] = R2_GRID_UNKNOWN_VALUE;
      else grid_values[i] *= grid.grid_values[i];
    }
  }
}

// Assembly:
movslq 0xcc(%rdi), %rax
testq %rax, %rax
jle 0x5d9a4
movq 0xb8(%rdi), %rcx
movq 0xb8(%rsi), %rdx
xorl %esi, %esi
movsd 0x4564c(%rip), %xmm0    # 0xa2fb8
movsd (%rcx,%rsi,8), %xmm1
ucomisd %xmm0, %xmm1
jne 0x5d979
jnp 0x5d99c
movsd (%rdx,%rsi,8), %xmm2
mulsd %xmm2, %xmm1
cmpeqsd %xmm0, %xmm2
movapd %xmm2, %xmm3
andnpd %xmm1, %xmm3
andpd %xmm0, %xmm2
orpd %xmm3, %xmm2
movlpd %xmm2, (%rcx,%rsi,8)
incq %rsi
cmpq %rsi, %rax
jne 0x5d96c
retq
nop
// File: /workspace/github_cpp_makefile_star2_O3/tomfunkhouser[P]gaps/pkgs/R2Shapes/R2Grid.cpp
// Function: gaps::R2Grid::Divide(gaps::R2Grid const&)
void R2Grid::
Divide(const R2Grid& grid) 
{
  // Resolutions must be the same (for now)
  assert(grid_resolution[0] == grid.grid_resolution[0]);
  assert(grid_resolution[1] == grid.grid_resolution[1]);

  // Divide entries of this grid by by corresponding entries of passed grid 
  for (int i = 0; i < grid_size; i++) {
    if (grid_values[i] != R2_GRID_UNKNOWN_VALUE) {
      if (grid.grid_values[i] == R2_GRID_UNKNOWN_VALUE) {
       grid_values[i] = R2_GRID_UNKNOWN_VALUE;
      }
      else if (grid.grid_values[i] == 0) {
        if (grid_values[i] > 0) grid_values[i] = RN_INFINITY;
        else if (grid_values[i] < 0) grid_values[i] = -RN_INFINITY;
      }
      else {
        grid_values[i] /= grid.grid_values[i];
      }
    }
  }
}

// Assembly:
movslq 0xcc(%rdi), %rax
testq %rax, %rax
jle 0x5da3c
movq 0xb8(%rdi), %rcx
movq 0xb8(%rsi), %rdx
xorl %esi, %esi
movsd 0x455ea(%rip), %xmm0    # 0xa2fb8
xorpd %xmm1, %xmm1
leaq 0x881cf(%rip), %rdi     # 0xe5ba8
movapd 0x4463f(%rip), %xmm2    # 0xa2020
movsd (%rcx,%rsi,8), %xmm3
ucomisd %xmm0, %xmm3
jne 0x5d9ee
jnp 0x5da04
movsd (%rdx,%rsi,8), %xmm5
ucomisd %xmm0, %xmm5
movapd %xmm0, %xmm4
jne 0x5da0e
jp 0x5da0e
movsd %xmm4, (%rcx,%rsi,8)
incq %rsi
cmpq %rsi, %rax
jne 0x5d9e1
jmp 0x5da3c
ucomisd %xmm1, %xmm5
jne 0x5da22
jp 0x5da22
ucomisd %xmm1, %xmm3
jbe 0x5da2c
movsd (%rdi), %xmm4
jmp 0x5d9ff
divsd %xmm5, %xmm3
movapd %xmm3, %xmm4
jmp 0x5d9ff
ucomisd %xmm3, %xmm1
jbe 0x5da04
movsd (%rdi), %xmm4
xorpd %xmm2, %xmm4
jmp 0x5d9ff
retq
nop
// File: /workspace/github_cpp_makefile_star2_O3/tomfunkhouser[P]gaps/pkgs/R2Shapes/R2Grid.cpp
// Function: gaps::R2Grid::Pow(double)
void R2Grid::
Pow(RNScalar exponent) 
{
  // Apply exponent to all grid values 
  for (int i = 0; i < grid_size; i++) {
    RNScalar value = grid_values[i];
    if (value != R2_GRID_UNKNOWN_VALUE) {
      grid_values[i] = pow(value, exponent);
    }
  }
}

// Assembly:
pushq %r14
pushq %rbx
pushq %rax
movsd %xmm0, (%rsp)
movl 0xcc(%rdi), %eax
testl %eax, %eax
jle 0x5da98
movq %rdi, %rbx
movq 0xb8(%rdi), %rcx
xorl %r14d, %r14d
movsd (%rcx,%r14,8), %xmm0
ucomisd 0x4554c(%rip), %xmm0    # 0xa2fb8
jne 0x5da70
jnp 0x5da8d
movsd (%rsp), %xmm1
callq 0xe7d0
movq 0xb8(%rbx), %rcx
movsd %xmm0, (%rcx,%r14,8)
movl 0xcc(%rbx), %eax
incq %r14
movslq %eax, %rdx
cmpq %rdx, %r14
jl 0x5da5e
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::Mask(gaps::R2Grid const&)
void R2Grid::
Mask(const R2Grid& grid) 
{
  // Resolutions must be the same (for now)
  assert(grid_resolution[0] == grid.grid_resolution[0]);
  assert(grid_resolution[1] == grid.grid_resolution[1]);

  // Mask entries of grid
  for (int i = 0; i < grid_size; i++) {
    if (grid.grid_values[i] == 0) grid_values[i] = 0;
    else if (grid.grid_values[i] == R2_GRID_UNKNOWN_VALUE) grid_values[i] = R2_GRID_UNKNOWN_VALUE;
  }
}

// Assembly:
movslq 0xcc(%rdi), %rax
testq %rax, %rax
jle 0x5daee
movq 0xb8(%rsi), %rcx
movq 0xb8(%rdi), %rdx
xorl %esi, %esi
movsd 0x454f4(%rip), %xmm0    # 0xa2fb8
movsd (%rcx,%rsi,8), %xmm2
xorpd %xmm1, %xmm1
ucomisd %xmm1, %xmm2
jne 0x5dad5
jnp 0x5dae1
ucomisd %xmm0, %xmm2
movapd %xmm0, %xmm1
jne 0x5dae6
jp 0x5dae6
movsd %xmm1, (%rdx,%rsi,8)
incq %rsi
cmpq %rsi, %rax
jne 0x5dac4
retq
nop
// File: /workspace/github_cpp_makefile_star2_O3/tomfunkhouser[P]gaps/pkgs/R2Shapes/R2Grid.cpp
// Function: gaps::R2Grid::Overlay(gaps::R2Grid const&)
void R2Grid::
Overlay(const R2Grid& grid) 
{
  // Resolutions must be the same (for now)
  assert(grid_resolution[0] == grid.grid_resolution[0]);
  assert(grid_resolution[1] == grid.grid_resolution[1]);

  // Assign non-zero entries of grid 
  for (int i = 0; i < grid_size; i++) {
    if (grid.grid_values[i] == 0) continue;
    if (grid.grid_values[i] == R2_GRID_UNKNOWN_VALUE) continue;
    grid_values[i] = grid.grid_values[i];
  }
}

// Assembly:
movslq 0xcc(%rdi), %rax
testq %rax, %rax
jle 0x5db3a
movq 0xb8(%rsi), %rcx
movq 0xb8(%rdi), %rdx
xorl %esi, %esi
xorpd %xmm0, %xmm0
movsd 0x454a0(%rip), %xmm1    # 0xa2fb8
movsd (%rcx,%rsi,8), %xmm2
ucomisd %xmm0, %xmm2
jne 0x5db25
jnp 0x5db32
ucomisd %xmm1, %xmm2
jne 0x5db2d
jnp 0x5db32
movsd %xmm2, (%rdx,%rsi,8)
incq %rsi
cmpq %rsi, %rax
jne 0x5db18
retq
nop
// File: /workspace/github_cpp_makefile_star2_O3/tomfunkhouser[P]gaps/pkgs/R2Shapes/R2Grid.cpp
// Function: gaps::R2Grid::Threshold(gaps::R2Grid const&, double, double)
void R2Grid::
Threshold(const R2Grid& threshold, RNScalar low, RNScalar high) 
{
  // Set grid value to low (high) if less/equal (greater) than threshold
  for (int i = 0; i < grid_size; i++) {
    if ((grid_values[i] != R2_GRID_UNKNOWN_VALUE) && (threshold.grid_values[i] != R2_GRID_UNKNOWN_VALUE)) {
      if (grid_values[i] <= threshold.grid_values[i]) {
        if (low == R2_GRID_INPUT_VALUE) grid_values [i]= threshold.grid_values[i];
        else if (low != R2_GRID_KEEP_VALUE) grid_values[i] = low;
      }
      else {
        if (high == R2_GRID_INPUT_VALUE) grid_values[i] = threshold.grid_values[i];
        else if (high != R2_GRID_KEEP_VALUE) grid_values[i] = high;
      }
    }
  }
}

// Assembly:
movslq 0xcc(%rdi), %rax
testq %rax, %rax
jle 0x5dc19
movq 0xb8(%rdi), %rcx
movq 0xb8(%rsi), %rdx
movsd 0x45446(%rip), %xmm2    # 0xa2fa8
movapd %xmm0, %xmm3
cmpneqpd %xmm2, %xmm3
movsd 0x4b7a5(%rip), %xmm4    # 0xa9318
movapd %xmm0, %xmm5
cmpeqpd %xmm4, %xmm5
orpd %xmm3, %xmm5
movd %xmm5, %esi
cmpneqpd %xmm1, %xmm2
cmpeqpd %xmm1, %xmm4
orpd %xmm2, %xmm4
movd %xmm4, %edi
xorl %r8d, %r8d
movsd 0x45417(%rip), %xmm2    # 0xa2fb8
movsd 0x4b76f(%rip), %xmm3    # 0xa9318
cmpeqsd %xmm1, %xmm3
movapd %xmm3, %xmm4
andnpd %xmm1, %xmm4
movsd 0x4b75a(%rip), %xmm1    # 0xa9318
cmpeqsd %xmm0, %xmm1
movapd %xmm1, %xmm5
andnpd %xmm0, %xmm5
movsd (%rcx,%r8,8), %xmm6
ucomisd %xmm2, %xmm6
jne 0x5dbd9
jnp 0x5dc11
movsd (%rdx,%r8,8), %xmm0
ucomisd %xmm2, %xmm0
jne 0x5dbe7
jnp 0x5dc11
ucomisd %xmm6, %xmm0
jae 0x5dbfd
testb $0x1, %dil
je 0x5dc11
andpd %xmm3, %xmm0
orpd %xmm4, %xmm0
jmp 0x5dc0b
testb $0x1, %sil
je 0x5dc11
andpd %xmm1, %xmm0
orpd %xmm5, %xmm0
movsd %xmm0, (%rcx,%r8,8)
incq %r8
cmpq %r8, %rax
jne 0x5dbcb
retq
// File: /workspace/github_cpp_makefile_star2_O3/tomfunkhouser[P]gaps/pkgs/R2Shapes/R2Grid.cpp
// Function: gaps::R2Grid::SignedDistanceTransform()
void R2Grid::
SignedDistanceTransform(void)
{
  // Compute distance from boundary into interior (negative) and into exterior (positive)
  R2Grid copy(*this);
  SquaredDistanceTransform();
  Sqrt();
  copy.Threshold(0, 1, 0);
  copy.Substitute(R2_GRID_UNKNOWN_VALUE, 1);
  copy.SquaredDistanceTransform();
  copy.Sqrt();
  Subtract(copy);
}

// Assembly:
pushq %r14
pushq %rbx
subq $0xd8, %rsp
movq %rdi, %rbx
leaq 0x8(%rsp), %rdi
movq %rbx, %rsi
callq 0x59934
movq %rbx, %rdi
callq 0x5b168
movl 0xcc(%rbx), %eax
testl %eax, %eax
jle 0x5dca5
movq 0xb8(%rbx), %rcx
xorl %r14d, %r14d
movsd 0x45360(%rip), %xmm1    # 0xa2fb8
xorpd %xmm2, %xmm2
movsd (%rcx,%r14,8), %xmm0
ucomisd %xmm1, %xmm0
jne 0x5dc6a
jnp 0x5dc9a
ucomisd %xmm2, %xmm0
jb 0x5dc76
sqrtsd %xmm0, %xmm0
jmp 0x5dc87
callq 0xe340
xorpd %xmm2, %xmm2
movsd 0x45331(%rip), %xmm1    # 0xa2fb8
movq 0xb8(%rbx), %rcx
movsd %xmm0, (%rcx,%r14,8)
movl 0xcc(%rbx), %eax
incq %r14
movslq %eax, %rdx
cmpq %rdx, %r14
jl 0x5dc5c
movslq 0xd4(%rsp), %rax
testq %rax, %rax
jle 0x5dd18
movq 0xc0(%rsp), %rcx
xorl %edx, %edx
movsd 0x452f4(%rip), %xmm0    # 0xa2fb8
xorpd %xmm1, %xmm1
movsd 0x44368(%rip), %xmm2    # 0xa2038
movsd (%rcx,%rdx,8), %xmm3
ucomisd %xmm0, %xmm3
jne 0x5dcdd
jnp 0x5dceb
cmpnlesd %xmm1, %xmm3
andnpd %xmm2, %xmm3
movlpd %xmm3, (%rcx,%rdx,8)
incq %rdx
cmpq %rdx, %rax
jne 0x5dcd0
xorl %edx, %edx
movabsq $0x3ff0000000000000, %rsi # imm = 0x3FF0000000000000
movsd (%rcx,%rdx,8), %xmm1
ucomisd %xmm0, %xmm1
jne 0x5dd10
jp 0x5dd10
movq %rsi, (%rcx,%rdx,8)
incq %rdx
cmpq %rdx, %rax
jne 0x5dcff
leaq 0x8(%rsp), %rdi
callq 0x5b168
movl 0xd4(%rsp), %eax
testl %eax, %eax
jle 0x5dd8f
movq 0xc0(%rsp), %rcx
xorl %r14d, %r14d
movsd 0x45278(%rip), %xmm1    # 0xa2fb8
xorpd %xmm2, %xmm2
movsd (%rcx,%r14,8), %xmm0
ucomisd %xmm1, %xmm0
jne 0x5dd52
jnp 0x5dd84
ucomisd %xmm2, %xmm0
jb 0x5dd5e
sqrtsd %xmm0, %xmm0
jmp 0x5dd6f
callq 0xe340
xorpd %xmm2, %xmm2
movsd 0x45249(%rip), %xmm1    # 0xa2fb8
movq 0xc0(%rsp), %rcx
movsd %xmm0, (%rcx,%r14,8)
movl 0xd4(%rsp), %eax
incq %r14
movslq %eax, %rdx
cmpq %rdx, %r14
jl 0x5dd44
movslq 0xcc(%rbx), %rax
testq %rax, %rax
jle 0x5ddec
movq 0xb8(%rbx), %rcx
movq 0xc0(%rsp), %rdx
xorl %esi, %esi
movsd 0x45204(%rip), %xmm0    # 0xa2fb8
movsd (%rcx,%rsi,8), %xmm1
ucomisd %xmm0, %xmm1
jne 0x5ddc1
jnp 0x5dde4
movsd (%rdx,%rsi,8), %xmm2
subsd %xmm2, %xmm1
cmpeqsd %xmm0, %xmm2
movapd %xmm2, %xmm3
andnpd %xmm1, %xmm3
andpd %xmm0, %xmm2
orpd %xmm3, %xmm2
movlpd %xmm2, (%rcx,%rsi,8)
incq %rsi
cmpq %rsi, %rax
jne 0x5ddb4
leaq 0x8(%rsp), %rdi
callq 0x59b0c
addq $0xd8, %rsp
popq %rbx
popq %r14
retq
movq %rax, %rbx
leaq 0x8(%rsp), %rdi
callq 0x59b0c
movq %rbx, %rdi
callq 0xe7e0
// File: /workspace/github_cpp_makefile_star2_O3/tomfunkhouser[P]gaps/pkgs/R2Shapes/R2Grid.cpp
// Function: gaps::R2Grid::Gauss(double, int)
void R2Grid::
Gauss(RNLength sigma, RNBoolean square)
{
  // Check sigma
  if (sigma == 0.0) return;    

  // Replace each grid value with Gaussian of what was there before
  RNScalar fac = 1.0 / (2.0 * sigma * sigma);
  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 0x5e5bb
jp 0x5e5bb
retq
pushq %r15
pushq %r14
pushq %rbx
subq $0x20, %rsp
movsd 0x43c34(%rip), %xmm2    # 0xa2200
mulsd %xmm0, %xmm2
mulsd %xmm0, %xmm2
movapd 0x43c94(%rip), %xmm1    # 0xa2270
movapd %xmm2, 0x10(%rsp)
andpd %xmm2, %xmm1
movsd 0x43bf2(%rip), %xmm2    # 0xa21e0
ucomisd %xmm1, %xmm2
jae 0x5e665
movq %rdi, %r14
cmpl $0x0, 0xcc(%rdi)
jle 0x5e665
movl %esi, %ebx
movapd %xmm0, %xmm1
addsd %xmm0, %xmm1
mulsd %xmm0, %xmm1
movsd 0x43a22(%rip), %xmm0    # 0xa2038
divsd %xmm1, %xmm0
movsd %xmm0, 0x8(%rsp)
movq 0xb8(%r14), %rax
xorl %r15d, %r15d
movsd (%rax,%r15,8), %xmm0
testl %ebx, %ebx
je 0x5e638
mulsd %xmm0, %xmm0
divsd 0x10(%rsp), %xmm0
callq 0xe7f0
mulsd 0x8(%rsp), %xmm0
movq 0xb8(%r14), %rax
movsd %xmm0, (%rax,%r15,8)
incq %r15
movslq 0xcc(%r14), %rcx
cmpq %rcx, %r15
jl 0x5e62a
addq $0x20, %rsp
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::PadWithZero(int, int)
void R2Grid::
PadWithZero(int xresolution, int yresolution)
{
  // Add zeros to achieve desired resolution
  if ((XResolution() >= xresolution) && (YResolution() >= yresolution)) return;

  // Copy this grid
  R2Grid copy(*this);

  // Set grid resolution
  grid_resolution[0] = xresolution;
  grid_resolution[1] = yresolution;
  grid_row_size = xresolution;
  grid_size = grid_row_size * yresolution;

  // Allocate grid values
  if (grid_values) delete [] grid_values;
  if (grid_size == 0) grid_values = NULL;
  else grid_values = new RNScalar [ grid_size ];
  assert(!grid_size || grid_values);

  // Set all values to zero
  for (int i = 0; i < grid_size; i++) grid_values[i] = 0;

  // Copy original values
  for (int iy = 0; iy < copy.YResolution(); iy++) {
    for (int ix = 0; ix < copy.XResolution(); ix++) {
      RNScalar value = copy.GridValue(ix, iy);
      SetGridValue(ix, iy, value);
    }
  }
}

// Assembly:
pushq %rbp
pushq %r14
pushq %rbx
subq $0xd0, %rsp
movl %edx, %ebp
movl %esi, %r14d
movq %rdi, %rbx
cmpl %esi, 0xc0(%rdi)
jl 0x5e697
cmpl %ebp, 0xc4(%rbx)
jge 0x5e789
movq %rsp, %rdi
movq %rbx, %rsi
callq 0x59934
movl %r14d, 0xc0(%rbx)
movl %ebp, 0xc4(%rbx)
movl %r14d, 0xc8(%rbx)
imull %r14d, %ebp
movl %ebp, 0xcc(%rbx)
movq 0xb8(%rbx), %rdi
testq %rdi, %rdi
je 0x5e6d7
callq 0xe5b0
movl 0xcc(%rbx), %ebp
testl %ebp, %ebp
je 0x5e714
movslq %ebp, %rax
shlq $0x3, %rax
testl %ebp, %ebp
movq $-0x1, %rdi
cmovnsq %rax, %rdi
callq 0xe030
movq %rax, %r14
movq %rax, 0xb8(%rbx)
testl %ebp, %ebp
jle 0x5e722
movl %ebp, %edx
shlq $0x3, %rdx
movq %r14, %rdi
xorl %esi, %esi
callq 0xe260
jmp 0x5e722
movq $0x0, 0xb8(%rbx)
xorl %r14d, %r14d
movslq 0xc4(%rsp), %rax
testq %rax, %rax
jle 0x5e781
movl 0xc0(%rsp), %ecx
movq 0xb8(%rsp), %rdx
movslq 0xc8(%rsp), %rsi
movslq 0xc8(%rbx), %rdi
shlq $0x3, %rsi
shlq $0x3, %rdi
xorl %r8d, %r8d
testl %ecx, %ecx
jle 0x5e773
xorl %r9d, %r9d
movsd (%rdx,%r9,8), %xmm0
movsd %xmm0, (%r14,%r9,8)
incq %r9
cmpq %r9, %rcx
jne 0x5e75f
incq %r8
addq %rsi, %rdx
addq %rdi, %r14
cmpq %rax, %r8
jne 0x5e758
movq %rsp, %rdi
callq 0x59b0c
addq $0xd0, %rsp
popq %rbx
popq %r14
popq %rbp
retq
movq %rax, %rbx
movq %rsp, %rdi
callq 0x59b0c
movq %rbx, %rdi
callq 0xe7e0
// File: /workspace/github_cpp_makefile_star2_O3/tomfunkhouser[P]gaps/pkgs/R2Shapes/R2Grid.cpp
// Function: gaps::R2Grid::RasterizeGridValue(int, int, double, int)
void R2Grid::
RasterizeGridValue(int ix, int iy, 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;

  // Update grid based on operation
  if (operation == R2_GRID_ADD_OPERATION) AddGridValue(ix, iy, value);
  else if (operation == R2_GRID_SUBTRACT_OPERATION) AddGridValue(ix, iy, -value);
  else if (operation == R2_GRID_REPLACE_OPERATION) SetGridValue(ix, iy, value);
  else RNAbort("Unrecognized grid rasterization operation\n");
}

// Assembly:
testl %esi, %esi
js 0x5ebdb
testl %edx, %edx
js 0x5ebdb
cmpl %esi, 0xc0(%rdi)
jle 0x5ebdb
cmpl %edx, 0xc4(%rdi)
jle 0x5ebdb
cmpl $0x2, %ecx
je 0x5ebdc
cmpl $0x1, %ecx
je 0x5eb91
testl %ecx, %ecx
jne 0x5ebf5
movq 0xb8(%rdi), %rax
imull 0xc8(%rdi), %edx
addl %esi, %edx
movslq %edx, %rcx
movsd (%rax,%rcx,8), %xmm1
movapd %xmm1, %xmm2
addsd %xmm0, %xmm2
cmpeqsd 0x4443d(%rip), %xmm1    # 0xa2fb8
movapd %xmm1, %xmm3
andnpd %xmm2, %xmm3
andpd %xmm0, %xmm1
orpd %xmm3, %xmm1
movlpd %xmm1, (%rax,%rcx,8)
retq
movapd 0x43487(%rip), %xmm1    # 0xa2020
xorpd %xmm0, %xmm1
movq 0xb8(%rdi), %rax
imull 0xc8(%rdi), %edx
addl %esi, %edx
movslq %edx, %rcx
movsd (%rax,%rcx,8), %xmm2
movapd %xmm2, %xmm3
subsd %xmm0, %xmm3
cmpeqsd 0x443f2(%rip), %xmm2    # 0xa2fb8
movapd %xmm2, %xmm0
andnpd %xmm3, %xmm0
andpd %xmm1, %xmm2
orpd %xmm0, %xmm2
movlpd %xmm2, (%rax,%rcx,8)
retq
imull 0xc8(%rdi), %edx
movq 0xb8(%rdi), %rax
addl %esi, %edx
movslq %edx, %rcx
movsd %xmm0, (%rax,%rcx,8)
retq
leaq 0x48b76(%rip), %rdi     # 0xa7772
xorl %eax, %eax
jmp 0x718f6
nop
// File: /workspace/github_cpp_makefile_star2_O3/tomfunkhouser[P]gaps/pkgs/R2Shapes/R2Grid.cpp
// Function: gaps::R2Grid::RasterizeGridPoint(double, double, double, int)
void R2Grid::
RasterizeGridPoint(RNScalar x, RNScalar y, RNScalar value, int operation)
{
  // Check if within bounds
  if ((x < 0) || (x > grid_resolution[0]-1)) return;
  if ((y < 0) || (y > grid_resolution[1]-1)) return;

  // Bilinear interpolation
  int ix1 = (int) x;
  int iy1 = (int) y;
  int ix2 = ix1 + 1;
  int iy2 = iy1 + 1;
  if (ix2 >= grid_resolution[0]) ix2 = ix1;
  if (iy2 >= grid_resolution[1]) iy2 = iy1;
  RNScalar dx = x - ix1;
  RNScalar dy = y - iy1;
  RasterizeGridValue(ix1, iy1, value * (1.0-dx) * (1.0-dy), operation);
  RasterizeGridValue(ix1, iy2, value * (1.0-dx) * dy, operation);
  RasterizeGridValue(ix2, iy1, value * dx * (1.0-dy), operation);
  RasterizeGridValue(ix2, iy2, value * dx * dy, operation);
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x48, %rsp
xorpd %xmm3, %xmm3
ucomisd %xmm0, %xmm3
jbe 0x5ec2b
addq $0x48, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
ucomisd %xmm1, %xmm3
ja 0x5ec1c
movq %rdi, %r14
movl 0xc0(%rdi), %eax
leal -0x1(%rax), %ecx
xorps %xmm3, %xmm3
cvtsi2sd %ecx, %xmm3
ucomisd %xmm3, %xmm0
ja 0x5ec1c
movl 0xc4(%r14), %ecx
leal -0x1(%rcx), %edx
xorps %xmm3, %xmm3
cvtsi2sd %edx, %xmm3
ucomisd %xmm3, %xmm1
ja 0x5ec1c
movl %esi, %ebx
cvttsd2si %xmm0, %r13d
cvttsd2si %xmm1, %r12d
leal 0x1(%r13), %ebp
leal 0x1(%r12), %r15d
cmpl %eax, %ebp
cmovgel %r13d, %ebp
cmpl %ecx, %r15d
cmovgel %r12d, %r15d
cvttpd2dq %xmm0, %xmm3
cvtdq2pd %xmm3, %xmm3
subsd %xmm3, %xmm0
movapd %xmm0, (%rsp)
cvttpd2dq %xmm1, %xmm3
cvtdq2pd %xmm3, %xmm3
subsd %xmm3, %xmm1
movapd %xmm1, 0x30(%rsp)
movsd 0x4338a(%rip), %xmm4    # 0xa2038
movapd %xmm4, %xmm3
subsd %xmm0, %xmm3
mulsd %xmm2, %xmm3
movsd %xmm3, 0x18(%rsp)
subsd %xmm1, %xmm4
movsd %xmm4, 0x28(%rsp)
movapd %xmm3, %xmm0
mulsd %xmm4, %xmm0
movq %r14, %rdi
movl %r13d, %esi
movl %r12d, %edx
movl %ebx, %ecx
movsd %xmm2, 0x20(%rsp)
callq 0x5eb14
movsd 0x18(%rsp), %xmm0
mulsd 0x30(%rsp), %xmm0
movq %r14, %rdi
movl %r13d, %esi
movl %r15d, %edx
movl %ebx, %ecx
callq 0x5eb14
movapd (%rsp), %xmm1
mulsd 0x20(%rsp), %xmm1
movapd %xmm1, (%rsp)
movsd 0x28(%rsp), %xmm0
mulsd %xmm1, %xmm0
movq %r14, %rdi
movl %ebp, %esi
movl %r12d, %edx
movl %ebx, %ecx
callq 0x5eb14
movapd (%rsp), %xmm0
mulsd 0x30(%rsp), %xmm0
movq %r14, %rdi
movl %ebp, %esi
movl %r15d, %edx
movl %ebx, %ecx
addq $0x48, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
jmp 0x5eb14
nop
// File: /workspace/github_cpp_makefile_star2_O3/tomfunkhouser[P]gaps/pkgs/R2Shapes/R2Grid.cpp
// Function: gaps::R2Grid::RasterizeGridSpan(gaps::R2Point const&, gaps::R2Point const&, double, double, int)
void R2Grid::
RasterizeGridSpan(const R2Point& p1, const R2Point& p2, RNScalar value1, RNScalar value2, int operation)
{
  // Splat value everywhere along span
  R2Vector vector = p2 - p1;
  RNLength length = vector.Length();
  int nsteps = length + 1;
  R2Vector dp = vector / nsteps;
  RNLength dv = (value2 - value1) / nsteps;
  for (int i = 0; i <= nsteps; i++) {
    RNScalar v = value1 + i*dv;
    gaps::R2Point p = p1 + i*dp;
    RasterizeGridPoint(p, v);
  }
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x68, %rsp
movsd %xmm1, (%rsp)
movsd %xmm0, 0x8(%rsp)
movq %rsi, %rbx
movq %rdi, %r14
leaq 0x58(%rsp), %r15
movq %r15, %rdi
movq %rdx, %rsi
movq %rbx, %rdx
callq 0x682e3
movq %r15, %rdi
callq 0x68476
addsd 0x432a0(%rip), %xmm0    # 0xa2038
cvttsd2si %xmm0, %ebp
cvttpd2dq %xmm0, %xmm0
cvtdq2pd %xmm0, %xmm0
leaq 0x38(%rsp), %rdi
movq %r15, %rsi
movapd %xmm0, 0x10(%rsp)
callq 0x6890d
testl %ebp, %ebp
js 0x5ee4e
movsd (%rsp), %xmm0
subsd 0x8(%rsp), %xmm0
divsd 0x10(%rsp), %xmm0
movsd %xmm0, (%rsp)
incl %ebp
xorpd %xmm0, %xmm0
leaq 0x48(%rsp), %r15
leaq 0x38(%rsp), %r12
leaq 0x28(%rsp), %r13
movsd %xmm0, 0x10(%rsp)
mulsd (%rsp), %xmm0
addsd 0x8(%rsp), %xmm0
movsd %xmm0, 0x20(%rsp)
movq %r15, %rdi
movq %r12, %rsi
movsd 0x10(%rsp), %xmm0
callq 0x6870c
movq %r13, %rdi
movq %rbx, %rsi
movq %r15, %rdx
callq 0x682cf
movsd 0x28(%rsp), %xmm0
movsd 0x30(%rsp), %xmm1
movq %r14, %rdi
movsd 0x20(%rsp), %xmm2
xorl %esi, %esi
callq 0x5ec04
movsd 0x10(%rsp), %xmm0
addsd 0x431ee(%rip), %xmm0    # 0xa2038
decl %ebp
jne 0x5edea
addq $0x68, %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::R2Grid::RasterizeGridSpan(int const*, int const*, double, double, int)
void R2Grid::
RasterizeGridSpan(const int p1[2], const int p2[2], RNScalar value1, RNScalar value2, int operation)
{
  // Resolve values
  if (value1 == R2_GRID_UNKNOWN_VALUE) return;
  if (value2 == R2_GRID_UNKNOWN_VALUE) return;

  // Get some convenient variables
  int d[2],p[2],dd[2],s[2];
  for (int i = 0; i < 2; i++) {
    d[i]= p2[i] - p1[i];
    if(d[i]<0){
      dd[i] = -d[i];
      s[i] = -1;
    }
    else{
      dd[i] = d[i];
      s[i] = 1;
    }
    p[i] = p1[i];
  }

  // Choose dimensions
  int i1=0;
  if(dd[1]>dd[i1]){i1=1;}
  int i2=(i1+1)%2;

  // Check span extent
  if(dd[i1]==0){
    // Span is a point - rasterize it
    RNScalar value = 0.5 * (value1 + value2);
    RasterizeGridValue(p[0], p[1], value, operation);
  }
  else {
    // Step along span
    int off[2] = { 0, 0 };
    RNScalar value = value1;
    RNScalar dvalue = (value2 - value1) / dd[i1];
    for (int i = 0; i <= dd[i1]; i++) {
      RasterizeGridValue(p[0], p[1], value, operation);
      off[i2]+=dd[i2];
      p[i1]+=s[i1];
      p[i2]+=s[i2]*off[i2]/dd[i1];
      off[i2]%=dd[i1];
      value += dvalue;
    }
  }
}

// Assembly:
ucomisd 0x44152(%rip), %xmm0    # 0xa2fb8
jne 0x5ee6e
jnp 0x5efd4
ucomisd 0x44142(%rip), %xmm1    # 0xa2fb8
jne 0x5ee7e
jnp 0x5efd4
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x38, %rsp
movl %ecx, %ebx
movq %rdi, %r14
leaq 0x1c(%rsp), %rax
leaq 0x14(%rsp), %rcx
leaq 0xc(%rsp), %rdi
leaq 0x8(%rsp), %r9
leaq 0x10(%rsp), %r11
leaq 0x18(%rsp), %r10
movb $0x1, %r8b
xorl %r15d, %r15d
movl (%rdx,%r15,4), %ebp
movl (%rsi,%r15,4), %r15d
subl %r15d, %ebp
movl %ebp, %r12d
negl %r12d
cmovsl %ebp, %r12d
sarl $0x1f, %ebp
orl $0x1, %ebp
movl %r12d, (%r11)
movl %ebp, (%r10)
movl %r15d, (%r9)
movl $0x1, %r15d
movq %rax, %r10
movq %rcx, %r11
movq %rdi, %r9
testb $0x1, %r8b
movl $0x0, %r8d
jne 0x5eeb5
movl 0x14(%rsp), %eax
xorl %r15d, %r15d
xorl %r12d, %r12d
cmpl 0x10(%rsp), %eax
setle %al
setg %r12b
movl 0x10(%rsp,%r12,4), %ebp
testl %ebp, %ebp
je 0x5efa8
movq $0x0, 0x20(%rsp)
js 0x5efc6
subsd %xmm0, %xmm1
cvtsi2sd %ebp, %xmm2
divsd %xmm2, %xmm1
movb %al, %r15b
movl $0xffffffff, %r13d      # imm = 0xFFFFFFFF
shll $0x2, %r15d
shll $0x2, %r12d
movsd %xmm1, 0x28(%rsp)
movsd %xmm0, 0x30(%rsp)
movl 0x8(%rsp), %esi
movl 0xc(%rsp), %edx
movq %r14, %rdi
movl %ebx, %ecx
callq 0x5eb14
movsd 0x28(%rsp), %xmm1
movsd 0x30(%rsp), %xmm0
movl 0x20(%rsp,%r15), %ecx
addl 0x10(%rsp,%r15), %ecx
movl 0x18(%rsp,%r12), %edx
movl 0x18(%rsp,%r15), %eax
addl %edx, 0x8(%rsp,%r12)
imull %ecx, %eax
cltd
idivl %ebp
addl %eax, 0x8(%rsp,%r15)
movl %ecx, %eax
cltd
idivl %ebp
movl %edx, 0x20(%rsp,%r15)
addsd %xmm1, %xmm0
incl %r13d
cmpl %r13d, %ebp
jne 0x5ef48
jmp 0x5efc6
addsd %xmm1, %xmm0
mulsd 0x4307c(%rip), %xmm0    # 0xa2030
movl 0x8(%rsp), %esi
movl 0xc(%rsp), %edx
movq %r14, %rdi
movl %ebx, %ecx
callq 0x5eb14
addq $0x38, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
nop