// File: /workspace/github_cpp_makefile_star2_O1/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 0x1d574
movsd 0x198(%r14), %xmm0
ucomisd 0x1b0(%r14), %xmm0
ja 0x1d574
movsd 0x1a0(%r14), %xmm0
ucomisd 0x1b8(%r14), %xmm0
ja 0x1d574
addq $0x188, %r14            # imm = 0x188
movq %rbx, %rdi
movq %r14, %rsi
callq 0x43678
jmp 0x1d994
leaq 0xe9dbd(%rip), %r13     # 0x107338
movq %rbx, %rdi
movq %r13, %rsi
callq 0x43678
cmpl $0x4, 0x24(%r14)
jl 0x1d6da
movq 0x18(%r14), %rax
cmpq $0x0, 0x18(%rax)
je 0x1d6da
leaq 0x8(%rbx), %rdi
leaq 0x8(%r13), %rsi
movq %rdi, 0x18(%rsp)
callq 0x4c1b4
leaq 0x20(%rbx), %r15
addq $0x20, %r13
movq %r15, %rdi
movq %r13, %rsi
callq 0x4c1b4
movq %r15, 0x80(%rsp)
cmpl $0x0, 0x2c(%r14)
jle 0x1d660
xorl %r12d, %r12d
leaq 0x68(%rsp), %r13
leaq 0x50(%rsp), %rbp
cmpl $0x0, 0x28(%r14)
jle 0x1d657
xorps %xmm0, %xmm0
cvtsi2sd %r12d, %xmm0
addsd 0x9fa24(%rip), %xmm0    # 0xbd020
movsd %xmm0, 0x90(%rsp)
xorl %r15d, %r15d
movq %r13, %rdi
callq 0x4be44
xorps %xmm0, %xmm0
cvtsi2sd %r15d, %xmm0
addsd 0x9fa00(%rip), %xmm0    # 0xbd020
movq %rbp, %rdi
movsd 0x90(%rsp), %xmm1
callq 0x6fee6
movq %rbp, %rdi
movq %r13, %rsi
movq %r14, %rdx
callq 0x16443
testl %eax, %eax
je 0x1d64e
movq %rbx, %rdi
movq %r13, %rsi
callq 0x44096
incl %r15d
cmpl 0x28(%r14), %r15d
jl 0x1d608
incl %r12d
cmpl 0x2c(%r14), %r12d
jl 0x1d5e5
movq 0x18(%rsp), %r15
movsd (%r15), %xmm0
movq 0x80(%rsp), %r12
ucomisd (%r12), %xmm0
ja 0x1d692
movsd 0x10(%rbx), %xmm0
ucomisd 0x28(%rbx), %xmm0
ja 0x1d692
movsd 0x18(%rbx), %xmm0
ucomisd 0x30(%rbx), %xmm0
jbe 0x1d6b4
leaq 0x38(%r14), %rsi
leaq 0xea513(%rip), %rdx     # 0x107bb0
leaq 0x68(%rsp), %rdi
callq 0x4a83e
leaq 0x68(%rsp), %rsi
movq %rbx, %rdi
callq 0x44096
leaq 0x190(%r14), %rdi
movq %r15, %rsi
callq 0x4c1b4
addq $0x1a8, %r14            # imm = 0x1A8
movq %r14, %rdi
movq %r12, %rsi
callq 0x4c1b4
jmp 0x1d994
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 0xea486(%rip), %rdx     # 0x107bb0
leaq 0x50(%rsp), %rdi
movq %r14, %rsi
callq 0x4a83e
leaq 0xa18aa(%rip), %rdx     # 0xbefe8
movq %rsp, %rdi
movq %r14, %rsi
callq 0x4a7c6
leaq 0x38(%rsp), %rdi
movq %rsp, %rsi
movsd 0xa08e7(%rip), %xmm0    # 0xbe040
callq 0x4d2ae
leaq 0x68(%rsp), %rdi
leaq 0x50(%rsp), %rsi
leaq 0x38(%rsp), %rdx
callq 0x4c191
leaq 0xa17f7(%rip), %rdx     # 0xbef70
leaq 0x20(%rsp), %rdi
movq %r14, %rsi
callq 0x4a7c6
movq %rsp, %rdi
leaq 0x20(%rsp), %rsi
movsd 0xa08aa(%rip), %xmm0    # 0xbe040
callq 0x4d2ae
movapd 0x90(%rsp), %xmm1
mulsd 0x9f874(%rip), %xmm1    # 0xbd020
movsd 0x18(%rsp), %xmm2
divsd %xmm2, %xmm1
xorpd %xmm0, %xmm0
cmpltsd %xmm2, %xmm0
andpd %xmm0, %xmm1
movsd 0x9f85d(%rip), %xmm2    # 0xbd028
andnpd %xmm2, %xmm0
orpd %xmm1, %xmm0
leaq 0x38(%rsp), %rdi
movq %rsp, %rsi
callq 0x4d2ae
leaq 0xa1789(%rip), %rdx     # 0xbef70
leaq 0xa8(%rsp), %rdi
movq %r14, %rsi
callq 0x4a7c6
leaq 0x50(%rsp), %rdi
leaq 0x38(%rsp), %rsi
leaq 0xa8(%rsp), %rdx
callq 0x4d5da
leaq 0xa175b(%rip), %rdx     # 0xbef70
leaq 0xa8(%rsp), %rdi
movq %r14, %rsi
callq 0x4a7c6
leaq 0x20(%rsp), %rdi
leaq 0xa8(%rsp), %rsi
movsd 0xa0806(%rip), %xmm0    # 0xbe040
callq 0x4d2ae
movapd 0x80(%rsp), %xmm2
mulsd 0x9f7d0(%rip), %xmm2    # 0xbd020
movsd 0xa0(%rsp), %xmm1
divsd %xmm1, %xmm2
xorpd %xmm0, %xmm0
cmpltsd %xmm1, %xmm0
andpd %xmm0, %xmm2
movsd 0x9f7b6(%rip), %xmm1    # 0xbd028
andnpd %xmm1, %xmm0
orpd %xmm2, %xmm0
movq %rsp, %rdi
leaq 0x20(%rsp), %rsi
callq 0x4d2ae
leaq 0xa16fa(%rip), %rdx     # 0xbef88
leaq 0xc0(%rsp), %rdi
movq %r14, %rsi
callq 0x4a7c6
leaq 0x38(%rsp), %rdi
movq %rsp, %rsi
leaq 0xc0(%rsp), %rdx
callq 0x4d5da
leaq 0xea2f6(%rip), %rdx     # 0x107bb0
movq %rsp, %rdi
movq %r14, %rsi
callq 0x4a83e
movq %rsp, %rsi
movq %rbx, %rdi
callq 0x44096
leaq 0x20(%rsp), %rdi
leaq 0x68(%rsp), %rsi
leaq 0x50(%rsp), %rdx
callq 0x4c86d
movq %rsp, %rdi
leaq 0x20(%rsp), %rsi
leaq 0x38(%rsp), %rdx
callq 0x4c86d
movq %rsp, %rsi
movq %rbx, %rdi
callq 0x44096
leaq 0x20(%rsp), %rdi
leaq 0x68(%rsp), %rsi
leaq 0x50(%rsp), %rdx
callq 0x4c191
movq %rsp, %rdi
leaq 0x20(%rsp), %rsi
leaq 0x38(%rsp), %rdx
callq 0x4c86d
movq %rsp, %rsi
movq %rbx, %rdi
callq 0x44096
leaq 0x20(%rsp), %rdi
leaq 0x68(%rsp), %rsi
leaq 0x50(%rsp), %rdx
callq 0x4c86d
movq %rsp, %rdi
leaq 0x20(%rsp), %rsi
leaq 0x38(%rsp), %rdx
callq 0x4c191
movq %rsp, %rsi
movq %rbx, %rdi
callq 0x44096
leaq 0x20(%rsp), %rdi
leaq 0x68(%rsp), %rsi
leaq 0x50(%rsp), %rdx
callq 0x4c191
movq %rsp, %rdi
leaq 0x20(%rsp), %rsi
leaq 0x38(%rsp), %rdx
callq 0x4c191
movq %rsp, %rsi
movq %rbx, %rdi
callq 0x44096
movq %rbx, %rax
addq $0xd8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
jmp 0x1d9c5
jmp 0x1d9c5
jmp 0x1d9c5
jmp 0x1d9c5
jmp 0x1d9c5
jmp 0x1d9c5
jmp 0x1d9c5
jmp 0x1d9c5
jmp 0x1d9c5
jmp 0x1d9c5
jmp 0x1d9c5
jmp 0x1d9c5
jmp 0x1d9c5
jmp 0x1d9c5
movq %rax, %r14
movq %rbx, %rdi
callq 0x444d0
movq %r14, %rdi
callq 0x11a70