// File: /workspace/github_cpp_makefile_star2_O1/donfreiday[P]gb/./imgui/imgui.cpp
// Function: ImGui::ColorEdit4(char const*, float*, bool)
bool ImGui::ColorEdit4(const char* label, float col[4], bool alpha)
{
    ImGuiWindow* window = GetCurrentWindow();
    if (window->SkipItems)
        return false;

    ImGuiState& g = *GImGui;
    const ImGuiStyle& style = g.Style;
    const ImGuiID id = window->GetID(label);
    const float w_full = CalcItemWidth();
    const float square_sz = (g.FontSize + style.FramePadding.y * 2.0f);

    ImGuiColorEditMode edit_mode = window->DC.ColorEditMode;
    if (edit_mode == ImGuiColorEditMode_UserSelect || edit_mode == ImGuiColorEditMode_UserSelectShowButton)
        edit_mode = g.ColorEditModeStorage.GetInt(id, 0) % 3;

    float f[4] = { col[0], col[1], col[2], col[3] };

    if (edit_mode == ImGuiColorEditMode_HSV)
        ImGui::ColorConvertRGBtoHSV(f[0], f[1], f[2], f[0], f[1], f[2]);

    int i[4] = { (int)(f[0] * 255.0f + 0.5f), (int)(f[1] * 255.0f + 0.5f), (int)(f[2] * 255.0f + 0.5f), (int)(f[3] * 255.0f + 0.5f) };

    int components = alpha ? 4 : 3;
    bool value_changed = false;

    ImGui::BeginGroup();
    ImGui::PushID(label);

    const bool hsv = (edit_mode == 1);
    switch (edit_mode)
    {
    case ImGuiColorEditMode_RGB:
    case ImGuiColorEditMode_HSV:
        {
            // RGB/HSV 0..255 Sliders
            const float w_items_all = w_full - (square_sz + style.ItemInnerSpacing.x);
            const float w_item_one  = ImMax(1.0f, (float)(int)((w_items_all - (style.FramePadding.x*2.0f + style.ItemInnerSpacing.x) * (components-1)) / (float)components));
            const float w_item_last = ImMax(1.0f, (float)(int)(w_items_all - (w_item_one + style.FramePadding.x*2.0f + style.ItemInnerSpacing.x) * (components-1)));

            const bool hide_prefix = (w_item_one <= CalcTextSize("M:999").x);
            const char* ids[4] = { "##X", "##Y", "##Z", "##W" };
            const char* fmt_table[3][4] =
            {
                {   "%3.0f",   "%3.0f",   "%3.0f",   "%3.0f" },
                { "R:%3.0f", "G:%3.0f", "B:%3.0f", "A:%3.0f" },
                { "H:%3.0f", "S:%3.0f", "V:%3.0f", "A:%3.0f" }
            };
            const char** fmt = hide_prefix ? fmt_table[0] : hsv ? fmt_table[2] : fmt_table[1];

            ImGui::PushItemWidth(w_item_one);
            for (int n = 0; n < components; n++)
            {
                if (n > 0)
                    ImGui::SameLine(0, style.ItemInnerSpacing.x);
                if (n + 1 == components)
                    ImGui::PushItemWidth(w_item_last);
                value_changed |= ImGui::DragInt(ids[n], &i[n], 1.0f, 0, 255, fmt[n]);
            }
            ImGui::PopItemWidth();
            ImGui::PopItemWidth();
        }
        break;
    case ImGuiColorEditMode_HEX:
        {
            // RGB Hexadecimal Input
            const float w_slider_all = w_full - square_sz;
            char buf[64];
            if (alpha)
                ImFormatString(buf, IM_ARRAYSIZE(buf), "#%02X%02X%02X%02X", i[0], i[1], i[2], i[3]);
            else
                ImFormatString(buf, IM_ARRAYSIZE(buf), "#%02X%02X%02X", i[0], i[1], i[2]);
            ImGui::PushItemWidth(w_slider_all - style.ItemInnerSpacing.x);
            value_changed |= ImGui::InputText("##Text", buf, IM_ARRAYSIZE(buf), ImGuiInputTextFlags_CharsHexadecimal | ImGuiInputTextFlags_CharsUppercase);
            ImGui::PopItemWidth();
            char* p = buf;
            while (*p == '#' || ImCharIsSpace(*p))
                p++;

            // Treat at unsigned (%X is unsigned)
            i[0] = i[1] = i[2] = i[3] = 0;
            if (alpha)
                sscanf(p, "%02X%02X%02X%02X", (unsigned int*)&i[0], (unsigned int*)&i[1], (unsigned int*)&i[2], (unsigned int*)&i[3]);
            else
                sscanf(p, "%02X%02X%02X", (unsigned int*)&i[0], (unsigned int*)&i[1], (unsigned int*)&i[2]);
        }
        break;
    }

    ImGui::SameLine(0, style.ItemInnerSpacing.x);

    const ImVec4 col_display(col[0], col[1], col[2], 1.0f);
    if (ImGui::ColorButton(col_display))
        g.ColorEditModeStorage.SetInt(id, (edit_mode + 1) % 3); // Don't set local copy of 'edit_mode' right away!

    if (window->DC.ColorEditMode == ImGuiColorEditMode_UserSelectShowButton)
    {
        ImGui::SameLine(0, style.ItemInnerSpacing.x);
        const char* button_titles[3] = { "RGB", "HSV", "HEX" };
        if (ButtonEx(button_titles[edit_mode], ImVec2(0,0), ImGuiButtonFlags_DontClosePopups))
            g.ColorEditModeStorage.SetInt(id, (edit_mode + 1) % 3); // Don't set local copy of 'edit_mode' right away!
        ImGui::SameLine();
    }
    else
    {
        ImGui::SameLine(0, style.ItemInnerSpacing.x);
    }

    ImGui::TextUnformatted(label, FindTextDisplayEnd(label));

    // Convert back
    for (int n = 0; n < 4; n++)
        f[n] = i[n] / 255.0f;
    if (edit_mode == 1)
        ImGui::ColorConvertHSVtoRGB(f[0], f[1], f[2], f[0], f[1], f[2]);

    if (value_changed)
    {
        col[0] = f[0];
        col[1] = f[1];
        col[2] = f[2];
        if (alpha)
            col[3] = f[3];
    }

    ImGui::PopID();
    ImGui::EndGroup();

    return value_changed;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0xd8, %rsp
movq 0x33721(%rip), %r15     # 0x55490
movq 0x1758(%r15), %r12
movb $0x1, 0x72(%r12)
cmpb $0x0, 0x74(%r12)
je 0x21d8c
xorl %r14d, %r14d
jmp 0x22489
movl %edx, %ebx
movq %rsi, %r13
movq %rdi, %r14
movq %r12, %rdi
movq %r14, %rsi
xorl %edx, %edx
callq 0xa872
movl %eax, -0x54(%rbp)
callq 0x14bda
movaps %xmm0, -0x80(%rbp)
movss 0x140c(%r15), %xmm0
addss %xmm0, %xmm0
movq %r15, -0x68(%rbp)
addss 0x1718(%r15), %xmm0
movss %xmm0, -0x60(%rbp)
movq %r12, -0x98(%rbp)
movl 0x178(%r12), %r15d
cmpl $-0x2, %r15d
jb 0x21e13
movq -0x68(%rbp), %rax
leaq 0x27a8(%rax), %rdi
movl -0x54(%rbp), %esi
xorl %edx, %edx
callq 0x90c0
movslq %eax, %r15
imulq $0x55555556, %r15, %rax # imm = 0x55555556
movq %rax, %rcx
shrq $0x3f, %rcx
shrq $0x20, %rax
addl %ecx, %eax
leal (%rax,%rax,2), %eax
subl %eax, %r15d
movss (%r13), %xmm2
movss %xmm2, -0x50(%rbp)
movss 0x4(%r13), %xmm3
movss %xmm3, -0x4c(%rbp)
movss 0x8(%r13), %xmm1
movss %xmm1, -0x48(%rbp)
movss 0xc(%r13), %xmm0
movss %xmm0, -0x44(%rbp)
cmpl $0x1, %r15d
jne 0x21ee2
movaps %xmm3, %xmm4
cmpltss %xmm1, %xmm4
movss 0x1b533(%rip), %xmm5    # 0x3d38c
andps %xmm4, %xmm5
movaps %xmm3, %xmm4
minss %xmm1, %xmm4
maxss %xmm3, %xmm1
movss 0x1b521(%rip), %xmm3    # 0x3d390
subss %xmm5, %xmm3
movaps %xmm2, %xmm6
cmpltss %xmm1, %xmm6
movaps %xmm6, %xmm7
andnps %xmm5, %xmm7
andps %xmm3, %xmm6
orps %xmm7, %xmm6
movaps %xmm2, %xmm3
minss %xmm1, %xmm3
maxss %xmm2, %xmm1
movaps %xmm3, %xmm2
minss %xmm4, %xmm2
movaps %xmm1, %xmm5
subss %xmm2, %xmm5
subss %xmm4, %xmm3
movss 0x1b4e8(%rip), %xmm2    # 0x3d394
mulss %xmm5, %xmm2
movss 0x1b4e0(%rip), %xmm4    # 0x3d398
addss %xmm4, %xmm2
divss %xmm2, %xmm3
addss %xmm6, %xmm3
andps 0x1b405(%rip), %xmm3    # 0x3d2d0
movss %xmm3, -0x50(%rbp)
addss %xmm1, %xmm4
divss %xmm4, %xmm5
movss %xmm5, -0x4c(%rbp)
movss %xmm1, -0x48(%rbp)
movss 0x1b49e(%rip), %xmm3    # 0x3d388
movss -0x50(%rbp), %xmm1
mulss %xmm3, %xmm1
movss 0x1b4c1(%rip), %xmm2    # 0x3d3bc
addss %xmm2, %xmm1
cvttss2si %xmm1, %eax
movl %eax, -0x40(%rbp)
movss -0x4c(%rbp), %xmm1
mulss %xmm3, %xmm1
addss %xmm2, %xmm1
cvttss2si %xmm1, %eax
movl %eax, -0x3c(%rbp)
movss -0x48(%rbp), %xmm1
mulss %xmm3, %xmm1
addss %xmm2, %xmm1
cvttss2si %xmm1, %eax
movl %eax, -0x38(%rbp)
mulss %xmm3, %xmm0
addss %xmm2, %xmm0
cvttss2si %xmm0, %eax
movl %eax, -0x34(%rbp)
callq 0x1b900
movq %r14, -0xa0(%rbp)
movq %r14, %rdi
callq 0x173b3
xorl %r14d, %r14d
cmpl $0x2, %r15d
movl %ebx, -0x88(%rbp)
movq %r15, -0x70(%rbp)
jae 0x221bb
movq %r13, -0x90(%rbp)
movzbl %bl, %r15d
addl $0x3, %r15d
movq -0x68(%rbp), %rax
movss 0x1408(%rax), %xmm0
movss 0x141c(%rax), %xmm1
movss -0x60(%rbp), %xmm2
addss %xmm1, %xmm2
movaps -0x80(%rbp), %xmm6
subss %xmm2, %xmm6
addss %xmm0, %xmm0
movaps %xmm0, %xmm2
addss %xmm1, %xmm2
leal -0x1(%r15), %eax
xorps %xmm3, %xmm3
cvtsi2ss %eax, %xmm3
mulss %xmm3, %xmm2
movaps %xmm6, %xmm4
xorps %xmm5, %xmm5
cvtsi2ss %r15d, %xmm5
subss %xmm2, %xmm4
divss %xmm5, %xmm4
cvttps2dq %xmm4, %xmm2
cvtdq2ps %xmm2, %xmm2
movss 0x1b3a8(%rip), %xmm4    # 0x3d380
movss %xmm4, -0x58(%rbp)
maxss %xmm2, %xmm4
movss %xmm4, -0x60(%rbp)
addss %xmm4, %xmm0
addss %xmm1, %xmm0
mulss %xmm3, %xmm0
subss %xmm0, %xmm6
cvttps2dq %xmm6, %xmm0
cvtdq2ps %xmm0, %xmm0
movaps %xmm0, -0x80(%rbp)
movq 0x33488(%rip), %rax     # 0x55490
movq 0x1710(%rax), %r14
movss 0x1718(%rax), %xmm0
leaq 0x1c710(%rip), %rsi     # 0x3e72e
movss 0x1b39a(%rip), %xmm1    # 0x3d3c0
movss 0x1b35e(%rip), %xmm2    # 0x3d38c
movq %r14, %rdi
movss %xmm0, -0x84(%rbp)
xorl %edx, %edx
xorl %ecx, %ecx
callq 0x35d02
xorps %xmm1, %xmm1
ucomiss %xmm1, %xmm0
jbe 0x22062
movss -0x84(%rbp), %xmm2
divss (%r14), %xmm2
movaps %xmm0, %xmm1
subss %xmm2, %xmm1
movss %xmm1, %xmm0            # xmm0 = xmm1[0],xmm0[1,2,3]
movss -0x58(%rbp), %xmm1
maxss -0x80(%rbp), %xmm1
movss %xmm1, -0x58(%rbp)
xorl %eax, %eax
cmpl $0x1, -0x70(%rbp)
sete %al
shll $0x5, %eax
movss -0x60(%rbp), %xmm1
ucomiss %xmm1, %xmm0
leaq 0x30b44(%rip), %rcx     # 0x52bd0
leaq 0x20(%rax,%rcx), %rax
cmovaeq %rcx, %rax
movq %rax, -0x80(%rbp)
movaps %xmm1, %xmm0
callq 0x9d0e
movl %r15d, %r13d
leaq -0x1(%r13), %rax
movq %rax, -0x60(%rbp)
leaq 0x1b4d5(%rip), %r15     # 0x3d588
xorl %ebx, %ebx
xorl %r14d, %r14d
testq %rbx, %rbx
je 0x2211b
movq -0x68(%rbp), %rax
movss 0x141c(%rax), %xmm0
movq 0x333c0(%rip), %rcx     # 0x55490
movq 0x1758(%rcx), %rax
movb $0x1, 0x72(%rax)
cmpb $0x0, 0x74(%rax)
jne 0x2211b
xorps %xmm1, %xmm1
ucomiss %xmm0, %xmm1
jbe 0x220f1
movss 0x1414(%rcx), %xmm0
addss 0xb0(%rax), %xmm0
movl 0xb4(%rax), %ecx
movq 0xd0(%rax), %rdx
movq %rdx, 0xc8(%rax)
movss %xmm0, 0xa8(%rax)
movl %ecx, 0xac(%rax)
cmpq %rbx, -0x60(%rbp)
jne 0x2212b
movss -0x58(%rbp), %xmm0
callq 0x9d0e
leaq 0x1(%rbx), %r12
movslq (%r15), %rdi
leaq 0x1b44f(%rip), %rax     # 0x3d588
addq %rax, %rdi
movq -0x80(%rbp), %rax
movq (%rax,%rbx,8), %rdx
testq %rdx, %rdx
leaq 0x1edad(%rip), %rax     # 0x40efb
cmoveq %rax, %rdx
xorps %xmm0, %xmm0
cvtsi2ssl -0x40(%rbp,%rbx,4), %xmm0
movss %xmm0, -0xf0(%rbp)
xorps %xmm1, %xmm1
leaq -0xf0(%rbp), %rsi
movss 0x1b20b(%rip), %xmm0    # 0x3d380
movss 0x1b20b(%rip), %xmm2    # 0x3d388
movaps %xmm0, %xmm3
callq 0x1c4a4
cvttss2si -0xf0(%rbp), %ecx
movl %ecx, -0x40(%rbp,%rbx,4)
orb %al, %r14b
addq $0x4, %r15
movq %r12, %rbx
cmpq %r12, %r13
jne 0x220b8
callq 0x9e68
callq 0x9e68
movq -0x90(%rbp), %r13
movq -0x70(%rbp), %r15
jmp 0x221ef
jne 0x221ef
movaps -0x80(%rbp), %xmm0
subss -0x60(%rbp), %xmm0
movaps %xmm0, -0x80(%rbp)
movl -0x40(%rbp), %ecx
movl -0x3c(%rbp), %r8d
movl -0x38(%rbp), %r9d
testb %bl, %bl
je 0x224a2
movl -0x34(%rbp), %eax
movl %eax, (%rsp)
leaq 0x1c532(%rip), %rdx     # 0x3e71c
jmp 0x224a9
movq -0x68(%rbp), %rbx
movss 0x141c(%rbx), %xmm0
movq 0x3328e(%rip), %rcx     # 0x55490
movq 0x1758(%rcx), %rax
movb $0x1, 0x72(%rax)
cmpb $0x0, 0x74(%rax)
jne 0x2224d
xorps %xmm1, %xmm1
ucomiss %xmm0, %xmm1
jbe 0x22223
movss 0x1414(%rcx), %xmm0
addss 0xb0(%rax), %xmm0
movl 0xb4(%rax), %ecx
movq 0xd0(%rax), %rdx
movq %rdx, 0xc8(%rax)
movss %xmm0, 0xa8(%rax)
movl %ecx, 0xac(%rax)
movq (%r13), %rax
movss 0x8(%r13), %xmm0
leaq -0xf0(%rbp), %rdi
movq %rax, (%rdi)
movss %xmm0, 0x8(%rdi)
movl $0x3f800000, 0xc(%rdi)  # imm = 0x3F800000
xorl %esi, %esi
movl $0x1, %edx
callq 0x21ada
testb %al, %al
je 0x222ac
leaq 0x27a8(%rbx), %rdi
leal 0x1(%r15), %eax
movslq %eax, %rdx
imulq $0x55555556, %rdx, %rax # imm = 0x55555556
movq %rax, %rcx
shrq $0x3f, %rcx
shrq $0x20, %rax
addl %ecx, %eax
leal (%rax,%rax,2), %eax
subl %eax, %edx
movl -0x54(%rbp), %esi
callq 0x9642
movq -0x98(%rbp), %rax
cmpl $-0x1, 0x178(%rax)
movss 0x141c(%rbx), %xmm0
movq 0x331c7(%rip), %rcx     # 0x55490
movq 0x1758(%rcx), %rax
movb $0x1, 0x72(%rax)
movb 0x74(%rax), %dl
je 0x222f2
testb %dl, %dl
jne 0x223d9
xorps %xmm1, %xmm1
ucomiss %xmm0, %xmm1
ja 0x223a7
jmp 0x223af
testb %dl, %dl
jne 0x22330
xorps %xmm1, %xmm1
ucomiss %xmm0, %xmm1
jbe 0x22306
movss 0x1414(%rcx), %xmm0
addss 0xb0(%rax), %xmm0
movl 0xb4(%rax), %ecx
movq 0xd0(%rax), %rdx
movq %rdx, 0xc8(%rax)
movss %xmm0, 0xa8(%rax)
movl %ecx, 0xac(%rax)
movslq %r15d, %rax
leaq 0x1b25e(%rip), %rcx     # 0x3d598
movslq (%rcx,%rax,4), %rdi
addq %rcx, %rdi
leaq -0xa8(%rbp), %rsi
movq $0x0, (%rsi)
movl $0x10, %edx
callq 0x166bc
testb %al, %al
je 0x2238f
addq $0x27a8, %rbx           # imm = 0x27A8
leal 0x1(%r15), %eax
movslq %eax, %rdx
imulq $0x55555556, %rdx, %rax # imm = 0x55555556
movq %rax, %rcx
shrq $0x3f, %rcx
shrq $0x20, %rax
addl %ecx, %eax
leal (%rax,%rax,2), %eax
subl %eax, %edx
movq %rbx, %rdi
movl -0x54(%rbp), %esi
callq 0x9642
movq 0x330fa(%rip), %rcx     # 0x55490
movq 0x1758(%rcx), %rax
movb $0x1, 0x72(%rax)
cmpb $0x0, 0x74(%rax)
jne 0x223d9
movss 0x1414(%rcx), %xmm0
addss 0xb0(%rax), %xmm0
movl 0xb4(%rax), %ecx
movq 0xd0(%rax), %rdx
movq %rdx, 0xc8(%rax)
movss %xmm0, 0xa8(%rax)
movl %ecx, 0xac(%rax)
leaq -0x48(%rbp), %r12
xorl %ebx, %ebx
movq -0xa0(%rbp), %r15
movq %r15, %rdi
xorl %esi, %esi
callq 0xe1e7
movq %r15, %rdi
movq %rax, %rsi
callq 0xd93a
movss 0x1af85(%rip), %xmm1    # 0x3d388
xorps %xmm0, %xmm0
cvtsi2ssl -0x40(%rbp,%rbx,4), %xmm0
divss %xmm1, %xmm0
movss %xmm0, -0x50(%rbp,%rbx,4)
incq %rbx
cmpq $0x4, %rbx
jne 0x22403
cmpl $0x1, -0x70(%rbp)
jne 0x22443
leaq -0x50(%rbp), %rdi
movss (%rdi), %xmm0
movss 0x4(%rdi), %xmm1
movss 0x8(%rdi), %xmm2
leaq -0x4c(%rbp), %rsi
movq %r12, %rdx
callq 0x8e02
testb $0x1, %r14b
movl -0x88(%rbp), %eax
je 0x2247f
movss -0x50(%rbp), %xmm0
movss %xmm0, (%r13)
movss -0x4c(%rbp), %xmm0
movss %xmm0, 0x4(%r13)
movss -0x48(%rbp), %xmm0
movss %xmm0, 0x8(%r13)
testb %al, %al
je 0x2247f
movss -0x44(%rbp), %xmm0
movss %xmm0, 0xc(%r13)
callq 0x16fc0
callq 0x1bd59
andb $0x1, %r14b
movl %r14d, %eax
addq $0xd8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
leaq 0x1c2d3(%rip), %rdx     # 0x3e77c
leaq -0xf0(%rbp), %rdi
movl $0x40, %esi
xorl %eax, %eax
callq 0x86d8
leaq -0x38(%rbp), %r12
movq -0x68(%rbp), %rax
movaps -0x80(%rbp), %xmm0
subss 0x141c(%rax), %xmm0
callq 0x9d0e
xorl %eax, %eax
leaq -0xa8(%rbp), %rcx
movq %rax, (%rcx)
movq %rax, (%rsp)
leaq 0x1c29e(%rip), %rdi     # 0x3e78a
leaq -0xf0(%rbp), %r15
movq %r15, %rsi
movl $0x40, %edx
movl $0x6, %r8d
xorl %r9d, %r9d
callq 0x18689
movl %eax, %r14d
callq 0x9e68
movabsq $0x900000200, %rax      # imm = 0x900000200
movzbl (%r15), %ecx
cmpq $0x23, %rcx
ja 0x22530
btq %rcx, %rax
jae 0x22530
incq %r15
jmp 0x2251b
xorps %xmm0, %xmm0
movaps %xmm0, -0x40(%rbp)
testb %bl, %bl
je 0x22560
leaq 0x1c1db(%rip), %rsi     # 0x3e71d
leaq -0x40(%rbp), %rdx
movq %r15, %rdi
leaq -0x3c(%rbp), %rcx
movq %r12, %r8
leaq -0x34(%rbp), %r9
xorl %eax, %eax
callq 0x70c0
jmp 0x221b5
leaq 0x1c216(%rip), %rsi     # 0x3e77d
leaq -0x40(%rbp), %rdx
movq %r15, %rdi
leaq -0x3c(%rbp), %rcx
movq %r12, %r8
xorl %eax, %eax
callq 0x70c0
jmp 0x221b5