// File: /workspace/github_cpp_makefile_star2_O1/tomfunkhouser[P]gaps/pkgs/R3Graphics/R3Scene.cpp
// Function: gaps::R3Scene::ReadSUNCGLightsFile(char const*)
int R3Scene::
ReadSUNCGLightsFile(const char *filename)
{
  // Open file
  FILE *fp = fopen(filename, "r");
  if (!fp) {
    RNFail("Unable to open lights file %s\n", filename);
    return 0;
  }

  // Read file
  char buffer[4096];
  int line_number = 0;
  while (fgets(buffer, 4096, fp)) {
    line_number++;
    char cmd[1024], reference_frame[1024];
    if (sscanf(buffer, "%s", cmd) != (unsigned int) 1) continue;
    if (cmd[0] == '#') continue;

    // Check cmd
    if (!strcmp(cmd, "directional_light")) {
      // Parse directional light 
      double intensity, r, g, b, dx, dy, dz;
      if (sscanf(buffer, "%s%s%lf%lf%lf%lf%lf%lf%lf", cmd, reference_frame,
        &intensity, &r, &g, &b, &dx, &dy, &dz) != (unsigned int) 9) {
        RNFail("Unable to parse directional light from line %d from %s\n", line_number, filename);
        return 0;
      }

      // Create directional light
      RNRgb color(r, g, b);
      R3Vector direction(dx, dy, dz);
      R3DirectionalLight light(direction, color, intensity);
      InsertCopiesOfLight(this, &light, reference_frame);
    }
    else if (!strcmp(cmd, "point_light")) {
      // Parse point light 
      double intensity, r, g, b, px, py, pz, ca, la, qa;
      if (sscanf(buffer, "%s%s%lf%lf%lf%lf%lf%lf%lf%lf%lf%lf", cmd, reference_frame,  
        &intensity, &r, &g, &b, &px, &py, &pz, &ca, &la, &qa) != (unsigned int) 12) {
        RNFail("Unable to parse point light from line %d from %s\n", line_number, filename);
        return 0;
      }

      // Create point light
      RNRgb color(r, g, b);
      R3Point position(px, py, pz);
      R3PointLight light(position, color, intensity, TRUE, ca, la, qa);
      InsertCopiesOfLight(this, &light, reference_frame);
    }
    else if (!strcmp(cmd, "spot_light")) {
      // Parse spot light 
      double intensity, r, g, b, px, py, pz, dx, dy, dz, sd, sc, ca, la, qa;
      if (sscanf(buffer, "%s%s%lf%lf%lf%lf%lf%lf%lf%lf%lf%lf%lf%lf%lf%lf%lf", cmd, reference_frame,  
        &intensity, &r, &g, &b, &px, &py, &pz, &dx, &dy, &dz, &sd, &sc, &ca, &la, &qa) != (unsigned int) 17) {
        RNFail("Unable to parse spot light from line %d from %s\n", line_number, filename);
        return 0;
      }

      // Create spot light
      RNRgb color(r, g, b);
      R3Point position(px, py, pz);
      R3Vector direction(dx, dy, dz);
      R3SpotLight light(position, direction, color, sd, sc, intensity, TRUE, ca, la, qa);
      InsertCopiesOfLight(this, &light, reference_frame);
    }
    else if (!strcmp(cmd, "line_light")) {
      // Parse spot light 
      double intensity, r, g, b, px1, py1, pz1, px2, py2, pz2, dx, dy, dz, sd, sc, ca, la, qa;
      if (sscanf(buffer, "%s%s%lf%lf%lf%lf%lf%lf%lf%lf%lf%lf%lf%lf%lf%lf%lf%lf%lf%lf", cmd, reference_frame,  
        &intensity, &r, &g, &b, &px1, &py1, &pz1, &px2, &py2, &pz2, &dx, &dy, &dz, &sd, &sc, &ca, &la, &qa) != (unsigned int) 20) {
        RNFail("Unable to parse line light from line %d from %s\n", line_number, filename);
        return 0;
      }

      // Create spot light
      RNRgb color(r, g, b);
      R3Point position1(px1, py1, pz1);
      R3Point position2(px2, py2, pz2);
      R3Point position = 0.5 * (position1 + position2);
      R3Vector direction(dx, dy, dz);
      R3SpotLight light(position, direction, color, sd, sc, intensity, TRUE, ca, la, qa);
      InsertCopiesOfLight(this, &light, reference_frame);
    }
    else {
      RNFail("Unrecognized light type %s at line %d of %s\n", cmd, line_number, filename);
      return 0;
    }
  }

  // Close file
  fclose(fp);

  // Return success
  return 1;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x19d8, %rsp           # imm = 0x19D8
movq %rsi, %rax
movq %rdi, 0x40(%rsp)
leaq 0xad2f3(%rip), %rsi     # 0xe3043
movq %rax, 0x20(%rsp)
movq %rax, %rdi
callq 0x21ac0
testq %rax, %rax
je 0x3653a
movq %rax, %r15
leaq 0x9d0(%rsp), %rdi
movl $0x1000, %esi           # imm = 0x1000
movq %rax, %rdx
callq 0x21f40
testq %rax, %rax
je 0x3652b
movabsq $0x67696c5f656e696c, %rax # imm = 0x67696C5F656E696C
movl $0x1, %ebp
movabsq $0x746867696c5f65, %rcx # imm = 0x746867696C5F65
leaq 0xc61b4(%rip), %r12     # 0xfbf5b
leaq 0x9d0(%rsp), %rbx
leaq 0x1d0(%rsp), %r14
addq $0xf010707, %rax        # imm = 0xF010707
movq %rax, 0xb0(%rsp)
leaq 0xf(%rcx), %rax
movq %rax, 0xa8(%rsp)
movq %rbx, %rdi
movq %r12, %rsi
movq %r14, %rdx
xorl %eax, %eax
callq 0x21890
movl $0x2, %ecx
cmpl $0x1, %eax
jne 0x3650b
cmpb $0x23, 0x1d0(%rsp)
leaq 0x5d0(%rsp), %r8
je 0x3650b
movzwl 0x1e0(%rsp), %eax
movd %eax, %xmm0
pcmpeqb 0xa6757(%rip), %xmm0    # 0xdc570
movdqa 0x1d0(%rsp), %xmm1
pcmpeqb 0xa6736(%rip), %xmm1    # 0xdc560
pand %xmm0, %xmm1
pmovmskb %xmm1, %eax
cmpl $0xffff, %eax           # imm = 0xFFFF
je 0x35ee7
movq 0x1d0(%rsp), %rax
movabsq $0x696c5f746e696f70, %rcx # imm = 0x696C5F746E696F70
xorq %rcx, %rax
movl 0x1d8(%rsp), %ecx
xorq $0x746867, %rcx         # imm = 0x746867
orq %rax, %rcx
je 0x35fe7
movq 0x1d0(%rsp), %rax
xorq 0xb0(%rsp), %rax
movq 0x1d3(%rsp), %rcx
xorq 0xa8(%rsp), %rcx
orq %rax, %rcx
je 0x36124
movq 0x1d0(%rsp), %rax
movabsq $0x67696c5f656e696c, %rcx # imm = 0x67696C5F656E696C
xorq %rcx, %rax
movq 0x1d3(%rsp), %rcx
movabsq $0x746867696c5f65, %rdx # imm = 0x746867696C5F65
xorq %rdx, %rcx
orq %rax, %rcx
je 0x362c8
leaq 0xa762b(%rip), %rdi     # 0xdd4f7
movq %r14, %rsi
movl %ebp, %edx
movq 0x20(%rsp), %rcx
xorl %eax, %eax
callq 0x8b53a
movl $0x1, %ecx
jmp 0x3650b
subq $0x8, %rsp
movq %rbx, %rdi
leaq 0xa7481(%rip), %rsi     # 0xdd376
movq %r14, %rdx
movq %r8, %rcx
leaq 0xe8(%rsp), %r8
leaq 0x80(%rsp), %r9
xorl %eax, %eax
leaq 0x8(%rsp), %r10
pushq %r10
leaq 0x18(%rsp), %r10
pushq %r10
leaq 0x28(%rsp), %r10
pushq %r10
leaq 0x38(%rsp), %r10
pushq %r10
leaq 0xb8(%rsp), %r10
pushq %r10
callq 0x21890
addq $0x30, %rsp
movl %eax, %r12d
cmpl $0x9, %eax
jne 0x36101
movq %r14, %rbx
movsd 0x78(%rsp), %xmm0
movsd 0x90(%rsp), %xmm1
movsd 0x18(%rsp), %xmm2
leaq 0xf8(%rsp), %r14
movq %r14, %rdi
callq 0x88530
movsd 0x10(%rsp), %xmm0
movq 0x8(%rsp), %xmm1
movsd (%rsp), %xmm2
leaq 0x110(%rsp), %r13
movq %r13, %rdi
callq 0x76d52
movq 0xe0(%rsp), %xmm0
leaq 0x128(%rsp), %rdi
movq %r13, %rsi
leaq 0x128(%rsp), %r13
movq %r14, %rdx
movl $0x1, %ecx
callq 0x429d2
movq 0x40(%rsp), %rdi
movq %r13, %rsi
leaq 0x5d0(%rsp), %rdx
callq 0x36585
movq %r13, %rdi
callq 0x4315a
movq %rbx, %r14
leaq 0x9d0(%rsp), %rbx
jmp 0x36116
movq %rbx, %rdi
leaq 0xa73d7(%rip), %rsi     # 0xdd3c8
movq %r14, %rdx
movq %r8, %rcx
leaq 0xe0(%rsp), %r8
leaq 0x78(%rsp), %r9
xorl %eax, %eax
leaq 0x28(%rsp), %r10
pushq %r10
leaq 0x38(%rsp), %r10
pushq %r10
leaq 0x48(%rsp), %r10
pushq %r10
leaq 0x18(%rsp), %r10
pushq %r10
leaq 0x28(%rsp), %r10
pushq %r10
leaq 0x38(%rsp), %r10
pushq %r10
leaq 0x48(%rsp), %r10
pushq %r10
leaq 0xc8(%rsp), %r10
pushq %r10
callq 0x21890
addq $0x40, %rsp
movl %eax, %r12d
cmpl $0xc, %eax
jne 0x362a5
movsd 0x78(%rsp), %xmm0
movsd 0x90(%rsp), %xmm1
movsd 0x18(%rsp), %xmm2
leaq 0xf8(%rsp), %rbx
movq %rbx, %rdi
callq 0x88530
movsd 0x10(%rsp), %xmm0
movsd 0x8(%rsp), %xmm1
movsd (%rsp), %xmm2
leaq 0x110(%rsp), %r13
movq %r13, %rdi
callq 0x762ba
movq 0xe0(%rsp), %xmm0
movq 0x38(%rsp), %xmm1
movsd 0x30(%rsp), %xmm2
movsd 0x28(%rsp), %xmm3
leaq 0x128(%rsp), %rdi
movq %r13, %rsi
leaq 0x128(%rsp), %r13
movq %rbx, %rdx
movl $0x1, %ecx
callq 0x42168
movq 0x40(%rsp), %rdi
movq %r13, %rsi
leaq 0x5d0(%rsp), %rdx
callq 0x36585
movq %r13, %rdi
callq 0x4315a
leaq 0x9d0(%rsp), %rbx
jmp 0x362ba
leaq 0xa7288(%rip), %rdi     # 0xdd390
movl %ebp, %esi
movq 0x20(%rsp), %rdx
xorl %eax, %eax
callq 0x8b53a
movl $0x1, %ecx
cmpl $0x9, %r12d
jmp 0x36500
subq $0x8, %rsp
movq %rbx, %rdi
leaq 0xa72eb(%rip), %rsi     # 0xdd41d
movq %r14, %rdx
movq %r8, %rcx
leaq 0x80(%rsp), %r8
leaq 0x98(%rsp), %r9
xorl %eax, %eax
leaq 0x50(%rsp), %r10
pushq %r10
leaq 0x60(%rsp), %r10
pushq %r10
leaq 0x70(%rsp), %r10
pushq %r10
leaq 0x80(%rsp), %r10
pushq %r10
leaq 0x90(%rsp), %r10
pushq %r10
leaq 0xa0(%rsp), %r10
pushq %r10
leaq 0x60(%rsp), %r10
pushq %r10
leaq 0x70(%rsp), %r10
pushq %r10
leaq 0x80(%rsp), %r10
pushq %r10
leaq 0x50(%rsp), %r10
pushq %r10
leaq 0x60(%rsp), %r10
pushq %r10
leaq 0x70(%rsp), %r10
pushq %r10
leaq 0x80(%rsp), %r10
pushq %r10
callq 0x21890
addq $0x70, %rsp
movl %eax, %r12d
cmpl $0x11, %eax
jne 0x364c2
movsd 0x90(%rsp), %xmm0
movsd 0x18(%rsp), %xmm1
movsd 0x10(%rsp), %xmm2
leaq 0xf8(%rsp), %rdi
callq 0x88530
movsd 0x8(%rsp), %xmm0
movsd (%rsp), %xmm1
movsd 0x38(%rsp), %xmm2
leaq 0x110(%rsp), %r13
movq %r13, %rdi
callq 0x762ba
movsd 0x30(%rsp), %xmm0
movsd 0x28(%rsp), %xmm1
movsd 0x70(%rsp), %xmm2
leaq 0xe0(%rsp), %rbx
movq %rbx, %rdi
callq 0x76d52
movq 0x68(%rsp), %xmm0
movq 0x60(%rsp), %xmm1
movsd 0x78(%rsp), %xmm2
movsd 0x58(%rsp), %xmm3
movsd 0x50(%rsp), %xmm4
movsd 0x48(%rsp), %xmm5
leaq 0x128(%rsp), %rdi
movq %r13, %rsi
leaq 0x128(%rsp), %r13
movq %rbx, %rdx
leaq 0xf8(%rsp), %rcx
movl $0x1, %r8d
callq 0x41d7c
movq 0x40(%rsp), %rdi
movq %r13, %rsi
leaq 0x5d0(%rsp), %rdx
callq 0x36585
movq %r13, %rdi
callq 0x4315a
leaq 0x9d0(%rsp), %rbx
jmp 0x364d7
leaq 0xa713f(%rip), %rdi     # 0xdd3eb
movl %ebp, %esi
movq 0x20(%rsp), %rdx
xorl %eax, %eax
callq 0x8b53a
movl $0x1, %ecx
cmpl $0xc, %r12d
jmp 0x36500
movq %rbx, %rdi
leaq 0xa71b9(%rip), %rsi     # 0xdd48b
movq %r14, %rdx
movq %r8, %rcx
leaq 0x18(%rsp), %r8
leaq 0x10(%rsp), %r9
xorl %eax, %eax
leaq 0xb8(%rsp), %r10
pushq %r10
leaq 0xc8(%rsp), %r10
pushq %r10
leaq 0xd8(%rsp), %r10
pushq %r10
leaq 0xe8(%rsp), %r10
pushq %r10
leaq 0xf8(%rsp), %r10
pushq %r10
leaq 0x70(%rsp), %r10
pushq %r10
leaq 0x80(%rsp), %r10
pushq %r10
leaq 0x90(%rsp), %r10
pushq %r10
leaq 0xa0(%rsp), %r10
pushq %r10
leaq 0xb0(%rsp), %r10
pushq %r10
leaq 0xc0(%rsp), %r10
pushq %r10
leaq 0x80(%rsp), %r10
pushq %r10
leaq 0x90(%rsp), %r10
pushq %r10
leaq 0xa0(%rsp), %r10
pushq %r10
leaq 0x70(%rsp), %r10
pushq %r10
leaq 0x80(%rsp), %r10
pushq %r10
callq 0x21890
addq $0x80, %rsp
movl %eax, %r12d
cmpl $0x14, %eax
jne 0x364e2
movsd 0x10(%rsp), %xmm0
movsd 0x8(%rsp), %xmm1
movsd (%rsp), %xmm2
leaq 0xf8(%rsp), %rdi
callq 0x88530
movsd 0x38(%rsp), %xmm0
movsd 0x30(%rsp), %xmm1
movsd 0x28(%rsp), %xmm2
leaq 0x110(%rsp), %r13
movq %r13, %rdi
callq 0x762ba
movsd 0x70(%rsp), %xmm0
movsd 0x68(%rsp), %xmm1
movsd 0x60(%rsp), %xmm2
leaq 0xe0(%rsp), %rbx
movq %rbx, %rdi
callq 0x762ba
leaq 0x128(%rsp), %rdi
movq %r13, %rsi
leaq 0x128(%rsp), %r13
movq %rbx, %rdx
callq 0x76cbe
leaq 0x78(%rsp), %rdi
movq %r13, %rsi
movsd 0xa5bfd(%rip), %xmm0    # 0xdc020
callq 0x76d04
movsd 0x58(%rsp), %xmm0
movsd 0x50(%rsp), %xmm1
movsd 0x48(%rsp), %xmm2
leaq 0x90(%rsp), %rbx
movq %rbx, %rdi
callq 0x76d52
movq 0xd8(%rsp), %xmm0
movq 0xd0(%rsp), %xmm1
movsd 0x18(%rsp), %xmm2
movsd 0xc8(%rsp), %xmm3
movsd 0xc0(%rsp), %xmm4
movsd 0xb8(%rsp), %xmm5
movq %r13, %rdi
leaq 0x78(%rsp), %rsi
movq %rbx, %rdx
leaq 0xf8(%rsp), %rcx
movl $0x1, %r8d
callq 0x41d7c
movq 0x40(%rsp), %rdi
movq %r13, %rsi
leaq 0x5d0(%rsp), %rdx
callq 0x36585
movq %r13, %rdi
callq 0x4315a
leaq 0x9d0(%rsp), %rbx
jmp 0x364f7
leaq 0xa6f86(%rip), %rdi     # 0xdd44f
movl %ebp, %esi
movq 0x20(%rsp), %rdx
xorl %eax, %eax
callq 0x8b53a
movl $0x1, %ecx
cmpl $0x11, %r12d
jmp 0x36500
leaq 0xa6fdd(%rip), %rdi     # 0xdd4c6
movl %ebp, %esi
movq 0x20(%rsp), %rdx
xorl %eax, %eax
callq 0x8b53a
movl $0x1, %ecx
cmpl $0x14, %r12d
leaq 0xc5a54(%rip), %r12     # 0xfbf5b
jne 0x3650b
xorl %ecx, %ecx
testb $0x1, %cl
jne 0x36551
movq %rbx, %rdi
movl $0x1000, %esi           # imm = 0x1000
movq %r15, %rdx
callq 0x21f40
incl %ebp
testq %rax, %rax
jne 0x35dd1
movq %r15, %rdi
callq 0x218b0
movl $0x1, %ebp
jmp 0x36553
leaq 0xa6e04(%rip), %rdi     # 0xdd345
xorl %ebp, %ebp
movq 0x20(%rsp), %rsi
xorl %eax, %eax
callq 0x8b53a
jmp 0x36553
xorl %ebp, %ebp
movl %ebp, %eax
addq $0x19d8, %rsp           # imm = 0x19D8
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
jmp 0x3656d
jmp 0x3656d
jmp 0x3656d
movq %rax, %rbx
leaq 0x128(%rsp), %rdi
callq 0x4315a
movq %rbx, %rdi
callq 0x220d0