// File: /workspace/github_cpp_makefile_star2_O3/Ciaxur[P]yagb-emu/include/imgui/imgui_widgets.cpp
// Function: ImGui::Selectable(char const*, bool, int, ImVec2 const&)
bool ImGui::Selectable(const char* label, bool selected, ImGuiSelectableFlags flags, const ImVec2& size_arg)
{
    ImGuiWindow* window = GetCurrentWindow();
    if (window->SkipItems)
        return false;

    ImGuiContext& g = *GImGui;
    const ImGuiStyle& style = g.Style;

    // Submit label or explicit size to ItemSize(), whereas ItemAdd() will submit a larger/spanning rectangle.
    ImGuiID id = window->GetID(label);
    ImVec2 label_size = CalcTextSize(label, NULL, true);
    ImVec2 size(size_arg.x != 0.0f ? size_arg.x : label_size.x, size_arg.y != 0.0f ? size_arg.y : label_size.y);
    ImVec2 pos = window->DC.CursorPos;
    pos.y += window->DC.CurrLineTextBaseOffset;
    ItemSize(size, 0.0f);

    // Fill horizontal space
    // We don't support (size < 0.0f) in Selectable() because the ItemSpacing extension would make explicitely right-aligned sizes not visibly match other widgets.
    const bool span_all_columns = (flags & ImGuiSelectableFlags_SpanAllColumns) != 0;
    const float min_x = span_all_columns ? window->ParentWorkRect.Min.x : pos.x;
    const float max_x = span_all_columns ? window->ParentWorkRect.Max.x : window->WorkRect.Max.x;
    if (size_arg.x == 0.0f || (flags & ImGuiSelectableFlags_SpanAvailWidth))
        size.x = ImMax(label_size.x, max_x - min_x);

    // Text stays at the submission position, but bounding box may be extended on both sides
    const ImVec2 text_min = pos;
    const ImVec2 text_max(min_x + size.x, pos.y + size.y);

    // Selectables are meant to be tightly packed together with no click-gap, so we extend their box to cover spacing between selectable.
    ImRect bb(min_x, pos.y, text_max.x, text_max.y);
    if ((flags & ImGuiSelectableFlags_NoPadWithHalfSpacing) == 0)
    {
        const float spacing_x = span_all_columns ? 0.0f : style.ItemSpacing.x;
        const float spacing_y = style.ItemSpacing.y;
        const float spacing_L = IM_FLOOR(spacing_x * 0.50f);
        const float spacing_U = IM_FLOOR(spacing_y * 0.50f);
        bb.Min.x -= spacing_L;
        bb.Min.y -= spacing_U;
        bb.Max.x += (spacing_x - spacing_L);
        bb.Max.y += (spacing_y - spacing_U);
    }
    //if (g.IO.KeyCtrl) { GetForegroundDrawList()->AddRect(bb.Min, bb.Max, IM_COL32(0, 255, 0, 255)); }

    // Modify ClipRect for the ItemAdd(), faster than doing a PushColumnsBackground/PushTableBackground for every Selectable..
    const float backup_clip_rect_min_x = window->ClipRect.Min.x;
    const float backup_clip_rect_max_x = window->ClipRect.Max.x;
    if (span_all_columns)
    {
        window->ClipRect.Min.x = window->ParentWorkRect.Min.x;
        window->ClipRect.Max.x = window->ParentWorkRect.Max.x;
    }

    bool item_add;
    if (flags & ImGuiSelectableFlags_Disabled)
    {
        ImGuiItemFlags backup_item_flags = window->DC.ItemFlags;
        window->DC.ItemFlags |= ImGuiItemFlags_Disabled | ImGuiItemFlags_NoNavDefaultFocus;
        item_add = ItemAdd(bb, id);
        window->DC.ItemFlags = backup_item_flags;
    }
    else
    {
        item_add = ItemAdd(bb, id);
    }

    if (span_all_columns)
    {
        window->ClipRect.Min.x = backup_clip_rect_min_x;
        window->ClipRect.Max.x = backup_clip_rect_max_x;
    }

    if (!item_add)
        return false;

    // FIXME: We can standardize the behavior of those two, we could also keep the fast path of override ClipRect + full push on render only,
    // which would be advantageous since most selectable are not selected.
    if (span_all_columns && window->DC.CurrentColumns)
        PushColumnsBackground();
    else if (span_all_columns && g.CurrentTable)
        TablePushBackgroundChannel();

    // We use NoHoldingActiveID on menus so user can click and _hold_ on a menu then drag to browse child entries
    ImGuiButtonFlags button_flags = 0;
    if (flags & ImGuiSelectableFlags_NoHoldingActiveID) { button_flags |= ImGuiButtonFlags_NoHoldingActiveId; }
    if (flags & ImGuiSelectableFlags_SelectOnClick)     { button_flags |= ImGuiButtonFlags_PressedOnClick; }
    if (flags & ImGuiSelectableFlags_SelectOnRelease)   { button_flags |= ImGuiButtonFlags_PressedOnRelease; }
    if (flags & ImGuiSelectableFlags_Disabled)          { button_flags |= ImGuiButtonFlags_Disabled; }
    if (flags & ImGuiSelectableFlags_AllowDoubleClick)  { button_flags |= ImGuiButtonFlags_PressedOnClickRelease | ImGuiButtonFlags_PressedOnDoubleClick; }
    if (flags & ImGuiSelectableFlags_AllowItemOverlap)  { button_flags |= ImGuiButtonFlags_AllowItemOverlap; }

    if (flags & ImGuiSelectableFlags_Disabled)
        selected = false;

    const bool was_selected = selected;
    bool hovered, held;
    bool pressed = ButtonBehavior(bb, id, &hovered, &held, button_flags);

    // Update NavId when clicking or when Hovering (this doesn't happen on most widgets), so navigation can be resumed with gamepad/keyboard
    if (pressed || (hovered && (flags & ImGuiSelectableFlags_SetNavIdOnHover)))
    {
        if (!g.NavDisableMouseHover && g.NavWindow == window && g.NavLayer == window->DC.NavLayerCurrent)
        {
            g.NavDisableHighlight = true;
            SetNavID(id, window->DC.NavLayerCurrent, window->DC.NavFocusScopeIdCurrent);
        }
    }
    if (pressed)
        MarkItemEdited(id);

    if (flags & ImGuiSelectableFlags_AllowItemOverlap)
        SetItemAllowOverlap();

    // In this branch, Selectable() cannot toggle the selection so this will never trigger.
    if (selected != was_selected) //-V547
        window->DC.LastItemStatusFlags |= ImGuiItemStatusFlags_ToggledSelection;

    // Render
    if (held && (flags & ImGuiSelectableFlags_DrawHoveredWhenHeld))
        hovered = true;
    if (hovered || selected)
    {
        const ImU32 col = GetColorU32((held && hovered) ? ImGuiCol_HeaderActive : hovered ? ImGuiCol_HeaderHovered : ImGuiCol_Header);
        RenderFrame(bb.Min, bb.Max, col, false, 0.0f);
        RenderNavHighlight(bb, id, ImGuiNavHighlightFlags_TypeThin | ImGuiNavHighlightFlags_NoRounding);
    }

    if (span_all_columns && window->DC.CurrentColumns)
        PopColumnsBackground();
    else if (span_all_columns && g.CurrentTable)
        TablePopBackgroundChannel();

    if (flags & ImGuiSelectableFlags_Disabled) PushStyleColor(ImGuiCol_Text, style.Colors[ImGuiCol_TextDisabled]);
    RenderTextClipped(text_min, text_max, label, NULL, &label_size, style.SelectableTextAlign, &bb);
    if (flags & ImGuiSelectableFlags_Disabled) PopStyleColor();

    // Automatically close popups
    if (pressed && (window->Flags & ImGuiWindowFlags_Popup) && !(flags & ImGuiSelectableFlags_DontClosePopups) && !(window->DC.ItemFlags & ImGuiItemFlags_SelectableDontClosePopup))
        CloseCurrentPopup();

    IMGUI_TEST_ENGINE_ITEM_INFO(id, label, window->DC.ItemFlags);
    return pressed;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x78, %rsp
leaq 0x67668(%rip), %rax     # 0xfbcd0
movq (%rax), %r12
movq 0x1ae0(%r12), %rbx
movb $0x1, 0x90(%rbx)
cmpb $0x0, 0x93(%rbx)
je 0x94698
xorl %r13d, %r13d
movl %r13d, %eax
addq $0x78, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq %rcx, %r13
movl %edx, %r15d
movq %rdi, %r14
movl %esi, -0x54(%rbp)
movq %rbx, %rdi
movq %r14, %rsi
xorl %edx, %edx
callq 0x4570a
movl %eax, -0x30(%rbp)
movss 0x20914(%rip), %xmm0    # 0xb4fd0
movq %r14, %rdi
xorl %esi, %esi
movl $0x1, %edx
callq 0x44a23
movlps %xmm0, -0x80(%rbp)
movss (%r13), %xmm5
movss 0x4(%r13), %xmm1
xorps %xmm2, %xmm2
movaps %xmm5, %xmm3
cmpneqss %xmm2, %xmm3
movaps %xmm3, %xmm4
andnps %xmm0, %xmm4
andps %xmm5, %xmm3
orps %xmm4, %xmm3
movaps %xmm0, -0x90(%rbp)
shufps $0x55, %xmm0, %xmm0     # xmm0 = xmm0[1,1,1,1]
movaps %xmm1, %xmm4
cmpneqss %xmm2, %xmm4
movaps %xmm4, %xmm2
andnps %xmm0, %xmm2
andps %xmm1, %xmm4
orps %xmm2, %xmm4
leaq -0x6c(%rbp), %rdi
movss %xmm3, (%rdi)
movss %xmm4, 0x4(%rdi)
movss 0xd8(%rbx), %xmm0
movss %xmm0, -0x34(%rbp)
movss 0xdc(%rbx), %xmm0
addss 0x110(%rbx), %xmm0
movss %xmm0, -0x40(%rbp)
xorps %xmm0, %xmm0
callq 0x52315
movss -0x34(%rbp), %xmm5
movaps %xmm5, %xmm0
testb $0x2, %r15b
je 0x9475e
movss 0x248(%rbx), %xmm0
btl $0x17, %r15d
jb 0x9477c
movss (%r13), %xmm1
xorps %xmm2, %xmm2
ucomiss %xmm2, %xmm1
jne 0x94775
jnp 0x9477c
movss -0x6c(%rbp), %xmm1
jmp 0x947af
movl %r15d, %eax
andl $0x2, %eax
movss 0x240(%rbx,%rax,8), %xmm2
subss %xmm0, %xmm2
movaps %xmm2, %xmm1
movaps -0x90(%rbp), %xmm4
cmpless %xmm4, %xmm1
movaps %xmm1, %xmm3
andnps %xmm2, %xmm3
andps %xmm4, %xmm1
orps %xmm3, %xmm1
movss %xmm1, -0x6c(%rbp)
movss -0x40(%rbp), %xmm7
movss %xmm5, -0x64(%rbp)
movss %xmm7, -0x60(%rbp)
addss %xmm0, %xmm1
movss -0x68(%rbp), %xmm2
addss %xmm7, %xmm2
movss %xmm1, -0x5c(%rbp)
movss %xmm2, -0x58(%rbp)
movss %xmm0, -0x50(%rbp)
movss %xmm7, -0x4c(%rbp)
movss %xmm1, -0x48(%rbp)
movss %xmm2, -0x44(%rbp)
btl $0x1a, %r15d
jb 0x9485a
xorps %xmm3, %xmm3
testb $0x2, %r15b
jne 0x94803
movss 0x15a8(%r12), %xmm3
movss 0x15ac(%r12), %xmm4
movss 0x207ef(%rip), %xmm5    # 0xb5004
movaps %xmm3, %xmm6
mulss %xmm5, %xmm6
cvttps2dq %xmm6, %xmm6
cvtdq2ps %xmm6, %xmm6
mulss %xmm4, %xmm5
cvttps2dq %xmm5, %xmm5
cvtdq2ps %xmm5, %xmm5
subss %xmm6, %xmm0
movss %xmm0, -0x50(%rbp)
subss %xmm5, %xmm7
movss %xmm7, -0x4c(%rbp)
subss %xmm6, %xmm3
addss %xmm3, %xmm1
movss %xmm1, -0x48(%rbp)
subss %xmm5, %xmm4
addss %xmm4, %xmm2
movss %xmm2, -0x44(%rbp)
movss 0x258(%rbx), %xmm0
movss %xmm0, -0x40(%rbp)
movss 0x260(%rbx), %xmm0
movss %xmm0, -0x34(%rbp)
testb $0x2, %r15b
je 0x9489a
movss 0x248(%rbx), %xmm0
movss 0x250(%rbx), %xmm1
movss %xmm0, 0x258(%rbx)
movss %xmm1, 0x260(%rbx)
movl %r15d, %r13d
andl $0x8, %r13d
movq %r14, -0x78(%rbp)
jne 0x948b7
leaq -0x50(%rbp), %rdi
movl -0x30(%rbp), %esi
xorl %edx, %edx
callq 0x524a8
jmp 0x948df
movl 0x1cc(%rbx), %r14d
movl %r14d, %eax
orl $0x14, %eax
movl %eax, 0x1cc(%rbx)
leaq -0x50(%rbp), %rdi
movl -0x30(%rbp), %esi
xorl %edx, %edx
callq 0x524a8
movl %r14d, 0x1cc(%rbx)
testb $0x2, %r15b
jne 0x948ef
testb %al, %al
je 0x94683
jmp 0x94932
movss -0x40(%rbp), %xmm0
movss %xmm0, 0x258(%rbx)
movss -0x34(%rbp), %xmm0
movss %xmm0, 0x260(%rbx)
testb %al, %al
je 0x94683
cmpq $0x0, 0x1b0(%rbx)
je 0x94922
callq 0x8e950
jmp 0x94932
cmpq $0x0, 0x20a8(%r12)
je 0x94932
callq 0x8bfab
movq %r12, -0x40(%rbp)
testl %r13d, %r13d
sete %r12b
movl %r15d, %eax
shrl $0x3, %eax
andl $0x20000, %eax          # imm = 0x20000
movl %r15d, %ecx
shrl $0x11, %ecx
andl $0x10, %ecx
orl %eax, %ecx
movl %r15d, %eax
shrl $0xf, %eax
andl $0x80, %eax
orl %ecx, %eax
movl %r13d, -0x34(%rbp)
movl %r13d, %ecx
shll $0xb, %ecx
leal (%rax,%rcx), %edx
testb $0x4, %r15b
leal 0x120(%rcx,%rax), %eax
cmovel %edx, %eax
movl %r15d, %r14d
andl $0x10, %r14d
movl %r14d, %r8d
shll $0x8, %r8d
orl %eax, %r8d
leaq -0x50(%rbp), %rdi
leaq -0x29(%rbp), %rdx
leaq -0x2a(%rbp), %rcx
movl -0x30(%rbp), %esi
callq 0x90b6f
movl %eax, %r13d
testb %al, %al
jne 0x949b4
btl $0x19, %r15d
jae 0x949fa
cmpb $0x0, -0x29(%rbp)
je 0x949fa
movq -0x40(%rbp), %rax
cmpb $0x0, 0x1ce7(%rax)
jne 0x949ed
cmpq %rbx, 0x1c90(%rax)
jne 0x949ed
movl 0x1cdc(%rax), %esi
cmpl 0x14c(%rbx), %esi
jne 0x949ed
movb $0x1, 0x1ce6(%rax)
movl 0x158(%rbx), %edx
movl -0x30(%rbp), %edi
callq 0x57bad
testb %r13b, %r13b
je 0x949fa
movl -0x30(%rbp), %edi
callq 0x4618e
testl %r14d, %r14d
je 0x94a04
callq 0x51c22
movb -0x2a(%rbp), %al
movl %eax, %ecx
xorb $0x1, %cl
btl $0x18, %r15d
setae %dl
orb %cl, %dl
jne 0x94a24
movb $0x1, -0x29(%rbp)
movzbl %al, %edi
addl $0x19, %edi
jmp 0x94a45
andb -0x54(%rbp), %r12b
movb -0x29(%rbp), %cl
orb %cl, %r12b
testb $0x1, %r12b
je 0x94a7f
movzbl %al, %eax
addl $0x19, %eax
testb $0x1, %cl
movl $0x18, %edi
cmovnel %eax, %edi
movss 0x20597(%rip), %xmm0    # 0xb4fe4
callq 0x43bca
leaq -0x50(%rbp), %r12
movsd (%r12), %xmm0
movsd 0x8(%r12), %xmm1
xorps %xmm2, %xmm2
movl %eax, %edi
xorl %esi, %esi
callq 0x44f69
movq %r12, %rdi
movl -0x30(%rbp), %esi
movl $0xa, %edx
callq 0x4521b
testb $0x2, %r15b
movq -0x40(%rbp), %r14
je 0x94aa9
cmpq $0x0, 0x1b0(%rbx)
je 0x94a9a
callq 0x8e9c7
jmp 0x94aa9
cmpq $0x0, 0x20a8(%r14)
je 0x94aa9
callq 0x8c02b
cmpl $0x0, -0x34(%rbp)
jne 0x94ada
addq $0x15fc, %r14           # imm = 0x15FC
leaq -0x50(%rbp), %rax
movq %rax, (%rsp)
leaq -0x64(%rbp), %rdi
leaq -0x5c(%rbp), %rsi
leaq -0x80(%rbp), %r8
movq -0x78(%rbp), %rdx
xorl %ecx, %ecx
movq %r14, %r9
callq 0x44ac2
jmp 0x94b1b
leaq 0x1634(%r14), %rsi
xorl %edi, %edi
callq 0x43e1b
addq $0x15fc, %r14           # imm = 0x15FC
leaq -0x50(%rbp), %rax
movq %rax, (%rsp)
leaq -0x64(%rbp), %rdi
leaq -0x5c(%rbp), %rsi
leaq -0x80(%rbp), %r8
movq -0x78(%rbp), %rdx
xorl %ecx, %ecx
movq %r14, %r9
callq 0x44ac2
movl $0x1, %edi
callq 0x43f55
testb %r13b, %r13b
je 0x94686
testb $0x1, %r15b
jne 0x94686
movl $0x4000000, %eax        # imm = 0x4000000
andl 0xc(%rbx), %eax
je 0x94686
testb $0x20, 0x1cc(%rbx)
jne 0x94686
callq 0x571d9
jmp 0x94686