// File: /workspace/github_cpp_makefile_star2_O3/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
movl %edx, -0x2c(%rbp)
movq 0x339b9(%rip), %r15     # 0x55480
movq 0x1758(%r15), %r13
movb $0x1, 0x72(%r13)
cmpb $0x0, 0x74(%r13)
je 0x21ae2
xorl %r14d, %r14d
jmp 0x222a5
movq %rsi, %rbx
movq %rdi, %r14
movq %r13, %rdi
movq %r14, %rsi
xorl %edx, %edx
callq 0xa766
movl %eax, %r12d
callq 0x14877
movaps %xmm0, -0x80(%rbp)
movss 0x140c(%r15), %xmm0
addss %xmm0, %xmm0
addss 0x1718(%r15), %xmm0
movss %xmm0, -0x48(%rbp)
movl 0x178(%r13), %edx
cmpl $-0x2, %edx
jb 0x21b55
leaq 0x27a8(%r15), %rdi
movl %r12d, %esi
xorl %edx, %edx
callq 0x906c
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 %rdx, -0x68(%rbp)
movss (%rbx), %xmm3
movss %xmm3, -0x40(%rbp)
movss 0x4(%rbx), %xmm2
movss %xmm2, -0x3c(%rbp)
movss 0x8(%rbx), %xmm1
movss %xmm1, -0x38(%rbp)
movss 0xc(%rbx), %xmm0
movss %xmm0, -0x34(%rbp)
cmpl $0x1, %edx
movq %r15, -0x70(%rbp)
movq %rbx, -0xa0(%rbp)
movl %r12d, -0x88(%rbp)
movq %r13, -0x90(%rbp)
jne 0x21c3e
movaps %xmm2, %xmm4
cmpltss %xmm1, %xmm4
movss 0x1b7ea(%rip), %xmm5    # 0x3d39c
andps %xmm4, %xmm5
movaps %xmm2, %xmm6
minss %xmm1, %xmm6
maxss %xmm2, %xmm1
movss 0x1b7d8(%rip), %xmm2    # 0x3d3a0
subss %xmm5, %xmm2
movaps %xmm3, %xmm7
cmpltss %xmm1, %xmm7
movaps %xmm7, %xmm4
andnps %xmm5, %xmm4
andps %xmm2, %xmm7
orps %xmm4, %xmm7
movaps %xmm3, %xmm4
minss %xmm1, %xmm4
maxss %xmm3, %xmm1
movaps %xmm4, %xmm3
minss %xmm6, %xmm3
movaps %xmm1, %xmm2
subss %xmm3, %xmm2
subss %xmm6, %xmm4
movss 0x1b79f(%rip), %xmm3    # 0x3d3a4
mulss %xmm2, %xmm3
movss 0x1b797(%rip), %xmm5    # 0x3d3a8
addss %xmm5, %xmm3
divss %xmm3, %xmm4
addss %xmm7, %xmm4
andps 0x1b6bc(%rip), %xmm4    # 0x3d2e0
movss %xmm4, -0x40(%rbp)
addss %xmm1, %xmm5
divss %xmm5, %xmm2
movss %xmm2, -0x3c(%rbp)
movss %xmm1, -0x38(%rbp)
movaps %xmm4, %xmm3
movss 0x1b752(%rip), %xmm5    # 0x3d398
mulss %xmm5, %xmm3
movss 0x1b77a(%rip), %xmm4    # 0x3d3cc
addss %xmm4, %xmm3
cvttss2si %xmm3, %r15d
mulss %xmm5, %xmm2
addss %xmm4, %xmm2
cvttss2si %xmm2, %ebx
movl %r15d, -0x60(%rbp)
movl %ebx, -0x5c(%rbp)
mulss %xmm5, %xmm1
addss %xmm4, %xmm1
cvttss2si %xmm1, %r13d
movl %r13d, -0x58(%rbp)
mulss %xmm5, %xmm0
addss %xmm4, %xmm0
cvttss2si %xmm0, %r12d
movl %r12d, -0x54(%rbp)
callq 0x1b560
movq %r14, -0x98(%rbp)
movq %r14, %rdi
callq 0x16f0c
xorl %r14d, %r14d
cmpl $0x2, -0x68(%rbp)
jae 0x21eee
movzbl -0x2c(%rbp), %r14d
addl $0x3, %r14d
movq -0x70(%rbp), %rax
movss 0x1408(%rax), %xmm0
movss 0x141c(%rax), %xmm1
movss -0x48(%rbp), %xmm2
addss %xmm1, %xmm2
movaps -0x80(%rbp), %xmm6
subss %xmm2, %xmm6
addss %xmm0, %xmm0
movaps %xmm0, %xmm2
addss %xmm1, %xmm2
leal -0x1(%r14), %eax
xorps %xmm3, %xmm3
cvtsi2ss %eax, %xmm3
mulss %xmm3, %xmm2
movaps %xmm6, %xmm4
xorps %xmm5, %xmm5
cvtsi2ss %r14d, %xmm5
subss %xmm2, %xmm4
divss %xmm5, %xmm4
cvttps2dq %xmm4, %xmm2
cvtdq2ps %xmm2, %xmm2
movss 0x1b675(%rip), %xmm4    # 0x3d390
movss %xmm4, -0x30(%rbp)
maxss %xmm2, %xmm4
movss %xmm4, -0x48(%rbp)
addss %xmm4, %xmm0
addss %xmm1, %xmm0
mulss %xmm3, %xmm0
subss %xmm0, %xmm6
cvttps2dq %xmm6, %xmm0
cvtdq2ps %xmm0, %xmm0
movaps %xmm0, -0x80(%rbp)
movq 0x33735(%rip), %rax     # 0x55480
movq 0x1710(%rax), %rbx
movss 0x1718(%rax), %xmm0
leaq 0x1c9fd(%rip), %rsi     # 0x3e75e
movss 0x1b667(%rip), %xmm1    # 0x3d3d0
movss 0x1b62b(%rip), %xmm2    # 0x3d39c
movq %rbx, %rdi
movss %xmm0, -0x84(%rbp)
xorl %edx, %edx
xorl %ecx, %ecx
callq 0x35430
xorps %xmm1, %xmm1
ucomiss %xmm1, %xmm0
jbe 0x21d9d
movss -0x84(%rbp), %xmm1
divss (%rbx), %xmm1
subss %xmm1, %xmm0
movss -0x30(%rbp), %xmm1
maxss -0x80(%rbp), %xmm1
movss %xmm1, -0x30(%rbp)
xorl %eax, %eax
cmpl $0x1, -0x68(%rbp)
sete %al
shll $0x5, %eax
movss -0x48(%rbp), %xmm1
ucomiss %xmm1, %xmm0
leaq 0x30e09(%rip), %rcx     # 0x52bd0
leaq 0x20(%rax,%rcx), %rax
cmovaeq %rcx, %rax
movq %rax, -0x80(%rbp)
movaps %xmm1, %xmm0
callq 0x9c64
movl %r14d, %r13d
leaq -0x1(%r13), %rax
movq %rax, -0x48(%rbp)
leaq 0x1b78a(%rip), %r15     # 0x3d578
xorl %ebx, %ebx
xorl %r14d, %r14d
testq %rbx, %rbx
je 0x21e56
movq -0x70(%rbp), %rax
movss 0x141c(%rax), %xmm0
movq 0x33675(%rip), %rcx     # 0x55480
movq 0x1758(%rcx), %rax
movb $0x1, 0x72(%rax)
cmpb $0x0, 0x74(%rax)
jne 0x21e56
xorps %xmm1, %xmm1
ucomiss %xmm0, %xmm1
jbe 0x21e2c
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, -0x48(%rbp)
jne 0x21e66
movss -0x30(%rbp), %xmm0
callq 0x9c64
leaq 0x1(%rbx), %r12
movslq (%r15), %rdi
leaq 0x1b704(%rip), %rax     # 0x3d578
addq %rax, %rdi
movq -0x80(%rbp), %rax
movq (%rax,%rbx,8), %rdx
testq %rdx, %rdx
leaq 0x1eff2(%rip), %rax     # 0x40e7b
cmoveq %rax, %rdx
xorps %xmm0, %xmm0
cvtsi2ssl -0x60(%rbp,%rbx,4), %xmm0
movss %xmm0, -0xf0(%rbp)
xorps %xmm1, %xmm1
leaq -0xf0(%rbp), %rsi
movss 0x1b4e0(%rip), %xmm0    # 0x3d390
movss 0x1b4e0(%rip), %xmm2    # 0x3d398
movaps %xmm0, %xmm3
callq 0x1c08e
cvttss2si -0xf0(%rbp), %ecx
movl %ecx, -0x60(%rbp,%rbx,4)
orb %al, %r14b
addq $0x4, %r15
movq %r12, %rbx
cmpq %r12, %r13
jne 0x21df3
callq 0x9db1
callq 0x9db1
jmp 0x21ffa
jne 0x21ffa
movaps -0x80(%rbp), %xmm0
subss -0x48(%rbp), %xmm0
movaps %xmm0, -0x80(%rbp)
cmpb $0x0, -0x2c(%rbp)
je 0x21f14
movl %r12d, (%rsp)
leaq 0x1c83a(%rip), %rdx     # 0x3e74c
jmp 0x21f1b
leaq 0x1c891(%rip), %rdx     # 0x3e7ac
leaq -0xf0(%rbp), %rdi
movl $0x40, %esi
movl %r15d, %ecx
movl %ebx, %r8d
movl %r13d, %r9d
xorl %eax, %eax
callq 0x8678
leaq -0x5c(%rbp), %r15
leaq -0x58(%rbp), %r12
leaq -0x54(%rbp), %r13
movq -0x70(%rbp), %rax
movaps -0x80(%rbp), %xmm0
subss 0x141c(%rax), %xmm0
callq 0x9c64
xorl %eax, %eax
leaq -0xa8(%rbp), %rcx
movq %rax, (%rcx)
movq %rax, (%rsp)
leaq 0x1c84b(%rip), %rdi     # 0x3e7ba
leaq -0xf0(%rbp), %rbx
movq %rbx, %rsi
movl $0x40, %edx
movl $0x6, %r8d
xorl %r9d, %r9d
callq 0x18159
movl %eax, %r14d
callq 0x9db1
movabsq $0x900000200, %rax      # imm = 0x900000200
movzbl (%rbx), %ecx
cmpq $0x23, %rcx
ja 0x21fb2
btq %rcx, %rax
jae 0x21fb2
incq %rbx
jmp 0x21f9e
xorps %xmm0, %xmm0
movaps %xmm0, -0x60(%rbp)
cmpb $0x0, -0x2c(%rbp)
je 0x21fdf
leaq 0x1c787(%rip), %rsi     # 0x3e74d
leaq -0x60(%rbp), %rdx
movq %rbx, %rdi
movq %r15, %rcx
movq %r12, %r8
movq %r13, %r9
xorl %eax, %eax
callq 0x70c0
jmp 0x21ffa
leaq 0x1c7c7(%rip), %rsi     # 0x3e7ad
leaq -0x60(%rbp), %rdx
movq %rbx, %rdi
movq %r15, %rcx
movq %r12, %r8
xorl %eax, %eax
callq 0x70c0
movq -0x70(%rbp), %r15
movss 0x141c(%r15), %xmm0
movq 0x33472(%rip), %rcx     # 0x55480
movq 0x1758(%rcx), %rax
movb $0x1, 0x72(%rax)
cmpb $0x0, 0x74(%rax)
movq -0xa0(%rbp), %r13
movq -0x68(%rbp), %rbx
movl -0x88(%rbp), %r12d
jne 0x2206b
xorps %xmm1, %xmm1
ucomiss %xmm0, %xmm1
jbe 0x22041
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 0x21844
testb %al, %al
je 0x220c9
leaq 0x27a8(%r15), %rdi
leal 0x1(%rbx), %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 %r12d, %esi
callq 0x95c6
movq -0x90(%rbp), %rax
cmpl $-0x1, 0x178(%rax)
movss 0x141c(%r15), %xmm0
movq 0x33399(%rip), %rcx     # 0x55480
movq 0x1758(%rcx), %rax
movb $0x1, 0x72(%rax)
movb 0x74(%rax), %dl
je 0x22110
testb %dl, %dl
jne 0x221f6
xorps %xmm1, %xmm1
ucomiss %xmm0, %xmm1
ja 0x221c4
jmp 0x221cc
testb %dl, %dl
jne 0x2214e
xorps %xmm1, %xmm1
ucomiss %xmm0, %xmm1
jbe 0x22124
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 %ebx, %rax
leaq 0x1b430(%rip), %rcx     # 0x3d588
movslq (%rcx,%rax,4), %rdi
addq %rcx, %rdi
leaq -0xa8(%rbp), %rsi
movq $0x0, (%rsi)
movl $0x10, %edx
callq 0x1621f
testb %al, %al
je 0x221ac
addq $0x27a8, %r15           # imm = 0x27A8
leal 0x1(%rbx), %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 %r15, %rdi
movl %r12d, %esi
callq 0x95c6
movq 0x332cd(%rip), %rcx     # 0x55480
movq 0x1758(%rcx), %rax
movb $0x1, 0x72(%rax)
cmpb $0x0, 0x74(%rax)
jne 0x221f6
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 -0x38(%rbp), %r15
xorl %r12d, %r12d
movq -0x98(%rbp), %rbx
movq %rbx, %rdi
xorl %esi, %esi
callq 0xdfc4
movq %rbx, %rdi
movq %rax, %rsi
callq 0xd741
movss 0x1b177(%rip), %xmm1    # 0x3d398
xorps %xmm0, %xmm0
cvtsi2ssl -0x60(%rbp,%r12,4), %xmm0
divss %xmm1, %xmm0
movss %xmm0, -0x40(%rbp,%r12,4)
incq %r12
cmpq $0x4, %r12
jne 0x22221
cmpl $0x1, -0x68(%rbp)
jne 0x22263
leaq -0x40(%rbp), %rdi
movss (%rdi), %xmm0
movss 0x4(%rdi), %xmm1
movss 0x8(%rdi), %xmm2
leaq -0x3c(%rbp), %rsi
movq %r15, %rdx
callq 0x8db6
testb $0x1, %r14b
je 0x2229b
movss -0x40(%rbp), %xmm0
movss %xmm0, (%r13)
movss -0x3c(%rbp), %xmm0
movss %xmm0, 0x4(%r13)
movss -0x38(%rbp), %xmm0
movss %xmm0, 0x8(%r13)
cmpb $0x0, -0x2c(%rbp)
je 0x2229b
movss -0x34(%rbp), %xmm0
movss %xmm0, 0xc(%r13)
callq 0x16b19
callq 0x1b97c
andb $0x1, %r14b
movl %r14d, %eax
addq $0xd8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq