// File: /workspace/github_c_makefile_star2_O1/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 $0x3a8, %rsp            # imm = 0x3A8
movq %rdi, %r13
leaq 0x83fd2(%rip), %rsi     # 0x943dc
callq 0x61d0
testq %rax, %rax
je 0x10c20
movq %rax, %r14
leaq 0xa0(%rsp), %r15
xorl %ebx, %ebx
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 0x6240
cmpb $0x23, (%r15)
jne 0x10722
movl %ebx, 0x34(%rsp)
movl %ebx, 0x24(%rsp)
movl %ebx, 0x38(%rsp)
movq %r14, %rdi
callq 0x6600
testl %eax, %eax
jne 0x1071a
leaq 0x1a0(%rsp), %rbx
leaq 0x2a0(%rsp), %rbp
leaq 0xa0(%rsp), %r15
movq %r13, 0x98(%rsp)
movzbl 0xa0(%rsp), %eax
cmpl $0x66, %eax
je 0x104d6
cmpl $0x70, %eax
jne 0x106fa
movq %r15, %rdi
leaq 0x57e08(%rip), %rsi     # 0x682b2
leaq 0x34(%rsp), %rdx
leaq 0x24(%rsp), %rcx
leaq 0x38(%rsp), %r8
xorl %eax, %eax
callq 0x6140
movl 0x34(%rsp), %edi
movl 0x24(%rsp), %esi
movl 0x38(%rsp), %edx
callq 0x6d91
jmp 0x106fa
movl $0x0, 0x30(%rsp)
movl $0x100, %edx            # imm = 0x100
movq %rbx, %rdi
xorl %esi, %esi
callq 0x6060
movl $0x100, %edx            # imm = 0x100
movq %rbp, %rdi
xorl %esi, %esi
callq 0x6060
movq %r15, %rdi
leaq 0x57db9(%rip), %rsi     # 0x682bf
leaq 0x30(%rsp), %rdx
movq %rbx, %rcx
movq %rbp, %r8
xorl %eax, %eax
callq 0x6140
xorps %xmm0, %xmm0
movaps %xmm0, 0x70(%rsp)
movaps %xmm0, 0x80(%rsp)
cmpb $0x30, 0x1a0(%rsp)
jne 0x10594
movq %r13, %rdi
callq 0x2df51
leaq 0x57d8e(%rip), %rdi     # 0x682cf
movq %rax, %rsi
movq %rbp, %rdx
xorl %eax, %eax
callq 0x50f37
movl 0x30(%rsp), %edx
leaq 0x40(%rsp), %rdi
movq %rax, %rsi
xorl %ecx, %ecx
xorl %r8d, %r8d
callq 0x4d099
movl 0x40(%rsp), %r15d
movl 0x44(%rsp), %r12d
movl 0x48(%rsp), %ebx
movl 0x4c(%rsp), %ebp
leaq 0x50(%rsp), %rax
movups (%rax), %xmm0
movups 0x10(%rax), %xmm1
movaps %xmm0, 0x70(%rsp)
movaps %xmm1, 0x80(%rsp)
jmp 0x10678
movq %rbx, %rdi
callq 0x557e9
testq %rax, %rax
je 0x1066e
movq %r13, %r12
movl $0x0, 0x28(%rsp)
movq %rax, %rdi
movl $0xa, %esi
leaq 0x28(%rsp), %rdx
callq 0x52112
movq %rax, %r15
movslq 0x28(%rsp), %rbx
leaq (,%rbx,4), %rdi
callq 0x61c0
movq %rax, %r13
testq %rbx, %rbx
jle 0x105fc
xorl %ebx, %ebx
movq (%r15,%rbx,8), %rdi
callq 0x51cda
movl %eax, (%r13,%rbx,4)
incq %rbx
movslq 0x28(%rsp), %rax
cmpq %rax, %rbx
jl 0x105e1
movq %r12, %rdi
callq 0x2df51
leaq 0x57cc4(%rip), %rdi     # 0x682cf
movq %rax, %rsi
movq %rbp, %rdx
xorl %eax, %eax
callq 0x50f37
movl 0x30(%rsp), %edx
movl 0x28(%rsp), %r8d
leaq 0x40(%rsp), %rdi
movq %rax, %rsi
movq %r13, %rcx
callq 0x4d099
movl 0x40(%rsp), %r15d
movl 0x44(%rsp), %r12d
movl 0x48(%rsp), %ebx
movl 0x4c(%rsp), %ebp
leaq 0x50(%rsp), %rax
movups (%rax), %xmm0
movups 0x10(%rax), %xmm1
movaps %xmm0, 0x70(%rsp)
movaps %xmm1, 0x80(%rsp)
movq %r13, %rdi
movq 0x98(%rsp), %r13
callq 0x62e0
jmp 0x10678
xorl %r15d, %r15d
xorl %r12d, %r12d
xorl %ebx, %ebx
xorl %ebp, %ebp
testl %ebp, %ebp
setne %al
testl %r12d, %r12d
setg %cl
andb %al, %cl
cmpb $0x1, %cl
jne 0x106e2
cmpb $0x0, 0x96bc4(%rip)     # 0xa7255
jne 0x10698
callq 0x6a18
movl %r15d, 0x96bb9(%rip)    # 0xa7258
movl %r12d, 0x96bb6(%rip)    # 0xa725c
movl %ebx, 0x96bb4(%rip)     # 0xa7260
movl %ebp, 0x96bb2(%rip)     # 0xa7264
movaps 0x70(%rsp), %xmm0
movaps 0x80(%rsp), %xmm1
movups %xmm0, 0x96ba2(%rip)    # 0xa7268
movups %xmm1, 0x96bab(%rip)    # 0xa7278
cmpb $0x0, 0x96b81(%rip)     # 0xa7255
jne 0x106db
callq 0x6a18
movl %r15d, 0x96bee(%rip)    # 0xa72d0
leaq 0x1a0(%rsp), %rbx
leaq 0x2a0(%rsp), %rbp
leaq 0xa0(%rsp), %r15
movq %r15, %rdi
movl $0x100, %esi            # imm = 0x100
movq %r14, %rdx
callq 0x6240
movq %r14, %rdi
callq 0x6600
testl %eax, %eax
je 0x1048a
movq %r14, %rdi
jmp 0x10c1b
movq %r14, %rdi
callq 0x6620
leaq 0x57ba4(%rip), %rsi     # 0x682d5
movq %r13, %rdi
callq 0x61d0
testq %rax, %rax
je 0x10c20
movq %rax, %rbx
xorl %eax, %eax
leaq 0x40(%rsp), %r14
movl %eax, (%r14)
movb $0x0, 0x4(%r14)
leaq 0x3e(%rsp), %r12
movw %ax, (%r12)
leaq 0x3c(%rsp), %r13
movw %ax, (%r13)
leaq 0x34(%rsp), %r15
movl %eax, (%r15)
movl $0x1, %esi
movl $0x4, %edx
movq %r14, %rdi
movq %rbx, %rcx
callq 0x64a0
movl $0x1, %esi
movl $0x2, %edx
movq %r12, %rdi
movq %rbx, %rcx
callq 0x64a0
movl $0x1, %esi
movl $0x2, %edx
movq %r13, %rdi
movq %rbx, %rcx
callq 0x64a0
movl $0x1, %esi
movl $0x4, %edx
movq %r15, %rdi
movq %rbx, %rcx
callq 0x64a0
cmpb $0x72, (%r14)
jne 0x10c18
cmpb $0x47, 0x41(%rsp)
jne 0x10c18
cmpb $0x53, 0x42(%rsp)
jne 0x10c18
cmpb $0x20, 0x43(%rsp)
jne 0x10c18
xorl %r15d, %r15d
movw %r15w, 0x2e(%rsp)
movw %r15w, 0x22(%rsp)
movl $0x0, 0x24(%rsp)
movl 0x34(%rsp), %r12d
testl %r12d, %r12d
jle 0x108b5
movl $0x1, %esi
movl $0x2, %edx
leaq 0x2e(%rsp), %rdi
movq %rbx, %rcx
callq 0x64a0
movl $0x1, %esi
movl $0x2, %edx
leaq 0x22(%rsp), %rdi
movq %rbx, %rcx
callq 0x64a0
movl $0x1, %esi
movl $0x4, %edx
leaq 0x24(%rsp), %rdi
movq %rbx, %rcx
callq 0x64a0
movswl 0x2e(%rsp), %edi
testl %edi, %edi
je 0x10872
movswl 0x22(%rsp), %esi
movl 0x24(%rsp), %edx
callq 0x6d91
jmp 0x108a9
movswl 0x22(%rsp), %ebp
movl 0x24(%rsp), %r13d
xorl %edi, %edi
movl %ebp, %esi
movl %r13d, %edx
callq 0x6d91
cmpl $0xf, %ebp
jg 0x108a9
movl $0x1, %r14d
movl %r14d, %edi
movl %ebp, %esi
movl %r13d, %edx
callq 0x6d91
incl %r14d
cmpl $0x10, %r14d
jne 0x10893
incl %r15d
cmpl %r12d, %r15d
jne 0x10814
leaq 0x38(%rsp), %r14
movl $0x0, (%r14)
movl $0x1, %esi
movl $0x4, %edx
movq %r14, %rdi
movq %rbx, %rcx
callq 0x64a0
cmpl $0x0, (%r14)
jle 0x10c18
xorps %xmm0, %xmm0
leaq 0xa0(%rsp), %rdi
movaps %xmm0, 0x20(%rdi)
movaps %xmm0, 0x10(%rdi)
movaps %xmm0, (%rdi)
xorl %ebp, %ebp
leaq 0x30(%rsp), %r15
movl %ebp, (%r15)
leaq 0x2a0(%rsp), %r14
movaps %xmm0, (%r14)
movl $0x1, %esi
movl $0x4, %edx
movq %rbx, %rcx
callq 0x64a0
leaq 0xa4(%rsp), %rdi
movl $0x1, %esi
movl $0x4, %edx
movq %rbx, %rcx
callq 0x64a0
movl $0x1, %esi
movl $0x4, %edx
movq %r15, %rdi
movq %rbx, %rcx
callq 0x64a0
movl $0x1, %esi
movl $0x10, %edx
movq %r14, %rdi
movq %rbx, %rcx
callq 0x64a0
leaq 0x28(%rsp), %r14
movl %ebp, (%r14)
movl $0x1, %esi
movl $0x4, %edx
movq %r14, %rdi
movq %rbx, %rcx
callq 0x64a0
movslq (%r14), %r14
testq %r14, %r14
jle 0x10a47
leaq 0x1a8(%rsp), %rdi
xorps %xmm0, %xmm0
movaps %xmm0, -0x8(%rdi)
movq $0x0, 0x8(%rdi)
movl $0x1, 0x8(%rdi)
movl $0x1, %esi
movl $0x4, %edx
movq %rbx, %rcx
callq 0x64a0
leaq 0x1ac(%rsp), %rdi
movl $0x1, %esi
movl $0x4, %edx
movq %rbx, %rcx
callq 0x64a0
leaq 0x1b4(%rsp), %r15
movl $0x1, %esi
movl $0x4, %edx
movq %r15, %rdi
movq %rbx, %rcx
callq 0x64a0
movq %r14, %rdi
callq 0x61c0
movq %rax, -0x14(%r15)
movl $0x1, %esi
movq %rax, %rdi
movq %r14, %rdx
movq %rbx, %rcx
callq 0x64a0
leaq 0xac(%rsp), %rdi
movq -0x4(%r15), %rax
movq %rax, 0x10(%rsp)
movaps -0x14(%r15), %xmm0
movups %xmm0, (%rsp)
callq 0x4207c
movq -0x4(%r15), %rax
movq %rax, 0x10(%rsp)
movaps -0x14(%r15), %xmm0
movups %xmm0, (%rsp)
callq 0x3c3b4
movslq 0xa4(%rsp), %r14
movl $0x10, %esi
movq %r14, %rdi
callq 0x65e0
movq %rax, 0xc0(%rsp)
testq %r14, %r14
jle 0x10a8d
movq %rax, %r15
movq %r14, %r12
movl $0x1, %esi
movl $0x10, %edx
movq %r15, %rdi
movq %rbx, %rcx
callq 0x64a0
addq $0x10, %r15
decq %r12
jne 0x10a6f
movl $0x28, %esi
movq %r14, %rdi
callq 0x65e0
movq %rax, 0xc8(%rsp)
testl %r14d, %r14d
jle 0x10b0a
movq %rax, %r15
movl $0x1, %esi
movl $0x4, %edx
movq %r15, %rdi
movq %rbx, %rcx
callq 0x64a0
leaq 0x4(%r15), %rdi
movl $0x1, %esi
movl $0x4, %edx
movq %rbx, %rcx
callq 0x64a0
leaq 0x8(%r15), %rdi
movl $0x1, %esi
movl $0x4, %edx
movq %rbx, %rcx
callq 0x64a0
leaq 0xc(%r15), %rdi
movl $0x1, %esi
movl $0x4, %edx
movq %rbx, %rcx
callq 0x64a0
addq $0x28, %r15
decq %r14
jne 0x10aaa
movl 0xa0(%rsp), %ebp
movq 0xa4(%rsp), %r14
movl 0xac(%rsp), %r15d
movaps 0xb0(%rsp), %xmm0
movaps %xmm0, 0x1a0(%rsp)
movq 0xc0(%rsp), %rax
movq %rax, 0x1b0(%rsp)
movq 0xc8(%rsp), %rax
movq %rax, 0x1b8(%rsp)
testl %r15d, %r15d
je 0x10baa
cmpb $0x0, 0x966f8(%rip)     # 0xa7255
jne 0x10b64
callq 0x6a18
movl %ebp, 0x966ee(%rip)     # 0xa7258
movq %r14, 0x966eb(%rip)     # 0xa725c
movl %r15d, 0x966ec(%rip)    # 0xa7264
movaps 0x1a0(%rsp), %xmm0
movaps 0x1b0(%rsp), %xmm1
movups %xmm0, 0x966d9(%rip)    # 0xa7268
movups %xmm1, 0x966e2(%rip)    # 0xa7278
cmpb $0x0, 0x966b8(%rip)     # 0xa7255
jne 0x10ba4
callq 0x6a18
movl %ebp, 0x96726(%rip)     # 0xa72d0
movss 0x2a8(%rsp), %xmm1
xorps %xmm0, %xmm0
ucomiss %xmm0, %xmm1
jne 0x10bbd
jnp 0x10c18
movss 0x2ac(%rsp), %xmm1
ucomiss %xmm0, %xmm1
jne 0x10bcd
jnp 0x10c18
leaq 0xac(%rsp), %rax
movl 0x10(%rax), %ecx
movl %ecx, 0x1b0(%rsp)
movups (%rax), %xmm0
movaps %xmm0, 0x1a0(%rsp)
movsd 0x2a0(%rsp), %xmm0
movsd 0x2a8(%rsp), %xmm1
movl 0x1b0(%rsp), %eax
movl %eax, 0x10(%rsp)
movaps 0x1a0(%rsp), %xmm2
movups %xmm2, (%rsp)
callq 0x2411e
movq %rbx, %rdi
callq 0x6620
addq $0x3a8, %rsp            # imm = 0x3A8
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq