// File: /workspace/github_cpp_makefile_star2_O2/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, %r12
movq %rdi, 0x50(%rsp)
leaq 0x98c71(%rip), %rsi     # 0xcbda3
movq %r12, %rdi
callq 0x21ab0
testq %rax, %rax
je 0x337dd
movq %rax, %r15
movq %r12, 0x30(%rsp)
pushq $0x1
popq %rbp
leaq 0x9d0(%rsp), %r12
leaq 0x5d0(%rsp), %rbx
leaq 0xa0(%rsp), %r13
pushq $0xb
popq %r14
movl %ebp, 0xc(%rsp)
movq %r12, %rdi
movl $0x1000, %esi           # imm = 0x1000
movq %r15, %rdx
callq 0x21f50
testq %rax, %rax
je 0x337d0
movq %r12, %rdi
leaq 0xb1aca(%rip), %rsi     # 0xe4c5b
movq %rbx, %rdx
xorl %eax, %eax
callq 0x21890
cmpl $0x1, %eax
jne 0x337c7
cmpb $0x23, 0x5d0(%rsp)
je 0x337c7
movq %rbx, %rdi
leaq 0x93188(%rip), %rsi     # 0xc6344
pushq $0x12
popq %rdx
callq 0x21920
testl %eax, %eax
je 0x33434
movq %rbx, %rdi
leaq 0x929fa(%rip), %rsi     # 0xc5bd0
pushq $0xc
popq %rdx
callq 0x21920
testl %eax, %eax
je 0x33520
movq %rbx, %rdi
leaq 0x92a21(%rip), %rsi     # 0xc5c11
movq %r14, %rdx
callq 0x21920
testl %eax, %eax
je 0x3363e
movq %rbx, %rdi
leaq 0x93256(%rip), %rsi     # 0xc6460
movq %r14, %rdx
callq 0x21920
testl %eax, %eax
jne 0x337fb
movq %r12, %rdi
leaq 0x93247(%rip), %rsi     # 0xc646b
movq %rbx, %rdx
leaq 0x1d0(%rsp), %rcx
leaq 0x28(%rsp), %r8
leaq 0x20(%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 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 0xd0(%rsp), %r10
pushq %r10
leaq 0x90(%rsp), %r10
pushq %r10
leaq 0xa0(%rsp), %r10
pushq %r10
leaq 0xb0(%rsp), %r10
pushq %r10
leaq 0x80(%rsp), %r10
pushq %r10
leaq 0x90(%rsp), %r10
pushq %r10
callq 0x21890
addq $0x80, %rsp
cmpl $0x14, %eax
jne 0x3381c
movq %r12, %rbx
movq %r15, %r12
movsd 0x20(%rsp), %xmm0
movsd 0x18(%rsp), %xmm1
movsd 0x10(%rsp), %xmm2
leaq 0x110(%rsp), %rbp
movq %rbp, %rdi
callq 0x7c03e
movsd 0x48(%rsp), %xmm0
movsd 0x40(%rsp), %xmm1
movsd 0x38(%rsp), %xmm2
leaq 0xf8(%rsp), %r14
movq %r14, %rdi
callq 0x6b874
movsd 0x80(%rsp), %xmm0
movsd 0x78(%rsp), %xmm1
movsd 0x70(%rsp), %xmm2
leaq 0xe0(%rsp), %r15
movq %r15, %rdi
callq 0x6b874
leaq 0x128(%rsp), %rdi
movq %r14, %rsi
movq %r15, %rdx
callq 0x6bfa2
movq %r13, %rdi
leaq 0x128(%rsp), %rsi
movsd 0x91cbb(%rip), %xmm0    # 0xc5040
callq 0x6bfe8
movsd 0x68(%rsp), %xmm0
movsd 0x60(%rsp), %xmm1
movsd 0x58(%rsp), %xmm2
leaq 0x88(%rsp), %r14
movq %r14, %rdi
callq 0x6c034
movsd 0xd8(%rsp), %xmm0
movsd 0xd0(%rsp), %xmm1
movsd 0x28(%rsp), %xmm2
movsd 0xc8(%rsp), %xmm3
movsd 0xc0(%rsp), %xmm4
movsd 0xb8(%rsp), %xmm5
leaq 0x128(%rsp), %rdi
movq %r13, %rsi
movq %r14, %rdx
movq 0x50(%rsp), %r14
movq %rbp, %rcx
pushq $0x1
popq %r8
callq 0x3d4c6
movq %r14, %rdi
leaq 0x128(%rsp), %r14
movq %r14, %rsi
leaq 0x1d0(%rsp), %rdx
callq 0x33879
movq %r14, %rdi
callq 0x3e6fe
movq %r12, %r15
movq %rbx, %r12
leaq 0x5d0(%rsp), %rbx
jmp 0x337bb
subq $0x8, %rsp
movq %r12, %rdi
leaq 0x92f14(%rip), %rsi     # 0xc6356
movq %rbx, %rdx
leaq 0x1d8(%rsp), %rcx
leaq 0xe8(%rsp), %r8
movq %r13, %r9
xorl %eax, %eax
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 0xb0(%rsp), %r10
pushq %r10
callq 0x21890
addq $0x30, %rsp
cmpl $0x9, %eax
jne 0x337f2
movq %r13, %rbp
movsd 0xa0(%rsp), %xmm0
movsd 0x88(%rsp), %xmm1
movsd 0x28(%rsp), %xmm2
leaq 0x110(%rsp), %r14
movq %r14, %rdi
callq 0x7c03e
movsd 0x20(%rsp), %xmm0
movsd 0x18(%rsp), %xmm1
movsd 0x10(%rsp), %xmm2
leaq 0xf8(%rsp), %r13
movq %r13, %rdi
callq 0x6c034
movsd 0xe0(%rsp), %xmm0
leaq 0x128(%rsp), %rdi
movq %r13, %rsi
movq %r14, %rdx
leaq 0x128(%rsp), %r14
pushq $0x1
popq %rcx
callq 0x3e054
movq 0x50(%rsp), %rdi
movq %r14, %rsi
leaq 0x1d0(%rsp), %rdx
callq 0x33879
jmp 0x3362a
movq %r12, %rdi
leaq 0x92e7e(%rip), %rsi     # 0xc63a8
movq %rbx, %rdx
leaq 0x1d0(%rsp), %rcx
leaq 0xe0(%rsp), %r8
movq %r13, %r9
xorl %eax, %eax
leaq 0x38(%rsp), %r10
pushq %r10
leaq 0x48(%rsp), %r10
pushq %r10
leaq 0x58(%rsp), %r10
pushq %r10
leaq 0x28(%rsp), %r10
pushq %r10
leaq 0x38(%rsp), %r10
pushq %r10
leaq 0x48(%rsp), %r10
pushq %r10
leaq 0x58(%rsp), %r10
pushq %r10
leaq 0xc0(%rsp), %r10
pushq %r10
callq 0x21890
addq $0x40, %rsp
cmpl $0xc, %eax
jne 0x33825
movq %r13, %rbp
movsd 0xa0(%rsp), %xmm0
movsd 0x88(%rsp), %xmm1
movsd 0x28(%rsp), %xmm2
leaq 0x110(%rsp), %r14
movq %r14, %rdi
callq 0x7c03e
movsd 0x20(%rsp), %xmm0
movsd 0x18(%rsp), %xmm1
movsd 0x10(%rsp), %xmm2
leaq 0xf8(%rsp), %r13
movq %r13, %rdi
callq 0x6b874
movsd 0xe0(%rsp), %xmm0
movsd 0x48(%rsp), %xmm1
movsd 0x40(%rsp), %xmm2
movsd 0x38(%rsp), %xmm3
leaq 0x128(%rsp), %rdi
movq %r13, %rsi
movq %r14, %rdx
leaq 0x128(%rsp), %r14
pushq $0x1
popq %rcx
callq 0x3d8a6
movq 0x50(%rsp), %rdi
movq %r14, %rsi
leaq 0x1d0(%rsp), %rdx
callq 0x33879
movq %r14, %rdi
callq 0x3e6fe
pushq $0xb
popq %r14
movq %rbp, %r13
jmp 0x337c7
subq $0x8, %rsp
movq %r12, %rdi
leaq 0x92db1(%rip), %rsi     # 0xc63fd
movq %rbx, %rdx
leaq 0x1d8(%rsp), %rcx
movq %r13, %r8
leaq 0x90(%rsp), %r9
xorl %eax, %eax
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 0xb0(%rsp), %r10
pushq %r10
leaq 0x70(%rsp), %r10
pushq %r10
leaq 0x80(%rsp), %r10
pushq %r10
leaq 0x90(%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
callq 0x21890
addq $0x70, %rsp
cmpl $0x11, %eax
jne 0x3382e
movsd 0x88(%rsp), %xmm0
movsd 0x28(%rsp), %xmm1
movsd 0x20(%rsp), %xmm2
leaq 0x110(%rsp), %rbp
movq %rbp, %rdi
callq 0x7c03e
movsd 0x18(%rsp), %xmm0
movsd 0x10(%rsp), %xmm1
movsd 0x48(%rsp), %xmm2
leaq 0xf8(%rsp), %r14
movq %r14, %rdi
callq 0x6b874
movsd 0x40(%rsp), %xmm0
movsd 0x38(%rsp), %xmm1
movsd 0x80(%rsp), %xmm2
leaq 0xe0(%rsp), %r13
movq %r13, %rdi
callq 0x6c034
movsd 0x78(%rsp), %xmm0
movsd 0x70(%rsp), %xmm1
movsd 0xa0(%rsp), %xmm2
movsd 0x68(%rsp), %xmm3
movsd 0x60(%rsp), %xmm4
movsd 0x58(%rsp), %xmm5
leaq 0x128(%rsp), %rdi
movq %r14, %rsi
leaq 0x128(%rsp), %r14
movq %r13, %rdx
movq %rbp, %rcx
pushq $0x1
popq %r8
callq 0x3d4c6
movq 0x50(%rsp), %rdi
movq %r14, %rsi
leaq 0x1d0(%rsp), %rdx
callq 0x33879
movq %r14, %rdi
callq 0x3e6fe
leaq 0xa0(%rsp), %r13
pushq $0xb
popq %r14
incl 0xc(%rsp)
jmp 0x3316e
movq %r15, %rdi
callq 0x218c0
pushq $0x1
popq %rbx
jmp 0x33847
leaq 0x92b41(%rip), %rdi     # 0xc6325
xorl %ebx, %ebx
movq %r12, %rsi
xorl %eax, %eax
callq 0x7e83e
jmp 0x33847
leaq 0x92b77(%rip), %rdi     # 0xc6370
jmp 0x33835
leaq 0x92cd5(%rip), %rdi     # 0xc64d7
leaq 0x5d0(%rsp), %rsi
movl 0xc(%rsp), %edx
movq 0x30(%rsp), %rcx
xorl %eax, %eax
callq 0x7e83e
jmp 0x33845
leaq 0x92c83(%rip), %rdi     # 0xc64a6
jmp 0x33835
leaq 0x92b9f(%rip), %rdi     # 0xc63cb
jmp 0x33835
leaq 0x92bfa(%rip), %rdi     # 0xc642f
movl 0xc(%rsp), %esi
movq 0x30(%rsp), %rdx
xorl %eax, %eax
callq 0x7e83e
xorl %ebx, %ebx
movl %ebx, %eax
addq $0x19d8, %rsp           # imm = 0x19D8
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
jmp 0x33861
jmp 0x33861
jmp 0x33861
movq %rax, %rbx
leaq 0x128(%rsp), %rdi
callq 0x3e6fe
movq %rbx, %rdi
callq 0x220e0