// File: /workspace/github_cpp_makefile_star2_O3/tomfunkhouser[P]gaps/pkgs/R3Utils/R3SurfelViewer.cpp
// Function: gaps::R3SurfelViewer::NodeVisibility(gaps::R3SurfelNode*) const
int R3SurfelViewer::
NodeVisibility(R3SurfelNode *node) const
{
  // Check node
  if (!node) return 0;

  // Check node complexity
  if (subsampling_factor > 1) {
    if (node->Complexity() < subsampling_factor) return 0;
  }

  // Check if drawing human labeled objects
  if (!human_labeled_object_visibility) {
    R3SurfelObject *object = node->Object(TRUE, TRUE);
    while (object) {
      if (object->HumanLabel()) return 0;
      object = object->Parent();
    }
  }

  // Check if label is visible
  R3SurfelObject *object = node->Object(TRUE, TRUE);
  while (object && object->Parent() && (object->Parent() != scene->RootObject())) object = object->Parent();
  if (object) {
    if (!AttributeVisibility(object->Flags())) return 0;
    R3SurfelLabel *label = object->CurrentLabel();
    if ((label) && !LabelVisibility(label)) return 0;
  }

  // Check elevation range
  if (!elevation_range.IsEmpty()) {
    RNInterval node_range = node->ElevationRange();
    if (!elevation_range.Contains(node_range)) return 0;
  }

  // Check viewing extent
  if (!viewing_extent.IsEmpty()) {
    if (!R3Intersects(viewing_extent, node->BBox())) return 0;
  }
  
#if (R3_SURFEL_VIEWER_DRAW_METHOD != R3_SURFEL_VIEWER_DRAW_WITH_VBO)
  // Check viewing frustum
  if (node->Complexity() > 1000) {
    if (!viewing_frustum.IsEmpty()) {
      if (!R3Intersects(viewing_frustum, node->BBox())) return 0;
    }
  }
#endif
  
  // Passed all tests
  return 1;
}

// Assembly:
pushq %r15
pushq %r14
pushq %r12
pushq %rbx
subq $0x18, %rsp
xorl %ebx, %ebx
testq %rsi, %rsi
je 0x2cffd
movq %rsi, %r15
movq %rdi, %r14
cmpl $0x2, 0x48c(%rdi)
jl 0x2cea6
movq %r15, %rdi
callq 0x3ff0e
cvtsi2sdl 0x48c(%r14), %xmm1
ucomisd %xmm0, %xmm1
ja 0x2cffd
cmpl $0x0, 0x304(%r14)
je 0x2d00b
movq %r15, %rdi
movl $0x1, %esi
movl $0x1, %edx
callq 0x401d4
movq 0x8(%r14), %rcx
testq %rax, %rax
je 0x2cf4c
movq %rax, %rdi
movq 0x18(%rax), %rax
testq %rax, %rax
je 0x2cee4
movq 0x10(%rcx), %rdx
cmpq (%rdx), %rax
jne 0x2ceca
movq 0xe8(%rdi), %rax
testq %rax, %rax
movl $0x40000000, %ecx       # imm = 0x40000000
cmovneq %rax, %rcx
testq %rcx, 0x358(%r14)
je 0x2cffd
callq 0x4713e
testq %rax, %rax
je 0x2cf4c
movslq 0x10(%rax), %rax
testq %rax, %rax
js 0x2cffd
movq 0x8(%r14), %rcx
cmpl %eax, 0x2c(%rcx)
jle 0x2cffd
movq 0x340(%r14), %rcx
movq 0x348(%r14), %rdx
subq %rcx, %rdx
sarq $0x2, %rdx
cmpq %rax, %rdx
jbe 0x2cf4c
cmpl $0x0, (%rcx,%rax,4)
je 0x2cffd
movsd 0x158(%r14), %xmm0
ucomisd 0x160(%r14), %xmm0
ja 0x2cf9a
movq %r15, %rdi
callq 0x40064
leaq 0x8(%rsp), %r12
movq %r12, %rdi
movq %rax, %rsi
callq 0xe76d4
movsd (%r12), %xmm0
ucomisd 0x158(%r14), %xmm0
jb 0x2cffd
movsd 0x160(%r14), %xmm0
ucomisd 0x10(%rsp), %xmm0
jb 0x2cffd
movsd 0x128(%r14), %xmm0
ucomisd 0x140(%r14), %xmm0
ja 0x2cff8
movsd 0x130(%r14), %xmm0
ucomisd 0x148(%r14), %xmm0
ja 0x2cff8
movsd 0x138(%r14), %xmm0
ucomisd 0x150(%r14), %xmm0
ja 0x2cff8
addq $0x120, %r14            # imm = 0x120
movq %r15, %rdi
callq 0x4003c
xorl %ebx, %ebx
movq %r14, %rdi
movq %rax, %rsi
xorl %edx, %edx
callq 0x883e0
testl %eax, %eax
je 0x2cffd
movl $0x1, %ebx
movl %ebx, %eax
addq $0x18, %rsp
popq %rbx
popq %r12
popq %r14
popq %r15
retq
movq %r15, %rdi
movl $0x1, %esi
movl $0x1, %edx
callq 0x401d4
testq %rax, %rax
je 0x2ceb4
movq %rax, %r12
movq %r12, %rdi
callq 0x470a2
testq %rax, %rax
jne 0x2cffd
movq 0x18(%r12), %r12
testq %r12, %r12
jne 0x2d029
jmp 0x2ceb4
nop