// File: /workspace/github_cpp_makefile_star2_O3/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 0x5df45(%rip), %rax     # 0xfbcd0
movq (%rax), %r15
movq 0x1ae0(%r15), %rbx
movb $0x1, 0x90(%rbx)
cmpb $0x0, 0x93(%rbx)
je 0x9ddac
xorl %eax, %eax
jmp 0x9e2bb
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 0x4570a
movl %eax, %r14d
callq 0x562ff
movaps -0x90(%rbp), %xmm3
movaps %xmm0, %xmm1
xorps %xmm0, %xmm0
ucomiss %xmm0, %xmm3
jne 0x9ddf0
jp 0x9ddf0
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 0x9de0b
jp 0x9de0b
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)
movaps %xmm3, %xmm4
shufps $0x55, %xmm3, %xmm4     # xmm4 = xmm4[1,1],xmm3[1,1]
movss 0xd8(%rbx), %xmm2
movaps %xmm3, -0x90(%rbp)
addss %xmm3, %xmm2
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 0x9de59
movss 0x159c(%r15), %xmm0
leaq -0x70(%rbp), %r14
movq %r14, %rdi
callq 0x559be
movq $0x0, -0xa0(%rbp)
movq %r14, %rdi
movl -0x30(%rbp), %r14d
movl %r14d, %esi
xorl %edx, %edx
callq 0x524a8
testb %al, %al
je 0x9e2b4
leaq -0x70(%rbp), %rdi
leaq -0x29(%rbp), %rdx
leaq -0x31(%rbp), %rcx
movl %r14d, %esi
xorl %r8d, %r8d
callq 0x90b6f
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 0x9dee7
leaq -0x5c(%rbp), %rsi
movss -0x4(%rsi), %xmm0
movss (%rsi), %xmm1
leaq -0x58(%rbp), %rdx
movss (%rdx), %xmm2
leaq -0x60(%rbp), %rdi
callq 0x42749
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 0x32e8d(%rip), %xmm3    # 0xd0da0
movl $0x3f800000, -0xb4(%rbp) # imm = 0x3F800000
movss 0x15a0(%r15), %xmm4
movss 0x170d6(%rip), %xmm0    # 0xb5004
mulss %xmm3, %xmm0
movups -0x70(%rbp), %xmm1
movaps %xmm1, -0x50(%rbp)
xorps %xmm2, %xmm2
btl $0xa, %r14d
jb 0x9df88
movss 0x17958(%rip), %xmm1    # 0xb58a4
movss -0x50(%rbp), %xmm2
addss %xmm1, %xmm2
movss %xmm2, -0x50(%rbp)
addss -0x4c(%rbp), %xmm1
movss %xmm1, -0x4c(%rbp)
movss 0x28a00(%rip), %xmm2    # 0xc696c
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 0x9e0b4
movss 0x17040(%rip), %xmm0    # 0xb4fe4
ucomiss -0x54(%rbp), %xmm0
jbe 0x9e0b4
leaq -0x50(%rbp), %rax
movss (%rax), %xmm5
movss 0x8(%rax), %xmm0
addss %xmm5, %xmm0
movss 0x1703d(%rip), %xmm1    # 0xb5004
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 0x43c0c
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]
movq %r12, %rdi
movaps -0x100(%rbp), %xmm0
movaps -0x110(%rbp), %xmm1
movl %eax, %esi
movss -0x80(%rbp), %xmm4
movl $0xa, %edx
callq 0x830fd
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 0x43c0c
movq %r12, %rdi
movq -0xe0(%rbp), %r12
leaq -0x50(%rbp), %rsi
movq %r13, %rdx
movl %eax, %ecx
movss -0x80(%rbp), %xmm0
movl $0x5, %r8d
jmp 0x9e176
btl $0x11, %r14d
leaq -0xc0(%rbp), %rax
leaq -0x60(%rbp), %rcx
cmovaeq %rax, %rcx
movups (%rcx), %xmm0
movaps %xmm0, -0xb0(%rbp)
movss 0x16f0a(%rip), %xmm0    # 0xb4fe4
ucomiss -0xa4(%rbp), %xmm0
movq 0x2b8(%rbx), %r13
jbe 0x9e152
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 0x43c0c
movaps -0xf0(%rbp), %xmm3
shufps $0x0, %xmm3, %xmm3      # xmm3 = xmm3[0,0,0,0]
movq %r13, %rdi
movaps -0xe0(%rbp), %xmm0
movaps -0xd0(%rbp), %xmm1
movl %eax, %esi
movaps -0x90(%rbp), %xmm2
movss -0x80(%rbp), %xmm4
movl $0xffffffff, %edx       # imm = 0xFFFFFFFF
callq 0x830fd
jmp 0x9e17b
leaq -0xb0(%rbp), %rdi
callq 0x43c0c
leaq -0x50(%rbp), %rsi
movq %r13, %rdi
leaq -0x48(%rbp), %rdx
movl %eax, %ecx
movss -0x80(%rbp), %xmm0
movl $0xf, %r8d
callq 0x785e6
leaq -0x70(%rbp), %rdi
movl -0x30(%rbp), %esi
movl $0x1, %edx
callq 0x4521b
btl $0xa, %r14d
jb 0x9e201
movss 0x15a4(%r15), %xmm0
xorps %xmm1, %xmm1
ucomiss %xmm1, %xmm0
jbe 0x9e1ba
movsd -0x70(%rbp), %xmm0
movsd -0x68(%rbp), %xmm1
movss -0x80(%rbp), %xmm2
callq 0x450e0
jmp 0x9e201
movq %r12, %r13
leaq -0x68(%rbp), %r12
movq 0x2b8(%rbx), %rbx
movss 0x16e14(%rip), %xmm0    # 0xb4fe4
movl $0x7, %edi
callq 0x43bca
leaq -0x70(%rbp), %rsi
movq %rbx, %rdi
movq %r12, %rdx
movq %r13, %r12
movl %eax, %ecx
movss -0x80(%rbp), %xmm0
movl $0xf, %r8d
movss 0x16de8(%rip), %xmm1    # 0xb4fe4
callq 0x7851c
btl $0x9, %r14d
jb 0x9e28f
movl -0x30(%rbp), %eax
cmpl %eax, 0x1b30(%r15)
jne 0x9e28f
xorl %edi, %edi
callq 0x58189
testb %al, %al
je 0x9e28f
testb $0x2, %r14b
jne 0x9e23b
leaq 0x20b82(%rip), %rdi     # 0xbedb2
leaq -0x60(%rbp), %rsi
movl $0x10, %edx
jmp 0x9e24b
leaq 0x20b69(%rip), %rdi     # 0xbedab
leaq -0x60(%rbp), %rsi
movl $0xc, %edx
movl $0x2, %ecx
callq 0x584b0
xorps %xmm0, %xmm0
movq -0x98(%rbp), %rdi
movq %r12, %rsi
movl %r14d, %edx
callq 0x9dd70
movss 0x16d5e(%rip), %xmm1    # 0xb4fd0
xorps %xmm0, %xmm0
callq 0x5591d
leaq 0x20bb7(%rip), %rdi     # 0xbee38
xorl %esi, %esi
xorl %edx, %edx
callq 0x8fe70
callq 0x58429
testb $0x40, %r14b
jne 0x9e2b4
cmpb $0x1, -0x29(%rbp)
jne 0x9e2b4
andl $0x18060002, %r14d      # imm = 0x18060002
movq -0x98(%rbp), %rdi
movq %r12, %rsi
movl %r14d, %edx
callq 0xa03c9
movq -0xa0(%rbp), %rax
addq $0xe8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq