// File: /workspace/github_cpp_makefile_star2_O1/tomfunkhouser[P]gaps/pkgs/R3Graphics/R3Scene.cpp
// Function: gaps::DrawNodeWithLights(gaps::R3Scene const*, gaps::R3SceneNode*, gaps::R3Affine const&, gaps::RNFlags, int, int)
static void 
DrawNodeWithLights(const R3Scene *scene, R3SceneNode *node,
  const R3Affine& parent_transformation, const R3DrawFlags draw_flags,
  int min_light = 0, int max_light = 7)
{
  // Load lights
  if ((node->NElements() > 0) || (node->NReferences() > 0)) {
    R3Box world_bbox = node->BBox();
    world_bbox.Transform(parent_transformation);
    scene->LoadLights(world_bbox, min_light, max_light);
  }
  
  // Push transformation
  R3Affine transformation = parent_transformation;
  transformation.Transform(node->Transformation());
  transformation.Push();

  // Draw elements
  for (int i = 0; i < node->NElements(); i++) {
    R3SceneElement *element = node->Element(i);
    element->Draw(draw_flags);
  }

  // Draw references
  for (int i = 0; i < node->NReferences(); i++) {
    R3SceneReference *reference = node->Reference(i);
    reference->Draw(draw_flags);
  }

  // Pop transformation
  transformation.Pop();

  // Draw children
  for (int i = 0; i < node->NChildren(); i++) {
    R3SceneNode *child = node->Child(i);
    DrawNodeWithLights(scene, child, transformation, draw_flags, min_light, max_light);
  }
}

// Assembly:
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x110, %rsp            # imm = 0x110
movq %rcx, %rbx
movq %rdx, %r12
movq %rsi, %r14
movq %rdi, %r15
cmpl $0x0, 0x3c(%rsi)
jg 0x294c9
cmpl $0x0, 0x4c(%r14)
jle 0x29507
movq %r14, %rdi
callq 0x3c988
movq %rsp, %r13
movq %r13, %rdi
movq %rax, %rsi
callq 0x6daec
movq %r13, %rdi
movq %r12, %rsi
callq 0x6e810
movq %rsp, %rsi
movq %r15, %rdi
movl $0x1, %edx
movl $0x7, %ecx
callq 0x291ee
movq %rsp, %rdi
callq 0x6e944
leaq 0x111c3a(%rip), %rax    # 0x13b148
addq $0x10, %rax
leaq 0x8(%rsp), %rdi
movq %rax, -0x8(%rdi)
leaq 0x8(%r12), %rsi
callq 0x72bb6
movl $0x88, %esi
movq %rsp, %rdi
addq %rsi, %rdi
addq %r12, %rsi
callq 0x72bb6
movq 0x108(%r12), %rax
movq %rsp, %rdi
movq %rax, 0x108(%rdi)
leaq 0x58(%r14), %rsi
callq 0x709e6
movq %rsp, %rdi
callq 0x45806
cmpl $0x0, 0x3c(%r14)
jle 0x29583
xorl %r12d, %r12d
movq 0x30(%r14), %rax
movq (%rax,%r12,8), %rdi
movq %rbx, %rsi
xorl %edx, %edx
callq 0x3e086
incq %r12
movslq 0x3c(%r14), %rax
cmpq %rax, %r12
jl 0x29565
cmpl $0x0, 0x4c(%r14)
jle 0x295ab
xorl %r12d, %r12d
movq 0x40(%r14), %rax
movq (%rax,%r12,8), %rdi
movq %rbx, %rsi
xorl %edx, %edx
callq 0x3e512
incq %r12
movslq 0x4c(%r14), %rax
cmpq %rax, %r12
jl 0x2958d
movq %rsp, %rdi
callq 0x45842
cmpl $0x0, 0x2c(%r14)
jle 0x295e2
xorl %r13d, %r13d
movq %rsp, %r12
movq 0x20(%r14), %rax
movq (%rax,%r13,8), %rsi
movq %r15, %rdi
movq %r12, %rdx
movq %rbx, %rcx
callq 0x294a0
incq %r13
movslq 0x2c(%r14), %rax
cmpq %rax, %r13
jl 0x295c0
movq %rsp, %rdi
callq 0x70878
addq $0x110, %rsp            # imm = 0x110
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
retq
movq %rax, %rbx
movq %rsp, %rdi
callq 0x6e944
jmp 0x29626
movq %rax, %rbx
movq %rsp, %rdi
callq 0x70f00
jmp 0x29626
jmp 0x2961b
jmp 0x2961b
jmp 0x2961b
movq %rax, %rbx
movq %rsp, %rdi
callq 0x70878
movq %rbx, %rdi
callq 0x220d0