// File: /workspace/github_cpp_makefile_star2_O1/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 $0x68, %rsp
leaq 0x679f3(%rip), %rax     # 0xfdcd0
movq (%rax), %r15
movq 0x1ae0(%r15), %rbx
movb $0x1, 0x90(%rbx)
cmpb $0x0, 0x93(%rbx)
jne 0x96570
movq %rcx, %r13
movl %edx, %r12d
movq %rdi, %r14
movl %esi, -0x5c(%rbp)
movq %rbx, %rdi
movq %r14, %rsi
xorl %edx, %edx
callq 0x46258
movl %eax, -0x30(%rbp)
movss 0x20cb1(%rip), %xmm0    # 0xb6fd0
movq %r14, %rdi
xorl %esi, %esi
movl $0x1, %edx
callq 0x4548d
movlps %xmm0, -0x58(%rbp)
movss (%r13), %xmm0
movss 0x4(%r13), %xmm1
xorps %xmm2, %xmm2
movaps %xmm0, %xmm3
cmpneqss %xmm2, %xmm3
andps %xmm3, %xmm0
movss -0x58(%rbp), %xmm4
movss -0x54(%rbp), %xmm5
andnps %xmm4, %xmm3
orps %xmm0, %xmm3
movaps %xmm1, %xmm0
cmpneqss %xmm2, %xmm0
andps %xmm0, %xmm1
andnps %xmm5, %xmm0
orps %xmm1, %xmm0
leaq -0x74(%rbp), %rdi
movss %xmm3, (%rdi)
movss %xmm0, 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 0x532de
movss -0x34(%rbp), %xmm5
movaps %xmm5, %xmm0
testb $0x2, %r12b
je 0x963ba
movss 0x248(%rbx), %xmm0
btl $0x17, %r12d
jb 0x963d1
movss (%r13), %xmm1
xorps %xmm2, %xmm2
ucomiss %xmm2, %xmm1
jne 0x96402
jp 0x96402
movl %r12d, %eax
andl $0x2, %eax
movss 0x240(%rbx,%rax,8), %xmm1
movss -0x58(%rbp), %xmm2
subss %xmm0, %xmm1
movaps %xmm1, %xmm3
cmpless %xmm2, %xmm3
movaps %xmm3, %xmm4
andnps %xmm1, %xmm4
andps %xmm2, %xmm3
orps %xmm4, %xmm3
movss %xmm3, -0x74(%rbp)
movss %xmm5, -0x6c(%rbp)
movss -0x40(%rbp), %xmm7
movss %xmm7, -0x68(%rbp)
movss -0x74(%rbp), %xmm2
addss %xmm0, %xmm2
movss -0x70(%rbp), %xmm1
addss %xmm7, %xmm1
movss %xmm2, -0x64(%rbp)
movss %xmm1, -0x60(%rbp)
movss %xmm0, -0x50(%rbp)
movss %xmm7, -0x4c(%rbp)
movss %xmm2, -0x48(%rbp)
movss %xmm1, -0x44(%rbp)
btl $0x1a, %r12d
jb 0x964b0
xorps %xmm3, %xmm3
testb $0x2, %r12b
jne 0x9645a
movss 0x15a8(%r15), %xmm3
movss 0x15ac(%r15), %xmm4
movss 0x20b99(%rip), %xmm5    # 0xb7004
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, %xmm2
movss %xmm2, -0x48(%rbp)
subss %xmm5, %xmm4
addss %xmm4, %xmm1
movss %xmm1, -0x44(%rbp)
movss 0x258(%rbx), %xmm0
movss %xmm0, -0x40(%rbp)
movss 0x260(%rbx), %xmm0
movss %xmm0, -0x34(%rbp)
testb $0x2, %r12b
je 0x964f0
movss 0x248(%rbx), %xmm0
movss 0x250(%rbx), %xmm1
movss %xmm0, 0x258(%rbx)
movss %xmm1, 0x260(%rbx)
movl %r12d, %r13d
andl $0x8, %r13d
movq %r14, -0x80(%rbp)
jne 0x9650d
leaq -0x50(%rbp), %rdi
movl -0x30(%rbp), %esi
xorl %edx, %edx
callq 0x5346f
jmp 0x96535
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 0x5346f
movl %r14d, 0x1cc(%rbx)
testb $0x2, %r12b
je 0x96555
movss -0x40(%rbp), %xmm0
movss %xmm0, 0x258(%rbx)
movss -0x34(%rbp), %xmm0
movss %xmm0, 0x260(%rbx)
testb %al, %al
je 0x96570
testb $0x2, %r12b
je 0x96594
cmpq $0x0, 0x1b0(%rbx)
je 0x96585
callq 0x9064e
jmp 0x96594
xorl %r13d, %r13d
movl %r13d, %eax
addq $0x68, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
cmpq $0x0, 0x20a8(%r15)
je 0x96594
callq 0x8dc8f
movq %r15, -0x40(%rbp)
testl %r13d, %r13d
sete %r15b
movl %r12d, %eax
shrl $0x3, %eax
andl $0x20000, %eax          # imm = 0x20000
movl %r12d, %ecx
shrl $0x11, %ecx
andl $0x10, %ecx
orl %eax, %ecx
movl %r12d, %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, %r12b
leal 0x120(%rcx,%rax), %eax
cmovel %edx, %eax
movl %r12d, %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 0x92870
movl %eax, %r13d
testb %al, %al
jne 0x96616
btl $0x19, %r12d
jae 0x9665b
cmpb $0x0, -0x29(%rbp)
je 0x9665b
movq -0x40(%rbp), %rax
cmpb $0x0, 0x1ce7(%rax)
jne 0x9665b
movq -0x40(%rbp), %rax
cmpq %rbx, 0x1c90(%rax)
jne 0x9665b
movl 0x14c(%rbx), %esi
movq -0x40(%rbp), %rax
cmpl %esi, 0x1cdc(%rax)
jne 0x9665b
movq -0x40(%rbp), %rax
movb $0x1, 0x1ce6(%rax)
movl 0x158(%rbx), %edx
movl -0x30(%rbp), %edi
callq 0x58d20
testb %r13b, %r13b
je 0x96668
movl -0x30(%rbp), %edi
callq 0x46ca4
testl %r14d, %r14d
je 0x96672
callq 0x52c1e
andb -0x5c(%rbp), %r15b
movb -0x2a(%rbp), %al
movl %eax, %ecx
xorb $0x1, %cl
btl $0x18, %r12d
setae %dl
orb %cl, %dl
jne 0x9668e
movb $0x1, -0x29(%rbp)
movb -0x29(%rbp), %cl
orb %cl, %r15b
cmpb $0x1, %r15b
jne 0x966e2
movzbl %al, %eax
addl $0x19, %eax
testb %cl, %cl
movl $0x18, %edi
cmovnel %eax, %edi
movss 0x20932(%rip), %xmm0    # 0xb6fe4
callq 0x445bd
leaq -0x50(%rbp), %r14
movsd (%r14), %xmm0
movsd 0x8(%r14), %xmm1
xorps %xmm2, %xmm2
movl %eax, %edi
xorl %esi, %esi
callq 0x459e5
movq %r14, %rdi
movl -0x30(%rbp), %esi
movl $0xa, %edx
callq 0x45ca4
testb $0x2, %r12b
movq -0x40(%rbp), %r14
je 0x9670c
cmpq $0x0, 0x1b0(%rbx)
je 0x966fd
callq 0x906ca
jmp 0x9670c
cmpq $0x0, 0x20a8(%r14)
je 0x9670c
callq 0x8dd17
cmpl $0x0, -0x34(%rbp)
jne 0x9673d
addq $0x15fc, %r14           # imm = 0x15FC
leaq -0x50(%rbp), %rax
movq %rax, (%rsp)
leaq -0x6c(%rbp), %rdi
leaq -0x64(%rbp), %rsi
leaq -0x58(%rbp), %r8
movq -0x80(%rbp), %rdx
xorl %ecx, %ecx
movq %r14, %r9
callq 0x45527
jmp 0x9677e
leaq 0x1634(%r14), %rsi
xorl %edi, %edi
callq 0x4481b
addq $0x15fc, %r14           # imm = 0x15FC
leaq -0x50(%rbp), %rax
movq %rax, (%rsp)
leaq -0x6c(%rbp), %rdi
leaq -0x64(%rbp), %rsi
leaq -0x58(%rbp), %r8
movq -0x80(%rbp), %rdx
xorl %ecx, %ecx
movq %r14, %r9
callq 0x45527
movl $0x1, %edi
callq 0x44964
testb %r13b, %r13b
je 0x96573
testb $0x1, %r12b
jne 0x96573
movl $0x4000000, %eax        # imm = 0x4000000
andl 0xc(%rbx), %eax
je 0x96573
testb $0x20, 0x1cc(%rbx)
jne 0x96573
callq 0x58305
jmp 0x96573