// File: tomfunkhouser[P]gaps/pkgs/RGBD/RGBDUtil.cpp
// Function: gaps::RGBDCreateNormalChannels(gaps::RGBDImage*, gaps::R2Grid&, gaps::R2Grid&, gaps::R2Grid&, double, int, int, int)
int RGBDCreateNormalChannels(RGBDImage *image,
  R2Grid& output_nx_image, R2Grid& output_ny_image, R2Grid& output_nz_image,
  RNLength neighborhood_world_radius, int neighborhood_pixel_radius, RNBoolean neighborhood_search,
  RNBoolean world_coordinates)
{
  R2Grid boundary_image, px_image, py_image, pz_image, radius_image;
  if (!RGBDCreateBoundaryChannel(image, boundary_image)) return 0;
  if (!RGBDCreatePositionChannels(image, px_image, py_image, pz_image, world_coordinates)) return 0;
  return RGBDCreateNormalChannels(*(image->DepthChannel()),
    px_image, py_image, pz_image, boundary_image,
    output_nx_image, output_ny_image, output_nz_image, radius_image,
    image->WorldViewpoint(), image->WorldTowards(), image->WorldUp(),
    neighborhood_world_radius, neighborhood_pixel_radius, neighborhood_search);
}

// Assembly:
subq $0x528, %rsp            # imm = 0x528
movl 0x530(%rsp), %eax
movq %rdi, 0x518(%rsp)
movq %rsi, 0x510(%rsp)
movq %rdx, 0x508(%rsp)
movq %rcx, 0x500(%rsp)
movsd %xmm0, 0x4f8(%rsp)
movl %r8d, 0x4f4(%rsp)
movl %r9d, 0x4f0(%rsp)
leaq 0x420(%rsp), %rdi
xorl %edx, %edx
movl %edx, 0x7c(%rsp)
movl %edx, %esi
callq 0xb1ee0
movl 0x7c(%rsp), %edx
leaq 0x350(%rsp), %rdi
movl %edx, %esi
callq 0xb1ee0
jmp 0x30e01
leaq 0x270(%rsp), %rdi
xorl %edx, %edx
movl %edx, %esi
callq 0xb1ee0
jmp 0x30e14
leaq 0x1a0(%rsp), %rdi
xorl %edx, %edx
movl %edx, %esi
callq 0xb1ee0
jmp 0x30e27
leaq 0xd0(%rsp), %rdi
xorl %edx, %edx
movl %edx, %esi
callq 0xb1ee0
jmp 0x30e3a
movq 0x518(%rsp), %rdi
leaq 0x420(%rsp), %rsi
movsd 0x136356(%rip), %xmm0   # 0x1671a8
callq 0x31130
movl %eax, 0x78(%rsp)
jmp 0x30e5d
movl 0x78(%rsp), %eax
cmpl $0x0, %eax
jne 0x30f0f
movl $0x0, 0x524(%rsp)
movl $0x1, 0xcc(%rsp)
jmp 0x31099
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x348(%rsp)
movl %eax, 0x344(%rsp)
jmp 0x31110
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x348(%rsp)
movl %eax, 0x344(%rsp)
jmp 0x31103
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x348(%rsp)
movl %eax, 0x344(%rsp)
jmp 0x310f6
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x348(%rsp)
movl %eax, 0x344(%rsp)
jmp 0x310e9
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x348(%rsp)
movl %eax, 0x344(%rsp)
leaq 0xd0(%rsp), %rdi
callq 0xb3390
jmp 0x310e9
movq 0x518(%rsp), %rdi
movl 0x530(%rsp), %r8d
leaq 0x350(%rsp), %rsi
leaq 0x270(%rsp), %rdx
leaq 0x1a0(%rsp), %rcx
callq 0x30930
movl %eax, 0x74(%rsp)
jmp 0x30f42
movl 0x74(%rsp), %eax
cmpl $0x0, %eax
jne 0x30f66
movl $0x0, 0x524(%rsp)
movl $0x1, 0xcc(%rsp)
jmp 0x31099
movq 0x518(%rsp), %rdi
callq 0x303c0
movq %rax, 0x68(%rsp)
jmp 0x30f7a
movq 0x510(%rsp), %rax
movq %rax, 0x50(%rsp)
movq 0x508(%rsp), %rax
movq %rax, 0x58(%rsp)
movq 0x500(%rsp), %rax
movq %rax, 0x60(%rsp)
movq 0x518(%rsp), %rsi
leaq 0xb0(%rsp), %rdi
callq 0x19db0
jmp 0x30fb8
movq 0x518(%rsp), %rsi
leaq 0x98(%rsp), %rdi
callq 0x1a320
jmp 0x30fcf
movq 0x518(%rsp), %rsi
leaq 0x80(%rsp), %rdi
callq 0x22a50
jmp 0x30fe6
movq 0x50(%rsp), %r9
movq 0x68(%rsp), %rdi
movq 0x58(%rsp), %rcx
movq 0x60(%rsp), %rdx
movsd 0x4f8(%rsp), %xmm0
movl 0x4f4(%rsp), %esi
movl 0x4f0(%rsp), %r8d
movq %rsp, %rax
movq %rax, 0x40(%rsp)
movl %r8d, 0x38(%rax)
movl %esi, 0x30(%rax)
leaq 0x80(%rsp), %rsi
movq %rsi, 0x28(%rax)
leaq 0x98(%rsp), %rsi
movq %rsi, 0x20(%rax)
leaq 0xb0(%rsp), %rsi
movq %rsi, 0x18(%rax)
leaq 0xd0(%rsp), %rsi
movq %rsi, 0x10(%rax)
movq %rdx, 0x8(%rax)
movq %rcx, (%rax)
leaq 0x350(%rsp), %rsi
leaq 0x270(%rsp), %rdx
leaq 0x1a0(%rsp), %rcx
leaq 0x420(%rsp), %r8
callq 0x31170
movl %eax, 0x4c(%rsp)
jmp 0x31083
movl 0x4c(%rsp), %eax
movl %eax, 0x524(%rsp)
movl $0x1, 0xcc(%rsp)
leaq 0xd0(%rsp), %rdi
callq 0xb3390
leaq 0x1a0(%rsp), %rdi
callq 0xb3390
leaq 0x270(%rsp), %rdi
callq 0xb3390
leaq 0x350(%rsp), %rdi
callq 0xb3390
leaq 0x420(%rsp), %rdi
callq 0xb3390
movl 0x524(%rsp), %eax
addq $0x528, %rsp            # imm = 0x528
retq
leaq 0x1a0(%rsp), %rdi
callq 0xb3390
leaq 0x270(%rsp), %rdi
callq 0xb3390
leaq 0x350(%rsp), %rdi
callq 0xb3390
leaq 0x420(%rsp), %rdi
callq 0xb3390
movq 0x348(%rsp), %rdi
callq 0x12c20
nopw (%rax,%rax)