// File: /workspace/github_cpp_makefile_star2_O3/FreeSlave[P]vhlt/hlrad/qrad.cpp
// Function: ReadLightFile(char const*)
static void     ReadLightFile(const char* const filename)
{
    FILE*           f;
    char            scan[MAXTOKEN];
    short           argCnt;
    unsigned int    file_texlights = 0;

    f = fopen(filename, "r");
    if (!f)
    {
        Warning("Could not open texlight file %s", filename);
        return;
    }
    else
    {
#ifdef HLRAD_CUSTOMTEXLIGHT
		Log("Reading texlights from '%s'\n", filename);
#else
        Log("[Reading texlights from '%s']\n", filename);
#endif
    }

    while (fgets(scan, sizeof(scan), f))
    {
        char*           comment;
        char            szTexlight[_MAX_PATH];
        vec_t           r, g, b, i = 1;

        comment = strstr(scan, "//");
        if (comment)
        {
            // Newline and Null terminate the string early if there is a c++ style single line comment
            comment[0] = '\n';
            comment[1] = 0;
        }

        argCnt = sscanf(scan, "%s %f %f %f %f", szTexlight, &r, &g, &b, &i);

        if (argCnt == 2)
        {
            // With 1+1 args, the R,G,B values are all equal to the first value
            g = b = r;
        }
        else if (argCnt == 5)
        {
            // With 1+4 args, the R,G,B values are "scaled" by the fourth numeric value i;
            r *= i / 255.0;
            g *= i / 255.0;
            b *= i / 255.0;
        }
        else if (argCnt != 4)
        {
            if (strlen(scan) > 4)
            {
                Warning("ignoring bad texlight '%s' in %s", scan, filename);
            }
            continue;
        }

        texlight_i it;
        for (it = s_texlights.begin(); it != s_texlights.end(); it++)
        {
            if (strcmp(it->name.c_str(), szTexlight) == 0)
            {
                if (strcmp(it->filename, filename) == 0)
                {
                    Warning("Duplication of texlight '%s' in file '%s'!", it->name.c_str(), it->filename);
                }
                else if (it->value[0] != r || it->value[1] != g || it->value[2] != b)
                {
                    Warning("Overriding '%s' from '%s' with '%s'!", it->name.c_str(), it->filename, filename);
                }
                else
                {
                    Warning("Redundant '%s' def in '%s' AND '%s'!", it->name.c_str(), it->filename, filename);
                }
                s_texlights.erase(it);
                break;
            }
        }

        texlight_t      texlight;
        texlight.name = szTexlight;
        texlight.value[0] = r;
        texlight.value[1] = g;
        texlight.value[2] = b;
        texlight.filename = filename;
        file_texlights++;
        s_texlights.push_back(texlight);
    }
	fclose (f); //--vluzacn
#ifndef HLRAD_CUSTOMTEXLIGHT
    Log("[%u texlights parsed from '%s']\n\n", file_texlights, filename);
#endif
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x2068, %rsp           # imm = 0x2068
movq %rdi, %r12
leaq 0x12340(%rip), %rsi     # 0x3a0d8
callq 0x4360
testq %rax, %rax
je 0x28072
movq %rax, %r14
leaq 0x14cf7(%rip), %rdi     # 0x3caa7
movq %r12, %rsi
xorl %eax, %eax
callq 0x9c46
leaq 0x60(%rsp), %rdi
movl $0x1000, %esi           # imm = 0x1000
movq %r14, %rdx
callq 0x4520
testq %rax, %rax
je 0x28058
leaq 0x60(%rsp), %r15
leaq 0x1060(%rsp), %rbp
movq %r14, 0x20(%rsp)
movl $0x3f800000, 0x1c(%rsp) # imm = 0x3F800000
movq %r15, %rdi
leaq 0x14ccb(%rip), %rsi     # 0x3cac4
callq 0x40c0
testq %rax, %rax
je 0x27e08
movw $0xa, (%rax)
leaq 0x1c(%rsp), %rax
movq %rax, (%rsp)
movq %r15, %rdi
leaq 0x14cac(%rip), %rsi     # 0x3cac7
movq %rbp, %rdx
leaq 0x18(%rsp), %rcx
leaq 0x14(%rsp), %r8
leaq 0x10(%rsp), %r9
xorl %eax, %eax
callq 0x42c0
cmpw $0x5, %ax
je 0x27e5f
movzwl %ax, %eax
cmpl $0x4, %eax
je 0x27eb2
cmpl $0x2, %eax
jne 0x27ef3
movss 0x18(%rsp), %xmm0
movss %xmm0, 0x10(%rsp)
movss %xmm0, 0x14(%rsp)
jmp 0x27eb2
xorps %xmm0, %xmm0
cvtss2sd 0x1c(%rsp), %xmm0
divsd 0x13d78(%rip), %xmm0    # 0x3bbe8
cvtss2sd 0x18(%rsp), %xmm1
mulsd %xmm0, %xmm1
cvtsd2ss %xmm1, %xmm1
cvtss2sd 0x14(%rsp), %xmm2
mulsd %xmm0, %xmm2
cvtsd2ss %xmm2, %xmm2
movss %xmm1, 0x18(%rsp)
movss %xmm2, 0x14(%rsp)
xorps %xmm1, %xmm1
cvtss2sd 0x10(%rsp), %xmm1
mulsd %xmm0, %xmm1
xorps %xmm0, %xmm0
cvtsd2ss %xmm1, %xmm0
movss %xmm0, 0x10(%rsp)
movq 0x5511ca7(%rip), %r15   # 0x5539b60
movq 0x5511ca8(%rip), %r14   # 0x5539b68
cmpq %r14, %r15
je 0x27fa1
movq %r15, %rbx
negq %rbx
movq (%r15), %r13
movq %r13, %rdi
movq %rbp, %rsi
callq 0x4430
testl %eax, %eax
je 0x27f1e
addq $0x38, %r15
addq $-0x38, %rbx
cmpq %r14, %r15
jne 0x27ecf
jmp 0x27fa1
movq %r15, %rdi
callq 0x4150
cmpq $0x5, %rax
jb 0x28031
leaq 0x14bca(%rip), %rdi     # 0x3cad6
movq %r15, %rsi
movq %r12, %rdx
xorl %eax, %eax
callq 0xa2a6
jmp 0x28031
movq 0x30(%r15), %r14
movq %r14, %rdi
movq %r12, %rsi
callq 0x4430
testl %eax, %eax
je 0x27f7b
movss 0x20(%r15), %xmm0
ucomiss 0x18(%rsp), %xmm0
jne 0x27f62
jp 0x27f62
movss 0x24(%r15), %xmm0
ucomiss 0x14(%rsp), %xmm0
jne 0x27f62
jp 0x27f62
movss 0x28(%r15), %xmm0
ucomiss 0x10(%rsp), %xmm0
jne 0x27f62
jnp 0x2804c
leaq 0x14bb9(%rip), %rdi     # 0x3cb22
movq %r13, %rsi
movq %r14, %rdx
movq %r12, %rcx
xorl %eax, %eax
callq 0xa2a6
jmp 0x27f8f
leaq 0x14b75(%rip), %rdi     # 0x3caf7
movq %r13, %rsi
movq %r14, %rdx
xorl %eax, %eax
callq 0xa2a6
negq %rbx
leaq 0x5511bc7(%rip), %rdi   # 0x5539b60
movq %rbx, %rsi
callq 0x2ecce
leaq 0x38(%rsp), %r14
movq %r14, 0x28(%rsp)
movq $0x0, 0x30(%rsp)
movb $0x0, 0x38(%rsp)
movq %rbp, %rdi
callq 0x4150
leaq 0x28(%rsp), %r15
movq %r15, %rdi
xorl %esi, %esi
xorl %edx, %edx
movq %rbp, %rcx
movq %rax, %r8
callq 0x44e0
movss 0x18(%rsp), %xmm0
movss %xmm0, 0x48(%rsp)
movss 0x14(%rsp), %xmm0
movss %xmm0, 0x4c(%rsp)
movss 0x10(%rsp), %xmm0
movss %xmm0, 0x50(%rsp)
movq %r12, 0x58(%rsp)
leaq 0x5511b58(%rip), %rdi   # 0x5539b60
movq %r15, %rsi
callq 0x2ec70
movq 0x28(%rsp), %rdi
cmpq %r14, %rdi
movq 0x20(%rsp), %r14
leaq 0x60(%rsp), %r15
je 0x28031
movq 0x38(%rsp), %rsi
incq %rsi
callq 0x42f0
movq %r15, %rdi
movl $0x1000, %esi           # imm = 0x1000
movq %r14, %rdx
callq 0x4520
testq %rax, %rax
jne 0x27de7
jmp 0x28058
leaq 0x14af4(%rip), %rdi     # 0x3cb47
jmp 0x27f69
movq %r14, %rdi
callq 0x42d0
addq $0x2068, %rsp           # imm = 0x2068
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
leaq 0x14a0e(%rip), %rdi     # 0x3ca87
movq %r12, %rsi
xorl %eax, %eax
addq $0x2068, %rsp           # imm = 0x2068
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
jmp 0xa2a6
movq %rax, %rbx
movq 0x28(%rsp), %rdi
cmpq %r14, %rdi
je 0x280ae
movq 0x38(%rsp), %rsi
incq %rsi
callq 0x42f0
movq %rbx, %rdi
callq 0x4580