// File: /workspace/github_cpp_makefile_star2_O1/tomfunkhouser[P]gaps/pkgs/R2Shapes/R2Grid.cpp
// Function: gaps::R2Grid::PointSymmetryTransform(int)
void R2Grid::
PointSymmetryTransform(int radius)
{
  // Make copy of grid
  R2Grid copy(*this);
  copy.Normalize();

  // Brute force for now
  for (int j = 0; j < grid_resolution[1]; j++) {
    int y_radius = (j < grid_resolution[1]/2) ? j : grid_resolution[1]-1 - j;
    if ((radius > 0) && (y_radius > radius)) y_radius = radius;
    for (int i = 0; i < grid_resolution[0]; i++) {
      int x_radius = (i < grid_resolution[0]/2) ? i : grid_resolution[0]-1 - i;
      if ((radius > 0) && (x_radius > radius)) x_radius = radius;
      RNScalar dot = 0;
      RNScalar norm = 0;
      for (int t = -y_radius; t <= y_radius; t++) {
        for (int s = -x_radius; s <= x_radius; s++) {
          RNScalar value1 = GridValue(i-s, j-t);
          RNScalar value2 = GridValue(i+s, j+t);
          dot += 2 * value1 * value2;
          norm += value1 * value1; 
          norm += value2 * value2; 
        }
      }
      if (norm > 0) dot /= norm;
      SetGridValue(i, j, dot);
    }
  }
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x148, %rsp            # imm = 0x148
movl %esi, 0x4(%rsp)
movq %rdi, %rbx
leaq 0x78(%rsp), %r15
movq %r15, %rdi
movq %rbx, %rsi
callq 0x5a63c
movq %r15, %rdi
callq 0x5b34a
movq %rbx, 0x18(%rsp)
movl 0xc4(%rbx), %eax
movq %rax, 0x8(%rsp)
testl %eax, %eax
jle 0x5f362
movq 0x8(%rsp), %rax
shrl %eax
movq %rax, 0x30(%rsp)
movq 0x18(%rsp), %rcx
movl 0xc0(%rcx), %edx
movl %edx, %eax
shrl $0x1f, %eax
movq %rdx, 0x10(%rsp)
addl %edx, %eax
sarl %eax
movq 0xb8(%rcx), %rdx
movq %rdx, 0x28(%rsp)
movslq 0xc8(%rcx), %rcx
movq %rcx, 0x20(%rsp)
cltq
movq %rax, 0x38(%rsp)
xorl %r9d, %r9d
movabsq $-0x100000000, %r11     # imm = 0xFFFFFFFF00000000
cmpl $0x0, 0x10(%rsp)
jle 0x5f354
movl %r9d, %eax
notl %eax
addl 0x8(%rsp), %eax
cmpq 0x30(%rsp), %r9
cmovbl %r9d, %eax
movl 0x4(%rsp), %ecx
cmpl %ecx, %eax
movl %ecx, %edx
cmovll %eax, %edx
testl %ecx, %ecx
cmovlel %eax, %edx
movl %edx, %eax
negl %eax
movq %r9, %rcx
imulq 0x20(%rsp), %rcx
movslq %eax, %rsi
movq %rdx, 0x58(%rsp)
leal 0x1(%rdx), %ebp
movq 0x28(%rsp), %rax
leaq (%rax,%rcx,8), %rax
movq %rax, 0x50(%rsp)
movq %rsi, 0x48(%rsp)
leaq (%r9,%rsi), %rax
shlq $0x3, %rax
movq %rax, 0x40(%rsp)
xorl %edi, %edi
xorl %esi, %esi
xorl %edx, %edx
cmpl $0x0, 0x58(%rsp)
movq %rdi, 0x70(%rsp)
movq %rsi, 0x68(%rsp)
movq %rdx, 0x60(%rsp)
js 0x5f2f7
movl %edx, %ecx
notl %ecx
addl 0x10(%rsp), %ecx
cmpq 0x38(%rsp), %rdx
cmovll %edx, %ecx
movl 0x4(%rsp), %eax
cmpl %eax, %ecx
movl %eax, %r10d
cmovll %ecx, %r10d
testl %eax, %eax
cmovlel %ecx, %r10d
movl %r10d, %ecx
negl %ecx
movq 0x18(%rsp), %rax
movq 0xb8(%rax), %r8
movslq 0xc8(%rax), %r12
movslq %ecx, %rcx
movq 0x40(%rsp), %rdx
imulq %r12, %rdx
addq %rsi, %rdx
leaq (%rdx,%rcx,8), %rsi
addq %r8, %rsi
leaq (,%r12,8), %r14
shlq $0x20, %rcx
movq %rdi, %rax
subq %rcx, %rax
leal (%r10,%r10), %r15d
incq %r15
xorpd %xmm2, %xmm2
movq 0x48(%rsp), %rdx
xorpd %xmm0, %xmm0
testl %r10d, %r10d
js 0x5f2e3
movq %r9, %rcx
subq %rdx, %rcx
imulq %r12, %rcx
leaq (%r8,%rcx,8), %rbx
movq %rax, %r13
xorl %ecx, %ecx
movq %r13, %rdi
sarq $0x1d, %rdi
movsd (%rbx,%rdi), %xmm3
movsd (%rsi,%rcx,8), %xmm1
movapd %xmm3, %xmm4
addsd %xmm3, %xmm4
mulsd %xmm1, %xmm4
addsd %xmm4, %xmm0
mulsd %xmm3, %xmm3
addsd %xmm2, %xmm3
mulsd %xmm1, %xmm1
addsd %xmm3, %xmm1
incq %rcx
addq %r11, %r13
movapd %xmm1, %xmm2
cmpl %ecx, %r15d
jne 0x5f2a1
jmp 0x5f2e7
movapd %xmm2, %xmm1
incq %rdx
addq %r14, %rsi
movapd %xmm1, %xmm2
cmpl %edx, %ebp
jne 0x5f289
jmp 0x5f2ff
xorpd %xmm0, %xmm0
xorpd %xmm1, %xmm1
movapd %xmm0, %xmm2
divsd %xmm1, %xmm2
xorpd %xmm3, %xmm3
cmpltsd %xmm1, %xmm3
andpd %xmm3, %xmm2
andnpd %xmm0, %xmm3
orpd %xmm2, %xmm3
movq 0x50(%rsp), %rax
movq 0x60(%rsp), %rdx
movlpd %xmm3, (%rax,%rdx,8)
incq %rdx
movq 0x68(%rsp), %rsi
addq $0x8, %rsi
movabsq $0x100000000, %rax      # imm = 0x100000000
movq 0x70(%rsp), %rdi
addq %rax, %rdi
cmpq 0x10(%rsp), %rdx
jne 0x5f1f8
incq %r9
cmpq 0x8(%rsp), %r9
jne 0x5f18d
leaq 0x78(%rsp), %rdi
callq 0x5a814
addq $0x148, %rsp            # imm = 0x148
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq