LLM4Binary/decompile-bench-makefile huggingface dataset:
// File: /workspace/github_cpp_makefile_star2_O2/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 0x51fb4
movq %rbx, %rdi
callq 0x5365e
movsd 0x8(%rsp), %xmm0
mulsd %xmm0, %xmm0
movsd 0x3fa22(%rip), %xmm1    # 0x93008
xorps %xmm2, %xmm2
movq %rbx, %rdi
callq 0x53990
movslq 0xcc(%rbx), %rax
movq 0xc8(%rsp), %rcx
movq 0xb8(%rbx), %rdx
xorl %esi, %esi
movsd 0x40957(%rip), %xmm0    # 0x93f68
movabsq $-0x3f8bf00000000000, %rdi # imm = 0xC074100000000000
cmpq %rax, %rsi
jge 0x53636
movsd (%rcx,%rsi,8), %xmm1
ucomisd %xmm0, %xmm1
jne 0x53631
jp 0x53631
movq %rdi, (%rdx,%rsi,8)
incq %rsi
jmp 0x5361b
leaq 0x10(%rsp), %rdi
callq 0x5216c
addq $0xe0, %rsp
popq %rbx
retq
movq %rax, %rbx
leaq 0x10(%rsp), %rdi
callq 0x5216c
movq %rbx, %rdi
callq 0xe810
// File: /workspace/github_cpp_makefile_star2_O2/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
movq 0xb8(%rdi), %rcx
xorl %edx, %edx
movsd 0x405c0(%rip), %xmm3    # 0x93f68
movsd 0x405a8(%rip), %xmm4    # 0x93f58
cmpq %rax, %rdx
jge 0x539e8
movsd (%rcx,%rdx,8), %xmm5
ucomisd %xmm3, %xmm5
jne 0x539c2
jnp 0x539e3
ucomisd %xmm5, %xmm0
jae 0x539d2
ucomisd %xmm4, %xmm2
movapd %xmm2, %xmm5
jmp 0x539da
ucomisd %xmm4, %xmm1
movapd %xmm1, %xmm5
jne 0x539de
jnp 0x539e3
movsd %xmm5, (%rcx,%rdx,8)
incq %rdx
jmp 0x539b0
retq
nop
// File: /workspace/github_cpp_makefile_star2_O2/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 0x51fb4
movsd 0x40540(%rip), %xmm0    # 0x93f50
movsd 0x3f5f0(%rip), %xmm1    # 0x93008
xorps %xmm2, %xmm2
movq %rbx, %rdi
callq 0x53990
movq %rbx, %rdi
callq 0x5365e
movsd 0x8(%rsp), %xmm0
mulsd %xmm0, %xmm0
movsd 0x3f5cb(%rip), %xmm2    # 0x93008
xorpd %xmm1, %xmm1
movq %rbx, %rdi
callq 0x53990
movslq 0xcc(%rbx), %rax
movq 0xc8(%rsp), %rcx
movq 0xb8(%rbx), %rdx
xorl %esi, %esi
movsd 0x404ff(%rip), %xmm0    # 0x93f68
movabsq $-0x3f8bf00000000000, %rdi # imm = 0xC074100000000000
cmpq %rax, %rsi
jge 0x53a8e
movsd (%rcx,%rsi,8), %xmm1
ucomisd %xmm0, %xmm1
jne 0x53a89
jp 0x53a89
movq %rdi, (%rdx,%rsi,8)
incq %rsi
jmp 0x53a73
leaq 0x10(%rsp), %rdi
callq 0x5216c
addq $0xe0, %rsp
popq %rbx
retq
movq %rax, %rbx
leaq 0x10(%rsp), %rdi
callq 0x5216c
movq %rbx, %rdi
callq 0xe810
// File: /workspace/github_cpp_makefile_star2_O2/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 0x541ec
jp 0x541ec
addq $0x18, %rsp
popq %rbx
popq %r12
popq %r14
popq %r15
retq
movq %rdi, %rbx
xorl %r14d, %r14d
movsd 0x3fd6e(%rip), %xmm1    # 0x93f68
leaq 0x460df(%rip), %r15     # 0x9a2e0
movslq 0xcc(%rbx), %rax
cmpq %rax, %r14
jge 0x541e0
movq 0xb8(%rbx), %rax
movsd (%rax,%r14,8), %xmm0
ucomisd %xmm1, %xmm0
jne 0x54226
jnp 0x542af
callq 0x67e16
movsd %xmm0, 0x10(%rsp)
callq 0x67e16
xorl %r12d, %r12d
movsd 0x3edcf(%rip), %xmm1    # 0x93010
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 0x3efed(%rip), %xmm0    # 0x93260
mulsd %xmm1, %xmm0
callq 0xe820
movsd 0x3ed84(%rip), %xmm1    # 0x93008
subsd %xmm0, %xmm1
mulsd 0x8(%rsp), %xmm1
mulsd (%r15,%r12,8), %xmm1
movq 0xb8(%rbx), %rax
addsd (%rax,%r14,8), %xmm1
movsd %xmm1, (%rax,%r14,8)
movsd 0x3fcb9(%rip), %xmm1    # 0x93f68
incq %r14
jmp 0x54201
nop
// File: /workspace/github_cpp_makefile_star2_O2/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 0x45139(%rip), %xmm1    # 0x9a2f0
movaps %xmm1, 0x10(%rsp)
movaps 0x4513d(%rip), %xmm1    # 0x9a300
movups %xmm1, 0x28(%rsp)
movabsq $0x3fd0000000000000, %rcx # imm = 0x3FD0000000000000
movq %rcx, 0x40(%rsp)
movaps %xmm0, 0x60(%rsp)
movaps %xmm0, 0x70(%rsp)
movaps 0x45128(%rip), %xmm0    # 0x9a310
movaps %xmm0, 0x50(%rsp)
movq %rax, 0x60(%rsp)
movaps 0x45127(%rip), %xmm0    # 0x9a320
movaps %xmm0, 0x80(%rsp)
movq %rcx, 0x90(%rsp)
cmpl $0x1, %esi
je 0x55217
testl %esi, %esi
jne 0x55229
movq %rsp, %rsi
jmp 0x5521c
leaq 0x50(%rsp), %rsi
callq 0x54fd0
addq $0x98, %rsp
retq
leaq 0x434e0(%rip), %rdi     # 0x98710
xorl %eax, %eax
addq $0x98, %rsp
jmp 0x680f0
// File: /workspace/github_cpp_makefile_star2_O2/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 0x51fb4
movq %r14, %rdi
xorl %esi, %esi
callq 0x5518a
leaq 0x10(%rsp), %rdi
movq %rbx, %rsi
callq 0x51fb4
leaq 0x10(%rsp), %rdi
pushq $0x1
popq %rsi
callq 0x5518a
leaq 0x45cad(%rip), %rax     # 0x9af58
movsd (%rax), %xmm2
xorl %r14d, %r14d
movsd 0x3ecae(%rip), %xmm3    # 0x93f68
movabsq $-0x3f8bf00000000000, %r15 # imm = 0xC074100000000000
xorpd %xmm4, %xmm4
movslq 0xcc(%rbx), %rax
cmpq %rax, %r14
jge 0x55362
movq 0xb8(%rbx), %rax
movsd (%rax,%r14,8), %xmm0
ucomisd %xmm3, %xmm0
jne 0x552ed
jnp 0x5531d
movq 0x198(%rsp), %rcx
movsd (%rcx,%r14,8), %xmm1
ucomisd %xmm3, %xmm1
jne 0x55303
jnp 0x55319
movq 0xc8(%rsp), %rcx
movsd (%rcx,%r14,8), %xmm0
ucomisd %xmm3, %xmm0
jne 0x55322
jp 0x55322
movq %r15, (%rax,%r14,8)
incq %r14
jmp 0x552c8
ucomisd %xmm4, %xmm1
jne 0x55332
jp 0x55332
movsd %xmm2, (%rax,%r14,8)
jmp 0x5531d
divsd %xmm1, %xmm0
movsd %xmm2, 0x8(%rsp)
callq 0xe390
xorpd %xmm4, %xmm4
movsd 0x3ec1b(%rip), %xmm3    # 0x93f68
movsd 0x8(%rsp), %xmm2
movq 0xb8(%rbx), %rax
movsd %xmm0, (%rax,%r14,8)
jmp 0x5531d
leaq 0x10(%rsp), %rdi
callq 0x5216c
leaq 0xe0(%rsp), %rdi
callq 0x5216c
addq $0x1b0, %rsp            # imm = 0x1B0
popq %rbx
popq %r14
popq %r15
retq
movq %rax, %rbx
leaq 0x10(%rsp), %rdi
callq 0x5216c
jmp 0x5539a
jmp 0x55397
movq %rax, %rbx
leaq 0xe0(%rsp), %rdi
callq 0x5216c
movq %rbx, %rdi
callq 0xe810
nop
// File: /workspace/github_cpp_makefile_star2_O2/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 0x51fb4
movq %r14, %rdi
xorl %esi, %esi
callq 0x5518a
leaq 0x8(%rsp), %rdi
movq %rbx, %rsi
callq 0x51fb4
leaq 0x8(%rsp), %rdi
pushq $0x1
popq %rsi
callq 0x5518a
movl 0xcc(%rbx), %eax
movq 0xb8(%rbx), %rcx
movq 0x190(%rsp), %rdx
movq 0xc0(%rsp), %rsi
xorl %edi, %edi
testl %eax, %eax
cmovlel %edi, %eax
movsd 0x3eb48(%rip), %xmm0    # 0x93f68
cmpq %rdi, %rax
je 0x5546e
movsd (%rcx,%rdi,8), %xmm1
ucomisd %xmm0, %xmm1
jne 0x55432
jnp 0x55469
movsd (%rdx,%rdi,8), %xmm1
ucomisd %xmm0, %xmm1
movapd %xmm0, %xmm3
jne 0x55443
jnp 0x55464
movsd (%rsi,%rdi,8), %xmm2
ucomisd %xmm0, %xmm2
movapd %xmm0, %xmm3
jne 0x55454
jnp 0x55464
mulsd %xmm2, %xmm2
mulsd %xmm1, %xmm1
addsd %xmm2, %xmm1
sqrtsd %xmm1, %xmm3
movsd %xmm3, (%rcx,%rdi,8)
incq %rdi
jmp 0x55420
leaq 0x8(%rsp), %rdi
callq 0x5216c
leaq 0xd8(%rsp), %rdi
callq 0x5216c
addq $0x1a8, %rsp            # imm = 0x1A8
popq %rbx
popq %r14
retq
movq %rax, %rbx
leaq 0x8(%rsp), %rdi
callq 0x5216c
jmp 0x554a4
jmp 0x554a1
movq %rax, %rbx
leaq 0xd8(%rsp), %rdi
callq 0x5216c
movq %rbx, %rdi
callq 0xe810
nop
// File: /workspace/github_cpp_makefile_star2_O2/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
movq 0xb8(%rdi), %rcx
xorl %edx, %edx
cmpq %rax, %rdx
jge 0x55992
movsd (%rcx,%rdx,8), %xmm2
ucomisd %xmm0, %xmm2
jne 0x5598d
jp 0x5598d
movsd %xmm1, (%rcx,%rdx,8)
incq %rdx
jmp 0x55976
retq
nop
// File: /workspace/github_cpp_makefile_star2_O2/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:
movl 0xcc(%rdi), %eax
movq 0xb8(%rdi), %rcx
xorl %edx, %edx
testl %eax, %eax
cmovlel %edx, %eax
movsd 0x3e5b8(%rip), %xmm1    # 0x93f68
cmpq %rdx, %rax
je 0x559d0
movsd (%rcx,%rdx,8), %xmm2
ucomisd %xmm1, %xmm2
jne 0x559c2
jnp 0x559cb
addsd %xmm0, %xmm2
movsd %xmm2, (%rcx,%rdx,8)
incq %rdx
jmp 0x559b0
retq
nop
// File: /workspace/github_cpp_makefile_star2_O2/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
movq 0xb8(%rdi), %rcx
movq 0xb8(%rsi), %rdx
xorl %esi, %esi
movsd 0x3e577(%rip), %xmm0    # 0x93f68
cmpq %rax, %rsi
jge 0x55a2b
movsd (%rcx,%rsi,8), %xmm1
ucomisd %xmm0, %xmm1
jne 0x55a03
jnp 0x55a26
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
jmp 0x559f1
retq
// File: /workspace/github_cpp_makefile_star2_O2/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
movq 0xb8(%rdi), %rcx
movq 0xb8(%rsi), %rdx
xorl %esi, %esi
movsd 0x3e511(%rip), %xmm0    # 0x93f68
cmpq %rax, %rsi
jge 0x55a91
movsd (%rcx,%rsi,8), %xmm1
ucomisd %xmm0, %xmm1
jne 0x55a69
jnp 0x55a8c
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
jmp 0x55a57
retq
// File: /workspace/github_cpp_makefile_star2_O2/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:
movl 0xcc(%rdi), %eax
movq 0xb8(%rdi), %rcx
xorl %edx, %edx
testl %eax, %eax
cmovlel %edx, %eax
movsd 0x3e4ba(%rip), %xmm1    # 0x93f68
cmpq %rdx, %rax
je 0x55ace
movsd (%rcx,%rdx,8), %xmm2
ucomisd %xmm1, %xmm2
jne 0x55ac0
jnp 0x55ac9
mulsd %xmm0, %xmm2
movsd %xmm2, (%rcx,%rdx,8)
incq %rdx
jmp 0x55aae
retq
nop
// File: /workspace/github_cpp_makefile_star2_O2/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
movq 0xb8(%rdi), %rcx
movq 0xb8(%rsi), %rdx
xorl %esi, %esi
movsd 0x3e479(%rip), %xmm0    # 0x93f68
cmpq %rax, %rsi
jge 0x55b29
movsd (%rcx,%rsi,8), %xmm1
ucomisd %xmm0, %xmm1
jne 0x55b01
jnp 0x55b24
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
jmp 0x55aef
retq
// File: /workspace/github_cpp_makefile_star2_O2/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
movq 0xb8(%rdi), %rcx
movq 0xb8(%rsi), %rdx
xorl %esi, %esi
movsd 0x3e41f(%rip), %xmm0    # 0x93f68
xorpd %xmm1, %xmm1
leaq 0x85064(%rip), %rdi     # 0xdabb8
movapd 0x3d4d4(%rip), %xmm2    # 0x93030
cmpq %rax, %rsi
jge 0x55bb7
movsd (%rcx,%rsi,8), %xmm3
ucomisd %xmm0, %xmm3
jne 0x55b6e
jnp 0x55b84
movsd (%rdx,%rsi,8), %xmm5
ucomisd %xmm0, %xmm5
movapd %xmm0, %xmm4
jne 0x55b89
jp 0x55b89
movsd %xmm4, (%rcx,%rsi,8)
incq %rsi
jmp 0x55b5c
ucomisd %xmm1, %xmm5
jne 0x55b9d
jp 0x55b9d
ucomisd %xmm1, %xmm3
jbe 0x55ba7
movsd (%rdi), %xmm4
jmp 0x55b7f
divsd %xmm5, %xmm3
movapd %xmm3, %xmm4
jmp 0x55b7f
ucomisd %xmm3, %xmm1
jbe 0x55b84
movsd (%rdi), %xmm4
xorpd %xmm2, %xmm4
jmp 0x55b7f
retq
// File: /workspace/github_cpp_makefile_star2_O2/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)
movq %rdi, %rbx
xorl %r14d, %r14d
movslq 0xcc(%rbx), %rax
cmpq %rax, %r14
jge 0x55c08
movq 0xb8(%rbx), %rax
movsd (%rax,%r14,8), %xmm0
ucomisd 0x3e380(%rip), %xmm0    # 0x93f68
jne 0x55bec
jnp 0x55c03
movsd (%rsp), %xmm1
callq 0xe800
movq 0xb8(%rbx), %rax
movsd %xmm0, (%rax,%r14,8)
incq %r14
jmp 0x55bc7
addq $0x8, %rsp
popq %rbx
popq %r14
retq
// File: /workspace/github_cpp_makefile_star2_O2/tomfunkhouser[P]gaps/pkgs/R2Shapes/R2Grid.cpp
// Function: gaps::R2Grid::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:
movl 0xcc(%rdi), %eax
movq 0xb8(%rsi), %rcx
movq 0xb8(%rdi), %rdx
xorl %esi, %esi
testl %eax, %eax
cmovlel %esi, %eax
movsd 0x3e335(%rip), %xmm0    # 0x93f68
cmpq %rsi, %rax
je 0x55c5f
movsd (%rcx,%rsi,8), %xmm2
xorpd %xmm1, %xmm1
ucomisd %xmm1, %xmm2
jne 0x55c49
jnp 0x55c55
ucomisd %xmm0, %xmm2
movapd %xmm0, %xmm1
jne 0x55c5a
jp 0x55c5a
movsd %xmm1, (%rdx,%rsi,8)
incq %rsi
jmp 0x55c33
retq
// File: /workspace/github_cpp_makefile_star2_O2/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
movq 0xb8(%rsi), %rcx
movq 0xb8(%rdi), %rdx
xorl %esi, %esi
xorpd %xmm0, %xmm0
movsd 0x3e2e5(%rip), %xmm1    # 0x93f68
cmpq %rax, %rsi
jge 0x55ca7
movsd (%rcx,%rsi,8), %xmm2
ucomisd %xmm0, %xmm2
jne 0x55c95
jnp 0x55ca2
ucomisd %xmm1, %xmm2
jne 0x55c9d
jnp 0x55ca2
movsd %xmm2, (%rdx,%rsi,8)
incq %rsi
jmp 0x55c83
retq
// File: /workspace/github_cpp_makefile_star2_O2/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:
movsd 0x3e2a8(%rip), %xmm4    # 0x93f58
movapd %xmm0, %xmm5
movsd 0x4460c(%rip), %xmm2    # 0x9a2c8
cmpeqsd %xmm0, %xmm2
movapd %xmm2, %xmm3
andnpd %xmm0, %xmm3
cmpneqpd %xmm4, %xmm0
movsd 0x445f2(%rip), %xmm6    # 0x9a2c8
cmpeqpd %xmm6, %xmm5
orpd %xmm0, %xmm5
movslq 0xcc(%rdi), %rax
movq 0xb8(%rdi), %rcx
movq 0xb8(%rsi), %rdx
movd %xmm5, %esi
cmpneqpd %xmm1, %xmm4
cmpeqpd %xmm1, %xmm6
orpd %xmm4, %xmm6
movd %xmm6, %edi
xorl %r8d, %r8d
movsd 0x3e253(%rip), %xmm0    # 0x93f68
movsd 0x445ab(%rip), %xmm4    # 0x9a2c8
cmpeqsd %xmm1, %xmm4
movapd %xmm4, %xmm5
andnpd %xmm1, %xmm5
cmpq %rax, %r8
jge 0x55d7a
movsd (%rcx,%r8,8), %xmm6
ucomisd %xmm0, %xmm6
jne 0x55d3d
jnp 0x55d75
movsd (%rdx,%r8,8), %xmm1
ucomisd %xmm0, %xmm1
jne 0x55d4b
jnp 0x55d75
ucomisd %xmm6, %xmm1
jae 0x55d61
testb $0x1, %dil
je 0x55d75
andpd %xmm4, %xmm1
orpd %xmm5, %xmm1
jmp 0x55d6f
testb $0x1, %sil
je 0x55d75
andpd %xmm2, %xmm1
orpd %xmm3, %xmm1
movsd %xmm1, (%rcx,%r8,8)
incq %r8
jmp 0x55d2a
retq
nop
// File: /workspace/github_cpp_makefile_star2_O2/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 0x51fb4
movq %rbx, %rdi
callq 0x5365e
movq %rbx, %rdi
callq 0x52a60
leaq 0x8(%rsp), %r14
movsd 0x3d255(%rip), %xmm1    # 0x93008
xorps %xmm0, %xmm0
xorps %xmm2, %xmm2
movq %r14, %rdi
callq 0x53990
movsd 0x3e19f(%rip), %xmm0    # 0x93f68
movq %r14, %rdi
movsd 0x3d234(%rip), %xmm1    # 0x93008
callq 0x55966
movq %r14, %rdi
callq 0x5365e
leaq 0x8(%rsp), %r14
movq %r14, %rdi
callq 0x52a60
movq %rbx, %rdi
movq %r14, %rsi
callq 0x55a38
movq %r14, %rdi
callq 0x5216c
addq $0xd8, %rsp
popq %rbx
popq %r14
retq
movq %rax, %rbx
leaq 0x8(%rsp), %rdi
callq 0x5216c
movq %rbx, %rdi
callq 0xe810
nop
// File: /workspace/github_cpp_makefile_star2_O2/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 0x5651f
jp 0x5651f
retq
pushq %r15
pushq %r14
pushq %rbx
subq $0x20, %rsp
movsd 0x3ccd0(%rip), %xmm2    # 0x93200
mulsd %xmm0, %xmm2
mulsd %xmm0, %xmm2
movapd 0x3cd30(%rip), %xmm1    # 0x93270
movapd %xmm2, 0x10(%rsp)
andpd %xmm2, %xmm1
movsd 0x3cc8e(%rip), %xmm2    # 0x931e0
ucomisd %xmm1, %xmm2
jae 0x565c2
movl %esi, %ebx
movq %rdi, %r14
movapd %xmm0, %xmm1
addsd %xmm0, %xmm1
mulsd %xmm0, %xmm1
movsd 0x3ca97(%rip), %xmm0    # 0x93008
divsd %xmm1, %xmm0
movsd %xmm0, 0x8(%rsp)
xorl %r15d, %r15d
movslq 0xcc(%r14), %rax
cmpq %rax, %r15
jge 0x565c2
movq 0xb8(%r14), %rax
movsd (%rax,%r15,8), %xmm0
testl %ebx, %ebx
je 0x5659f
mulsd %xmm0, %xmm0
divsd 0x10(%rsp), %xmm0
callq 0xe820
mulsd 0x8(%rsp), %xmm0
movq 0xb8(%r14), %rax
movsd %xmm0, (%rax,%r15,8)
incq %r15
jmp 0x5657e
addq $0x20, %rsp
popq %rbx
popq %r14
popq %r15
retq
// File: /workspace/github_cpp_makefile_star2_O2/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 %r15
pushq %r14
pushq %rbx
subq $0xd8, %rsp
movl %edx, %r14d
movl %esi, %ebp
movq %rdi, %rbx
cmpl %esi, 0xc0(%rdi)
jl 0x565f6
cmpl %r14d, 0xc4(%rbx)
jge 0x566e7
leaq 0x8(%rsp), %rdi
movq %rbx, %rsi
callq 0x51fb4
movl %ebp, 0xc0(%rbx)
movl %r14d, 0xc4(%rbx)
movl %ebp, 0xc8(%rbx)
imull %ebp, %r14d
movl %r14d, 0xcc(%rbx)
movq 0xb8(%rbx), %rdi
testq %rdi, %rdi
je 0x56639
callq 0xe5d0
movl 0xcc(%rbx), %r14d
xorl %r15d, %r15d
testl %r14d, %r14d
je 0x56659
movslq %r14d, %rax
shlq $0x3, %rax
testl %r14d, %r14d
pushq $-0x1
popq %rdi
cmovnsq %rax, %rdi
callq 0xe030
jmp 0x5665b
xorl %eax, %eax
movq %rax, 0xb8(%rbx)
testl %r14d, %r14d
cmovlel %r15d, %r14d
cmpq %r15, %r14
je 0x56678
andq $0x0, (%rax,%r15,8)
incq %r15
jmp 0x56669
movl 0xcc(%rsp), %ecx
movl 0xc8(%rsp), %edx
movq 0xc0(%rsp), %rsi
movslq 0xd0(%rsp), %rdi
movslq 0xc8(%rbx), %r8
xorl %r9d, %r9d
testl %edx, %edx
cmovlel %r9d, %edx
testl %ecx, %ecx
cmovlel %r9d, %ecx
shlq $0x3, %rdi
shlq $0x3, %r8
cmpq %rcx, %r9
je 0x566dd
xorl %r10d, %r10d
cmpq %r10, %rdx
je 0x566d2
movsd (%rsi,%r10,8), %xmm0
movsd %xmm0, (%rax,%r10,8)
incq %r10
jmp 0x566bc
incq %r9
addq %rdi, %rsi
addq %r8, %rax
jmp 0x566b4
leaq 0x8(%rsp), %rdi
callq 0x5216c
addq $0xd8, %rsp
popq %rbx
popq %r14
popq %r15
popq %rbp
retq
movq %rax, %rbx
leaq 0x8(%rsp), %rdi
callq 0x5216c
movq %rbx, %rdi
callq 0xe810
// File: /workspace/github_cpp_makefile_star2_O2/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 0x56aaf
testl %edx, %edx
js 0x56aaf
cmpl %esi, 0xc0(%rdi)
jle 0x56aaf
cmpl %edx, 0xc4(%rdi)
jle 0x56aaf
cmpl $0x2, %ecx
je 0x56ab0
cmpl $0x1, %ecx
je 0x56a65
testl %ecx, %ecx
jne 0x56ac9
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 0x3d519(%rip), %xmm1    # 0x93f68
movapd %xmm1, %xmm3
andnpd %xmm2, %xmm3
andpd %xmm0, %xmm1
orpd %xmm3, %xmm1
movlpd %xmm1, (%rax,%rcx,8)
retq
movapd 0x3c5c3(%rip), %xmm1    # 0x93030
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 0x3d4ce(%rip), %xmm2    # 0x93f68
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 0x41c52(%rip), %rdi     # 0x98722
xorl %eax, %eax
jmp 0x680f0
nop
// File: /workspace/github_cpp_makefile_star2_O2/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 0x56aff
addq $0x48, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
ucomisd %xmm1, %xmm3
ja 0x56af0
movq %rdi, %r14
movl 0xc0(%rdi), %eax
leal -0x1(%rax), %ecx
cvtsi2sd %ecx, %xmm3
ucomisd %xmm3, %xmm0
ja 0x56af0
movl 0xc4(%r14), %ecx
leal -0x1(%rcx), %edx
cvtsi2sd %edx, %xmm3
ucomisd %xmm3, %xmm1
ja 0x56af0
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 0x3c48c(%rip), %xmm4    # 0x93008
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 0x569e8
movsd 0x18(%rsp), %xmm0
mulsd 0x30(%rsp), %xmm0
movq %r14, %rdi
movl %r13d, %esi
movl %r15d, %edx
movl %ebx, %ecx
callq 0x569e8
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 0x569e8
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 0x569e8
nop
// File: /workspace/github_cpp_makefile_star2_O2/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), %r12
movq %r12, %rdi
movq %rdx, %rsi
movq %rbx, %rdx
callq 0x5f7c9
movq %r12, %rdi
callq 0x5f958
addsd 0x3c3a2(%rip), %xmm0    # 0x93008
cvttsd2si %xmm0, %ebp
cvttpd2dq %xmm0, %xmm0
cvtdq2pd %xmm0, %xmm0
movaps %xmm0, 0x10(%rsp)
leaq 0x28(%rsp), %rdi
movq %r12, %rsi
callq 0x5fde7
movsd (%rsp), %xmm0
subsd 0x8(%rsp), %xmm0
divsd 0x10(%rsp), %xmm0
movsd %xmm0, (%rsp)
xorl %r15d, %r15d
xorpd %xmm0, %xmm0
leaq 0x38(%rsp), %r12
leaq 0x48(%rsp), %r13
cmpl %ebp, %r15d
jg 0x56d12
movapd %xmm0, %xmm1
mulsd (%rsp), %xmm1
addsd 0x8(%rsp), %xmm1
movsd %xmm1, 0x20(%rsp)
movq %r12, %rdi
leaq 0x28(%rsp), %rsi
movsd %xmm0, 0x10(%rsp)
movsd 0x10(%rsp), %xmm0
callq 0x5fbe5
movq %r13, %rdi
movq %rbx, %rsi
movq %r12, %rdx
callq 0x5f7b5
movq %r14, %rdi
movq %r13, %rsi
movsd 0x20(%rsp), %xmm0
xorl %edx, %edx
callq 0x5ad28
movsd 0x10(%rsp), %xmm0
addsd 0x3c2fb(%rip), %xmm0    # 0x93008
incl %r15d
jmp 0x56cab
addq $0x68, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
nop
// File: /workspace/github_cpp_makefile_star2_O2/tomfunkhouser[P]gaps/pkgs/R2Shapes/R2Grid.cpp
// Function: gaps::R2Grid::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 0x3d23e(%rip), %xmm0    # 0x93f68
jne 0x56d32
jnp 0x56e5f
ucomisd 0x3d22e(%rip), %xmm1    # 0x93f68
jne 0x56d42
jnp 0x56e5f
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x38, %rsp
movl %ecx, %ebx
movq %rdi, %r14
xorl %eax, %eax
cmpq $0x2, %rax
je 0x56d87
movl (%rdx,%rax,4), %ecx
movl (%rsi,%rax,4), %edi
subl %edi, %ecx
movl %ecx, %r8d
negl %r8d
cmovsl %ecx, %r8d
sarl $0x1f, %ecx
orl $0x1, %ecx
movl %r8d, 0x10(%rsp,%rax,4)
movl %ecx, 0x20(%rsp,%rax,4)
movl %edi, 0x8(%rsp,%rax,4)
incq %rax
jmp 0x56d57
movl 0x10(%rsp), %eax
movl 0x14(%rsp), %ecx
xorl %r15d, %r15d
cmpl %eax, %ecx
setg %r15b
movl 0x10(%rsp,%r15,4), %ebp
testl %ebp, %ebp
je 0x56e33
xorl %r12d, %r12d
cmpl %eax, %ecx
setle %r12b
andq $0x0, 0x18(%rsp)
cvtsi2sd %ebp, %xmm2
subsd %xmm0, %xmm1
divsd %xmm2, %xmm1
xorl %r13d, %r13d
shll $0x2, %r12d
movsd %xmm1, 0x28(%rsp)
cmpl %ebp, %r13d
jg 0x56e51
movl 0x8(%rsp), %esi
movl 0xc(%rsp), %edx
movq %r14, %rdi
movl %ebx, %ecx
movsd %xmm0, 0x30(%rsp)
callq 0x569e8
movsd 0x28(%rsp), %xmm1
movsd 0x30(%rsp), %xmm0
movl 0x18(%rsp,%r12), %ecx
addl 0x10(%rsp,%r12), %ecx
leal (,%r15,4), %eax
movl 0x20(%rsp,%rax), %edx
addl %edx, 0x8(%rsp,%rax)
movl 0x20(%rsp,%r12), %eax
imull %ecx, %eax
cltd
idivl %ebp
addl %eax, 0x8(%rsp,%r12)
movl %ecx, %eax
cltd
idivl %ebp
movl %edx, 0x18(%rsp,%r12)
addsd %xmm1, %xmm0
incl %r13d
jmp 0x56dcd
addsd %xmm1, %xmm0
mulsd 0x3c1d1(%rip), %xmm0    # 0x93010
movl 0x8(%rsp), %esi
movl 0xc(%rsp), %edx
movq %r14, %rdi
movl %ebx, %ecx
callq 0x569e8
addq $0x38, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
// File: /workspace/github_cpp_makefile_star2_O2/tomfunkhouser[P]gaps/pkgs/R2Shapes/R2Grid.cpp
// Function: gaps::R2Grid::RasterizeGridBox(int const*, int const*, double, int)
void R2Grid::
RasterizeGridBox(const int p1[2], const int p2[2], RNScalar value, int operation)
{
  // Check value
  if (value == R2_GRID_UNKNOWN_VALUE) return;

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

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

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x18, %rsp
movsd %xmm0, 0x10(%rsp)
ucomisd 0x3d0ec(%rip), %xmm0    # 0x93f68
jne 0x56e80
jnp 0x56eff
movq %rdi, %r14
movl (%rsi), %eax
xorl %ebp, %ebp
testl %eax, %eax
cmovgl %eax, %ebp
movl 0xc0(%rdi), %eax
cmpl %eax, %ebp
jge 0x56eff
movl %ecx, %ebx
movl (%rdx), %ecx
testl %ecx, %ecx
js 0x56eff
leal -0x1(%rax), %edi
cmpl %eax, %ecx
cmovbl %ecx, %edi
movl %edi, 0xc(%rsp)
movl 0x4(%rsi), %eax
xorl %r13d, %r13d
testl %eax, %eax
cmovgl %eax, %r13d
movl 0xc4(%r14), %eax
cmpl %eax, %r13d
jge 0x56eff
movl 0x4(%rdx), %ecx
testl %ecx, %ecx
js 0x56eff
leal -0x1(%rax), %r12d
cmpl %eax, %ecx
cmovbl %ecx, %r12d
cmpl 0xc(%rsp), %ebp
jg 0x56eff
movl %r13d, %r15d
cmpl %r12d, %r15d
jg 0x56efb
movq %r14, %rdi
movl %ebp, %esi
movl %r15d, %edx
movsd 0x10(%rsp), %xmm0
movl %ebx, %ecx
callq 0x569e8
incl %r15d
jmp 0x56edc
incl %ebp
jmp 0x56ed3
addq $0x18, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
// File: /workspace/github_cpp_makefile_star2_O2/tomfunkhouser[P]gaps/pkgs/R2Shapes/R2Grid.cpp
// Function: gaps::CompareScanLineCrossings(void const*, void const*)
static int CompareScanLineCrossings(const void *data1, const void *data2)
{
  ScanLineCrossing *crossing1 = (ScanLineCrossing *) data1;
  ScanLineCrossing *crossing2 = (ScanLineCrossing *) data2;
  if (RNIsLess(crossing1->x, crossing2->x)) return -1;
  else if (RNIsGreater(crossing1->x, crossing2->x)) return 1;
  else if (crossing1->side < crossing2->side) return -1;
  else if (crossing1->side > crossing2->side) return 1;
  else return 0;
}

// Assembly:
movsd (%rdi), %xmm0
leaq 0x83535(%rip), %rax     # 0xdaba8
movsd (%rax), %xmm1
subsd (%rsi), %xmm0
movapd 0x3b9ad(%rip), %xmm2    # 0x93030
xorpd %xmm1, %xmm2
pushq $-0x1
popq %rax
ucomisd %xmm0, %xmm2
ja 0x576a4
ucomisd %xmm1, %xmm0
ja 0x576a5
movl 0x8(%rsi), %ecx
cmpl %ecx, 0x8(%rdi)
jl 0x576a4
setg %al
movzbl %al, %eax
retq
pushq $0x1
popq %rax
retq
nop
// File: /workspace/github_cpp_makefile_star2_O2/tomfunkhouser[P]gaps/pkgs/R2Shapes/R2Grid.cpp
// Function: gaps::R2Grid::RasterizeWorldPolygon(gaps::R2Polygon const&, double, int)
void R2Grid::
RasterizeWorldPolygon(const R2Polygon& polygon, RNScalar value, int operation) 
{
  // Rasterize polygon into grid coordinates
  R2Polygon transformed_polygon(polygon);
  transformed_polygon.Transform(WorldToGridTransformation());
  RasterizeGridPolygon(transformed_polygon, value, operation);
}

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

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

// Assembly:
movl 0xcc(%rdi), %eax
movq 0xb8(%rdi), %rcx
movq 0xb8(%rsi), %rdx
xorl %esi, %esi
testl %eax, %eax
cmovlel %esi, %eax
xorpd %xmm0, %xmm0
movsd 0x3c82d(%rip), %xmm1    # 0x93f68
cmpq %rsi, %rax
je 0x57767
movsd (%rcx,%rsi,8), %xmm2
ucomisd %xmm1, %xmm2
jne 0x5774d
jnp 0x57762
movsd (%rdx,%rsi,8), %xmm3
ucomisd %xmm1, %xmm3
jne 0x5775a
jnp 0x57762
mulsd %xmm3, %xmm2
addsd %xmm2, %xmm0
incq %rsi
jmp 0x5773b
retq
// File: /workspace/github_cpp_makefile_star2_O2/tomfunkhouser[P]gaps/pkgs/R2Shapes/R2Grid.cpp
// Function: gaps::R2Grid::L1Distance(gaps::R2Grid const&) const
RNScalar R2Grid::
L1Distance(const R2Grid& grid) const
{
  // Compute distance between this and grid
  RNScalar distance = 0.0;
  for (int i = 0; i < grid_size; i++) {
    if (grid_values[i] == R2_GRID_UNKNOWN_VALUE) continue;
    if (grid.grid_values[i] == R2_GRID_UNKNOWN_VALUE) continue;
    distance += fabs(grid_values[i] - grid.grid_values[i]);
  }
  return distance;
}

// Assembly:
movl 0xcc(%rdi), %eax
movq 0xb8(%rdi), %rcx
xorl %edx, %edx
testl %eax, %eax
cmovlel %edx, %eax
movq 0xb8(%rsi), %rsi
xorpd %xmm0, %xmm0
movsd 0x3c259(%rip), %xmm1    # 0x93f68
movapd 0x3b559(%rip), %xmm2    # 0x93270
cmpq %rdx, %rax
je 0x57d47
movsd (%rcx,%rdx,8), %xmm3
ucomisd %xmm1, %xmm3
jne 0x57d29
jnp 0x57d42
movsd (%rsi,%rdx,8), %xmm4
ucomisd %xmm1, %xmm4
jne 0x57d36
jnp 0x57d42
subsd %xmm4, %xmm3
andpd %xmm2, %xmm3
addsd %xmm3, %xmm0
incq %rdx
jmp 0x57d17
retq
// File: /workspace/github_cpp_makefile_star2_O2/tomfunkhouser[P]gaps/pkgs/R2Shapes/R2Grid.cpp
// Function: gaps::R2Grid::L2DistanceSquared(gaps::R2Grid const&) const
RNScalar R2Grid::
L2DistanceSquared(const R2Grid& grid) const
{
  // Compute distance between this and grid
  RNScalar distance_squared = 0.0;
  for (int i = 0; i < grid_size; i++) {
    if (grid_values[i] == R2_GRID_UNKNOWN_VALUE) continue;
    if (grid.grid_values[i] == R2_GRID_UNKNOWN_VALUE) continue;
    RNScalar delta = (grid_values[i] - grid.grid_values[i]);
    distance_squared += delta * delta;
  }

  // Return result
  return distance_squared;
}

// Assembly:
movl 0xcc(%rdi), %eax
movq 0xb8(%rdi), %rcx
movq 0xb8(%rsi), %rdx
xorl %esi, %esi
testl %eax, %eax
cmovlel %esi, %eax
xorpd %xmm0, %xmm0
movsd 0x3c1f9(%rip), %xmm1    # 0x93f68
cmpq %rsi, %rax
je 0x57d9f
movsd (%rcx,%rsi,8), %xmm2
ucomisd %xmm1, %xmm2
jne 0x57d81
jnp 0x57d9a
movsd (%rdx,%rsi,8), %xmm3
ucomisd %xmm1, %xmm3
jne 0x57d8e
jnp 0x57d9a
subsd %xmm3, %xmm2
mulsd %xmm2, %xmm2
addsd %xmm2, %xmm0
incq %rsi
jmp 0x57d6f
retq
// File: /workspace/github_cpp_makefile_star2_O2/tomfunkhouser[P]gaps/pkgs/R2Shapes/R2Grid.cpp
// Function: gaps::R2Grid::SetWorldToGridTransformation(gaps::R2Point const&, gaps::R2Vector const&, double)
void R2Grid::
SetWorldToGridTransformation(const R2Point& world_origin, const R2Vector& world_xaxis, RNLength world_radius)
{
  // Just checking
  if (grid_size == 0) return;

  // Compute grid origin
  R2Vector grid_diagonal(XResolution()-1, YResolution()-1);
  R2Vector grid_origin = 0.5 * grid_diagonal;
  RNScalar grid_radius = grid_origin[0];
  if (grid_origin[1] < grid_radius) grid_radius = grid_origin[1];

  // Compute scale
  if (RNIsZero(world_radius)) return;
  if (RNIsZero(grid_radius)) return;
  RNScalar scale = grid_radius / world_radius;

  // Compute rotation
  RNAngle rotation = R2InteriorAngle(world_xaxis, R2posx_vector);
  if (world_xaxis.Y() < 0.0) rotation = RN_TWO_PI - rotation;

  // Compute world-to-grid transformation
  R2Affine affine(R2identity_affine);
  affine.Translate(grid_origin);
  affine.Rotate(-rotation);
  affine.Scale(scale);
  affine.Translate(-(world_origin.Vector()));

  // Set transformations
  SetWorldToGridTransformation(affine);
}

// Assembly:
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0xd0, %rsp
cmpl $0x0, 0xcc(%rdi)
je 0x57f33
movaps %xmm0, %xmm2
movq %rdx, %r15
movq %rsi, %r14
movq %rdi, %rbx
movl 0xc0(%rdi), %eax
decl %eax
cvtsi2sd %eax, %xmm0
movl 0xc4(%rdi), %eax
decl %eax
cvtsi2sd %eax, %xmm1
leaq 0x68(%rsp), %r12
movq %r12, %rdi
movsd %xmm2, (%rsp)
callq 0x5f8b4
leaq 0x58(%rsp), %r13
movsd 0x3b210(%rip), %xmm0    # 0x93010
movq %r13, %rdi
movq %r12, %rsi
callq 0x5fbe5
movsd (%rsp), %xmm2
movsd 0x8(%r13), %xmm3
minsd (%r13), %xmm3
leaq 0x82d85(%rip), %rax     # 0xdaba8
movsd (%rax), %xmm0
movapd 0x3b201(%rip), %xmm1    # 0x93030
xorpd %xmm0, %xmm1
ucomisd %xmm1, %xmm2
jb 0x57e43
ucomisd %xmm2, %xmm0
jae 0x57f33
ucomisd %xmm1, %xmm3
jb 0x57e53
ucomisd %xmm3, %xmm0
jae 0x57f33
movsd %xmm3, 0x8(%rsp)
leaq 0x42b78(%rip), %rsi     # 0x9a9d8
movq %r15, %rdi
callq 0x63ecc
movapd %xmm0, 0x10(%rsp)
movsd 0x8(%r15), %xmm0
movapd %xmm0, 0x20(%rsp)
leaq 0x4850e7(%rip), %rsi    # 0x4dcf68
leaq 0x78(%rsp), %rdi
callq 0x5ad70
leaq 0x80(%rsp), %r15
leaq 0x58(%rsp), %rsi
movq %r15, %rdi
callq 0x5de7a
leaq 0x430c1(%rip), %rax     # 0x9af68
movsd (%rax), %xmm2
movapd 0x10(%rsp), %xmm3
subsd %xmm3, %xmm2
xorpd %xmm1, %xmm1
movapd 0x20(%rsp), %xmm0
cmpltsd %xmm1, %xmm0
andpd %xmm0, %xmm2
andnpd %xmm3, %xmm0
orpd %xmm2, %xmm0
xorpd 0x3b158(%rip), %xmm0    # 0x93030
movq %r15, %rdi
callq 0x5df98
movsd 0x8(%rsp), %xmm0
divsd (%rsp), %xmm0
movq %r15, %rdi
callq 0x5df40
leaq 0x38(%rsp), %rdi
movq %r14, %rsi
callq 0x51538
leaq 0x48(%rsp), %rdi
leaq 0x38(%rsp), %rsi
callq 0x5fd59
leaq 0x48(%rsp), %rsi
movq %r15, %rdi
callq 0x5de7a
leaq 0x78(%rsp), %rsi
movq %rbx, %rdi
callq 0x51a6a
leaq 0x78(%rsp), %rdi
callq 0x5d61e
addq $0xd0, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
retq
jmp 0x57f46
movq %rax, %rbx
leaq 0x78(%rsp), %rdi
callq 0x5d61e
movq %rbx, %rdi
callq 0xe810
nop
// File: /workspace/github_cpp_makefile_star2_O2/tomfunkhouser[P]gaps/pkgs/R2Shapes/R2Grid.cpp
// Function: gaps::R2Grid::Capture()
void R2Grid::
Capture(void)
{
  // Check image size
  GLint viewport[4];
  glGetIntegerv(GL_VIEWPORT, viewport);
  assert(grid_resolution[0] >= viewport[2]);
  assert(grid_resolution[1] >= viewport[3]);
  assert(grid_values);

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

  // Read pixels from frame buffer 
  glReadPixels(0, 0, grid_resolution[0], grid_resolution[1], GL_LUMINANCE, GL_FLOAT, pixels); 

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

  // Delete pixels
  delete [] pixels;
}

// Assembly:
pushq %r15
pushq %r14
pushq %rbx
subq $0x20, %rsp
movq %rdi, %r14
leaq 0x10(%rsp), %rsi
movl $0xba2, %edi            # imm = 0xBA2
callq 0xe410
movslq 0xcc(%r14), %rax
leaq (,%rax,4), %rcx
testq %rax, %rax
pushq $-0x1
popq %rdi
cmovnsq %rcx, %rdi
callq 0xe030
movq %rax, %rbx
movl 0xc0(%r14), %edx
movl 0xc4(%r14), %ecx
movq %rax, (%rsp)
xorl %r15d, %r15d
xorl %edi, %edi
xorl %esi, %esi
movl $0x1909, %r8d           # imm = 0x1909
movl $0x1406, %r9d           # imm = 0x1406
callq 0xe210
movslq 0xcc(%r14), %rax
movq 0xb8(%r14), %rcx
cmpq %rax, %r15
jge 0x58036
cvtss2sd (%rbx,%r15,4), %xmm0
movsd %xmm0, (%rcx,%r15,8)
incq %r15
jmp 0x58020
movq %rbx, %rdi
callq 0xe5d0
addq $0x20, %rsp
popq %rbx
popq %r14
popq %r15
retq