// File: /workspace/github_cpp_makefile_star2_O3/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 0x293fb
cmpl $0x0, 0x4c(%r14)
jle 0x29439
movq %r14, %rdi
callq 0x3c478
movq %rsp, %r13
movq %r13, %rdi
movq %rax, %rsi
callq 0x6ccdc
movq %r13, %rdi
movq %r12, %rsi
callq 0x6d9c8
movq %rsp, %rsi
movq %r15, %rdi
movl $0x1, %edx
movl $0x7, %ecx
callq 0x2911c
movq %rsp, %rdi
callq 0x6dafc
leaq 0x10fd08(%rip), %rax    # 0x139148
addq $0x10, %rax
leaq 0x8(%rsp), %rdi
movq %rax, -0x8(%rdi)
leaq 0x8(%r12), %rsi
callq 0x71cc6
movl $0x88, %esi
movq %rsp, %rdi
addq %rsi, %rdi
addq %r12, %rsi
callq 0x71cc6
movq 0x108(%r12), %rax
movq %rsp, %rdi
movq %rax, 0x108(%rdi)
leaq 0x58(%r14), %rsi
callq 0x6fb9e
movq %rsp, %rdi
callq 0x4521a
cmpl $0x0, 0x3c(%r14)
jle 0x294b5
xorl %r12d, %r12d
movq 0x30(%r14), %rax
movq (%rax,%r12,8), %rdi
movq %rbx, %rsi
xorl %edx, %edx
callq 0x3dbd0
incq %r12
movslq 0x3c(%r14), %rax
cmpq %rax, %r12
jl 0x29497
cmpl $0x0, 0x4c(%r14)
jle 0x294dd
xorl %r12d, %r12d
movq 0x40(%r14), %rax
movq (%rax,%r12,8), %rdi
movq %rbx, %rsi
xorl %edx, %edx
callq 0x3e052
incq %r12
movslq 0x4c(%r14), %rax
cmpq %rax, %r12
jl 0x294bf
movq %rsp, %rdi
callq 0x45256
cmpl $0x0, 0x2c(%r14)
jle 0x29514
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 0x293d2
incq %r13
movslq 0x2c(%r14), %rax
cmpq %rax, %r13
jl 0x294f2
movq %rsp, %rdi
callq 0x6fa30
addq $0x110, %rsp            # imm = 0x110
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
retq
movq %rax, %rbx
movq %rsp, %rdi
callq 0x6dafc
jmp 0x29558
movq %rax, %rbx
movq %rsp, %rdi
callq 0x700c4
jmp 0x29558
jmp 0x2954d
jmp 0x2954d
jmp 0x2954d
movq %rax, %rbx
movq %rsp, %rdi
callq 0x6fa30
movq %rbx, %rdi
callq 0x220c0