// File: /workspace/github_cpp_makefile_star2_O3/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 $0x19e8, %rsp           # imm = 0x19E8
movq %rsi, %r12
movq %rdi, 0x48(%rsp)
leaq 0xab6af(%rip), %rsi     # 0xe1083
movq %r12, %rdi
callq 0x21ab0
movq %rax, 0x50(%rsp)
testq %rax, %rax
je 0x360f9
movq %r12, 0x28(%rsp)
leaq 0x9e0(%rsp), %rdi
movl $0x1000, %esi           # imm = 0x1000
movq 0x50(%rsp), %rdx
callq 0x21f30
testq %rax, %rax
je 0x360e8
movabsq $0x67696c5f656e696c, %rax # imm = 0x67696C5F656E696C
movl $0x1, %ebp
movabsq $0x746867696c5f65, %rcx # imm = 0x746867696C5F65
leaq 0x9e0(%rsp), %r13
leaq 0x1e0(%rsp), %rbx
addq $0xf010707, %rax        # imm = 0xF010707
movq %rax, 0xc0(%rsp)
leaq 0xf(%rcx), %rax
movq %rax, 0xb8(%rsp)
movq %r13, %rdi
leaq 0xc454f(%rip), %rsi     # 0xf9fab
movq %rbx, %rdx
xorl %eax, %eax
callq 0x21890
cmpl $0x1, %eax
jne 0x360cb
cmpb $0x23, 0x1e0(%rsp)
je 0x360cb
movzwl 0x1f0(%rsp), %eax
movd %eax, %xmm0
pcmpeqb 0xa4aef(%rip), %xmm0    # 0xda580
movdqa 0x1e0(%rsp), %xmm1
pcmpeqb 0xa4ace(%rip), %xmm1    # 0xda570
pand %xmm0, %xmm1
pmovmskb %xmm1, %eax
cmpl $0xffff, %eax           # imm = 0xFFFF
je 0x35d5b
movq 0x1e0(%rsp), %rax
movabsq $0x696c5f746e696f70, %rcx # imm = 0x696C5F746E696F70
xorq %rcx, %rax
movl 0x1e8(%rsp), %ecx
xorq $0x746867, %rcx         # imm = 0x746867
orq %rax, %rcx
leaq 0x5e0(%rsp), %r12
je 0x35e49
movq 0x1e0(%rsp), %rax
xorq 0xc0(%rsp), %rax
movq 0x1e3(%rsp), %rcx
xorq 0xb8(%rsp), %rcx
orq %rax, %rcx
je 0x35f52
movq 0x1e0(%rsp), %rax
movabsq $0x67696c5f656e696c, %rcx # imm = 0x67696C5F656E696C
xorq %rcx, %rax
movq 0x1e3(%rsp), %rcx
movabsq $0x746867696c5f65, %rdx # imm = 0x746867696C5F65
xorq %rdx, %rcx
orq %rax, %rcx
jne 0x36117
movq %r13, %rdi
leaq 0xa594c(%rip), %rsi     # 0xdb49b
movq %rbx, %rdx
movq %r12, %rcx
leaq 0x20(%rsp), %r8
leaq 0x18(%rsp), %r9
xorl %eax, %eax
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 0x108(%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 0x88(%rsp), %r10
pushq %r10
leaq 0x98(%rsp), %r10
pushq %r10
leaq 0xa8(%rsp), %r10
pushq %r10
leaq 0x78(%rsp), %r10
pushq %r10
leaq 0x88(%rsp), %r10
pushq %r10
callq 0x21890
addq $0x80, %rsp
cmpl $0x14, %eax
jne 0x36136
movq %r13, %r15
movq %rbx, %r12
movsd 0x18(%rsp), %xmm0
movsd 0x10(%rsp), %xmm1
movsd 0x8(%rsp), %xmm2
leaq 0x108(%rsp), %rdi
callq 0x87400
movsd 0x40(%rsp), %xmm0
movsd 0x38(%rsp), %xmm1
movsd 0x30(%rsp), %xmm2
leaq 0x120(%rsp), %r14
movq %r14, %rdi
callq 0x753ca
movsd 0x80(%rsp), %xmm0
movsd 0x78(%rsp), %xmm1
movsd 0x70(%rsp), %xmm2
leaq 0xf0(%rsp), %rbx
movq %rbx, %rdi
callq 0x753ca
leaq 0x138(%rsp), %rdi
movq %r14, %rsi
movq %rbx, %rdx
callq 0x75dc8
leaq 0xa0(%rsp), %r13
movq %r13, %rdi
leaq 0x138(%rsp), %rsi
movsd 0xa4373(%rip), %xmm0    # 0xda020
callq 0x75e0e
movsd 0x68(%rsp), %xmm0
movsd 0x60(%rsp), %xmm1
movsd 0x58(%rsp), %xmm2
leaq 0x88(%rsp), %r14
movq %r14, %rdi
callq 0x75e5e
movsd 0xe8(%rsp), %xmm0
movsd 0xe0(%rsp), %xmm1
movsd 0x20(%rsp), %xmm2
movsd 0xd8(%rsp), %xmm3
movsd 0xd0(%rsp), %xmm4
movsd 0xc8(%rsp), %xmm5
leaq 0x138(%rsp), %rdi
movq %r13, %rsi
movq %r14, %rdx
leaq 0x138(%rsp), %r14
movq 0x48(%rsp), %rbx
leaq 0x108(%rsp), %rcx
movl $0x1, %r8d
callq 0x41864
movq %rbx, %rdi
movq %r14, %rsi
leaq 0x5e0(%rsp), %rdx
callq 0x36191
movq %r14, %rdi
callq 0x42c42
movq %r12, %rbx
movq %r15, %r13
jmp 0x360cb
subq $0x8, %rsp
movq %r13, %rdi
leaq 0xa561d(%rip), %rsi     # 0xdb386
movq %rbx, %rdx
leaq 0x5e8(%rsp), %r12
movq %r12, %rcx
leaq 0xf8(%rsp), %r8
leaq 0xa8(%rsp), %r9
xorl %eax, %eax
leaq 0x10(%rsp), %r10
pushq %r10
leaq 0x20(%rsp), %r10
pushq %r10
leaq 0x30(%rsp), %r10
pushq %r10
leaq 0x40(%rsp), %r10
pushq %r10
leaq 0xb0(%rsp), %r10
pushq %r10
callq 0x21890
addq $0x30, %rsp
cmpl $0x9, %eax
jne 0x3610e
movsd 0xa0(%rsp), %xmm0
movsd 0x88(%rsp), %xmm1
movsd 0x20(%rsp), %xmm2
leaq 0x108(%rsp), %r14
movq %r14, %rdi
callq 0x87400
movsd 0x18(%rsp), %xmm0
movsd 0x10(%rsp), %xmm1
movsd 0x8(%rsp), %xmm2
leaq 0x120(%rsp), %r15
movq %r15, %rdi
callq 0x75e5e
movsd 0xf0(%rsp), %xmm0
leaq 0x138(%rsp), %rdi
movq %r15, %rsi
movq %r14, %rdx
leaq 0x138(%rsp), %r14
movl $0x1, %ecx
callq 0x424ba
movq 0x48(%rsp), %rdi
movq %r14, %rsi
movq %r12, %rdx
callq 0x36191
jmp 0x360c3
movq %r13, %rdi
leaq 0xa5585(%rip), %rsi     # 0xdb3d8
movq %rbx, %rdx
movq %r12, %rcx
leaq 0xf0(%rsp), %r8
leaq 0xa0(%rsp), %r9
xorl %eax, %eax
leaq 0x30(%rsp), %r10
pushq %r10
leaq 0x40(%rsp), %r10
pushq %r10
leaq 0x50(%rsp), %r10
pushq %r10
leaq 0x20(%rsp), %r10
pushq %r10
leaq 0x30(%rsp), %r10
pushq %r10
leaq 0x40(%rsp), %r10
pushq %r10
leaq 0x50(%rsp), %r10
pushq %r10
leaq 0xc0(%rsp), %r10
pushq %r10
callq 0x21890
addq $0x40, %rsp
cmpl $0xc, %eax
jne 0x3613f
movsd 0xa0(%rsp), %xmm0
movsd 0x88(%rsp), %xmm1
movsd 0x20(%rsp), %xmm2
leaq 0x108(%rsp), %r14
movq %r14, %rdi
callq 0x87400
movsd 0x18(%rsp), %xmm0
movsd 0x10(%rsp), %xmm1
movsd 0x8(%rsp), %xmm2
leaq 0x120(%rsp), %r15
movq %r15, %rdi
callq 0x753ca
movsd 0xf0(%rsp), %xmm0
movsd 0x40(%rsp), %xmm1
movsd 0x38(%rsp), %xmm2
movsd 0x30(%rsp), %xmm3
leaq 0x138(%rsp), %rdi
movq %r15, %rsi
movq %r14, %rdx
leaq 0x138(%rsp), %r14
movl $0x1, %ecx
callq 0x41c50
movq 0x48(%rsp), %rdi
movq %r14, %rsi
movq %r12, %rdx
callq 0x36191
jmp 0x360c3
subq $0x8, %rsp
movq %r13, %rdi
leaq 0xa54cd(%rip), %rsi     # 0xdb42d
movq %rbx, %rdx
movq %r12, %rcx
movq %r12, %r15
leaq 0xa8(%rsp), %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 0x68(%rsp), %r10
pushq %r10
leaq 0x78(%rsp), %r10
pushq %r10
leaq 0x88(%rsp), %r10
pushq %r10
leaq 0x58(%rsp), %r10
pushq %r10
leaq 0x68(%rsp), %r10
pushq %r10
leaq 0x78(%rsp), %r10
pushq %r10
leaq 0x88(%rsp), %r10
pushq %r10
callq 0x21890
addq $0x70, %rsp
cmpl $0x11, %eax
jne 0x36148
movsd 0x88(%rsp), %xmm0
movsd 0x20(%rsp), %xmm1
movsd 0x18(%rsp), %xmm2
leaq 0x108(%rsp), %rdi
callq 0x87400
movsd 0x10(%rsp), %xmm0
movsd 0x8(%rsp), %xmm1
movsd 0x40(%rsp), %xmm2
leaq 0x120(%rsp), %r14
movq %r14, %rdi
callq 0x753ca
movsd 0x38(%rsp), %xmm0
movsd 0x30(%rsp), %xmm1
movsd 0x80(%rsp), %xmm2
leaq 0xf0(%rsp), %r12
movq %r12, %rdi
callq 0x75e5e
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 0x138(%rsp), %rdi
movq %r14, %rsi
leaq 0x138(%rsp), %r14
movq %r12, %rdx
leaq 0x108(%rsp), %rcx
movl $0x1, %r8d
callq 0x41864
movq 0x48(%rsp), %rdi
movq %r14, %rsi
movq %r15, %rdx
callq 0x36191
movq %r14, %rdi
callq 0x42c42
movq %r13, %rdi
movl $0x1000, %esi           # imm = 0x1000
movq 0x50(%rsp), %rdx
callq 0x21f30
incl %ebp
testq %rax, %rax
jne 0x35a52
movq 0x50(%rsp), %rdi
callq 0x218b0
movl $0x1, %ebx
jmp 0x3615f
leaq 0xa5255(%rip), %rdi     # 0xdb355
xorl %ebx, %ebx
movq %r12, %rsi
xorl %eax, %eax
callq 0x8a0fe
jmp 0x3615f
leaq 0xa528b(%rip), %rdi     # 0xdb3a0
jmp 0x3614f
leaq 0xa53e9(%rip), %rdi     # 0xdb507
leaq 0x1e0(%rsp), %rsi
movl %ebp, %edx
movq 0x28(%rsp), %rcx
xorl %eax, %eax
callq 0x8a0fe
jmp 0x3615d
leaq 0xa5399(%rip), %rdi     # 0xdb4d6
jmp 0x3614f
leaq 0xa52b5(%rip), %rdi     # 0xdb3fb
jmp 0x3614f
leaq 0xa5310(%rip), %rdi     # 0xdb45f
movl %ebp, %esi
movq 0x28(%rsp), %rdx
xorl %eax, %eax
callq 0x8a0fe
xorl %ebx, %ebx
movl %ebx, %eax
addq $0x19e8, %rsp           # imm = 0x19E8
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
jmp 0x36179
jmp 0x36179
jmp 0x36179
movq %rax, %rbx
leaq 0x138(%rsp), %rdi
callq 0x42c42
movq %rbx, %rdi
callq 0x220c0