// File: /workspace/github_cpp_makefile_star2_O3/tomfunkhouser[P]gaps/pkgs/R3Shapes/R3Grid.cpp
// Function: gaps::R3Grid::Resample(int, int, int)
void R3Grid::
Resample(int xresolution, int yresolution, int zresolution)
{
  // Resample grid values at new resolution
  RNScalar *new_grid_values = NULL;
  int new_grid_size = xresolution * yresolution * zresolution;
  if (new_grid_size > 0) {
    new_grid_values = new RNScalar [ new_grid_size ];
    assert(new_grid_values);
    RNScalar *new_grid_valuesp = new_grid_values;
    RNScalar xscale = (RNScalar) (grid_resolution[0]-1) / (RNScalar) (xresolution - 1);
    RNScalar yscale = (RNScalar) (grid_resolution[1]-1) / (RNScalar) (yresolution - 1);
    RNScalar zscale = (RNScalar) (grid_resolution[2]-1) / (RNScalar) (zresolution - 1);
    for (int k = 0; k < zresolution; k++) {
      RNScalar z = (k == zresolution-1) ? grid_resolution[2]-1 : k * zscale;
      for (int j = 0; j < yresolution; j++) {
        RNScalar y = (j == yresolution-1) ? grid_resolution[1]-1 : j * yscale;
        for (int i = 0; i < xresolution; i++) {
          RNScalar x = (i == xresolution-1) ? grid_resolution[0]-1 : i * xscale;
          *(new_grid_valuesp++) = GridValue(x, y, z);
        }
      }
    }
  }

  // Reset grid variables
  grid_resolution[0] = xresolution;
  grid_resolution[1] = yresolution;
  grid_resolution[2] = zresolution;
  grid_row_size = xresolution;
  grid_sheet_size = grid_row_size * yresolution;
  grid_size = grid_sheet_size * zresolution;
  if (grid_values) delete [] grid_values;
  grid_values = new_grid_values;

  // Reset transformations
  SetWorldToGridTransformation(WorldBox());
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x118, %rsp            # imm = 0x118
movl %ecx, %r14d
movl %esi, %r15d
movq %rdi, %rbx
movq %rdx, (%rsp)
movl %edx, %ebp
imull %esi, %ebp
movl %ebp, %r12d
imull %ecx, %r12d
testl %r12d, %r12d
jle 0x33712
movl %r12d, %edi
shlq $0x3, %rdi
callq 0xe030
movq %rax, %r13
testl %r14d, %r14d
jle 0x33715
movl %r12d, 0x10(%rsp)
movl %ebp, 0x14(%rsp)
movl 0x238(%rbx), %eax
decl %eax
cvtsi2sd %eax, %xmm1
leal -0x1(%r15), %eax
cvtsi2sd %eax, %xmm0
movl 0x23c(%rbx), %eax
decl %eax
cvtsi2sd %eax, %xmm2
movsd %xmm1, 0x70(%rsp)
movapd %xmm1, %xmm3
movq (%rsp), %rax
movq %r13, %rbp
decl %eax
movl %eax, 0x1c(%rsp)
xorps %xmm1, %xmm1
cvtsi2sd %eax, %xmm1
divsd %xmm0, %xmm3
movsd %xmm3, 0x68(%rsp)
movsd %xmm2, 0x58(%rsp)
divsd %xmm1, %xmm2
movsd %xmm2, 0x50(%rsp)
movl 0x240(%rbx), %eax
decl %eax
xorps %xmm1, %xmm1
cvtsi2sd %eax, %xmm1
leal -0x1(%r14), %eax
movl %eax, 0x18(%rsp)
xorps %xmm0, %xmm0
cvtsi2sd %eax, %xmm0
movsd %xmm1, 0x40(%rsp)
divsd %xmm0, %xmm1
movsd %xmm1, 0x38(%rsp)
xorl %r13d, %r13d
xorpd %xmm0, %xmm0
movsd %xmm0, 0x8(%rsp)
movq %rbp, 0x30(%rsp)
movq %r14, 0x48(%rsp)
movsd 0x40(%rsp), %xmm0
movsd %xmm0, 0x20(%rsp)
cmpl 0x18(%rsp), %r13d
je 0x33630
movsd 0x38(%rsp), %xmm0
mulsd 0x8(%rsp), %xmm0
movsd %xmm0, 0x20(%rsp)
cmpl $0x0, (%rsp)
jle 0x336dd
xorl %r14d, %r14d
xorpd %xmm0, %xmm0
movsd 0x58(%rsp), %xmm1
movsd %xmm1, 0x28(%rsp)
cmpl 0x1c(%rsp), %r14d
je 0x33664
movsd 0x50(%rsp), %xmm1
mulsd %xmm0, %xmm1
movsd %xmm1, 0x28(%rsp)
movsd %xmm0, 0x60(%rsp)
testl %r15d, %r15d
jle 0x336c2
xorpd %xmm1, %xmm1
movl %r15d, %r12d
movsd 0x70(%rsp), %xmm0
cmpl $0x1, %r12d
je 0x3368c
movsd 0x68(%rsp), %xmm0
mulsd %xmm1, %xmm0
movq %rbx, %rdi
movsd %xmm1, 0x78(%rsp)
movsd 0x28(%rsp), %xmm1
movsd 0x20(%rsp), %xmm2
callq 0x2f0d6
movsd 0x78(%rsp), %xmm1
movsd %xmm0, (%rbp)
addq $0x8, %rbp
addsd 0x6e97b(%rip), %xmm1    # 0xa2038
decl %r12d
jne 0x33676
movsd 0x60(%rsp), %xmm0
addsd 0x6e968(%rip), %xmm0    # 0xa2038
incl %r14d
cmpl (%rsp), %r14d
jne 0x33641
movsd 0x8(%rsp), %xmm0
addsd 0x6e94d(%rip), %xmm0    # 0xa2038
movsd %xmm0, 0x8(%rsp)
incl %r13d
movq 0x48(%rsp), %r14
cmpl %r14d, %r13d
jne 0x3360b
movl 0x14(%rsp), %ebp
movl 0x10(%rsp), %r12d
movq 0x30(%rsp), %r13
jmp 0x33715
xorl %r13d, %r13d
movl %r15d, 0x238(%rbx)
movq (%rsp), %rax
movl %eax, 0x23c(%rbx)
movl %r14d, 0x240(%rbx)
movl %r15d, 0x244(%rbx)
movl %ebp, 0x248(%rbx)
movl %r12d, 0x24c(%rbx)
movq 0x230(%rbx), %rdi
testq %rdi, %rdi
je 0x33752
callq 0xe5b0
movq %r13, 0x230(%rbx)
leaq 0x100(%rsp), %r14
xorpd %xmm0, %xmm0
xorpd %xmm1, %xmm1
xorpd %xmm2, %xmm2
movq %r14, %rdi
callq 0x3c532
movl 0x238(%rbx), %eax
decl %eax
xorps %xmm0, %xmm0
cvtsi2sd %eax, %xmm0
movl 0x23c(%rbx), %eax
decl %eax
xorps %xmm1, %xmm1
cvtsi2sd %eax, %xmm1
movl 0x240(%rbx), %eax
decl %eax
xorps %xmm2, %xmm2
cvtsi2sd %eax, %xmm2
leaq 0xe8(%rsp), %r15
movq %r15, %rdi
callq 0x3c532
movsd (%r14), %xmm0
movsd 0x8(%r14), %xmm1
movsd 0x10(%r14), %xmm2
leaq 0xd0(%rsp), %r14
movq %r14, %rdi
callq 0x3c532
movq %r14, %rdi
movq %rbx, %rsi
callq 0x3ce48
movsd (%r15), %xmm0
movsd 0x8(%r15), %xmm1
movsd 0x10(%r15), %xmm2
leaq 0xb8(%rsp), %r15
movq %r15, %rdi
callq 0x3c532
movq %r15, %rdi
movq %rbx, %rsi
callq 0x3ce48
leaq 0x80(%rsp), %r12
movq %r12, %rdi
movq %r14, %rsi
movq %r15, %rdx
callq 0x27326
movq %rbx, %rdi
movq %r12, %rsi
callq 0x2e67a
leaq 0x80(%rsp), %rdi
callq 0x280f4
addq $0x118, %rsp            # imm = 0x118
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq %rax, %rbx
leaq 0x80(%rsp), %rdi
callq 0x280f4
movq %rbx, %rdi
callq 0xe7e0