// File: tomfunkhouser[P]gaps/pkgs/R3Shapes/R3Grid.cpp
// Function: gaps::R3Grid::RasterizeGridBox(gaps::R3Box const&, double, int)
void R3Grid::
RasterizeGridBox(const R3Box& box, RNScalar value, int operation)
{
  // Get corner coordinates
  int ix1 = (int) (box.XMin() + 0.5);
  int ix2 = (int) (box.XMax() + 0.5);
  int iy1 = (int) (box.YMin() + 0.5);
  int iy2 = (int) (box.YMax() + 0.5);
  int iz1 = (int) (box.ZMin() + 0.5);
  int iz2 = (int) (box.ZMax() + 0.5);

  // Check for intersection
  if (ix1 >= XResolution()) return;
  if (iy1 >= YResolution()) return;
  if (iz1 >= ZResolution()) return;
  if (ix2 < 0) return;
  if (iy2 < 0) return;
  if (iz2 < 0) return;

  // Clip coordinates
  if (ix1 < 0) ix1 = 0;
  if (iy1 < 0) iy1 = 0;
  if (iz1 < 0) iz1 = 0;
  if (ix2 >= XResolution()) ix2 = XResolution()-1;
  if (iy2 >= YResolution()) iy2 = YResolution()-1;
  if (iz2 >= ZResolution()) iz2 = ZResolution()-1;

  // Add value to grid entries
  for (int iz = iz1; iz <= iz2; iz++) {
    for (int iy = iy1; iy <= iy2; iy++) {
      for (int ix = ix1; ix <= ix2; ix++) {
        RasterizeGridValue(ix, iy, iz, value, operation);
      }
    }
  }
}

// Assembly:
subq $0x68, %rsp
movq %rdi, 0x60(%rsp)
movq %rsi, 0x58(%rsp)
movsd %xmm0, 0x50(%rsp)
movl %edx, 0x4c(%rsp)
movq 0x60(%rsp), %rax
movq %rax, 0x18(%rsp)
movq 0x58(%rsp), %rdi
callq 0x37830
movsd 0xd0b4c(%rip), %xmm1    # 0x133010
addsd %xmm1, %xmm0
cvttsd2si %xmm0, %eax
movl %eax, 0x48(%rsp)
movq 0x58(%rsp), %rdi
callq 0x44f80
movsd 0xd0b2e(%rip), %xmm1    # 0x133010
addsd %xmm1, %xmm0
cvttsd2si %xmm0, %eax
movl %eax, 0x44(%rsp)
movq 0x58(%rsp), %rdi
callq 0x37880
movsd 0xd0b10(%rip), %xmm1    # 0x133010
addsd %xmm1, %xmm0
cvttsd2si %xmm0, %eax
movl %eax, 0x40(%rsp)
movq 0x58(%rsp), %rdi
callq 0x44fa0
movsd 0xd0af2(%rip), %xmm1    # 0x133010
addsd %xmm1, %xmm0
cvttsd2si %xmm0, %eax
movl %eax, 0x3c(%rsp)
movq 0x58(%rsp), %rdi
callq 0x378d0
movsd 0xd0ad4(%rip), %xmm1    # 0x133010
addsd %xmm1, %xmm0
cvttsd2si %xmm0, %eax
movl %eax, 0x38(%rsp)
movq 0x58(%rsp), %rdi
callq 0x44fc0
movq 0x18(%rsp), %rdi
movsd 0xd0ab1(%rip), %xmm1    # 0x133010
addsd %xmm1, %xmm0
cvttsd2si %xmm0, %eax
movl %eax, 0x34(%rsp)
movl 0x48(%rsp), %eax
movl %eax, 0x24(%rsp)
callq 0x138c0
movl %eax, %ecx
movl 0x24(%rsp), %eax
cmpl %ecx, %eax
jl 0x62587
jmp 0x62723
movq 0x18(%rsp), %rdi
movl 0x40(%rsp), %eax
movl %eax, 0x14(%rsp)
callq 0x138e0
movl %eax, %ecx
movl 0x14(%rsp), %eax
cmpl %ecx, %eax
jl 0x625a8
jmp 0x62723
movq 0x18(%rsp), %rdi
movl 0x38(%rsp), %eax
movl %eax, 0x10(%rsp)
callq 0x13900
movl %eax, %ecx
movl 0x10(%rsp), %eax
cmpl %ecx, %eax
jl 0x625c9
jmp 0x62723
cmpl $0x0, 0x44(%rsp)
jge 0x625d5
jmp 0x62723
cmpl $0x0, 0x3c(%rsp)
jge 0x625e1
jmp 0x62723
cmpl $0x0, 0x34(%rsp)
jge 0x625ed
jmp 0x62723
cmpl $0x0, 0x48(%rsp)
jge 0x625fc
movl $0x0, 0x48(%rsp)
cmpl $0x0, 0x40(%rsp)
jge 0x6260b
movl $0x0, 0x40(%rsp)
cmpl $0x0, 0x38(%rsp)
jge 0x6261a
movl $0x0, 0x38(%rsp)
movq 0x18(%rsp), %rdi
movl 0x44(%rsp), %eax
movl %eax, 0xc(%rsp)
callq 0x138c0
movl %eax, %ecx
movl 0xc(%rsp), %eax
cmpl %ecx, %eax
jl 0x62647
movq 0x18(%rsp), %rdi
callq 0x138c0
subl $0x1, %eax
movl %eax, 0x44(%rsp)
movq 0x18(%rsp), %rdi
movl 0x3c(%rsp), %eax
movl %eax, 0x8(%rsp)
callq 0x138e0
movl %eax, %ecx
movl 0x8(%rsp), %eax
cmpl %ecx, %eax
jl 0x62674
movq 0x18(%rsp), %rdi
callq 0x138e0
subl $0x1, %eax
movl %eax, 0x3c(%rsp)
movq 0x18(%rsp), %rdi
movl 0x34(%rsp), %eax
movl %eax, 0x4(%rsp)
callq 0x13900
movl %eax, %ecx
movl 0x4(%rsp), %eax
cmpl %ecx, %eax
jl 0x626a1
movq 0x18(%rsp), %rdi
callq 0x13900
subl $0x1, %eax
movl %eax, 0x34(%rsp)
movl 0x38(%rsp), %eax
movl %eax, 0x30(%rsp)
movl 0x30(%rsp), %eax
cmpl 0x34(%rsp), %eax
jg 0x62723
movl 0x40(%rsp), %eax
movl %eax, 0x2c(%rsp)
movl 0x2c(%rsp), %eax
cmpl 0x3c(%rsp), %eax
jg 0x62714
movl 0x48(%rsp), %eax
movl %eax, 0x28(%rsp)
movl 0x28(%rsp), %eax
cmpl 0x44(%rsp), %eax
jg 0x62705
movq 0x18(%rsp), %rdi
movl 0x28(%rsp), %esi
movl 0x2c(%rsp), %edx
movl 0x30(%rsp), %ecx
movsd 0x50(%rsp), %xmm0
movl 0x4c(%rsp), %r8d
callq 0x5f820
movl 0x28(%rsp), %eax
addl $0x1, %eax
movl %eax, 0x28(%rsp)
jmp 0x626cd
jmp 0x62707
movl 0x2c(%rsp), %eax
addl $0x1, %eax
movl %eax, 0x2c(%rsp)
jmp 0x626bb
jmp 0x62716
movl 0x30(%rsp), %eax
addl $0x1, %eax
movl %eax, 0x30(%rsp)
jmp 0x626a9
addq $0x68, %rsp
retq
nopl (%rax,%rax)