// File: /workspace/github_cpp_makefile_star2_O1/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 0x12478(%rip), %rsi     # 0x3b0d8
callq 0x4370
testq %rax, %rax
je 0x28f3a
movq %rax, %r14
leaq 0x14eb2(%rip), %rdi     # 0x3db2a
movq %r12, %rsi
xorl %eax, %eax
callq 0x9d2e
leaq 0x60(%rsp), %rdi
movl $0x1000, %esi           # imm = 0x1000
movq %r14, %rdx
callq 0x4530
testq %rax, %rax
je 0x28f20
leaq 0x60(%rsp), %r15
leaq 0x1060(%rsp), %rbp
movq %r14, 0x20(%rsp)
movl $0x3f800000, 0x1c(%rsp) # imm = 0x3F800000
movq %r15, %rdi
leaq 0x14e86(%rip), %rsi     # 0x3db47
callq 0x40c0
testq %rax, %rax
je 0x28cd0
movw $0xa, (%rax)
leaq 0x1c(%rsp), %rax
movq %rax, (%rsp)
movq %r15, %rdi
leaq 0x14e67(%rip), %rsi     # 0x3db4a
movq %rbp, %rdx
leaq 0x18(%rsp), %rcx
leaq 0x14(%rsp), %r8
leaq 0x10(%rsp), %r9
xorl %eax, %eax
callq 0x42d0
cmpw $0x5, %ax
je 0x28d27
movzwl %ax, %eax
cmpl $0x4, %eax
je 0x28d7a
cmpl $0x2, %eax
jne 0x28dbb
movss 0x18(%rsp), %xmm0
movss %xmm0, 0x10(%rsp)
movss %xmm0, 0x14(%rsp)
jmp 0x28d7a
xorps %xmm0, %xmm0
cvtss2sd 0x1c(%rsp), %xmm0
divsd 0x13fc8(%rip), %xmm0    # 0x3cd00
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 0x5511ddf(%rip), %r15   # 0x553ab60
movq 0x5511de0(%rip), %r14   # 0x553ab68
cmpq %r14, %r15
je 0x28e69
movq %r15, %rbx
negq %rbx
movq (%r15), %r13
movq %r13, %rdi
movq %rbp, %rsi
callq 0x4440
testl %eax, %eax
je 0x28de6
addq $0x38, %r15
addq $-0x38, %rbx
cmpq %r14, %r15
jne 0x28d97
jmp 0x28e69
movq %r15, %rdi
callq 0x4150
cmpq $0x5, %rax
jb 0x28ef9
leaq 0x14d85(%rip), %rdi     # 0x3db59
movq %r15, %rsi
movq %r12, %rdx
xorl %eax, %eax
callq 0xa38e
jmp 0x28ef9
movq 0x30(%r15), %r14
movq %r14, %rdi
movq %r12, %rsi
callq 0x4440
testl %eax, %eax
je 0x28e43
movss 0x20(%r15), %xmm0
ucomiss 0x18(%rsp), %xmm0
jne 0x28e2a
jp 0x28e2a
movss 0x24(%r15), %xmm0
ucomiss 0x14(%rsp), %xmm0
jne 0x28e2a
jp 0x28e2a
movss 0x28(%r15), %xmm0
ucomiss 0x10(%rsp), %xmm0
jne 0x28e2a
jnp 0x28f14
leaq 0x14d74(%rip), %rdi     # 0x3dba5
movq %r13, %rsi
movq %r14, %rdx
movq %r12, %rcx
xorl %eax, %eax
callq 0xa38e
jmp 0x28e57
leaq 0x14d30(%rip), %rdi     # 0x3db7a
movq %r13, %rsi
movq %r14, %rdx
xorl %eax, %eax
callq 0xa38e
negq %rbx
leaq 0x5511cff(%rip), %rdi   # 0x553ab60
movq %rbx, %rsi
callq 0x2fd3e
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 0x44f0
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 0x5511c90(%rip), %rdi   # 0x553ab60
movq %r15, %rsi
callq 0x2fce0
movq 0x28(%rsp), %rdi
cmpq %r14, %rdi
movq 0x20(%rsp), %r14
leaq 0x60(%rsp), %r15
je 0x28ef9
movq 0x38(%rsp), %rsi
incq %rsi
callq 0x4300
movq %r15, %rdi
movl $0x1000, %esi           # imm = 0x1000
movq %r14, %rdx
callq 0x4530
testq %rax, %rax
jne 0x28caf
jmp 0x28f20
leaq 0x14caf(%rip), %rdi     # 0x3dbca
jmp 0x28e31
movq %r14, %rdi
callq 0x42e0
addq $0x2068, %rsp           # imm = 0x2068
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
leaq 0x14bc9(%rip), %rdi     # 0x3db0a
movq %r12, %rsi
xorl %eax, %eax
addq $0x2068, %rsp           # imm = 0x2068
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
jmp 0xa38e
movq %rax, %rbx
movq 0x28(%rsp), %rdi
cmpq %r14, %rdi
je 0x28f76
movq 0x38(%rsp), %rsi
incq %rsi
callq 0x4300
movq %rbx, %rdi
callq 0x4590