// File: /workspace/github_cpp_makefile_star2_O3/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, %r13
movq %rdi, %r15
leaq 0xa5986(%rip), %rsi     # 0xdbb35
movq %rdx, 0x18(%rsp)
movq %rdx, %rdi
callq 0x21d00
testl %eax, %eax
je 0x3633e
movl 0x14(%r15), %r12d
testl %r12d, %r12d
jle 0x3632c
leaq 0x18(%r15), %rax
movq %rax, 0x20(%rsp)
xorl %r14d, %r14d
leaq 0x38(%rsp), %rbx
movl $0x0, 0x8(%rsp)
movq %r15, 0x30(%rsp)
movq %r13, 0x28(%rsp)
movq 0x8(%r15), %rax
movq (%rax,%r14,8), %rax
movq %rax, 0x10(%rsp)
movq 0x1a0(%rax), %rdi
testq %rdi, %rdi
je 0x3621f
movq 0x18(%rsp), %rsi
callq 0x21d00
testl %eax, %eax
je 0x362a0
movq 0x10(%rsp), %rax
movslq 0x4c(%rax), %rbx
testq %rbx, %rbx
jle 0x36318
movl %r12d, 0xc(%rsp)
movq 0x40(%rax), %r12
movq %rbx, %rbp
negq %rbp
movb $0x1, %r15b
movl $0x1, %r13d
movq -0x8(%r12,%r13,8), %rax
movq (%rax), %rax
movq 0x150(%rax), %rdi
testq %rdi, %rdi
je 0x3626b
movq 0x18(%rsp), %rsi
callq 0x21d00
testl %eax, %eax
je 0x36286
cmpq %rbx, %r13
setb %r15b
leaq 0x1(,%r13), %rax
addq %rbp, %rax
incq %r13
cmpq $0x1, %rax
jne 0x36249
testb $0x1, %r15b
movq 0x30(%rsp), %r15
movq 0x28(%rsp), %r13
leaq 0x38(%rsp), %rbx
movl 0xc(%rsp), %r12d
je 0x3631d
movq %r13, %rbp
movq %r13, %rdi
callq 0x42c90
movq %rax, %r12
leaq 0x148(%rsp), %rdi
movq 0x10(%rsp), %r13
movq %r13, %rsi
callq 0x3c696
movq %rbx, %rdi
movq %r13, %rsi
callq 0x3c696
movq (%r12), %rax
movq %r12, %rdi
movq %rbx, %rsi
callq *0x30(%rax)
movq %rbx, %rdi
callq 0x6fa30
movq %r15, 0x8(%r12)
movl 0x24(%r15), %edx
movl %edx, 0x10(%r12)
movq 0x20(%rsp), %rdi
movq %r12, %rsi
callq 0x87622
movq %rbp, %r13
incl 0x8(%rsp)
leaq 0x148(%rsp), %rdi
callq 0x6fa30
movl 0x14(%r15), %r12d
jmp 0x3631d
leaq 0x38(%rsp), %rbx
incq %r14
movslq %r12d, %rax
cmpq %rax, %r14
jl 0x361f4
addq $0x258, %rsp            # imm = 0x258
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq %r13, %rdi
callq 0x42c90
movq %r15, 0x8(%rax)
movl 0x24(%r15), %edx
addq $0x18, %r15
movl %edx, 0x10(%rax)
movq %r15, %rdi
movq %rax, %rsi
addq $0x258, %rsp            # imm = 0x258
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
jmp 0x87622
movq %rax, %rbx
leaq 0x38(%rsp), %rdi
callq 0x6fa30
jmp 0x36385
jmp 0x36382
movq %rax, %rbx
leaq 0x148(%rsp), %rdi
callq 0x6fa30
movq %rbx, %rdi
callq 0x220c0