// File: /workspace/github_cpp_makefile_star2_O3/tomfunkhouser[P]gaps/pkgs/RGBD/RGBDImage.cpp
// Function: gaps::RGBDImage::WorldBBox() const
R3Box RGBDImage::
WorldBBox(void) const
{
  // Return remembered bounding box of points in world coordinates, if valid
  if (!world_bbox.IsEmpty()) return world_bbox;

  // Compute world bounding box
  R3Box b = R3null_box;
  if (DepthChannel()) {
    // Compute world bounding box of points
    int skip = 1;
    b = R3null_box;
    for (int iy = 0; iy < height; iy += skip) {
      for (int ix = 0; ix < width; ix += skip) {
        R3Point world_position;
        R2Point image_position(ix+0.5, iy+0.5);
        if (RGBDTransformImageToWorld(image_position, world_position, this)) {
          b.Union(world_position);
        }
      }
    }

    // Just so that don't compute again if empty
    if (b.IsEmpty()) b.Union(WorldViewpoint());

    // Remember world bounding box
    ((RGBDImage *) this)->world_bbox = b;
  }
  else {
    // Return conservative bounding box without reading image
    RNLength max_depth = 7.0;
    RNScalar xfocal = Intrinsics()[0][0];
    RNScalar yfocal = Intrinsics()[1][1];
    RNScalar tan_xfov = (xfocal > 0) ? 0.5*NPixels(RN_X) / xfocal : 1.0;
    RNScalar tan_yfov = (yfocal > 0) ? 0.5*NPixels(RN_Y) / yfocal : 1.0;
    R3Point c = WorldViewpoint() + max_depth * WorldTowards();
    R3Vector dx = WorldRight() * max_depth * tan_xfov * WorldRight();
    R3Vector dy = WorldRight() * max_depth * tan_yfov * WorldUp();
    b.Union(WorldViewpoint());
    b.Union(c - dx - dy);
    b.Union(c + dx - dy);
    b.Union(c - dx + dy);
    b.Union(c + dx + dy);
  }

  // Return computed bounding box
  return b;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0xd8, %rsp
movq %rsi, %r14
movq %rdi, %rbx
movsd 0x190(%rsi), %xmm0
ucomisd 0x1a8(%rsi), %xmm0
ja 0x1d2c2
movsd 0x198(%r14), %xmm0
ucomisd 0x1b0(%r14), %xmm0
ja 0x1d2c2
movsd 0x1a0(%r14), %xmm0
ucomisd 0x1b8(%r14), %xmm0
ja 0x1d2c2
addq $0x188, %r14            # imm = 0x188
movq %rbx, %rdi
movq %r14, %rsi
callq 0x42f14
jmp 0x1d6ea
leaq 0xe805f(%rip), %r13     # 0x105328
movq %rbx, %rdi
movq %r13, %rsi
callq 0x42f14
cmpl $0x4, 0x24(%r14)
jl 0x1d430
movq 0x18(%r14), %rax
cmpq $0x0, 0x18(%rax)
je 0x1d430
leaq 0x8(%rbx), %rdi
leaq 0x8(%r13), %rsi
movq %rdi, 0x18(%rsp)
callq 0x4b96a
leaq 0x20(%rbx), %r15
addq $0x20, %r13
movq %r15, %rdi
movq %r13, %rsi
callq 0x4b96a
movq %r15, 0x80(%rsp)
movl 0x2c(%r14), %ecx
testl %ecx, %ecx
jle 0x1d3b6
movl 0x28(%r14), %eax
xorl %r12d, %r12d
leaq 0x68(%rsp), %r13
leaq 0x50(%rsp), %rbp
testl %eax, %eax
jle 0x1d3ae
xorps %xmm0, %xmm0
cvtsi2sd %r12d, %xmm0
addsd 0x9dcd4(%rip), %xmm0    # 0xbb020
movsd %xmm0, 0x90(%rsp)
xorl %r15d, %r15d
movq %r13, %rdi
callq 0x4b600
xorps %xmm0, %xmm0
cvtsi2sd %r15d, %xmm0
addsd 0x9dcb0(%rip), %xmm0    # 0xbb020
movq %rbp, %rdi
movsd 0x90(%rsp), %xmm1
callq 0x6f0d6
movq %rbp, %rdi
movq %r13, %rsi
movq %r14, %rdx
callq 0x16377
testl %eax, %eax
je 0x1d39e
movq %rbx, %rdi
movq %r13, %rsi
callq 0x43906
incl %r15d
movl 0x28(%r14), %eax
cmpl %eax, %r15d
jl 0x1d358
movl 0x2c(%r14), %ecx
incl %r12d
cmpl %ecx, %r12d
jl 0x1d338
movq 0x18(%rsp), %r15
movsd (%r15), %xmm0
movq 0x80(%rsp), %r12
ucomisd (%r12), %xmm0
ja 0x1d3e8
movsd 0x10(%rbx), %xmm0
ucomisd 0x28(%rbx), %xmm0
ja 0x1d3e8
movsd 0x18(%rbx), %xmm0
ucomisd 0x30(%rbx), %xmm0
jbe 0x1d40a
leaq 0x38(%r14), %rsi
leaq 0xe87ad(%rip), %rdx     # 0x105ba0
leaq 0x68(%rsp), %rdi
callq 0x49ffa
leaq 0x68(%rsp), %rsi
movq %rbx, %rdi
callq 0x43906
leaq 0x190(%r14), %rdi
movq %r15, %rsi
callq 0x4b96a
addq $0x1a8, %r14            # imm = 0x1A8
movq %r14, %rdi
movq %r12, %rsi
callq 0x4b96a
jmp 0x1d6ea
movsd 0x140(%r14), %xmm0
movsd %xmm0, 0x18(%rsp)
xorps %xmm0, %xmm0
cvtsi2sdl 0x28(%r14), %xmm0
movapd %xmm0, 0x90(%rsp)
movsd 0x160(%r14), %xmm0
movsd %xmm0, 0xa0(%rsp)
xorps %xmm0, %xmm0
cvtsi2sdl 0x2c(%r14), %xmm0
movapd %xmm0, 0x80(%rsp)
addq $0x38, %r14
leaq 0xe8720(%rip), %rdx     # 0x105ba0
leaq 0x50(%rsp), %rdi
movq %r14, %rsi
callq 0x49ffa
leaq 0x9fb54(%rip), %rdx     # 0xbcfe8
movq %rsp, %rdi
movq %r14, %rsi
callq 0x49f82
leaq 0x38(%rsp), %rdi
movq %rsp, %rsi
movsd 0x9eb91(%rip), %xmm0    # 0xbc040
callq 0x4ca32
leaq 0x68(%rsp), %rdi
leaq 0x50(%rsp), %rsi
leaq 0x38(%rsp), %rdx
callq 0x4b947
leaq 0x9faa1(%rip), %rdx     # 0xbcf70
leaq 0x20(%rsp), %rdi
movq %r14, %rsi
callq 0x49f82
movq %rsp, %rdi
leaq 0x20(%rsp), %rsi
movsd 0x9eb54(%rip), %xmm0    # 0xbc040
callq 0x4ca32
movapd 0x90(%rsp), %xmm1
mulsd 0x9db1e(%rip), %xmm1    # 0xbb020
movsd 0x18(%rsp), %xmm2
divsd %xmm2, %xmm1
xorpd %xmm0, %xmm0
cmpltsd %xmm2, %xmm0
andpd %xmm0, %xmm1
movsd 0x9db07(%rip), %xmm2    # 0xbb028
andnpd %xmm2, %xmm0
orpd %xmm1, %xmm0
leaq 0x38(%rsp), %rdi
movq %rsp, %rsi
callq 0x4ca32
leaq 0x9fa33(%rip), %rdx     # 0xbcf70
leaq 0xa8(%rsp), %rdi
movq %r14, %rsi
callq 0x49f82
leaq 0x50(%rsp), %rdi
leaq 0x38(%rsp), %rsi
leaq 0xa8(%rsp), %rdx
callq 0x4cd36
leaq 0x9fa05(%rip), %rdx     # 0xbcf70
leaq 0xa8(%rsp), %rdi
movq %r14, %rsi
callq 0x49f82
leaq 0x20(%rsp), %rdi
leaq 0xa8(%rsp), %rsi
movsd 0x9eab0(%rip), %xmm0    # 0xbc040
callq 0x4ca32
movapd 0x80(%rsp), %xmm2
mulsd 0x9da7a(%rip), %xmm2    # 0xbb020
movsd 0xa0(%rsp), %xmm1
divsd %xmm1, %xmm2
xorpd %xmm0, %xmm0
cmpltsd %xmm1, %xmm0
andpd %xmm0, %xmm2
movsd 0x9da60(%rip), %xmm1    # 0xbb028
andnpd %xmm1, %xmm0
orpd %xmm2, %xmm0
movq %rsp, %rdi
leaq 0x20(%rsp), %rsi
callq 0x4ca32
leaq 0x9f9a4(%rip), %rdx     # 0xbcf88
leaq 0xc0(%rsp), %rdi
movq %r14, %rsi
callq 0x49f82
leaq 0x38(%rsp), %rdi
movq %rsp, %rsi
leaq 0xc0(%rsp), %rdx
callq 0x4cd36
leaq 0xe8590(%rip), %rdx     # 0x105ba0
movq %rsp, %rdi
movq %r14, %rsi
callq 0x49ffa
movq %rsp, %rsi
movq %rbx, %rdi
callq 0x43906
leaq 0x20(%rsp), %rdi
leaq 0x68(%rsp), %rsi
leaq 0x50(%rsp), %rdx
callq 0x4c023
movq %rsp, %rdi
leaq 0x20(%rsp), %rsi
leaq 0x38(%rsp), %rdx
callq 0x4c023
movq %rsp, %rsi
movq %rbx, %rdi
callq 0x43906
leaq 0x20(%rsp), %rdi
leaq 0x68(%rsp), %rsi
leaq 0x50(%rsp), %rdx
callq 0x4b947
movq %rsp, %rdi
leaq 0x20(%rsp), %rsi
leaq 0x38(%rsp), %rdx
callq 0x4c023
movq %rsp, %rsi
movq %rbx, %rdi
callq 0x43906
leaq 0x20(%rsp), %rdi
leaq 0x68(%rsp), %rsi
leaq 0x50(%rsp), %rdx
callq 0x4c023
movq %rsp, %rdi
leaq 0x20(%rsp), %rsi
leaq 0x38(%rsp), %rdx
callq 0x4b947
movq %rsp, %rsi
movq %rbx, %rdi
callq 0x43906
leaq 0x20(%rsp), %rdi
leaq 0x68(%rsp), %rsi
leaq 0x50(%rsp), %rdx
callq 0x4b947
movq %rsp, %rdi
leaq 0x20(%rsp), %rsi
leaq 0x38(%rsp), %rdx
callq 0x4b947
movq %rsp, %rsi
movq %rbx, %rdi
callq 0x43906
movq %rbx, %rax
addq $0xd8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
jmp 0x1d71b
jmp 0x1d71b
jmp 0x1d71b
jmp 0x1d71b
jmp 0x1d71b
jmp 0x1d71b
jmp 0x1d71b
jmp 0x1d71b
jmp 0x1d71b
jmp 0x1d71b
jmp 0x1d71b
jmp 0x1d71b
jmp 0x1d71b
jmp 0x1d71b
movq %rax, %r14
movq %rbx, %rdi
callq 0x43d34
movq %r14, %rdi
callq 0x11a60