LLM4Binary/decompile-bench-makefile huggingface dataset:
// File: /workspace/github_cpp_makefile_star2_O1/tomfunkhouser[P]gaps/pkgs/RGBD/RGBDSurface.cpp
// Function: gaps::RGBDSurface::SetChannel(int, gaps::R2Grid const&)
void RGBDSurface::
SetChannel(int channel_index, const R2Grid& image)
{
  // Check if color channels are resident
  if ((channel_index >= RGBD_RED_CHANNEL) && (channel_index <= RGBD_BLUE_CHANNEL)) {
    if (color_resident_count == 0) {
      RNFail("Unable to set channel -- it has not been created\n");
      return;
    }
  }

  // Set channel
  *(channels[channel_index]) = image;

  // Set width and height
  this->width = image.XResolution();
  this->height = image.YResolution();

  // Invalidate opengl
  if ((channel_index >= RGBD_RED_CHANNEL) && (channel_index <= RGBD_BLUE_CHANNEL)) InvalidateOpenGL();
}

// Assembly:
pushq %rbp
pushq %r14
pushq %rbx
movq %rdx, %r14
movl %esi, %ebp
movq %rdi, %rbx
cmpl $0x2, %esi
ja 0x1b735
cmpl $0x0, 0x70(%rbx)
jne 0x1b735
leaq 0xa2820(%rip), %rdi     # 0xbdf4a
xorl %eax, %eax
popq %rbx
popq %r14
popq %rbp
jmp 0x79092
movq 0x18(%rbx), %rax
movslq %ebp, %rcx
movq (%rax,%rcx,8), %rdi
movq %r14, %rsi
callq 0x60d3c
movl 0xc0(%r14), %eax
movl %eax, 0x28(%rbx)
movl 0xc4(%r14), %eax
movl %eax, 0x2c(%rbx)
cmpl $0x2, %ebp
ja 0x1b771
movq (%rbx), %rax
movq %rbx, %rdi
popq %rbx
popq %r14
popq %rbp
jmpq *0xd8(%rax)
popq %rbx
popq %r14
popq %rbp
retq
// File: /workspace/github_cpp_makefile_star2_O1/tomfunkhouser[P]gaps/pkgs/RGBD/RGBDSurface.cpp
// Function: gaps::RGBDSurface::SetColorChannels(gaps::R2Image const&)
void RGBDSurface::
SetColorChannels(const R2Image& image)
{
  // Check if color channels are resident
  if (color_resident_count == 0) {
    RNFail("Unable to set color channels -- they have not been created\n");
    return;
  }

  // Copy color values
  for (int iy = 0; iy < image.Height(); iy++) {
    for (int ix = 0; ix < image.Width(); ix++) {
      RNRgb color = image.PixelRGB(ix, iy);
      channels[RGBD_RED_CHANNEL]->SetGridValue(ix, iy, color.R());      
      channels[RGBD_GREEN_CHANNEL]->SetGridValue(ix, iy, color.G());      
      channels[RGBD_BLUE_CHANNEL]->SetGridValue(ix, iy, color.B());
    }
  }

  // Set width and height
  this->width = image.Width();
  this->height = image.Height();

  // Invalidate opengl
  InvalidateOpenGL();
  
}

// Assembly:
cmpl $0x0, 0x70(%rdi)
je 0x1b871
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x18, %rsp
movq %rsi, %r14
movq %rdi, %rbx
movl 0x4(%rsi), %eax
testl %eax, %eax
jle 0x1b84d
xorl %ebp, %ebp
movq %rsp, %r15
cmpl $0x0, (%r14)
jle 0x1b83f
movslq %ebp, %r12
xorl %r13d, %r13d
movq %r15, %rdi
movq %r14, %rsi
movl %r13d, %edx
movl %r12d, %ecx
callq 0x70d74
movq 0x18(%rbx), %rax
movq (%rax), %rcx
movsd (%rsp), %xmm0
movq 0xb8(%rcx), %rdx
movslq 0xc8(%rcx), %rcx
imulq %r12, %rcx
addq %r13, %rcx
movsd %xmm0, (%rdx,%rcx,8)
movq 0x8(%rax), %rcx
movsd 0x8(%rsp), %xmm0
movq 0xb8(%rcx), %rdx
movslq 0xc8(%rcx), %rcx
imulq %r12, %rcx
addq %r13, %rcx
movsd %xmm0, (%rdx,%rcx,8)
movq 0x10(%rax), %rax
movsd 0x10(%rsp), %xmm0
movq 0xb8(%rax), %rcx
movslq 0xc8(%rax), %rax
imulq %r12, %rax
addq %r13, %rax
movsd %xmm0, (%rcx,%rax,8)
incq %r13
cmpl (%r14), %r13d
jl 0x1b7b4
incl %ebp
movl 0x4(%r14), %eax
cmpl %eax, %ebp
jl 0x1b7a4
movl (%r14), %ecx
movl %ecx, 0x28(%rbx)
movl %eax, 0x2c(%rbx)
movq (%rbx), %rax
movq %rbx, %rdi
callq *0xd8(%rax)
addq $0x18, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
leaq 0xa2704(%rip), %rdi     # 0xbdf7c
xorl %eax, %eax
jmp 0x79092
nop
// File: /workspace/github_cpp_makefile_star2_O1/tomfunkhouser[P]gaps/pkgs/RGBD/RGBDSurface.cpp
// Function: gaps::RGBDSurface::SetWorldTexelSpacing(double)
void RGBDSurface::
SetWorldTexelSpacing(RNLength texel_spacing)
{
  // Compute new width and height
  if (texel_spacing > 0) {
    width = surface_bbox.XLength() / texel_spacing;
    height = surface_bbox.YLength() / texel_spacing;
  }
  
  // Resample channels
  for (int i = 0; i < NChannels(); i++) {
    R2Grid *channel = Channel(i);
    if (channel) channel->Resample(width, height);
  }

  // Invalidate mesh face index
  InvalidateMeshFaceIndex();
}

// Assembly:
pushq %r15
pushq %r14
pushq %rbx
movq %rdi, %rbx
xorpd %xmm1, %xmm1
ucomisd %xmm1, %xmm0
jbe 0x1b941
movupd 0x50(%rbx), %xmm1
movupd 0x60(%rbx), %xmm2
subpd %xmm1, %xmm2
unpcklpd %xmm0, %xmm0            # xmm0 = xmm0[0,0]
divpd %xmm0, %xmm2
cvttpd2dq %xmm2, %xmm0
movlpd %xmm0, 0x28(%rbx)
cmpl $0x0, 0x24(%rbx)
jle 0x1b988
leaq 0xa26b1(%rip), %r14     # 0xbdfff
xorl %r15d, %r15d
movq 0x18(%rbx), %rax
movq (%rax,%r15,8), %rdi
testq %rdi, %rdi
jne 0x1b96a
movq %r14, %rdi
xorl %eax, %eax
callq 0x79092
xorl %edi, %edi
testq %rdi, %rdi
je 0x1b97c
movl 0x28(%rbx), %esi
movl 0x2c(%rbx), %edx
xorl %ecx, %ecx
callq 0x65d5a
incq %r15
movslq 0x24(%rbx), %rax
cmpq %rax, %r15
jl 0x1b951
movq (%rbx), %rax
movq %rbx, %rdi
popq %rbx
popq %r14
popq %r15
jmpq *0xf0(%rax)
nop
// File: /workspace/github_cpp_makefile_star2_O1/tomfunkhouser[P]gaps/pkgs/RGBD/RGBDSurface.cpp
// Function: gaps::RGBDSurface::TransformTextureToSurface(gaps::R2Point const&, gaps::R2Point&) const
int RGBDSurface::
TransformTextureToSurface(const R2Point& texture_position, R2Point& surface_position) const
{
  // Transform from position in texture coordinates to surface coordinates
  if ((width == 0) || (height == 0)) return 0;
  RNScalar xlength = surface_bbox.XLength();
  RNScalar ylength = surface_bbox.YLength();
  surface_position[0] = surface_bbox[0][0] + xlength * texture_position[0] / width;
  surface_position[1] = surface_bbox[0][1] + ylength * texture_position[1] / height;
  return 1;
}

// Assembly:
movl 0x28(%rdi), %r8d
xorl %eax, %eax
testl %r8d, %r8d
je 0x1ba3e
movl 0x2c(%rdi), %ecx
testl %ecx, %ecx
je 0x1ba3e
movsd 0x50(%rdi), %xmm0
movsd 0x60(%rdi), %xmm1
subsd %xmm0, %xmm1
movsd 0x68(%rdi), %xmm2
subsd 0x58(%rdi), %xmm2
mulsd (%rsi), %xmm1
cvtsi2sd %r8d, %xmm3
divsd %xmm3, %xmm1
addsd %xmm0, %xmm1
movsd %xmm1, (%rdx)
mulsd 0x8(%rsi), %xmm2
xorps %xmm0, %xmm0
cvtsi2sd %ecx, %xmm0
divsd %xmm0, %xmm2
addsd 0x58(%rdi), %xmm2
movsd %xmm2, 0x8(%rdx)
movl $0x1, %eax
retq
nop
// File: /workspace/github_cpp_makefile_star2_O1/tomfunkhouser[P]gaps/pkgs/RGBD/RGBDSurface.cpp
// Function: gaps::RGBDSurface::TransformSurfaceToWorld(gaps::R2Point const&, gaps::R3Point&) const
int RGBDSurface::
TransformSurfaceToWorld(const R2Point& surface_position, R3Point& world_position) const
{
  // Transform from position in surface coordinates to world coordinates
  if (rectangle) {
    world_position = rectangle->Corner(0,0);
    world_position += surface_position[0] * rectangle->Axis(0);
    world_position += surface_position[1] * rectangle->Axis(1);
  }
  else if (mesh) {
    R2Point texture_position;
    double barycentrics[3];
    if (!TransformSurfaceToTexture(surface_position, texture_position)) return 0;
    R3MeshFace *face = SearchMeshFaceIndex(texture_position, barycentrics);
    if (face) world_position = mesh->FacePoint(face, barycentrics);
    else return 0;
  }

  // Return success
  return 1;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x48, %rsp
movq %rdx, %rbx
movq %rsi, %r15
movq %rdi, %r14
movq 0x80(%rdi), %r12
testq %r12, %r12
je 0x1bb55
movsd 0x68(%r12), %xmm0
minsd 0x70(%r12), %xmm0
xorpd %xmm1, %xmm1
ucomisd %xmm0, %xmm1
ja 0x1bbd0
leaq 0x8(%r12), %rsi
leaq 0x20(%rsp), %r13
movq %r13, %rdi
callq 0x4be56
movsd 0x68(%r12), %xmm0
xorps 0xa1547(%rip), %xmm0    # 0xbd050
leaq 0x20(%r12), %rsi
movq %rsp, %rbp
movq %rbp, %rdi
callq 0x4d2ae
movq %r13, %rdi
movq %rbp, %rsi
callq 0x4c22e
movsd 0x70(%r12), %xmm0
xorpd 0xa151d(%rip), %xmm0    # 0xbd050
addq $0x38, %r12
movq %rsp, %rbp
movq %rbp, %rdi
movq %r12, %rsi
callq 0x4d2ae
movq %r13, %rdi
movq %rbp, %rsi
callq 0x4c22e
jmp 0x1bbe1
movl $0x1, %ebp
cmpq $0x0, 0x88(%r14)
je 0x1bc40
leaq 0x38(%rsp), %r12
movq %r12, %rdi
callq 0x6fee4
movq (%r14), %rax
movq %r14, %rdi
movq %r15, %rsi
movq %r12, %rdx
callq *0x40(%rax)
testl %eax, %eax
je 0x1bc51
movq (%r14), %rax
leaq 0x38(%rsp), %rsi
movq %rsp, %rdx
movq %r14, %rdi
callq *0xe8(%rax)
testq %rax, %rax
je 0x1bc51
movq 0x88(%r14), %rsi
leaq 0x20(%rsp), %r14
movq %rsp, %rcx
movq %r14, %rdi
movq %rax, %rdx
callq 0x2d938
movq %rbx, %rdi
movq %r14, %rsi
callq 0x4c1b4
jmp 0x1bc40
leaq 0xebfd9(%rip), %rsi     # 0x107bb0
leaq 0x20(%rsp), %rdi
callq 0x4be56
leaq 0x20(%rsp), %rsi
movq %rbx, %rdi
callq 0x4c1b4
movsd (%r15), %xmm0
movq 0x80(%r14), %rsi
addq $0x20, %rsi
movq %rsp, %r12
movq %r12, %rdi
callq 0x4d2ae
movq %rbx, %rdi
movq %r12, %rsi
callq 0x4c22e
movsd 0x8(%r15), %xmm0
movq 0x80(%r14), %rsi
addq $0x38, %rsi
movq %rsp, %r14
movq %r14, %rdi
callq 0x4d2ae
movq %rbx, %rdi
movq %r14, %rsi
callq 0x4c22e
movl $0x1, %ebp
movl %ebp, %eax
addq $0x48, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
xorl %ebp, %ebp
jmp 0x1bc40
nop
// File: /workspace/github_cpp_makefile_star2_O1/tomfunkhouser[P]gaps/pkgs/RGBD/RGBDSurface.cpp
// Function: gaps::RGBDSurface::TransformWorldToSurface(gaps::R3Point const&, gaps::R2Point&) const
int RGBDSurface::
TransformWorldToSurface(const R3Point& world_position, R2Point& surface_position) const
{
  // Transform from position in world coordinates to surface coordinates
  if (rectangle) {
    R3Point origin = rectangle->Corner(0,0);
    surface_position[0] = (world_position - origin).Dot(rectangle->Axis(0));;
    surface_position[1] = (world_position - origin).Dot(rectangle->Axis(1));;
  }
  else {
    return 0;
  }

  // Return success
  return 1;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x38, %rsp
movq 0x80(%rdi), %r12
testq %r12, %r12
je 0x1bd02
movq %rdx, %rbx
movq %rsi, %r15
movq %rdi, %r14
movsd 0x68(%r12), %xmm0
minsd 0x70(%r12), %xmm0
xorpd %xmm1, %xmm1
ucomisd %xmm0, %xmm1
ja 0x1bd06
leaq 0x8(%r12), %rsi
leaq 0x20(%rsp), %r13
movq %r13, %rdi
callq 0x4be56
movsd 0x68(%r12), %xmm0
xorps 0xa139b(%rip), %xmm0    # 0xbd050
leaq 0x20(%r12), %rsi
leaq 0x8(%rsp), %rbp
movq %rbp, %rdi
callq 0x4d2ae
movq %r13, %rdi
movq %rbp, %rsi
callq 0x4c22e
movsd 0x70(%r12), %xmm0
xorpd 0xa136f(%rip), %xmm0    # 0xbd050
addq $0x38, %r12
leaq 0x8(%rsp), %rbp
movq %rbp, %rdi
movq %r12, %rsi
callq 0x4d2ae
movq %r13, %rdi
movq %rbp, %rsi
callq 0x4c22e
jmp 0x1bd17
xorl %eax, %eax
jmp 0x1bd76
leaq 0xebea3(%rip), %rsi     # 0x107bb0
leaq 0x20(%rsp), %rdi
callq 0x4be56
leaq 0x8(%rsp), %r12
leaq 0x20(%rsp), %r13
movq %r12, %rdi
movq %r15, %rsi
movq %r13, %rdx
callq 0x4c0a8
movq 0x80(%r14), %rsi
addq $0x20, %rsi
movq %r12, %rdi
callq 0x4cb76
movsd %xmm0, (%rbx)
leaq 0x8(%rsp), %r12
movq %r12, %rdi
movq %r15, %rsi
movq %r13, %rdx
callq 0x4c0a8
movq 0x80(%r14), %rsi
addq $0x38, %rsi
movq %r12, %rdi
callq 0x4cb76
movsd %xmm0, 0x8(%rbx)
movl $0x1, %eax
addq $0x38, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
nop
// File: /workspace/github_cpp_makefile_star2_O1/tomfunkhouser[P]gaps/pkgs/RGBD/RGBDSurface.cpp
// Function: gaps::RGBDSurface::DrawVertices(int) const
void RGBDSurface::
DrawVertices(int color_scheme) const
{
  // Load color
  if (color_scheme == RGBD_NO_COLOR_SCHEME) LoadColor(color_scheme);
  else if (color_scheme == RGBD_HIGHLIGHT_COLOR_SCHEME) LoadColor(color_scheme);
  else LoadColor(RGBD_INDEX_COLOR_SCHEME);

  // Draw vertices
  if (rectangle) {
    RNGrfxBegin(RN_GRFX_POINTS);
    for (int i = 0; i < 4; i++) {
      R3Point position = rectangle->Corner(i);
      R3LoadPoint(position);
    }
    RNGrfxEnd();
  }
  else if (mesh) {
    RNGrfxBegin(RN_GRFX_POINTS);
    for (int i = 0; i < mesh->NVertices(); i++) {
      R3MeshVertex *vertex = mesh->Vertex(i);
      const R3Point& position = mesh->VertexPosition(vertex);
      R3LoadPoint(position);
    }
    RNGrfxEnd();
  }
}

// Assembly:
pushq %rbp
pushq %r14
pushq %rbx
subq $0x20, %rsp
movq %rdi, %rbx
movq (%rdi), %rax
xorl %ecx, %ecx
cmpl $0x4, %esi
sete %cl
addl $0x3, %ecx
testl %esi, %esi
cmovnel %ecx, %esi
callq *0x80(%rax)
cmpq $0x0, 0x80(%rbx)
je 0x1c006
xorl %ebp, %ebp
xorl %edi, %edi
callq 0x11150
leaq 0x8(%rsp), %r14
movq 0x80(%rbx), %rsi
movq %r14, %rdi
movl %ebp, %edx
callq 0x1cf90
movq %r14, %rdi
callq 0x11170
incl %ebp
cmpl $0x4, %ebp
jne 0x1bfd8
callq 0x117d0
addq $0x20, %rsp
popq %rbx
popq %r14
popq %rbp
retq
cmpq $0x0, 0x88(%rbx)
je 0x1bffd
xorl %edi, %edi
callq 0x11150
movq 0x88(%rbx), %rax
cmpl $0x0, 0x14(%rax)
jle 0x1bff8
xorl %r14d, %r14d
movq 0x8(%rax), %rax
movq (%rax,%r14,8), %rdi
addq $0x18, %rdi
callq 0x11170
incq %r14
movq 0x88(%rbx), %rax
movslq 0x14(%rax), %rcx
cmpq %rcx, %r14
jl 0x1c027
jmp 0x1bff8
nop
// File: /workspace/github_cpp_makefile_star2_O1/tomfunkhouser[P]gaps/pkgs/RGBD/RGBDSurface.cpp
// Function: gaps::RGBDSurface::LoadColor(int) const
void RGBDSurface::
LoadColor(int color_scheme) const
{
  // Check color scheme
  if (color_scheme == RGBD_INDEX_COLOR_SCHEME) {
    // Load color encoding index
    int k = 255.0 * (ConfigurationIndex()+1) / configuration->NSurfaces();
    unsigned char r = k;
    unsigned char g = 0;
    unsigned char b = 0;
    RNLoadRgb(r, g, b);
  }
  else if (color_scheme == RGBD_PHOTO_COLOR_SCHEME) {
    // Load white 
    RNLoadRgb(1.0, 1.0, 1.0);
  }
  else if (color_scheme == RGBD_RENDER_COLOR_SCHEME) {
    // Load white 
    RNLoadRgb(1.0, 1.0, 1.0);
  }
  else if (color_scheme == RGBD_HIGHLIGHT_COLOR_SCHEME) {
    // Load highlight color
    RNLoadRgb(1.0, 1.0, 0.0);
  }
}

// Assembly:
decl %esi
cmpl $0x3, %esi
ja 0x1c50b
leaq 0xa1a12(%rip), %rax     # 0xbdec0
movslq (%rax,%rsi,4), %rcx
addq %rax, %rcx
jmpq *%rcx
movsd 0xa0b69(%rip), %xmm0    # 0xbd028
movaps %xmm0, %xmm1
movaps %xmm0, %xmm2
jmp 0x11900
movl 0x10(%rdi), %eax
incl %eax
cvtsi2sd %eax, %xmm0
mulsd 0xa19bd(%rip), %xmm0    # 0xbde98
movq 0x8(%rdi), %rax
cvtsi2sdl 0x24(%rax), %xmm1
divsd %xmm1, %xmm0
cvttsd2si %xmm0, %eax
movzbl %al, %edi
xorl %esi, %esi
xorl %edx, %edx
jmp 0x11580
movsd 0xa0b28(%rip), %xmm0    # 0xbd028
xorps %xmm2, %xmm2
movaps %xmm0, %xmm1
jmp 0x11900
retq
// File: /workspace/github_cpp_makefile_star2_O1/tomfunkhouser[P]gaps/pkgs/RGBD/RGBDSurface.cpp
// Function: gaps::RGBDSurface::ReadColorChannels()
int RGBDSurface::
ReadColorChannels(void)
{
  // Initialize image
  R2Image rgb_image(width, height);

  // Check filename
  if (texture_filename) {
    // Get full filename
    char full_filename[4096];
    const char *dirname = (configuration) ? configuration->TextureDirectory() : NULL;
    if (dirname) sprintf(full_filename, "%s/%s", dirname, texture_filename);
    else sprintf(full_filename, "%s", texture_filename);
    if (!RNFileExists(full_filename)) return 0;
  
    // Read color image
    if (!rgb_image.Read(full_filename)) return 0;

    // Check image dimensions
    if ((rgb_image.Width() != width) || (rgb_image.Height() != height)) {
      RNFail("Mismatching image dimensions (%d,%d) vs (%d,%d) in %s\n",
        rgb_image.Width(), rgb_image.Height(), width, height, texture_filename);
      // return 0;
    }
  }

  // Create color channels
  return CreateColorChannels(rgb_image);
}

// Assembly:
pushq %rbx
subq $0x1020, %rsp           # imm = 0x1020
movq %rdi, %rbx
movl 0x28(%rdi), %esi
movl 0x2c(%rdi), %edx
leaq 0x8(%rsp), %rdi
movl $0x3, %ecx
callq 0x70afe
movq 0x38(%rbx), %rcx
testq %rcx, %rcx
je 0x1c5d6
movq 0x8(%rbx), %rax
testq %rax, %rax
je 0x1c55e
movq 0x50(%rax), %rdx
jmp 0x1c560
xorl %edx, %edx
testq %rdx, %rdx
je 0x1c57a
leaq 0xa1a4c(%rip), %rsi     # 0xbdfb8
leaq 0x20(%rsp), %rdi
xorl %eax, %eax
callq 0x11110
jmp 0x1c587
leaq 0x20(%rsp), %rdi
movq %rcx, %rsi
callq 0x11530
leaq 0x20(%rsp), %rdi
callq 0x783c0
testl %eax, %eax
je 0x1c5eb
leaq 0x8(%rsp), %rdi
leaq 0x20(%rsp), %rsi
callq 0x70800
testl %eax, %eax
je 0x1c5eb
movl 0x8(%rsp), %esi
movl 0x28(%rbx), %ecx
cmpl %ecx, %esi
jne 0x1c5bc
movl 0xc(%rsp), %eax
cmpl 0x2c(%rbx), %eax
je 0x1c5d6
movl 0xc(%rsp), %edx
movl 0x2c(%rbx), %r8d
movq 0x38(%rbx), %r9
leaq 0xa19ef(%rip), %rdi     # 0xbdfbe
xorl %eax, %eax
callq 0x79092
movq (%rbx), %rax
leaq 0x8(%rsp), %rsi
movq %rbx, %rdi
callq *0xb8(%rax)
movl %eax, %ebx
jmp 0x1c5ed
xorl %ebx, %ebx
leaq 0x8(%rsp), %rdi
callq 0x70d66
movl %ebx, %eax
addq $0x1020, %rsp           # imm = 0x1020
popq %rbx
retq
jmp 0x1c604
movq %rax, %rbx
leaq 0x8(%rsp), %rdi
callq 0x70d66
movq %rbx, %rdi
callq 0x11a70
nop
// File: /workspace/github_cpp_makefile_star2_O1/tomfunkhouser[P]gaps/pkgs/RGBD/RGBDSurface.cpp
// Function: gaps::RGBDSurface::WriteColorChannels()
int RGBDSurface::
WriteColorChannels(void)
{
  // Check filename
  if (NChannels() <= RGBD_BLUE_CHANNEL) return 0;

  // Create texture filename, if there is none
  if (!texture_filename) {
    char buffer[4096];
    sprintf(buffer, "t%06d.jpg", ConfigurationIndex());
    SetTextureFilename(buffer);
  }

  // Get full filename
  char full_filename[4096];
  const char *dirname = (configuration) ? configuration->TextureDirectory() : NULL;
  if (dirname) sprintf(full_filename, "%s/%s", dirname, texture_filename);
  else sprintf(full_filename, "%s", texture_filename);

  // Compute color image
  R2Image rgb_image(width, height, 3);
  for (int iy = 0; iy < height; iy++) {
    for (int ix = 0; ix < width; ix++) {
      RNRgb rgb = TexelColor(ix, iy);
      rgb_image.SetPixelRGB(ix, iy, rgb);
    }
  }

  // Write color image
  if (!rgb_image.Write(full_filename)) return 0;

  // Return success
  return 1;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r12
pushq %rbx
subq $0x1030, %rsp           # imm = 0x1030
xorl %ebp, %ebp
cmpl $0x3, 0x24(%rdi)
jl 0x1c732
movq %rdi, %rbx
cmpq $0x0, 0x38(%rdi)
jne 0x1c67d
movl 0x10(%rbx), %edx
leaq 0xa1996(%rip), %rsi     # 0xbdff5
leaq 0x30(%rsp), %r14
movq %r14, %rdi
xorl %eax, %eax
callq 0x11110
movq (%rbx), %rax
movq %rbx, %rdi
movq %r14, %rsi
callq *0xc0(%rax)
movq 0x8(%rbx), %rax
testq %rax, %rax
je 0x1c68c
movq 0x50(%rax), %rdx
jmp 0x1c68e
xorl %edx, %edx
movq 0x38(%rbx), %rcx
testq %rdx, %rdx
je 0x1c6ac
leaq 0xa191a(%rip), %rsi     # 0xbdfb8
leaq 0x30(%rsp), %rdi
xorl %eax, %eax
callq 0x11110
jmp 0x1c6b9
leaq 0x30(%rsp), %rdi
movq %rcx, %rsi
callq 0x11530
movl 0x28(%rbx), %esi
movl 0x2c(%rbx), %edx
movq %rsp, %rdi
movl $0x3, %ecx
callq 0x70afe
cmpl $0x0, 0x2c(%rbx)
jle 0x1c715
xorl %ebp, %ebp
leaq 0x18(%rsp), %r14
movq %rsp, %r15
cmpl $0x0, 0x28(%rbx)
jle 0x1c70e
xorl %r12d, %r12d
movq %r14, %rdi
movq %rbx, %rsi
movl %r12d, %edx
movl %ebp, %ecx
callq 0x1b132
movq %r15, %rdi
movl %r12d, %esi
movl %ebp, %edx
movq %r14, %rcx
callq 0x70eae
incl %r12d
cmpl 0x28(%rbx), %r12d
jl 0x1c6e5
incl %ebp
cmpl 0x2c(%rbx), %ebp
jl 0x1c6dc
movq %rsp, %rdi
leaq 0x30(%rsp), %rsi
callq 0x72938
xorl %ebp, %ebp
testl %eax, %eax
setne %bpl
movq %rsp, %rdi
callq 0x70d66
movl %ebp, %eax
addq $0x1030, %rsp           # imm = 0x1030
popq %rbx
popq %r12
popq %r14
popq %r15
popq %rbp
retq
jmp 0x1c746
movq %rax, %rbx
movq %rsp, %rdi
callq 0x70d66
movq %rbx, %rdi
callq 0x11a70
nop
// File: /workspace/github_cpp_makefile_star2_O1/tomfunkhouser[P]gaps/pkgs/RGBD/RGBDSurface.cpp
// Function: gaps::RGBDSurface::ReleaseColorChannels()
int RGBDSurface::
ReleaseColorChannels(void)
{
  // Check/update read count
  if (--color_resident_count > 0) return 1;

  // Write color channel before release???
  // WriteColorChannels();
  
  // Delete color channels
  for (int channel_index = RGBD_RED_CHANNEL; channel_index <= RGBD_BLUE_CHANNEL; channel_index++) {
    if (NChannels() <= channel_index) break;
    if (!channels[channel_index]) continue;
    delete channels[channel_index];
    channels[channel_index] = NULL;
  }

  // Return success;
  return 1;
}

// Assembly:
movl 0x70(%rdi), %eax
leal -0x1(%rax), %ecx
movl %ecx, 0x70(%rdi)
cmpl $0x1, %eax
jg 0x1c7d4
pushq %r15
pushq %r14
pushq %rbx
movq %rdi, %rbx
cmpl $0x0, 0x24(%rdi)
jle 0x1c7cf
xorl %r15d, %r15d
movq 0x18(%rbx), %rax
movq (%rax,%r15,8), %r14
testq %r14, %r14
je 0x1c7bd
movq %r14, %rdi
callq 0x60ff0
movl $0xd0, %esi
movq %r14, %rdi
callq 0x115c0
movq 0x18(%rbx), %rax
movq $0x0, (%rax,%r15,8)
cmpq $0x1, %r15
ja 0x1c7cf
incq %r15
movslq 0x24(%rbx), %rax
cmpq %rax, %r15
jl 0x1c78f
popq %rbx
popq %r14
popq %r15
movl $0x1, %eax
retq
// File: /workspace/github_cpp_makefile_star2_O1/tomfunkhouser[P]gaps/pkgs/RGBD/RGBDSurface.cpp
// Function: gaps::RGBDSurface::CreateColorChannels(gaps::R2Image const&)
int RGBDSurface::
CreateColorChannels(const R2Image& image)
{
  // Check/update read count
  if (color_resident_count++ > 0) return 1;

  // Create color channels
  while (channels.NEntries() <= RGBD_BLUE_CHANNEL) channels.Insert(NULL);
  if (!channels[RGBD_RED_CHANNEL]) channels[RGBD_RED_CHANNEL] = new R2Grid(image.Width(), image.Height());
  if (!channels[RGBD_GREEN_CHANNEL]) channels[RGBD_GREEN_CHANNEL] = new R2Grid(image.Width(), image.Height());
  if (!channels[RGBD_BLUE_CHANNEL]) channels[RGBD_BLUE_CHANNEL] = new R2Grid(image.Width(), image.Height());

  // Initialize color channels
  SetColorChannels(image);

  // Set width and height
  this->width = image.Width();
  this->height = image.Height();

  // Return success
  return 1;
}

// Assembly:
pushq %r15
pushq %r14
pushq %r12
pushq %rbx
pushq %rax
movl 0x70(%rdi), %eax
leal 0x1(%rax), %ecx
movl %ecx, 0x70(%rdi)
testl %eax, %eax
jg 0x1c8af
movq %rsi, %r14
movq %rdi, %rbx
leaq 0x18(%rdi), %r15
movl 0x24(%rdi), %edx
cmpl $0x2, %edx
jg 0x1c817
movq %r15, %rdi
xorl %esi, %esi
callq 0x762aa
movl 0x24(%rbx), %edx
cmpl $0x3, %edx
jl 0x1c805
movq (%r15), %rax
cmpq $0x0, (%rax)
jne 0x1c842
movl $0xd0, %edi
callq 0x115b0
movq %rax, %r12
movl (%r14), %esi
movl 0x4(%r14), %edx
movq %rax, %rdi
callq 0x603d0
movq (%r15), %rax
movq %r12, (%rax)
movq (%r15), %rax
cmpq $0x0, 0x8(%rax)
jne 0x1c86f
movl $0xd0, %edi
callq 0x115b0
movq %rax, %r12
movl (%r14), %esi
movl 0x4(%r14), %edx
movq %rax, %rdi
callq 0x603d0
movq (%r15), %rax
movq %r12, 0x8(%rax)
movq (%r15), %rax
cmpq $0x0, 0x10(%rax)
jne 0x1c89c
movl $0xd0, %edi
callq 0x115b0
movq %rax, %r12
movl (%r14), %esi
movl 0x4(%r14), %edx
movq %rax, %rdi
callq 0x603d0
movq (%r15), %rax
movq %r12, 0x10(%rax)
movq (%rbx), %rax
movq %rbx, %rdi
movq %r14, %rsi
callq *0x28(%rax)
movq (%r14), %rax
movq %rax, 0x28(%rbx)
movl $0x1, %eax
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r14
popq %r15
retq
jmp 0x1c8c4
jmp 0x1c8c4
movq %rax, %rbx
movl $0xd0, %esi
movq %r12, %rdi
callq 0x115c0
movq %rbx, %rdi
callq 0x11a70
// File: /workspace/github_cpp_makefile_star2_O1/tomfunkhouser[P]gaps/pkgs/RGBD/RGBDSurface.cpp
// Function: gaps::RGBDSurface::InvalidateOpenGL()
void RGBDSurface::
InvalidateOpenGL(void) 
{
  // Delete opengl texture
  if (opengl_texture_id > 0) {
    GLuint i = opengl_texture_id;
    glDeleteTextures(1, &i);
  }

  // Reset opengl identifier
  opengl_texture_id = -1;
}

// Assembly:
pushq %rbx
subq $0x10, %rsp
movq %rdi, %rbx
movl 0x30(%rdi), %eax
testl %eax, %eax
jle 0x1c8fc
leaq 0xc(%rsp), %rsi
movl %eax, (%rsi)
movl $0x1, %edi
callq 0x11810
movl $0xffffffff, 0x30(%rbx) # imm = 0xFFFFFFFF
addq $0x10, %rsp
popq %rbx
retq
nop
// File: /workspace/github_cpp_makefile_star2_O1/tomfunkhouser[P]gaps/pkgs/RGBD/RGBDImage.cpp
// Function: gaps::RGBDImage::~RGBDImage()
RGBDImage::
~RGBDImage(void)
{
  // Delete opengl texture
  if (opengl_texture_id >= 0) {
    GLuint i = opengl_texture_id;
    glDeleteTextures(1, &i);
  }
  
  // Remove from configuration
  if (configuration) {
    configuration->RemoveImage(this);
  }

  // Delete channels
  for (int i = 0; i < channels.NEntries(); i++) {
    if (channels[i]) delete channels[i];
  }

  // Delete filenames
  if (name) free(name);
  if (color_filename) free(color_filename);
  if (depth_filename) free(depth_filename);
  if (category_filename) free(category_filename);
  if (instance_filename) free(instance_filename);
}

// Assembly:
pushq %r15
pushq %r14
pushq %r12
pushq %rbx
pushq %rax
movq %rdi, %rbx
leaq 0xe4bd6(%rip), %rax     # 0x101ed8
movq %rax, (%rdi)
movl 0x1c8(%rdi), %eax
testl %eax, %eax
js 0x1d320
leaq 0x4(%rsp), %rsi
movl %eax, (%rsi)
movl $0x1, %edi
callq 0x11810
movq 0x8(%rbx), %rdi
testq %rdi, %rdi
je 0x1d332
movq (%rdi), %rax
movq %rbx, %rsi
callq *0x18(%rax)
leaq 0x18(%rbx), %r14
cmpl $0x0, 0x24(%rbx)
jle 0x1d36c
xorl %r12d, %r12d
movq (%r14), %rax
movq (%rax,%r12,8), %r15
testq %r15, %r15
je 0x1d360
movq %r15, %rdi
callq 0x60ff0
movl $0xd0, %esi
movq %r15, %rdi
callq 0x115c0
incq %r12
movslq 0x24(%rbx), %rax
cmpq %rax, %r12
jl 0x1d33f
movq 0x1d0(%rbx), %rdi
testq %rdi, %rdi
je 0x1d37d
callq 0x11720
movq 0x1d8(%rbx), %rdi
testq %rdi, %rdi
je 0x1d38e
callq 0x11720
movq 0x1e0(%rbx), %rdi
testq %rdi, %rdi
je 0x1d39f
callq 0x11720
movq 0x1e8(%rbx), %rdi
testq %rdi, %rdi
je 0x1d3b0
callq 0x11720
movq 0x1f0(%rbx), %rdi
testq %rdi, %rdi
je 0x1d3c1
callq 0x11720
leaq 0x188(%rbx), %rdi
callq 0x444d0
addq $0x30, %rbx
movq %rbx, %rdi
callq 0x46404
movq %r14, %rdi
callq 0x7627e
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r14
popq %r15
retq
movq %rax, %rdi
callq 0x1a90d
nop
// File: /workspace/github_cpp_makefile_star2_O1/tomfunkhouser[P]gaps/pkgs/RGBD/RGBDImage.cpp
// Function: gaps::RGBDImage::ProjectionMatrix(double, double) const
R4Matrix RGBDImage::
ProjectionMatrix(RNScalar neardist, RNScalar fardist) const
{
  // Return projection transformation from camera coordinates to normalized image coordinates
  RNScalar fx = Intrinsics()[0][0];
  RNScalar fy = Intrinsics()[1][1];
  RNScalar cx = Intrinsics()[0][2];
  RNScalar cy = Intrinsics()[1][2];
  RNScalar W = NPixels(RN_X);
  RNScalar H = NPixels(RN_Y);
  return R4Matrix(
    2*fx/W, 0, -2*(cx/W)+1, 0,
    0, 2*fy/H, -2*(cy/H)+1, 0,
    0, 0, -(fardist + neardist) / (fardist - neardist),  -2.0 * neardist * fardist / (fardist - neardist),
    0, 0, -1, 0 );
}

// Assembly:
pushq %rbx
subq $0x40, %rsp
movapd %xmm0, %xmm3
movq %rdi, %rbx
movsd 0x160(%rsi), %xmm5
movsd 0x140(%rsi), %xmm0
movsd 0x150(%rsi), %xmm4
cvtsi2sdl 0x28(%rsi), %xmm2
cvtsi2sdl 0x2c(%rsi), %xmm7
movsd 0x168(%rsi), %xmm8
addsd %xmm0, %xmm0
divsd %xmm2, %xmm0
divsd %xmm2, %xmm4
addsd %xmm4, %xmm4
movsd 0x9fbb9(%rip), %xmm6    # 0xbd028
movapd %xmm6, %xmm2
subsd %xmm4, %xmm2
addsd %xmm5, %xmm5
divsd %xmm7, %xmm5
divsd %xmm7, %xmm8
addsd %xmm8, %xmm8
movapd %xmm3, %xmm4
addsd %xmm1, %xmm4
xorpd 0x9fbb7(%rip), %xmm4    # 0xbd050
subsd %xmm8, %xmm6
movapd %xmm1, %xmm7
subsd %xmm3, %xmm7
divsd %xmm7, %xmm4
mulsd 0xa0b86(%rip), %xmm3    # 0xbe038
mulsd %xmm1, %xmm3
divsd %xmm7, %xmm3
movabsq $-0x4010000000000000, %rax # imm = 0xBFF0000000000000
movq %rax, 0x30(%rsp)
xorpd %xmm1, %xmm1
movupd %xmm1, 0x20(%rsp)
movsd %xmm3, 0x18(%rsp)
movupd %xmm1, (%rsp)
movsd %xmm4, 0x10(%rsp)
movq $0x0, 0x38(%rsp)
xorpd %xmm1, %xmm1
xorpd %xmm3, %xmm3
xorpd %xmm4, %xmm4
xorpd %xmm7, %xmm7
callq 0x487e2
movq %rbx, %rax
addq $0x40, %rsp
popq %rbx
retq
nop
// File: /workspace/github_cpp_makefile_star2_O1/tomfunkhouser[P]gaps/pkgs/RGBD/RGBDImage.cpp
// Function: gaps::RGBDImage::PixelColor(int, int) const
RNRgb RGBDImage::
PixelColor(int ix, int iy) const
{
  // Return color of pixel
  if (NChannels() < 3) return RNblack_rgb;
  RNScalar r = PixelChannelValue(ix, iy, RGBD_RED_CHANNEL);
  RNScalar g = PixelChannelValue(ix, iy, RGBD_GREEN_CHANNEL);
  RNScalar b = PixelChannelValue(ix, iy, RGBD_BLUE_CHANNEL);
  return RNRgb(r, g, b);
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %rbx
subq $0x18, %rsp
movq %rdi, %rbx
cmpl $0x2, 0x24(%rsi)
jg 0x1d9ff
leaq 0xebb0e(%rip), %rsi     # 0x109500
movq %rbx, %rdi
callq 0x7606a
jmp 0x1daee
movl %ecx, %ebp
movl %edx, %r14d
movq %rsi, %r15
movq 0x18(%rsi), %rax
movq (%rax), %rax
testq %rax, %rax
je 0x1da2f
movq 0xb8(%rax), %rcx
movl 0xc8(%rax), %eax
imull %ebp, %eax
addl %r14d, %eax
cltq
movsd (%rcx,%rax,8), %xmm0
jmp 0x1da45
leaq 0xa04d8(%rip), %rdi     # 0xbdf0e
xorl %eax, %eax
callq 0x79092
movsd 0x9f5d3(%rip), %xmm0    # 0xbd018
movq 0x18(%r15), %rax
movq 0x8(%rax), %rax
testq %rax, %rax
je 0x1da6e
movq 0xb8(%rax), %rcx
movl 0xc8(%rax), %eax
imull %ebp, %eax
addl %r14d, %eax
cltq
movsd (%rcx,%rax,8), %xmm1
jmp 0x1da90
leaq 0xa0499(%rip), %rdi     # 0xbdf0e
xorl %eax, %eax
movsd %xmm0, 0x8(%rsp)
callq 0x79092
movsd 0x8(%rsp), %xmm0
movsd 0x9f588(%rip), %xmm1    # 0xbd018
movq 0x18(%r15), %rax
movq 0x10(%rax), %rax
testq %rax, %rax
je 0x1dab8
imull 0xc8(%rax), %ebp
movq 0xb8(%rax), %rax
addl %r14d, %ebp
movslq %ebp, %rcx
movsd (%rax,%rcx,8), %xmm2
jmp 0x1dae6
leaq 0xa044f(%rip), %rdi     # 0xbdf0e
xorl %eax, %eax
movsd %xmm0, 0x8(%rsp)
movsd %xmm1, 0x10(%rsp)
callq 0x79092
movsd 0x10(%rsp), %xmm1
movsd 0x8(%rsp), %xmm0
movsd 0x9f532(%rip), %xmm2    # 0xbd018
movq %rbx, %rdi
callq 0x76088
movq %rbx, %rax
addq $0x18, %rsp
popq %rbx
popq %r14
popq %r15
popq %rbp
retq
// File: /workspace/github_cpp_makefile_star2_O1/tomfunkhouser[P]gaps/pkgs/RGBD/RGBDImage.cpp
// Function: gaps::RGBDImage::PixelColor(gaps::R2Point const&) const
RNRgb RGBDImage::
PixelColor(const R2Point& image_position) const
{
  // Return color of pixel
  if (NChannels() < 3) return RNblack_rgb;
  RNScalar r = PixelChannelValue(image_position, RGBD_RED_CHANNEL);
  RNScalar g = PixelChannelValue(image_position, RGBD_GREEN_CHANNEL);
  RNScalar b = PixelChannelValue(image_position, RGBD_BLUE_CHANNEL);
  return RNRgb(r, g, b);
}

// Assembly:
pushq %r15
pushq %r14
pushq %rbx
subq $0x10, %rsp
movq %rdi, %rbx
cmpl $0x2, 0x24(%rsi)
jg 0x1dcff
leaq 0xeb80b(%rip), %rsi     # 0x109500
movq %rbx, %rdi
callq 0x7606a
jmp 0x1dd6b
movq %rdx, %r14
movq %rsi, %r15
movq 0x18(%rsi), %rax
movq (%rax), %rdi
movsd (%rdx), %xmm0
movsd 0x8(%rdx), %xmm1
callq 0x6174e
movsd %xmm0, 0x8(%rsp)
movq 0x18(%r15), %rax
movq 0x8(%rax), %rdi
movsd (%r14), %xmm0
movsd 0x8(%r14), %xmm1
callq 0x6174e
movsd %xmm0, (%rsp)
movq 0x18(%r15), %rax
movq 0x10(%rax), %rdi
movsd (%r14), %xmm0
movsd 0x8(%r14), %xmm1
callq 0x6174e
movaps %xmm0, %xmm2
movq %rbx, %rdi
movsd 0x8(%rsp), %xmm0
movsd (%rsp), %xmm1
callq 0x76088
movq %rbx, %rax
addq $0x10, %rsp
popq %rbx
popq %r14
popq %r15
retq
// File: /workspace/github_cpp_makefile_star2_O1/tomfunkhouser[P]gaps/pkgs/RGBD/RGBDImage.cpp
// Function: gaps::RGBDImage::PixelWorldRay(gaps::R2Point const&) const
R3Ray RGBDImage::
PixelWorldRay(const R2Point& image_position) const
{
  // Get/check intrinsics matrix
  const R3Matrix& intrinsics_matrix = Intrinsics();
  if (RNIsZero(intrinsics_matrix[0][0])) return R3null_ray;
  if (RNIsZero(intrinsics_matrix[1][1])) return R3null_ray;

  // Get point at depth 1.0 along ray in camera coordinates
  R3Point camera_position;
  camera_position[0] = (image_position[0] - intrinsics_matrix[0][2]) / intrinsics_matrix[0][0];
  camera_position[1] = (image_position[1] - intrinsics_matrix[1][2]) / intrinsics_matrix[1][1];
  camera_position[2] = -1.0;

  // Create ray and transform into world coordinates
  R3Ray ray(R3zero_point, camera_position);
  ray.Transform(camera_to_world);

  // Return ray through pixel in world coordinates
  return ray;
}

// Assembly:
pushq %r15
pushq %r14
pushq %r12
pushq %rbx
subq $0x18, %rsp
movq %rdx, %r15
movq %rsi, %r14
movq %rdi, %rbx
movsd 0x140(%rsi), %xmm2
leaq 0xe8f19(%rip), %rax     # 0x106ce8
movsd (%rax), %xmm0
movapd 0x9f275(%rip), %xmm1    # 0xbd050
xorpd %xmm0, %xmm1
ucomisd %xmm1, %xmm2
jb 0x1ddeb
ucomisd %xmm2, %xmm0
jae 0x1de00
movsd 0x160(%r14), %xmm2
ucomisd %xmm1, %xmm2
jb 0x1de11
ucomisd %xmm2, %xmm0
jb 0x1de11
leaq 0xe9b09(%rip), %rsi     # 0x107910
movq %rbx, %rdi
callq 0x4ba2e
jmp 0x1de83
movq %rsp, %r12
movq %r12, %rdi
callq 0x4be44
movupd 0x140(%r14), %xmm0
movupd 0x150(%r14), %xmm1
movhpd 0x168(%r14), %xmm1      # xmm1 = xmm1[0],mem[0]
movupd (%r15), %xmm2
subpd %xmm1, %xmm2
movhpd 0x160(%r14), %xmm0      # xmm0 = xmm0[0],mem[0]
divpd %xmm0, %xmm2
movapd %xmm2, (%r12)
movabsq $-0x4010000000000000, %rax # imm = 0xBFF0000000000000
movq %rax, 0x10(%r12)
leaq 0xe9d47(%rip), %rsi     # 0x107bb0
movq %rbx, %rdi
movq %r12, %rdx
callq 0x4ba3a
addq $0x30, %r14
movq %rbx, %rdi
movq %r14, %rsi
callq 0x4bb08
movq %rbx, %rax
addq $0x18, %rsp
popq %rbx
popq %r12
popq %r14
popq %r15
retq
// File: /workspace/github_cpp_makefile_star2_O1/tomfunkhouser[P]gaps/pkgs/RGBD/RGBDImage.cpp
// Function: gaps::RGBDImage::SetNPixels(int, int)
void RGBDImage::
SetNPixels(int nx, int ny)
{
  // Resample color channels
  for (int i = RGBD_RED_CHANNEL; i <= RGBD_BLUE_CHANNEL; i++) {
    if (channels.NEntries() <= i) continue;
    if (channels[i]) channels[i]->Resample(nx, ny);
  }

  // Resample other channels (without interpolation)
  for (int i = RGBD_DEPTH_CHANNEL; i < channels.NEntries(); i++) {
    if (channels.NEntries() <= i) continue;
    R3Matrix tmp(R3identity_matrix);
    if (channels[i]) RGBDResampleDepthImage(*(channels[i]), tmp, nx, ny);
  }

  // Update intrinsics 
  double xscale = (nx > 0) ? (double) width / (double) nx : 1;
  double yscale = (ny > 0) ? (double) height / (double) ny : 1;
  this->intrinsics[0][0] /= xscale;
  this->intrinsics[0][2] /= xscale;
  this->intrinsics[1][1] /= yscale;
  this->intrinsics[1][2] /= yscale;

  // Update width and height of image
  this->width = nx;
  this->height = ny;

  // Invalidate opengl
  InvalidateOpenGL();
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x48, %rsp
movl %edx, %ebp
movl %esi, %r14d
movq %rdi, %rbx
xorl %r15d, %r15d
movslq 0x24(%rbx), %rax
cmpq %rax, %r15
jge 0x1decd
movq 0x18(%rbx), %rax
movq (%rax,%r15,8), %rdi
testq %rdi, %rdi
je 0x1decd
movl %r14d, %esi
movl %ebp, %edx
xorl %ecx, %ecx
callq 0x65d5a
incq %r15
cmpq $0x3, %r15
jne 0x1deab
cmpl $0x4, 0x24(%rbx)
jl 0x1df1d
movl $0x3, %r13d
leaq 0xa23bf(%rip), %r15     # 0xc02a8
movq %rsp, %r12
movq %r12, %rdi
movq %r15, %rsi
callq 0x6dfb2
movq 0x18(%rbx), %rax
movq (%rax,%r13,8), %rdi
testq %rdi, %rdi
je 0x1df11
movq %r12, %rsi
movl %r14d, %edx
movl %ebp, %ecx
callq 0x238b1
incq %r13
movslq 0x24(%rbx), %rax
cmpq %rax, %r13
jl 0x1deec
movsd 0x9f103(%rip), %xmm0    # 0xbd028
testl %r14d, %r14d
jg 0x1df30
movapd %xmm0, %xmm1
jmp 0x1df3e
cvtsi2sdl 0x28(%rbx), %xmm1
cvtsi2sd %r14d, %xmm2
divsd %xmm2, %xmm1
testl %ebp, %ebp
jle 0x1df55
xorps %xmm0, %xmm0
cvtsi2sdl 0x2c(%rbx), %xmm0
xorps %xmm2, %xmm2
cvtsi2sd %ebp, %xmm2
divsd %xmm2, %xmm0
movsd 0x140(%rbx), %xmm2
divsd %xmm1, %xmm2
movsd %xmm2, 0x140(%rbx)
movsd 0x150(%rbx), %xmm2
divsd %xmm1, %xmm2
movsd %xmm2, 0x150(%rbx)
movupd 0x160(%rbx), %xmm1
unpcklpd %xmm0, %xmm0            # xmm0 = xmm0[0,0]
divpd %xmm0, %xmm1
movupd %xmm1, 0x160(%rbx)
movl %r14d, 0x28(%rbx)
movl %ebp, 0x2c(%rbx)
movq (%rbx), %rax
movq %rbx, %rdi
callq *0x1c8(%rax)
addq $0x48, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
nop
// File: /workspace/github_cpp_makefile_star2_O1/tomfunkhouser[P]gaps/pkgs/RGBD/RGBDImage.cpp
// Function: gaps::RGBDImage::SetPixelColor(int, int, gaps::RNRgb const&)
void RGBDImage::
SetPixelColor(int ix, int iy, const RNRgb& color)
{
  // Set pixel red, green, and blue
  SetPixelChannelValue(ix, iy, RGBD_RED_CHANNEL, color.R());
  SetPixelChannelValue(ix, iy, RGBD_GREEN_CHANNEL, color.G());
  SetPixelChannelValue(ix, iy, RGBD_BLUE_CHANNEL, color.B());

  // Invalidate opengl
  InvalidateOpenGL();
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %rbx
pushq %rax
movq %rcx, %r14
movl %edx, %ebp
movl %esi, %r15d
movq %rdi, %rbx
movsd (%rcx), %xmm0
movq (%rdi), %rax
xorl %ecx, %ecx
callq *0x38(%rax)
movsd 0x8(%r14), %xmm0
movq (%rbx), %rax
movq %rbx, %rdi
movl %r15d, %esi
movl %ebp, %edx
movl $0x1, %ecx
callq *0x38(%rax)
movsd 0x10(%r14), %xmm0
movq (%rbx), %rax
movq %rbx, %rdi
movl %r15d, %esi
movl %ebp, %edx
movl $0x2, %ecx
callq *0x38(%rax)
movq (%rbx), %rax
movq %rbx, %rdi
addq $0x8, %rsp
popq %rbx
popq %r14
popq %r15
popq %rbp
jmpq *0x1c8(%rax)
// File: /workspace/github_cpp_makefile_star2_O1/tomfunkhouser[P]gaps/pkgs/RGBD/RGBDImage.cpp
// Function: gaps::RGBDImage::SetPixelDepth(int, int, double)
void RGBDImage::
SetPixelDepth(int ix, int iy, RNScalar depth)
{
  // Set pixel depth
  SetPixelChannelValue(ix, iy, RGBD_DEPTH_CHANNEL, depth);

  // Update bounding box
  R3Point world_position;
  R2Point image_position(ix+0.5, iy+0.5);
  if (RGBDTransformImageToWorld(image_position, world_position, this)) {
    world_bbox.Union(world_position);
  }
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %rbx
subq $0x28, %rsp
movl %edx, %ebp
movl %esi, %r14d
movq %rdi, %rbx
movq (%rdi), %rax
movl $0x3, %ecx
callq *0x38(%rax)
movq %rsp, %r15
movq %r15, %rdi
callq 0x4be44
xorps %xmm0, %xmm0
cvtsi2sd %r14d, %xmm0
movsd 0x9efca(%rip), %xmm2    # 0xbd020
addsd %xmm2, %xmm0
cvtsi2sd %ebp, %xmm1
addsd %xmm2, %xmm1
leaq 0x18(%rsp), %r14
movq %r14, %rdi
callq 0x6fee6
movq %r14, %rdi
movq %r15, %rsi
movq %rbx, %rdx
callq 0x16443
testl %eax, %eax
je 0x1e093
addq $0x188, %rbx            # imm = 0x188
movq %rsp, %rsi
movq %rbx, %rdi
callq 0x44096
addq $0x28, %rsp
popq %rbx
popq %r14
popq %r15
popq %rbp
retq
// File: /workspace/github_cpp_makefile_star2_O1/tomfunkhouser[P]gaps/pkgs/RGBD/RGBDImage.cpp
// Function: gaps::RGBDImage::SetPixelChannelValue(int, int, int, double)
void RGBDImage::
SetPixelChannelValue(int ix, int iy, int channel_index, RNScalar value)
{
  // Check channel
  if (!channels[channel_index]) {
    RNFail("RGBD channel is not resident in memory -- cannot set value\n");
    return;
  }
  
  // Set channel value at pixel
  if ((channel_index < 0) || (channel_index >= channels.NEntries())) return;
  if ((ix < 0) || (ix >= channels[channel_index]->XResolution())) return;
  if ((iy < 0) || (iy >= channels[channel_index]->YResolution())) return;
  channels[channel_index]->SetGridValue(ix, iy, value);

  // Update bounding box
  if (channel_index == RGBD_DEPTH_CHANNEL) {
    R3Point world_position;
    R2Point image_position(ix+0.5, iy+0.5);
    if (RGBDTransformImageToWorld(image_position, world_position, this)) {
      world_bbox.Union(world_position);
    }
  }

  // Invalidate opengl
  if ((channel_index >= RGBD_RED_CHANNEL) && (channel_index <= RGBD_BLUE_CHANNEL)) InvalidateOpenGL();
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r12
pushq %rbx
subq $0x30, %rsp
movl %ecx, %ebp
movq 0x18(%rdi), %rax
movslq %ecx, %rcx
movq (%rax,%rcx,8), %rax
testq %rax, %rax
je 0x1e1b8
testl %ebp, %ebp
js 0x1e1ab
movl %esi, %r15d
testl %esi, %esi
js 0x1e1ab
movq %rdi, %rbx
cmpl %ebp, 0x24(%rdi)
jle 0x1e1ab
movl %edx, %r14d
testl %edx, %edx
js 0x1e1ab
cmpl %r15d, 0xc0(%rax)
jle 0x1e1ab
cmpl %r14d, 0xc4(%rax)
jle 0x1e1ab
movq 0xb8(%rax), %rcx
movl 0xc8(%rax), %eax
imull %r14d, %eax
addl %r15d, %eax
cltq
movsd %xmm0, (%rcx,%rax,8)
cmpl $0x3, %ebp
jne 0x1e19a
leaq 0x8(%rsp), %r12
movq %r12, %rdi
callq 0x4be44
xorps %xmm0, %xmm0
cvtsi2sd %r15d, %xmm0
movsd 0x9eec3(%rip), %xmm2    # 0xbd020
addsd %xmm2, %xmm0
cvtsi2sd %r14d, %xmm1
addsd %xmm2, %xmm1
leaq 0x20(%rsp), %r14
movq %r14, %rdi
callq 0x6fee6
movq %r14, %rdi
movq %r12, %rsi
movq %rbx, %rdx
callq 0x16443
testl %eax, %eax
je 0x1e19a
leaq 0x188(%rbx), %rdi
leaq 0x8(%rsp), %rsi
callq 0x44096
cmpl $0x2, %ebp
jg 0x1e1ab
movq (%rbx), %rax
movq %rbx, %rdi
callq *0x1c8(%rax)
addq $0x30, %rsp
popq %rbx
popq %r12
popq %r14
popq %r15
popq %rbp
retq
leaq 0x9ff0b(%rip), %rdi     # 0xbe0ca
xorl %eax, %eax
addq $0x30, %rsp
popq %rbx
popq %r12
popq %r14
popq %r15
popq %rbp
jmp 0x79092
// File: /workspace/github_cpp_makefile_star2_O1/tomfunkhouser[P]gaps/pkgs/RGBD/RGBDImage.cpp
// Function: gaps::RGBDImage::SetChannel(int, gaps::R2Grid const&)
void RGBDImage::
SetChannel(int channel_index, const R2Grid& image)
{
  // Check channel
  if (!channels[channel_index]) {
    RNFail("RGBD channel is not resident in memory -- cannot set\n");
    return;
  }
  
  // Copy channel
  *(channels[channel_index]) = image;
  
  // Set width and height
  this->width = image.XResolution();
  this->height = image.YResolution();

  // Invalidate bounding box
  if (channel_index == RGBD_DEPTH_CHANNEL) InvalidateWorldBBox();

  // Invalidate opengl
  if ((channel_index >= RGBD_RED_CHANNEL) && (channel_index <= RGBD_BLUE_CHANNEL)) InvalidateOpenGL();
}

// Assembly:
pushq %rbp
pushq %r14
pushq %rbx
movq %rdi, %rbx
movq 0x18(%rdi), %rax
movslq %esi, %rcx
movq (%rax,%rcx,8), %rdi
testq %rdi, %rdi
je 0x1e230
movq %rdx, %r14
movl %esi, %ebp
movq %rdx, %rsi
callq 0x60d3c
movl 0xc0(%r14), %eax
movl %eax, 0x28(%rbx)
movl 0xc4(%r14), %eax
movl %eax, 0x2c(%rbx)
cmpl $0x3, %ebp
jne 0x1e21b
movq (%rbx), %rax
movq %rbx, %rdi
callq *0x1c0(%rax)
cmpl $0x2, %ebp
ja 0x1e242
movq (%rbx), %rax
movq %rbx, %rdi
popq %rbx
popq %r14
popq %rbp
jmpq *0x1c8(%rax)
leaq 0x9fecf(%rip), %rdi     # 0xbe106
xorl %eax, %eax
popq %rbx
popq %r14
popq %rbp
jmp 0x79092
popq %rbx
popq %r14
popq %rbp
retq
nop
// File: /workspace/github_cpp_makefile_star2_O1/tomfunkhouser[P]gaps/pkgs/RGBD/RGBDImage.cpp
// Function: gaps::RGBDImage::Transform(gaps::R3Transformation const&)
void RGBDImage::
Transform(const R3Transformation& transformation)
{
  // Update camera_to_world transformation
  R3Affine t = R3identity_affine;
  t.Transform(transformation);
  t.Transform(camera_to_world);
  camera_to_world = t;

  // Invalidate bounding box
  InvalidateWorldBBox();
}

// Assembly:
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x110, %rsp            # imm = 0x110
movq %rsi, %r12
movq %rdi, %rbx
leaq 0xe505f(%rip), %rax     # 0x103500
addq $0x10, %rax
leaq 0x8(%rsp), %r14
movq %rax, -0x8(%r14)
leaq 0xe8feb(%rip), %r13     # 0x1074a0
leaq 0x8(%r13), %rsi
movq %r14, %rdi
callq 0x48742
movl $0x88, %esi
movq %rsp, %r15
addq %rsi, %r15
addq 0xe7b0d(%rip), %rsi     # 0x105fe0
movq %r15, %rdi
callq 0x48742
movq 0x108(%r13), %rax
movq %rsp, %rdi
movq %rax, 0x108(%rdi)
movq %r12, %rsi
callq 0x469dc
leaq 0x30(%rbx), %rsi
movq %rsp, %rdi
callq 0x46572
leaq 0x38(%rbx), %rdi
movq %r14, %rsi
callq 0x4a326
leaq 0xb8(%rbx), %rdi
movq %r15, %rsi
callq 0x4a326
movq 0x108(%rsp), %rax
movq %rax, 0x138(%rbx)
movq (%rbx), %rax
movq %rbx, %rdi
callq *0x1c0(%rax)
movq %rsp, %rdi
callq 0x46404
addq $0x110, %rsp            # imm = 0x110
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
retq
movq %rax, %rbx
movq %rsp, %rdi
callq 0x46a8c
jmp 0x1e567
movq %rax, %rbx
movq %rsp, %rdi
callq 0x46404
movq %rbx, %rdi
callq 0x11a70
nop
// File: /workspace/github_cpp_makefile_star2_O1/tomfunkhouser[P]gaps/pkgs/RGBD/RGBDImage.cpp
// Function: gaps::RGBDImage::TransformImageToCamera(gaps::R2Point const&, gaps::R3Point&) const
int RGBDImage::
TransformImageToCamera(const R2Point& image_position, R3Point& camera_position) const
{
  // Check image position
  int ix = (int) image_position[0];
  if ((ix < 0) || (ix >= NPixels(RN_X))) return 0; 
  int iy = (int) image_position[1];
  if ((iy < 0) || (iy >= NPixels(RN_Y))) return 0; 
  
  // Get/check depth (point sample to avoid interpolation)
  RNScalar depth = PixelDepth(ix, iy);
  if ((RNIsZero(depth)) || (depth == R2_GRID_UNKNOWN_VALUE)) return 0;

  // Get/check intrinsics matrix
  const R3Matrix& intrinsics_matrix = Intrinsics();
  if (RNIsZero(intrinsics_matrix[0][0])) return 0;
  if (RNIsZero(intrinsics_matrix[1][1])) return 0;
  
  // Transform from position in image coordinates to camera coordinates (where camera is looking down -Z, up is +Y, right is +X)
  camera_position[0] = (image_position[0] - intrinsics_matrix[0][2]) * depth / intrinsics_matrix[0][0];
  camera_position[1] = (image_position[1] - intrinsics_matrix[1][2]) * depth / intrinsics_matrix[1][1];
  camera_position[2] = -depth;

  // Return success
  return 1;
}

// Assembly:
pushq %r15
pushq %r14
pushq %r12
pushq %rbx
pushq %rax
cvttsd2si (%rsi), %eax
xorl %ebx, %ebx
testl %eax, %eax
js 0x1e6b8
movq %rdi, %r15
cmpl %eax, 0x28(%rdi)
jle 0x1e6b8
movq %rsi, %r12
cvttsd2si 0x8(%rsi), %ecx
testl %ecx, %ecx
js 0x1e6b8
cmpl %ecx, 0x2c(%r15)
jle 0x1e6b8
movq %rdx, %r14
xorpd %xmm0, %xmm0
cmpl $0x4, 0x24(%r15)
jl 0x1e5f7
movq 0x18(%r15), %rdx
movq 0x18(%rdx), %rdx
testq %rdx, %rdx
je 0x1e5e1
imull 0xc8(%rdx), %ecx
movq 0xb8(%rdx), %rdx
addl %eax, %ecx
movslq %ecx, %rax
movsd (%rdx,%rax,8), %xmm0
jmp 0x1e5f7
leaq 0x9f926(%rip), %rdi     # 0xbdf0e
xorl %eax, %eax
callq 0x79092
movsd 0x9ea21(%rip), %xmm0    # 0xbd018
ucomisd 0x9ea19(%rip), %xmm0    # 0xbd018
jne 0x1e607
jnp 0x1e6b8
leaq 0xe86da(%rip), %rax     # 0x106ce8
movsd (%rax), %xmm1
movapd 0x9ea36(%rip), %xmm3    # 0xbd050
xorpd %xmm1, %xmm3
movapd %xmm0, %xmm2
cmplepd %xmm1, %xmm2
movapd %xmm3, %xmm4
cmplepd %xmm0, %xmm4
andpd %xmm2, %xmm4
movd %xmm4, %eax
testb $0x1, %al
jne 0x1e6b8
movsd 0x140(%r15), %xmm2
ucomisd %xmm3, %xmm2
jb 0x1e651
ucomisd %xmm2, %xmm1
jae 0x1e6b8
movsd 0x160(%r15), %xmm4
ucomisd %xmm3, %xmm4
jb 0x1e666
ucomisd %xmm4, %xmm1
jae 0x1e6b8
movsd (%r12), %xmm1
subsd 0x150(%r15), %xmm1
mulsd %xmm0, %xmm1
divsd %xmm2, %xmm1
movsd %xmm1, (%r14)
movsd 0x8(%r12), %xmm1
subsd 0x168(%r15), %xmm1
mulsd %xmm0, %xmm1
divsd 0x160(%r15), %xmm1
movsd %xmm1, 0x8(%r14)
xorpd 0x9e9a3(%rip), %xmm0    # 0xbd050
movlpd %xmm0, 0x10(%r14)
movl $0x1, %ebx
movl %ebx, %eax
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r14
popq %r15
retq
// File: /workspace/github_cpp_makefile_star2_O1/tomfunkhouser[P]gaps/pkgs/RGBD/RGBDImage.cpp
// Function: gaps::RGBDImage::TransformCameraToWorld(gaps::R3Point const&, gaps::R3Point&) const
int RGBDImage::
TransformCameraToWorld(const R3Point& camera_position, R3Point& world_position) const
{
  // Transform from camera coordinates to world coordinates
  world_position = camera_position;
  world_position.Transform(CameraToWorld());
  return 1;
}

// Assembly:
pushq %r14
pushq %rbx
pushq %rax
movq %rdx, %rbx
movq %rdi, %r14
movq %rdx, %rdi
callq 0x4c1b4
addq $0x30, %r14
movq %rbx, %rdi
movq %r14, %rsi
callq 0x4c762
movl $0x1, %eax
addq $0x8, %rsp
popq %rbx
popq %r14
retq
// File: /workspace/github_cpp_makefile_star2_O1/tomfunkhouser[P]gaps/pkgs/RGBD/RGBDImage.cpp
// Function: gaps::RGBDImage::TransformWorldToCamera(gaps::R3Point const&, gaps::R3Point&) const
int RGBDImage::
TransformWorldToCamera(const R3Point& world_position, R3Point& camera_position) const
{
  // Transform from position in world coordinates to camera coordinates
  camera_position = world_position;
  camera_position.InverseTransform(CameraToWorld());
  if (RNIsPositiveOrZero(camera_position[2])) return 0;
  return 1;
}

// Assembly:
pushq %r14
pushq %rbx
pushq %rax
movq %rdx, %rbx
movq %rdi, %r14
movq %rdx, %rdi
callq 0x4c1b4
addq $0x30, %r14
movq %rbx, %rdi
movq %r14, %rsi
callq 0x4c774
movsd 0x10(%rbx), %xmm0
leaq 0xe84fd(%rip), %rax     # 0x106ce8
movsd (%rax), %xmm1
xorpd 0x9e859(%rip), %xmm1    # 0xbd050
xorl %eax, %eax
ucomisd %xmm1, %xmm0
setb %al
addq $0x8, %rsp
popq %rbx
popq %r14
retq
// File: /workspace/github_cpp_makefile_star2_O1/tomfunkhouser[P]gaps/pkgs/RGBD/RGBDImage.cpp
// Function: gaps::RGBDImage::DrawCamera(int, double) const
void RGBDImage::
DrawCamera(int color_scheme, RNLength radius) const
{
  // Get useful variables
  R3Point viewpoint = WorldViewpoint();
  R3Vector towards = WorldTowards();
  R3Vector up = WorldUp();

  // Load color
  if (color_scheme == RGBD_NO_COLOR_SCHEME) LoadColor(color_scheme);
  else if (color_scheme == RGBD_HIGHLIGHT_COLOR_SCHEME) LoadColor(color_scheme);
  else if (color_scheme != RGBD_NO_COLOR_SCHEME) LoadColor(RGBD_INDEX_COLOR_SCHEME);

  // Draw camera
  RNGrfxBegin(RN_GRFX_LINES);
  R3LoadPoint(viewpoint);
  R3LoadPoint(viewpoint + radius * towards);
  R3LoadPoint(viewpoint);
  R3LoadPoint(viewpoint + 0.5*radius * up);
  RNGrfxEnd();
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x88, %rsp
movsd %xmm0, 0x8(%rsp)
movl %esi, %ebp
movq %rdi, %r12
leaq 0x38(%rdi), %r13
leaq 0xe930d(%rip), %rdx     # 0x107bb0
leaq 0x70(%rsp), %rbx
movq %rbx, %rdi
movq %r13, %rsi
callq 0x4a83e
leaq 0xa072e(%rip), %rdx     # 0xbefe8
leaq 0x58(%rsp), %r15
movq %r15, %rdi
movq %r13, %rsi
callq 0x4a7c6
leaq 0xa06b7(%rip), %rdx     # 0xbef88
leaq 0x40(%rsp), %r14
movq %r14, %rdi
movq %r13, %rsi
callq 0x4a7c6
movq (%r12), %rax
xorl %esi, %esi
cmpl $0x4, %ebp
sete %sil
addl $0x3, %esi
testl %ebp, %ebp
cmovel %ebp, %esi
movq %r12, %rdi
callq *0xf0(%rax)
movl $0x1, %edi
callq 0x11150
movq %rbx, %rdi
callq 0x11170
leaq 0x10(%rsp), %r12
movq %r12, %rdi
movq %r15, %rsi
movsd 0x8(%rsp), %xmm0
callq 0x4d2ae
leaq 0x28(%rsp), %r15
movq %r15, %rdi
movq %rbx, %rsi
movq %r12, %rdx
callq 0x4c191
movq %r15, %rdi
callq 0x11170
movq %rbx, %rdi
callq 0x11170
movsd 0x8(%rsp), %xmm0
mulsd 0x9e6c8(%rip), %xmm0    # 0xbd020
leaq 0x10(%rsp), %r15
movq %r15, %rdi
movq %r14, %rsi
callq 0x4d2ae
leaq 0x28(%rsp), %r14
movq %r14, %rdi
movq %rbx, %rsi
movq %r15, %rdx
callq 0x4c191
movq %r14, %rdi
callq 0x11170
callq 0x117d0
addq $0x88, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq