// File: tomfunkhouser[P]gaps/pkgs/R3Surfels/R3SurfelImage.cpp
// Function: gaps::R3SurfelImage::SetColorChannels(gaps::R2Image const&)
void R3SurfelImage::
SetColorChannels(const R2Image& color_image)
{
  // Initialize channels
  R2Grid red_channel(color_image.Width(), color_image.Height());
  R2Grid green_channel(color_image.Width(), color_image.Height());
  R2Grid blue_channel(color_image.Width(), color_image.Height());

  // Fill channels
  for (int iy = 0; iy < color_image.Height(); iy++) {
    for (int ix = 0; ix < color_image.Width(); ix++) {
      RNRgb rgb = color_image.PixelRGB(ix, iy);
      red_channel.SetGridValue(ix, iy, rgb.R());
      green_channel.SetGridValue(ix, iy, rgb.G());
      blue_channel.SetGridValue(ix, iy, rgb.B());
    }
  }

  // Set channels
  SetRedChannel(red_channel);
  SetGreenChannel(green_channel);
  SetBlueChannel(blue_channel);
}

// Assembly:
subq $0x318, %rsp            # imm = 0x318
movq %rdi, 0x310(%rsp)
movq %rsi, 0x308(%rsp)
movq 0x310(%rsp), %rax
movq %rax, 0x58(%rsp)
movq 0x308(%rsp), %rdi
callq 0x6b980
movl %eax, 0x60(%rsp)
movq 0x308(%rsp), %rdi
callq 0x6b990
movl 0x60(%rsp), %esi
movl %eax, %edx
leaq 0x238(%rsp), %rdi
callq 0x111300
movq 0x308(%rsp), %rdi
callq 0x6b980
movl %eax, 0x64(%rsp)
jmp 0x68788
movq 0x308(%rsp), %rdi
callq 0x6b990
movl %eax, 0x54(%rsp)
jmp 0x6879b
movl 0x54(%rsp), %edx
movl 0x64(%rsp), %esi
leaq 0x168(%rsp), %rdi
callq 0x111300
jmp 0x687b2
movq 0x308(%rsp), %rdi
callq 0x6b980
movl %eax, 0x50(%rsp)
jmp 0x687c5
movq 0x308(%rsp), %rdi
callq 0x6b990
movl %eax, 0x4c(%rsp)
jmp 0x687d8
movl 0x4c(%rsp), %edx
movl 0x50(%rsp), %esi
leaq 0x88(%rsp), %rdi
callq 0x111300
jmp 0x687ef
movl $0x0, 0x84(%rsp)
movl 0x84(%rsp), %eax
movl %eax, 0x44(%rsp)
movq 0x308(%rsp), %rdi
callq 0x6b990
movl %eax, 0x48(%rsp)
jmp 0x68818
movl 0x44(%rsp), %eax
movl 0x48(%rsp), %ecx
cmpl %ecx, %eax
jge 0x689da
movl $0x0, 0x80(%rsp)
movl 0x80(%rsp), %eax
movl %eax, 0x3c(%rsp)
movq 0x308(%rsp), %rdi
callq 0x6b980
movl %eax, 0x40(%rsp)
jmp 0x68851
movl 0x3c(%rsp), %eax
movl 0x40(%rsp), %ecx
cmpl %ecx, %eax
jge 0x689c2
movq 0x308(%rsp), %rsi
movl 0x80(%rsp), %edx
movl 0x84(%rsp), %ecx
leaq 0x68(%rsp), %rdi
callq 0x135d80
jmp 0x68883
movl 0x80(%rsp), %eax
movl %eax, 0x28(%rsp)
movl 0x84(%rsp), %eax
movl %eax, 0x2c(%rsp)
leaq 0x68(%rsp), %rdi
callq 0x31b50
movsd %xmm0, 0x30(%rsp)
jmp 0x688ab
movsd 0x30(%rsp), %xmm0
movl 0x2c(%rsp), %edx
movl 0x28(%rsp), %esi
leaq 0x238(%rsp), %rdi
callq 0x6b9a0
jmp 0x688c8
movl 0x80(%rsp), %eax
movl %eax, 0x18(%rsp)
movl 0x84(%rsp), %eax
movl %eax, 0x1c(%rsp)
leaq 0x68(%rsp), %rdi
callq 0x31b60
movsd %xmm0, 0x20(%rsp)
jmp 0x688f0
movsd 0x20(%rsp), %xmm0
movl 0x1c(%rsp), %edx
movl 0x18(%rsp), %esi
leaq 0x168(%rsp), %rdi
callq 0x6b9a0
jmp 0x6890d
movl 0x80(%rsp), %eax
movl %eax, 0x8(%rsp)
movl 0x84(%rsp), %eax
movl %eax, 0xc(%rsp)
leaq 0x68(%rsp), %rdi
callq 0x31b70
movsd %xmm0, 0x10(%rsp)
jmp 0x68935
movsd 0x10(%rsp), %xmm0
movl 0xc(%rsp), %edx
movl 0x8(%rsp), %esi
leaq 0x88(%rsp), %rdi
callq 0x6b9a0
jmp 0x68952
jmp 0x68954
movl 0x80(%rsp), %eax
addl $0x1, %eax
movl %eax, 0x80(%rsp)
jmp 0x68833
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x160(%rsp)
movl %eax, 0x15c(%rsp)
jmp 0x68a5e
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x160(%rsp)
movl %eax, 0x15c(%rsp)
jmp 0x68a51
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x160(%rsp)
movl %eax, 0x15c(%rsp)
leaq 0x88(%rsp), %rdi
callq 0x1127b0
jmp 0x68a51
jmp 0x689c4
movl 0x84(%rsp), %eax
addl $0x1, %eax
movl %eax, 0x84(%rsp)
jmp 0x687fa
movq 0x58(%rsp), %rdi
movq (%rdi), %rax
movq 0x18(%rax), %rax
leaq 0x238(%rsp), %rsi
callq *%rax
jmp 0x689f2
movq 0x58(%rsp), %rdi
movq (%rdi), %rax
movq 0x20(%rax), %rax
leaq 0x168(%rsp), %rsi
callq *%rax
jmp 0x68a0a
movq 0x58(%rsp), %rdi
movq (%rdi), %rax
movq 0x28(%rax), %rax
leaq 0x88(%rsp), %rsi
callq *%rax
jmp 0x68a22
leaq 0x88(%rsp), %rdi
callq 0x1127b0
leaq 0x168(%rsp), %rdi
callq 0x1127b0
leaq 0x238(%rsp), %rdi
callq 0x1127b0
addq $0x318, %rsp            # imm = 0x318
retq
leaq 0x168(%rsp), %rdi
callq 0x1127b0
leaq 0x238(%rsp), %rdi
callq 0x1127b0
movq 0x160(%rsp), %rdi
callq 0x13970
nopl (%rax,%rax)