// File: /workspace/github_cpp_makefile_star2_O2/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 $0xd8, %rsp
movl %ecx, %r14d
movl %edx, %r12d
movl %esi, %r15d
movq %rdi, %rbx
movl %edx, %eax
imull %esi, %eax
movl %eax, %ecx
imull %r14d, %ecx
xorl %r13d, %r13d
testl %ecx, %ecx
jle 0x2f9dd
movl %eax, 0x1c(%rsp)
movl %ecx, 0x18(%rsp)
movl %ecx, %edi
shlq $0x3, %rdi
callq 0xe030
movl 0x238(%rbx), %edx
movl 0x23c(%rbx), %ecx
decl %edx
cvtsi2sd %edx, %xmm1
movq %r12, %rdx
leal -0x1(%r15), %r12d
cvtsi2sd %r12d, %xmm0
movsd %xmm1, 0x90(%rsp)
divsd %xmm0, %xmm1
movsd %xmm1, 0x88(%rsp)
decl %ecx
cvtsi2sd %ecx, %xmm1
leal -0x1(%rdx), %ecx
movl %ecx, 0x28(%rsp)
cvtsi2sd %ecx, %xmm0
movsd %xmm1, 0x80(%rsp)
divsd %xmm0, %xmm1
movsd %xmm1, 0x78(%rsp)
movl 0x240(%rbx), %ecx
decl %ecx
cvtsi2sd %ecx, %xmm1
leal -0x1(%r14), %ecx
movl %ecx, 0x20(%rsp)
cvtsi2sd %ecx, %xmm0
movsd %xmm1, 0x68(%rsp)
testl %r15d, %r15d
movq %r15, %rcx
movl $0x0, %r15d
movq %rcx, 0x50(%rsp)
cmovgl %ecx, %r15d
testl %edx, %edx
movl $0x0, %ecx
movq %rdx, 0x48(%rsp)
cmovgl %edx, %ecx
movl %ecx, 0x2c(%rsp)
testl %r14d, %r14d
movl $0x0, %ecx
movq %r14, 0x58(%rsp)
cmovgl %r14d, %ecx
movl %ecx, 0x24(%rsp)
divsd %xmm0, %xmm1
movsd %xmm1, 0x60(%rsp)
xorpd %xmm0, %xmm0
movsd %xmm0, 0x8(%rsp)
movq %rax, 0x30(%rsp)
movq %rax, %r14
cmpl 0x24(%rsp), %r13d
je 0x2f9c4
movsd 0x68(%rsp), %xmm0
movsd %xmm0, 0x38(%rsp)
movq %r13, 0x70(%rsp)
cmpl 0x20(%rsp), %r13d
je 0x2f8e6
movsd 0x60(%rsp), %xmm0
mulsd 0x8(%rsp), %xmm0
movsd %xmm0, 0x38(%rsp)
xorl %r13d, %r13d
xorpd %xmm0, %xmm0
movsd %xmm0, 0x10(%rsp)
cmpl 0x2c(%rsp), %r13d
je 0x2f9a3
movsd 0x80(%rsp), %xmm0
movsd %xmm0, 0x40(%rsp)
cmpl 0x28(%rsp), %r13d
je 0x2f926
movsd 0x78(%rsp), %xmm0
mulsd 0x10(%rsp), %xmm0
movsd %xmm0, 0x40(%rsp)
xorl %ebp, %ebp
xorpd %xmm1, %xmm1
cmpl %ebp, %r15d
je 0x2f987
movsd 0x90(%rsp), %xmm0
cmpl %ebp, %r12d
je 0x2f94c
movsd 0x88(%rsp), %xmm0
mulsd %xmm1, %xmm0
movq %rbx, %rdi
movsd %xmm1, 0x98(%rsp)
movsd 0x40(%rsp), %xmm1
movsd 0x38(%rsp), %xmm2
callq 0x2be20
movsd 0x98(%rsp), %xmm1
movsd %xmm0, (%r14)
addq $0x8, %r14
addsd 0x63685(%rip), %xmm1    # 0x93008
incl %ebp
jmp 0x2f92c
movsd 0x10(%rsp), %xmm0
addsd 0x63673(%rip), %xmm0    # 0x93008
movsd %xmm0, 0x10(%rsp)
incl %r13d
jmp 0x2f8f3
movsd 0x8(%rsp), %xmm0
addsd 0x63657(%rip), %xmm0    # 0x93008
movsd %xmm0, 0x8(%rsp)
movq 0x70(%rsp), %r13
incl %r13d
jmp 0x2f8b1
movq 0x58(%rsp), %r14
movq 0x50(%rsp), %r15
movl 0x1c(%rsp), %eax
movq 0x48(%rsp), %r12
movl 0x18(%rsp), %ecx
jmp 0x2f9e6
movq $0x0, 0x30(%rsp)
movl %r15d, 0x238(%rbx)
movl %r12d, 0x23c(%rbx)
movl %r14d, 0x240(%rbx)
movl %r15d, 0x244(%rbx)
movl %eax, 0x248(%rbx)
movl %ecx, 0x24c(%rbx)
movq 0x230(%rbx), %rdi
testq %rdi, %rdi
je 0x2fa1f
callq 0xe5d0
movq 0x30(%rsp), %rax
movq %rax, 0x230(%rbx)
leaq 0xa0(%rsp), %r14
movq %r14, %rdi
movq %rbx, %rsi
callq 0x365d4
movq %rbx, %rdi
movq %r14, %rsi
callq 0x2b4b0
leaq 0xa0(%rsp), %rdi
callq 0x25832
addq $0xd8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq %rax, %rbx
leaq 0xa0(%rsp), %rdi
callq 0x25832
movq %rbx, %rdi
callq 0xe810