// File: /workspace/github_cpp_makefile_star2_O1/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 %rbp
pushq %r15
pushq %r14
pushq %r12
pushq %rbx
subq $0x10, %rsp
xorl %ebx, %ebx
testq %rsi, %rsi
je 0x2d16d
movq %rsi, %r15
movq %rdi, %r14
cmpl $0x2, 0x48c(%rdi)
jl 0x2cfc3
movq %r15, %rdi
callq 0x3fe32
cvtsi2sdl 0x48c(%r14), %xmm1
ucomisd %xmm0, %xmm1
ja 0x2d16d
cmpl $0x0, 0x304(%r14)
je 0x2d122
movq %r15, %rdi
movl $0x1, %esi
movl $0x1, %edx
callq 0x4013a
movq 0x8(%r14), %rcx
testq %rax, %rax
je 0x2d069
movq %rax, %rdi
movq 0x18(%rax), %rax
testq %rax, %rax
je 0x2d001
movq 0x10(%rcx), %rdx
cmpq (%rdx), %rax
jne 0x2cfe7
movq 0xe8(%rdi), %rax
testq %rax, %rax
movl $0x40000000, %ecx       # imm = 0x40000000
cmovneq %rax, %rcx
testq %rcx, 0x358(%r14)
je 0x2d16d
callq 0x47182
testq %rax, %rax
je 0x2d069
movslq 0x10(%rax), %rax
testq %rax, %rax
js 0x2d16d
movq 0x8(%r14), %rcx
cmpl %eax, 0x2c(%rcx)
jle 0x2d16d
movq 0x340(%r14), %rcx
movq 0x348(%r14), %rdx
subq %rcx, %rdx
sarq $0x2, %rdx
cmpq %rax, %rdx
jbe 0x2d069
cmpl $0x0, (%rcx,%rax,4)
je 0x2d16d
movsd 0x158(%r14), %xmm0
ucomisd 0x160(%r14), %xmm0
ja 0x2d0bd
movq %r15, %rdi
callq 0x3ff84
movq %rsp, %r12
movq %r12, %rdi
movq %rax, %rsi
callq 0xe9178
movsd (%r12), %xmm0
ucomisd 0x158(%r14), %xmm0
jb 0x2d16d
movsd 0x160(%r14), %xmm0
ucomisd 0x8(%rsp), %xmm0
jb 0x2d16d
movsd 0x128(%r14), %xmm0
ucomisd 0x140(%r14), %xmm0
ja 0x2d11b
movsd 0x130(%r14), %xmm0
ucomisd 0x148(%r14), %xmm0
ja 0x2d11b
movsd 0x138(%r14), %xmm0
ucomisd 0x150(%r14), %xmm0
ja 0x2d11b
addq $0x120, %r14            # imm = 0x120
movq %r15, %rdi
callq 0x3ff5c
xorl %ebx, %ebx
movq %r14, %rdi
movq %rax, %rsi
xorl %edx, %edx
callq 0x88f94
testl %eax, %eax
je 0x2d16d
movl $0x1, %ebx
jmp 0x2d16d
movq %r15, %rdi
movl $0x1, %esi
movl $0x1, %edx
callq 0x4013a
testq %rax, %rax
sete %bpl
je 0x2cfd1
movq %rax, %r12
movq %r12, %rdi
callq 0x470de
testq %rax, %rax
jne 0x2d164
movq 0x18(%r12), %r12
testq %r12, %r12
sete %bpl
jne 0x2d144
jmp 0x2cfd1
testb %bpl, %bpl
jne 0x2cfd1
movl %ebx, %eax
addq $0x10, %rsp
popq %rbx
popq %r12
popq %r14
popq %r15
popq %rbp
retq