// File: /workspace/github_cpp_makefile_star2_O1/tomfunkhouser[P]gaps/pkgs/R3Graphics/R3Scene.cpp
// Function: gaps::InsertCopiesOfLight(gaps::R3Scene*, gaps::R3Light*, char const*)
static int
InsertCopiesOfLight(R3Scene *scene, R3Light *original, const char *reference_frame)
{
  // Iniitalize return status
  int status = 0;
  
  // Insert copies of light into scene
  if (!strcmp(reference_frame, "world")) {
    // Insert one copy of light 
    R3Light *light = original->Copy();
    scene->InsertLight(light);
    status++;
  }
  else {
    // Insert copy of light for each matching node with name matching reference frame
    for (int i = 0; i < scene->NNodes(); i++) {
      R3SceneNode *node = scene->Node(i);
      if (!MatchReferencedSceneName(node, reference_frame)) continue;
      R3Light *light = original->Copy();
      R3Affine transformation_to_world = node->CumulativeTransformation();
      light->Transform(node->CumulativeTransformation());
      scene->InsertLight(light);
      status++;
    }
  }

  // Return whether inserted any lights
  return status;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x258, %rsp            # imm = 0x258
movq %rsi, %r14
movq %rdi, %rbx
leaq 0xa7582(%rip), %rsi     # 0xddb25
movq %rdx, 0x18(%rsp)
movq %rdx, %rdi
callq 0x21d10
testl %eax, %eax
je 0x36709
movq %r14, 0x28(%rsp)
cmpl $0x0, 0x14(%rbx)
jle 0x366f7
leaq 0x18(%rbx), %rax
movq %rax, 0x20(%rsp)
xorl %r14d, %r14d
leaq 0x38(%rsp), %r15
movl $0x0, 0xc(%rsp)
movq %rbx, 0x30(%rsp)
movq 0x8(%rbx), %rax
movq (%rax,%r14,8), %r13
movq 0x1a0(%r13), %rdi
testq %rdi, %rdi
je 0x36607
movq 0x18(%rsp), %rsi
callq 0x21d10
testl %eax, %eax
je 0x3667f
movq %r13, 0x10(%rsp)
movslq 0x4c(%r13), %r15
testq %r15, %r15
setg %bpl
jle 0x3666a
movq 0x10(%rsp), %rax
movq 0x40(%rax), %rbx
movq %r15, %r12
negq %r12
movb $0x1, %bpl
movl $0x1, %r13d
movq -0x8(%rbx,%r13,8), %rax
movq (%rax), %rax
movq 0x150(%rax), %rdi
testq %rdi, %rdi
je 0x36653
movq 0x18(%rsp), %rsi
callq 0x21d10
testl %eax, %eax
je 0x3666a
cmpq %r15, %r13
setb %bpl
leaq (%r12,%r13), %rax
incq %rax
incq %r13
cmpq $0x1, %rax
jne 0x36631
testb $0x1, %bpl
movq 0x30(%rsp), %rbx
leaq 0x38(%rsp), %r15
movq 0x10(%rsp), %r13
je 0x366e7
movq 0x28(%rsp), %rdi
callq 0x431a8
movq %rax, %r12
leaq 0x148(%rsp), %rdi
movq %r13, %rsi
callq 0x3cba6
movq %r15, %rdi
movq %r13, %rsi
callq 0x3cba6
movq (%r12), %rax
movq %r12, %rdi
movq %r15, %rsi
callq *0x30(%rax)
movq %r15, %rdi
callq 0x70878
movq %rbx, 0x8(%r12)
movl 0x24(%rbx), %edx
movl %edx, 0x10(%r12)
movq 0x20(%rsp), %rdi
movq %r12, %rsi
callq 0x88752
incl 0xc(%rsp)
leaq 0x148(%rsp), %rdi
callq 0x70878
incq %r14
movslq 0x14(%rbx), %rax
cmpq %rax, %r14
jl 0x365e5
addq $0x258, %rsp            # imm = 0x258
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq %r14, %rdi
callq 0x431a8
movq %rbx, 0x8(%rax)
movl 0x24(%rbx), %edx
addq $0x18, %rbx
movl %edx, 0x10(%rax)
movq %rbx, %rdi
movq %rax, %rsi
addq $0x258, %rsp            # imm = 0x258
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
jmp 0x88752
jmp 0x3673d
movq %rax, %rbx
jmp 0x3674f
movq %rax, %rbx
leaq 0x38(%rsp), %rdi
callq 0x70878
leaq 0x148(%rsp), %rdi
callq 0x70878
movq %rbx, %rdi
callq 0x220d0