// File: /workspace/github_cpp_makefile_star2_O2/Ciaxur[P]yagb-emu/include/imgui/imgui_widgets.cpp
// Function: ImGui::ColorButton(char const*, ImVec4 const&, int, ImVec2)
bool ImGui::ColorButton(const char* desc_id, const ImVec4& col, ImGuiColorEditFlags flags, ImVec2 size)
{
    ImGuiWindow* window = GetCurrentWindow();
    if (window->SkipItems)
        return false;

    ImGuiContext& g = *GImGui;
    const ImGuiID id = window->GetID(desc_id);
    float default_size = GetFrameHeight();
    if (size.x == 0.0f)
        size.x = default_size;
    if (size.y == 0.0f)
        size.y = default_size;
    const ImRect bb(window->DC.CursorPos, window->DC.CursorPos + size);
    ItemSize(bb, (size.y >= default_size) ? g.Style.FramePadding.y : 0.0f);
    if (!ItemAdd(bb, id))
        return false;

    bool hovered, held;
    bool pressed = ButtonBehavior(bb, id, &hovered, &held);

    if (flags & ImGuiColorEditFlags_NoAlpha)
        flags &= ~(ImGuiColorEditFlags_AlphaPreview | ImGuiColorEditFlags_AlphaPreviewHalf);

    ImVec4 col_rgb = col;
    if (flags & ImGuiColorEditFlags_InputHSV)
        ColorConvertHSVtoRGB(col_rgb.x, col_rgb.y, col_rgb.z, col_rgb.x, col_rgb.y, col_rgb.z);

    ImVec4 col_rgb_without_alpha(col_rgb.x, col_rgb.y, col_rgb.z, 1.0f);
    float grid_step = ImMin(size.x, size.y) / 2.99f;
    float rounding = ImMin(g.Style.FrameRounding, grid_step * 0.5f);
    ImRect bb_inner = bb;
    float off = 0.0f;
    if ((flags & ImGuiColorEditFlags_NoBorder) == 0)
    {
        off = -0.75f; // The border (using Col_FrameBg) tends to look off when color is near-opaque and rounding is enabled. This offset seemed like a good middle ground to reduce those artifacts.
        bb_inner.Expand(off);
    }
    if ((flags & ImGuiColorEditFlags_AlphaPreviewHalf) && col_rgb.w < 1.0f)
    {
        float mid_x = IM_ROUND((bb_inner.Min.x + bb_inner.Max.x) * 0.5f);
        RenderColorRectWithAlphaCheckerboard(window->DrawList, ImVec2(bb_inner.Min.x + grid_step, bb_inner.Min.y), bb_inner.Max, GetColorU32(col_rgb), grid_step, ImVec2(-grid_step + off, off), rounding, ImDrawCornerFlags_TopRight | ImDrawCornerFlags_BotRight);
        window->DrawList->AddRectFilled(bb_inner.Min, ImVec2(mid_x, bb_inner.Max.y), GetColorU32(col_rgb_without_alpha), rounding, ImDrawCornerFlags_TopLeft | ImDrawCornerFlags_BotLeft);
    }
    else
    {
        // Because GetColorU32() multiplies by the global style Alpha and we don't want to display a checkerboard if the source code had no alpha
        ImVec4 col_source = (flags & ImGuiColorEditFlags_AlphaPreview) ? col_rgb : col_rgb_without_alpha;
        if (col_source.w < 1.0f)
            RenderColorRectWithAlphaCheckerboard(window->DrawList, bb_inner.Min, bb_inner.Max, GetColorU32(col_source), grid_step, ImVec2(off, off), rounding);
        else
            window->DrawList->AddRectFilled(bb_inner.Min, bb_inner.Max, GetColorU32(col_source), rounding, ImDrawCornerFlags_All);
    }
    RenderNavHighlight(bb, id);
    if ((flags & ImGuiColorEditFlags_NoBorder) == 0)
    {
        if (g.Style.FrameBorderSize > 0.0f)
            RenderFrameBorder(bb.Min, bb.Max, rounding);
        else
            window->DrawList->AddRect(bb.Min, bb.Max, GetColorU32(ImGuiCol_FrameBg), rounding); // Color button are often in need of some sort of border
    }

    // Drag and Drop Source
    // NB: The ActiveId test is merely an optional micro-optimization, BeginDragDropSource() does the same test.
    if (g.ActiveId == id && !(flags & ImGuiColorEditFlags_NoDragDrop) && BeginDragDropSource())
    {
        if (flags & ImGuiColorEditFlags_NoAlpha)
            SetDragDropPayload(IMGUI_PAYLOAD_TYPE_COLOR_3F, &col_rgb, sizeof(float) * 3, ImGuiCond_Once);
        else
            SetDragDropPayload(IMGUI_PAYLOAD_TYPE_COLOR_4F, &col_rgb, sizeof(float) * 4, ImGuiCond_Once);
        ColorButton(desc_id, col, flags);
        SameLine();
        TextEx("Color");
        EndDragDropSource();
    }

    // Tooltip
    if (!(flags & ImGuiColorEditFlags_NoTooltip) && hovered)
        ColorTooltip(desc_id, &col.x, flags & (ImGuiColorEditFlags__InputMask | ImGuiColorEditFlags_NoAlpha | ImGuiColorEditFlags_AlphaPreview | ImGuiColorEditFlags_AlphaPreviewHalf));

    return pressed;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0xe8, %rsp
leaq 0x5dc5f(%rip), %rax     # 0xe3ce0
movq (%rax), %r15
movq 0x1ae0(%r15), %rbx
movb $0x1, 0x90(%rbx)
cmpb $0x0, 0x93(%rbx)
je 0x860a2
xorl %eax, %eax
jmp 0x86591
movl %edx, %r13d
movq %rsi, %r12
movq %rdi, %rcx
movq %rbx, %rdi
movq %rcx, -0x98(%rbp)
movq %rcx, %rsi
xorl %edx, %edx
movaps %xmm0, -0x90(%rbp)
callq 0x3700a
movl %eax, %r14d
callq 0x43ec9
movaps -0x90(%rbp), %xmm3
movaps %xmm0, %xmm1
xorps %xmm0, %xmm0
ucomiss %xmm0, %xmm3
jne 0x860e6
jp 0x860e6
movss %xmm1, %xmm3            # xmm3 = xmm1[0],xmm3[1,2,3]
movaps %xmm3, %xmm2
shufps $0x55, %xmm3, %xmm2     # xmm2 = xmm2[1,1],xmm3[1,1]
ucomiss %xmm0, %xmm2
jne 0x86101
jp 0x86101
movaps %xmm1, %xmm2
movlhps %xmm3, %xmm2            # xmm2 = xmm2[0],xmm3[0]
shufps $0xe2, %xmm3, %xmm2     # xmm2 = xmm2[2,0],xmm3[2,3]
movaps %xmm2, %xmm3
movl %r14d, -0x30(%rbp)
movss 0xd8(%rbx), %xmm2
addss %xmm3, %xmm2
movaps %xmm3, -0x90(%rbp)
movaps %xmm3, %xmm4
shufps $0x55, %xmm3, %xmm4     # xmm4 = xmm4[1,1],xmm3[1,1]
movss 0xdc(%rbx), %xmm3
addss %xmm4, %xmm3
unpcklps %xmm3, %xmm2            # xmm2 = xmm2[0],xmm3[0],xmm2[1],xmm3[1]
movq 0xd8(%rbx), %rax
movq %rax, -0x70(%rbp)
movlps %xmm2, -0x68(%rbp)
movaps %xmm4, -0x80(%rbp)
ucomiss %xmm1, %xmm4
jb 0x8614f
movss 0x159c(%r15), %xmm0
leaq -0x70(%rbp), %r14
movq %r14, %rdi
callq 0x4388d
movq $0x0, -0xa0(%rbp)
movq %r14, %rdi
movl -0x30(%rbp), %r14d
movl %r14d, %esi
xorl %edx, %edx
callq 0x40ea5
testb %al, %al
je 0x8658a
leaq -0x70(%rbp), %rdi
leaq -0x29(%rbp), %rdx
leaq -0x31(%rbp), %rcx
movl %r14d, %esi
xorl %r8d, %r8d
callq 0x79dde
movl %r13d, %r14d
andl $0xfff9ffff, %r14d      # imm = 0xFFF9FFFF
testb $0x2, %r13b
cmovel %r13d, %r14d
movq %rax, -0xa0(%rbp)
movups (%r12), %xmm0
movaps %xmm0, -0x60(%rbp)
btl $0x1c, %r14d
jae 0x861dd
leaq -0x5c(%rbp), %rsi
movss -0x4(%rsi), %xmm0
movss (%rsi), %xmm1
leaq -0x58(%rbp), %rdx
movss (%rdx), %xmm2
leaq -0x60(%rbp), %rdi
callq 0x34e2e
movq -0x60(%rbp), %rax
movss -0x58(%rbp), %xmm0
movq %rax, -0xc0(%rbp)
movss %xmm0, -0xb8(%rbp)
movaps -0x90(%rbp), %xmm3
minss -0x80(%rbp), %xmm3
divss 0x31eff(%rip), %xmm3    # 0xb8108
movl $0x3f800000, -0xb4(%rbp) # imm = 0x3F800000
movss 0x15a0(%r15), %xmm4
movss 0x15df4(%rip), %xmm0    # 0x9c018
mulss %xmm3, %xmm0
movups -0x70(%rbp), %xmm1
movaps %xmm1, -0x50(%rbp)
xorps %xmm2, %xmm2
btl $0xa, %r14d
jb 0x8627e
movss 0x16692(%rip), %xmm1    # 0x9c8d4
movss -0x50(%rbp), %xmm2
addss %xmm1, %xmm2
movss %xmm2, -0x50(%rbp)
addss -0x4c(%rbp), %xmm1
movss %xmm1, -0x4c(%rbp)
movss 0x27a3a(%rip), %xmm2    # 0xadc9c
movss -0x48(%rbp), %xmm1
addss %xmm2, %xmm1
movss %xmm1, -0x48(%rbp)
movss -0x44(%rbp), %xmm1
addss %xmm2, %xmm1
movss %xmm1, -0x44(%rbp)
minss %xmm0, %xmm4
btl $0x12, %r14d
movss %xmm4, -0x80(%rbp)
jae 0x8639f
movss 0x15d5e(%rip), %xmm0    # 0x9bff8
ucomiss -0x54(%rbp), %xmm0
jbe 0x8639f
leaq -0x50(%rbp), %rax
movss (%rax), %xmm5
movss 0x8(%rax), %xmm0
addss %xmm5, %xmm0
movss 0x15d5b(%rip), %xmm1    # 0x9c018
mulss %xmm1, %xmm0
addss %xmm1, %xmm0
cvttps2dq %xmm0, %xmm0
cvtdq2ps %xmm0, %xmm0
movaps %xmm0, -0xd0(%rbp)
movq %r12, -0xe0(%rbp)
movq 0x2b8(%rbx), %r12
addss %xmm3, %xmm5
movsd 0x8(%rax), %xmm0
movaps %xmm0, -0x110(%rbp)
movss 0x4(%rax), %xmm0
movq %rax, %r13
unpcklps %xmm0, %xmm5            # xmm5 = xmm5[0],xmm0[0],xmm5[1],xmm0[1]
movaps %xmm5, -0x100(%rbp)
leaq -0x60(%rbp), %rdi
movaps %xmm3, -0x90(%rbp)
movaps %xmm2, -0xf0(%rbp)
callq 0x35d75
movaps -0xf0(%rbp), %xmm0
movaps %xmm0, %xmm3
movaps -0x90(%rbp), %xmm2
subss %xmm2, %xmm3
unpcklps %xmm0, %xmm3            # xmm3 = xmm3[0],xmm0[0],xmm3[1],xmm0[1]
pushq $0xa
popq %rdx
movq %r12, %rdi
movaps -0x100(%rbp), %xmm0
movaps -0x110(%rbp), %xmm1
movl %eax, %esi
movss -0x80(%rbp), %xmm4
callq 0x6c6fc
movq 0x2b8(%rbx), %r12
movss 0xc(%r13), %xmm0
leaq -0xb0(%rbp), %r13
movaps -0xd0(%rbp), %xmm1
movss %xmm1, (%r13)
movss %xmm0, 0x4(%r13)
leaq -0xc0(%rbp), %rdi
callq 0x35d75
pushq $0x5
popq %r8
movq %r12, %rdi
movq -0xe0(%rbp), %r12
leaq -0x50(%rbp), %rsi
movq %r13, %rdx
jmp 0x86456
btl $0x11, %r14d
leaq -0xc0(%rbp), %rax
leaq -0x60(%rbp), %rcx
cmovaeq %rax, %rcx
movups (%rcx), %xmm0
movaps %xmm0, -0xb0(%rbp)
movss 0x15c33(%rip), %xmm0    # 0x9bff8
ucomiss -0xa4(%rbp), %xmm0
movq 0x2b8(%rbx), %r13
jbe 0x8643b
movsd -0x50(%rbp), %xmm0
movaps %xmm0, -0xe0(%rbp)
movsd -0x48(%rbp), %xmm0
movaps %xmm0, -0xd0(%rbp)
leaq -0xb0(%rbp), %rdi
movaps %xmm3, -0x90(%rbp)
movaps %xmm2, -0xf0(%rbp)
callq 0x35d75
movaps -0xf0(%rbp), %xmm3
shufps $0x0, %xmm3, %xmm3      # xmm3 = xmm3[0,0,0,0]
pushq $-0x1
popq %rdx
movq %r13, %rdi
movaps -0xe0(%rbp), %xmm0
movaps -0xd0(%rbp), %xmm1
movl %eax, %esi
movaps -0x90(%rbp), %xmm2
movss -0x80(%rbp), %xmm4
callq 0x6c6fc
jmp 0x86462
leaq -0xb0(%rbp), %rdi
callq 0x35d75
leaq -0x50(%rbp), %rsi
pushq $0xf
popq %r8
movq %r13, %rdi
leaq -0x48(%rbp), %rdx
movl %eax, %ecx
movss -0x80(%rbp), %xmm0
callq 0x64020
leaq -0x70(%rbp), %rdi
pushq $0x1
popq %rdx
movl -0x30(%rbp), %esi
callq 0x36c91
btl $0xa, %r14d
jb 0x864e2
movss 0x15a4(%r15), %xmm0
xorps %xmm1, %xmm1
ucomiss %xmm1, %xmm0
jbe 0x8649f
movsd -0x70(%rbp), %xmm0
movsd -0x68(%rbp), %xmm1
movss -0x80(%rbp), %xmm2
callq 0x36b98
jmp 0x864e2
movq %r12, %r13
leaq -0x68(%rbp), %r12
movq 0x2b8(%rbx), %rbx
pushq $0x7
popq %rdi
movss 0x15b40(%rip), %xmm0    # 0x9bff8
callq 0x35d33
leaq -0x70(%rbp), %rsi
pushq $0xf
popq %r8
movq %rbx, %rdi
movq %r12, %rdx
movq %r13, %r12
movl %eax, %ecx
movss -0x80(%rbp), %xmm0
movss 0x15b1b(%rip), %xmm1    # 0x9bff8
callq 0x63f6c
btl $0x9, %r14d
jb 0x86565
movl -0x30(%rbp), %eax
cmpl %eax, 0x1b30(%r15)
jne 0x86565
xorl %edi, %edi
callq 0x45995
testb %al, %al
je 0x86565
testb $0x2, %r14b
jne 0x86515
leaq 0x1fbd5(%rip), %rdi     # 0xa60e2
leaq -0x60(%rbp), %rsi
pushq $0x10
jmp 0x86522
leaq 0x1fbbf(%rip), %rdi     # 0xa60db
leaq -0x60(%rbp), %rsi
pushq $0xc
popq %rdx
pushq $0x2
popq %rcx
callq 0x45c77
xorps %xmm0, %xmm0
movq -0x98(%rbp), %rdi
movq %r12, %rsi
movl %r14d, %edx
callq 0x86066
movss 0x15aa8(%rip), %xmm1    # 0x9bff0
xorps %xmm0, %xmm0
callq 0x437ec
leaq 0x1fc11(%rip), %rdi     # 0xa6168
xorl %esi, %esi
xorl %edx, %edx
callq 0x7911c
callq 0x45bf0
testb $0x40, %r14b
jne 0x8658a
cmpb $0x1, -0x29(%rbp)
jne 0x8658a
andl $0x18060002, %r14d      # imm = 0x18060002
movq -0x98(%rbp), %rdi
movq %r12, %rsi
movl %r14d, %edx
callq 0x884c9
movq -0xa0(%rbp), %rax
addq $0xe8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq