// File: /workspace/github_c_makefile_star2_O2/arkanis[P]process-map/./deps/raygui.h
// Function: GuiLoadStyle
void GuiLoadStyle(const char *fileName)
{
    bool tryBinary = false;

    // Try reading the files as text file first
    FILE *rgsFile = fopen(fileName, "rt");

    if (rgsFile != NULL)
    {
        char buffer[256] = { 0 };
        fgets(buffer, 256, rgsFile);

        if (buffer[0] == '#')
        {
            int controlId = 0;
            int propertyId = 0;
            unsigned int propertyValue = 0;

            while (!feof(rgsFile))
            {
                switch (buffer[0])
                {
                    case 'p':
                    {
                        // Style property: p <control_id> <property_id> <property_value> <property_name>

                        sscanf(buffer, "p %d %d 0x%x", &controlId, &propertyId, &propertyValue);

                        GuiSetStyle(controlId, propertyId, (int)propertyValue);

                    } break;
                    case 'f':
                    {
                        // Style font: f <gen_font_size> <charmap_file> <font_file>

                        int fontSize = 0;
                        char charmapFileName[256] = { 0 };
                        char fontFileName[256] = { 0 };
                        sscanf(buffer, "f %d %s %[^\r\n]s", &fontSize, charmapFileName, fontFileName);

                        Font font = { 0 };

                        if (charmapFileName[0] != '0')
                        {
                            // Load characters from charmap file,
                            // expected '\n' separated list of integer values
                            char *charValues = LoadFileText(charmapFileName);
                            if (charValues != NULL)
                            {
                                int charsCount = 0;
                                const char **chars = TextSplit(charValues, '\n', &charsCount);

                                int *values = (int *)RAYGUI_MALLOC(charsCount*sizeof(int));
                                for (int i = 0; i < charsCount; i++) values[i] = TextToInteger(chars[i]);

                                font = LoadFontEx(TextFormat("%s/%s", GetDirectoryPath(fileName), fontFileName), fontSize, values, charsCount);

                                RAYGUI_FREE(values);
                            }
                        }
                        else font = LoadFontEx(TextFormat("%s/%s", GetDirectoryPath(fileName), fontFileName), fontSize, NULL, 0);

                        if ((font.texture.id > 0) && (font.charsCount > 0)) GuiSetFont(font);

                    } break;
                    default: break;
                }

                fgets(buffer, 256, rgsFile);
            }
        }
        else tryBinary = true;

        fclose(rgsFile);
    }

    if (tryBinary)
    {
        rgsFile = fopen(fileName, "rb");

        if (rgsFile == NULL) return;

        char signature[5] = "";
        short version = 0;
        short reserved = 0;
        int propertiesCount = 0;

        fread(signature, 1, 4, rgsFile);
        fread(&version, 1, sizeof(short), rgsFile);
        fread(&reserved, 1, sizeof(short), rgsFile);
        fread(&propertiesCount, 1, sizeof(int), rgsFile);

        if ((signature[0] == 'r') &&
            (signature[1] == 'G') &&
            (signature[2] == 'S') &&
            (signature[3] == ' '))
        {
            short controlId = 0;
            short propertyId = 0;
            int propertyValue = 0;

            for (int i = 0; i < propertiesCount; i++)
            {
                fread(&controlId, 1, sizeof(short), rgsFile);
                fread(&propertyId, 1, sizeof(short), rgsFile);
                fread(&propertyValue, 1, sizeof(int), rgsFile);

                if (controlId == 0) // DEFAULT control
                {
                    // If a DEFAULT property is loaded, it is propagated to all controls
                    // NOTE: All DEFAULT properties should be defined first in the file
                    GuiSetStyle(0, (int)propertyId, propertyValue);

                    if (propertyId < NUM_PROPS_DEFAULT) for (int i = 1; i < NUM_CONTROLS; i++) GuiSetStyle(i, (int)propertyId, propertyValue);
                }
                else GuiSetStyle((int)controlId, (int)propertyId, propertyValue);
            }

            // Font loading is highly dependant on raylib API to load font data and image
            // TODO: Find some mechanism to support it in standalone mode
#if !defined(RAYGUI_STANDALONE)
            // Load custom font if available
            int fontDataSize = 0;
            fread(&fontDataSize, 1, sizeof(int), rgsFile);

            if (fontDataSize > 0)
            {
                Font font = { 0 };
                int fontType = 0;   // 0-Normal, 1-SDF
                Rectangle whiteRec = { 0 };

                fread(&font.baseSize, 1, sizeof(int), rgsFile);
                fread(&font.charsCount, 1, sizeof(int), rgsFile);
                fread(&fontType, 1, sizeof(int), rgsFile);

                // Load font white rectangle
                fread(&whiteRec, 1, sizeof(Rectangle), rgsFile);

                // Load font image parameters
                int fontImageSize = 0;
                fread(&fontImageSize, 1, sizeof(int), rgsFile);

                if (fontImageSize > 0)
                {
                    Image imFont = { 0 };
                    imFont.mipmaps = 1;
                    fread(&imFont.width, 1, sizeof(int), rgsFile);
                    fread(&imFont.height, 1, sizeof(int), rgsFile);
                    fread(&imFont.format, 1, sizeof(int), rgsFile);

                    imFont.data = (unsigned char *)RAYGUI_MALLOC(fontImageSize);
                    fread(imFont.data, 1, fontImageSize, rgsFile);

                    font.texture = LoadTextureFromImage(imFont);

                    UnloadImage(imFont);
                }

                // Load font recs data
                font.recs = (Rectangle *)RAYGUI_CALLOC(font.charsCount, sizeof(Rectangle));
                for (int i = 0; i < font.charsCount; i++) fread(&font.recs[i], 1, sizeof(Rectangle), rgsFile);

                // Load font chars info data
                font.chars = (CharInfo *)RAYGUI_CALLOC(font.charsCount, sizeof(CharInfo));
                for (int i = 0; i < font.charsCount; i++)
                {
                    fread(&font.chars[i].value, 1, sizeof(int), rgsFile);
                    fread(&font.chars[i].offsetX, 1, sizeof(int), rgsFile);
                    fread(&font.chars[i].offsetY, 1, sizeof(int), rgsFile);
                    fread(&font.chars[i].advanceX, 1, sizeof(int), rgsFile);
                }

                GuiSetFont(font);

                // Set font texture source rectangle to be used as white texture to draw shapes
                // NOTE: This way, all gui can be draw using a single draw call
                if ((whiteRec.width != 0) && (whiteRec.height != 0)) SetShapesTexture(font.texture, whiteRec);
            }
#endif
        }

        fclose(rgsFile);
    }
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x3c8, %rsp            # imm = 0x3C8
leaq 0x76c0b(%rip), %rsi     # 0x854b2
movq %rdi, 0x48(%rsp)
callq 0x61d0
testq %rax, %rax
je 0xefb3
movq %rax, %r14
leaq 0xc0(%rsp), %r15
movl $0x100, %edx            # imm = 0x100
movq %r15, %rdi
xorl %esi, %esi
callq 0x6060
movq %r15, %rdi
movl $0x100, %esi            # imm = 0x100
movq %r14, %rdx
callq 0x6250
cmpb $0x23, (%r15)
jne 0xeb45
leaq 0x3c(%rsp), %rax
andl $0x0, (%rax)
leaq 0x58(%rsp), %r13
andl $0x0, (%r13)
leaq 0x54(%rsp), %rbp
andl $0x0, (%rbp)
leaq 0x2c0(%rsp), %r15
leaq 0xc0(%rsp), %r12
movq %r14, %rdi
callq 0x6610
testl %eax, %eax
jne 0xecc7
movzbl 0xc0(%rsp), %eax
cmpl $0x66, %eax
je 0xe971
cmpl $0x70, %eax
jne 0xeb30
movq %r12, %rdi
leaq 0x4aa71(%rip), %rsi     # 0x593ba
leaq 0x3c(%rsp), %rdx
movq %r13, %rcx
movq %rbp, %r8
xorl %eax, %eax
callq 0x6140
movl 0x3c(%rsp), %edi
movl 0x58(%rsp), %esi
movl 0x54(%rsp), %edx
callq 0x6e0e
jmp 0xeb30
andl $0x0, 0x44(%rsp)
movl $0x100, %edx            # imm = 0x100
leaq 0x1c0(%rsp), %rbx
movq %rbx, %rdi
xorl %esi, %esi
callq 0x6060
movl $0x100, %edx            # imm = 0x100
movq %r15, %rdi
xorl %esi, %esi
callq 0x6060
movq %r12, %rdi
leaq 0x4aa21(%rip), %rsi     # 0x593c7
leaq 0x44(%rsp), %rdx
movq %rbx, %rcx
movq %r15, %r8
xorl %eax, %eax
callq 0x6140
xorps %xmm0, %xmm0
movaps %xmm0, 0x80(%rsp)
movaps %xmm0, 0x70(%rsp)
movaps %xmm0, 0x60(%rsp)
cmpb $0x30, 0x1c0(%rsp)
jne 0xea3d
movq 0x48(%rsp), %rdi
callq 0x23d2b
leaq 0x4a9ef(%rip), %rdi     # 0x593d7
movq %rax, %rsi
movq %r15, %rdx
xorl %eax, %eax
callq 0x43d0d
movl 0x44(%rsp), %edx
leaq 0x90(%rsp), %rdi
movq %rax, %rsi
xorl %ecx, %ecx
xorl %r8d, %r8d
callq 0x404c1
movups 0x90(%rsp), %xmm0
movups 0xa0(%rsp), %xmm1
movups 0xb0(%rsp), %xmm2
movaps %xmm2, 0x80(%rsp)
movaps %xmm1, 0x70(%rsp)
movaps %xmm0, 0x60(%rsp)
jmp 0xeafd
movq %rbx, %rdi
callq 0x47d0c
testq %rax, %rax
je 0xeafd
andl $0x0, 0x90(%rsp)
movq %rax, %rdi
pushq $0xa
popq %rsi
leaq 0x90(%rsp), %rdx
callq 0x44bfb
movq %rax, %rbp
movslq 0x90(%rsp), %r15
movq %r15, %rdi
shlq $0x2, %rdi
callq 0x61c0
movq %rax, %r13
xorl %ebx, %ebx
movslq %r15d, %rax
cmpq %rax, %rbx
jge 0xeaa9
movq (%rbp,%rbx,8), %rdi
callq 0x448c2
movl %eax, (%r13,%rbx,4)
incq %rbx
movl 0x90(%rsp), %r15d
jmp 0xea85
movq 0x48(%rsp), %rdi
callq 0x23d2b
leaq 0x4a91d(%rip), %rdi     # 0x593d7
movq %rax, %rsi
leaq 0x2c0(%rsp), %r15
movq %r15, %rdx
xorl %eax, %eax
callq 0x43d0d
movl 0x44(%rsp), %edx
movl 0x90(%rsp), %r8d
leaq 0x60(%rsp), %rdi
movq %rax, %rsi
movq %r13, %rcx
callq 0x404c1
movq %r13, %rdi
callq 0x62f0
leaq 0x58(%rsp), %r13
leaq 0x54(%rsp), %rbp
cmpl $0x0, 0x6c(%rsp)
je 0xeb30
cmpl $0x0, 0x64(%rsp)
jle 0xeb30
movaps 0x60(%rsp), %xmm0
movaps 0x70(%rsp), %xmm1
movaps 0x80(%rsp), %xmm2
movups %xmm2, 0x20(%rsp)
movups %xmm1, 0x10(%rsp)
movups %xmm0, (%rsp)
callq 0x69a2
movq %r12, %rdi
movl $0x100, %esi            # imm = 0x100
movq %r14, %rdx
callq 0x6250
jmp 0xe919
movq %r14, %rdi
callq 0x6630
leaq 0x4a889(%rip), %rsi     # 0x593dd
movq 0x48(%rsp), %rdi
callq 0x61d0
testq %rax, %rax
je 0xefb3
movq %rax, %rbx
leaq 0x60(%rsp), %r14
movb $0x0, 0x4(%r14)
andl $0x0, (%r14)
leaq 0x5e(%rsp), %r15
andw $0x0, (%r15)
leaq 0x5c(%rsp), %r12
andw $0x0, (%r12)
leaq 0x90(%rsp), %rax
andl $0x0, (%rax)
pushq $0x1
popq %rbp
pushq $0x4
popq %rdx
movq %r14, %rdi
movq %rbp, %rsi
movq %rbx, %rcx
callq 0x64b0
pushq $0x2
popq %r13
movq %r15, %rdi
movq %rbp, %rsi
movq %r13, %rdx
movq %rbx, %rcx
callq 0x64b0
movq %r12, %rdi
movq %rbp, %rsi
movq %r13, %rdx
movq %rbx, %rcx
callq 0x64b0
leaq 0x90(%rsp), %rdi
movq %rbp, %rsi
pushq $0x4
popq %rdx
movq %rbx, %rcx
callq 0x64b0
cmpl $0x20534772, (%r14)     # imm = 0x20534772
jne 0xefab
leaq 0x42(%rsp), %rax
andw $0x0, (%rax)
leaq 0x3a(%rsp), %rax
andw $0x0, (%rax)
leaq 0x3c(%rsp), %rax
andl $0x0, (%rax)
movl 0x90(%rsp), %eax
xorl %ebp, %ebp
testl %eax, %eax
cmovlel %ebp, %eax
movl %eax, 0x48(%rsp)
pushq $0x1
popq %r13
cmpl 0x48(%rsp), %ebp
je 0xeccf
leaq 0x42(%rsp), %rdi
movq %r13, %rsi
pushq $0x2
popq %r14
movq %r14, %rdx
movq %rbx, %rcx
callq 0x64b0
leaq 0x3a(%rsp), %rdi
movq %r13, %rsi
movq %r14, %rdx
movq %rbx, %rcx
callq 0x64b0
leaq 0x3c(%rsp), %rdi
movq %r13, %rsi
pushq $0x4
popq %rdx
movq %rbx, %rcx
callq 0x64b0
movswl 0x42(%rsp), %edi
testl %edi, %edi
je 0xec85
movswl 0x3a(%rsp), %esi
movl 0x3c(%rsp), %edx
callq 0x6e0e
jmp 0xecc0
movswl 0x3a(%rsp), %r15d
movl 0x3c(%rsp), %r12d
xorl %edi, %edi
movl %r15d, %esi
movl %r12d, %edx
callq 0x6e0e
cmpl $0xf, %r15d
jg 0xecc0
pushq $0x1
popq %r14
cmpl $0x10, %r14d
je 0xecc0
movl %r14d, %edi
movl %r15d, %esi
movl %r12d, %edx
callq 0x6e0e
incl %r14d
jmp 0xeca7
incl %ebp
jmp 0xec25
movq %r14, %rdi
jmp 0xefae
leaq 0x58(%rsp), %r14
andl $0x0, (%r14)
pushq $0x1
popq %rsi
pushq $0x4
popq %rdx
movq %r14, %rdi
movq %rbx, %rcx
callq 0x64b0
cmpl $0x0, (%r14)
jle 0xefab
xorps %xmm0, %xmm0
leaq 0xc0(%rsp), %rdi
movaps %xmm0, 0x20(%rdi)
leaq 0x54(%rsp), %r12
andl $0x0, (%r12)
movaps %xmm0, 0x10(%rdi)
movaps %xmm0, (%rdi)
leaq 0x2c0(%rsp), %r13
movaps %xmm0, (%r13)
pushq $0x1
popq %r14
pushq $0x4
popq %r15
movq %r14, %rsi
movq %r15, %rdx
movq %rbx, %rcx
callq 0x64b0
leaq 0xc4(%rsp), %rdi
movq %r14, %rsi
movq %r15, %rdx
movq %rbx, %rcx
callq 0x64b0
movq %r12, %rdi
movq %r14, %rsi
movq %r15, %rdx
movq %rbx, %rcx
callq 0x64b0
pushq $0x10
popq %rdx
movq %r13, %rdi
movq %r14, %rsi
movq %rbx, %rcx
callq 0x64b0
leaq 0x44(%rsp), %r12
andl $0x0, (%r12)
movq %r12, %rdi
movq %r14, %rsi
movq %r15, %rdx
movq %rbx, %rcx
callq 0x64b0
movslq (%r12), %r14
testq %r14, %r14
jle 0xee49
leaq 0x1c8(%rsp), %rdi
xorps %xmm0, %xmm0
movaps %xmm0, -0x8(%rdi)
andq $0x0, 0x8(%rdi)
movl $0x1, 0x8(%rdi)
pushq $0x1
popq %r12
pushq $0x4
popq %r13
movq %r12, %rsi
movq %r13, %rdx
movq %rbx, %rcx
callq 0x64b0
leaq 0x1cc(%rsp), %rdi
movq %r12, %rsi
movq %r13, %rdx
movq %rbx, %rcx
callq 0x64b0
leaq 0x1d4(%rsp), %r15
movq %r15, %rdi
movq %r12, %rsi
movq %r13, %rdx
movq %rbx, %rcx
callq 0x64b0
movq %r14, %rdi
callq 0x61c0
movq %rax, -0x14(%r15)
movq %rax, %rdi
movq %r12, %rsi
movq %r14, %rdx
movq %rbx, %rcx
callq 0x64b0
leaq 0xcc(%rsp), %rdi
movq -0x4(%r15), %rax
movq %rax, 0x10(%rsp)
movaps -0x14(%r15), %xmm0
movups %xmm0, (%rsp)
callq 0x36594
movq -0x4(%r15), %rax
movq %rax, 0x10(%rsp)
movaps -0x14(%r15), %xmm0
movups %xmm0, (%rsp)
callq 0x3105c
movslq 0xc4(%rsp), %r14
pushq $0x10
popq %r15
movq %r14, %rdi
movq %r15, %rsi
callq 0x65f0
movq %rax, %r12
movq %rax, 0xe0(%rsp)
xorl %r13d, %r13d
testl %r14d, %r14d
movq %r14, 0x48(%rsp)
cmovgl %r14d, %r13d
pushq $0x1
popq %r14
movq %r13, %rbp
subq $0x1, %rbp
jb 0xee9e
movq %r12, %rdi
movq %r14, %rsi
movq %r15, %rdx
movq %rbx, %rcx
callq 0x64b0
addq $0x10, %r12
jmp 0xee81
pushq $0x28
popq %rsi
movq 0x48(%rsp), %rdi
callq 0x65f0
movq %rax, %r14
movq %rax, 0xe8(%rsp)
pushq $0x1
popq %r15
pushq $0x4
popq %r12
subq $0x1, %r13
jb 0xef11
movq %r14, %rdi
movq %r15, %rsi
movq %r12, %rdx
movq %rbx, %rcx
callq 0x64b0
leaq 0x4(%r14), %rdi
movq %r15, %rsi
movq %r12, %rdx
movq %rbx, %rcx
callq 0x64b0
leaq 0x8(%r14), %rdi
movq %r15, %rsi
movq %r12, %rdx
movq %rbx, %rcx
callq 0x64b0
leaq 0xc(%r14), %rdi
movq %r15, %rsi
movq %r12, %rdx
movq %rbx, %rcx
callq 0x64b0
addq $0x28, %r14
jmp 0xeebe
movaps 0xc0(%rsp), %xmm0
movaps 0xd0(%rsp), %xmm1
movaps 0xe0(%rsp), %xmm2
movups %xmm2, 0x20(%rsp)
movups %xmm1, 0x10(%rsp)
movups %xmm0, (%rsp)
callq 0x69a2
movss 0x2c8(%rsp), %xmm1
xorps %xmm0, %xmm0
ucomiss %xmm0, %xmm1
jne 0xef4f
jnp 0xefab
movss 0x2cc(%rsp), %xmm1
ucomiss %xmm0, %xmm1
jne 0xef5f
jnp 0xefab
movl 0xdc(%rsp), %eax
movl %eax, 0x1d0(%rsp)
movups 0xcc(%rsp), %xmm0
movaps %xmm0, 0x1c0(%rsp)
movsd 0x2c0(%rsp), %xmm0
movsd 0x2c8(%rsp), %xmm1
movl 0x1d0(%rsp), %eax
movl %eax, 0x10(%rsp)
movaps 0x1c0(%rsp), %xmm2
movups %xmm2, (%rsp)
callq 0x1c592
movq %rbx, %rdi
callq 0x6630
addq $0x3c8, %rsp            # imm = 0x3C8
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq