// File: /workspace/github_cpp_makefile_star2_O2/Ciaxur[P]yagb-emu/include/imgui/imgui_widgets.cpp
// Function: ImGui::MenuItem(char const*, char const*, bool, bool)
bool ImGui::MenuItem(const char* label, const char* shortcut, bool selected, bool enabled)
{
    ImGuiWindow* window = GetCurrentWindow();
    if (window->SkipItems)
        return false;

    ImGuiContext& g = *GImGui;
    ImGuiStyle& style = g.Style;
    ImVec2 pos = window->DC.CursorPos;
    ImVec2 label_size = CalcTextSize(label, NULL, true);

    // We've been using the equivalent of ImGuiSelectableFlags_SetNavIdOnHover on all Selectable() since early Nav system days (commit 43ee5d73),
    // but I am unsure whether this should be kept at all. For now moved it to be an opt-in feature used by menus only.
    ImGuiSelectableFlags flags = ImGuiSelectableFlags_SelectOnRelease | ImGuiSelectableFlags_SetNavIdOnHover | (enabled ? 0 : ImGuiSelectableFlags_Disabled);
    bool pressed;
    if (window->DC.LayoutType == ImGuiLayoutType_Horizontal)
    {
        // Mimic the exact layout spacing of BeginMenu() to allow MenuItem() inside a menu bar, which is a little misleading but may be useful
        // Note that in this situation we render neither the shortcut neither the selected tick mark
        float w = label_size.x;
        window->DC.CursorPos.x += IM_FLOOR(style.ItemSpacing.x * 0.5f);
        PushStyleVar(ImGuiStyleVar_ItemSpacing, ImVec2(style.ItemSpacing.x * 2.0f, style.ItemSpacing.y));
        pressed = Selectable(label, false, flags, ImVec2(w, 0.0f));
        PopStyleVar();
        window->DC.CursorPos.x += IM_FLOOR(style.ItemSpacing.x * (-1.0f + 0.5f)); // -1 spacing to compensate the spacing added when Selectable() did a SameLine(). It would also work to call SameLine() ourselves after the PopStyleVar().
    }
    else
    {
        // Menu item inside a vertical menu
        // (In a typical menu window where all items are BeginMenu() or MenuItem() calls, extra_w will always be 0.0f.
        //  Only when they are other items sticking out we're going to add spacing, yet only register minimum width into the layout system.
        float shortcut_w = shortcut ? CalcTextSize(shortcut, NULL).x : 0.0f;
        float min_w = window->DC.MenuColumns.DeclColumns(label_size.x, shortcut_w, IM_FLOOR(g.FontSize * 1.20f)); // Feedback for next frame
        float extra_w = ImMax(0.0f, GetContentRegionAvail().x - min_w);
        pressed = Selectable(label, false, flags | ImGuiSelectableFlags_SpanAvailWidth, ImVec2(min_w, 0.0f));
        if (shortcut_w > 0.0f)
        {
            PushStyleColor(ImGuiCol_Text, g.Style.Colors[ImGuiCol_TextDisabled]);
            RenderText(pos + ImVec2(window->DC.MenuColumns.Pos[1] + extra_w, 0.0f), shortcut, NULL, false);
            PopStyleColor();
        }
        if (selected)
            RenderCheckMark(window->DrawList, pos + ImVec2(window->DC.MenuColumns.Pos[2] + extra_w + g.FontSize * 0.40f, g.FontSize * 0.134f * 0.5f), GetColorU32(enabled ? ImGuiCol_Text : ImGuiCol_TextDisabled), g.FontSize  * 0.866f);
    }

    IMGUI_TEST_ENGINE_ITEM_INFO(window->DC.LastItemId, label, window->DC.ItemFlags | ImGuiItemStatusFlags_Checkable | (selected ? ImGuiItemStatusFlags_Checked : 0));
    return pressed;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x68, %rsp
leaq 0x58745(%rip), %rax     # 0xe3ce0
movq (%rax), %r15
movq 0x1ae0(%r15), %r13
movb $0x1, 0x90(%r13)
cmpb $0x0, 0x93(%r13)
je 0x8b5bf
xorl %r12d, %r12d
jmp 0x8b845
movl %ecx, %r14d
movq %rsi, %rbx
movq %rdi, %r12
movl %edx, -0x30(%rbp)
movss 0xd8(%r13), %xmm0
movaps %xmm0, -0x60(%rbp)
movss 0xdc(%r13), %xmm0
movaps %xmm0, -0x80(%rbp)
pushq $0x1
popq %rdx
movss 0x10a00(%rip), %xmm0    # 0x9bff0
xorl %esi, %esi
callq 0x365e8
movaps %xmm0, %xmm3
xorb $0x1, %r14b
movzbl %r14b, %eax
leal 0x2400000(,%rax,8), %r14d
cmpl $0x0, 0x1bc(%r13)
je 0x8b79c
movq %rax, -0x68(%rbp)
xorps %xmm1, %xmm1
testq %rbx, %rbx
je 0x8b643
movss 0x109c4(%rip), %xmm0    # 0x9bff0
movq %rbx, %rdi
xorl %esi, %esi
xorl %edx, %edx
movaps %xmm3, -0x40(%rbp)
callq 0x365e8
movaps -0x40(%rbp), %xmm3
movaps %xmm0, %xmm1
movaps %xmm1, -0x90(%rbp)
leaq 0x168(%r13), %rdi
movss 0x1980(%r15), %xmm0
mulss 0x2ca9e(%rip), %xmm0    # 0xb8100
cvttps2dq %xmm0, %xmm0
cvtdq2ps %xmm0, %xmm2
movaps %xmm3, %xmm0
callq 0x8a88c
movss %xmm0, -0x2c(%rbp)
callq 0x409d2
movss -0x2c(%rbp), %xmm3
subss %xmm3, %xmm0
movaps %xmm0, %xmm1
xorps %xmm2, %xmm2
cmpless %xmm2, %xmm1
andnps %xmm0, %xmm1
movaps %xmm1, -0x40(%rbp)
orl $0x800000, %r14d        # imm = 0x800000
leaq -0x48(%rbp), %rcx
movss %xmm3, (%rcx)
andl $0x0, 0x4(%rcx)
movq %r12, %rdi
xorl %esi, %esi
movl %r14d, %edx
callq 0x7d81c
movl %eax, %r12d
movaps -0x90(%rbp), %xmm0
ucomiss 0x111fd(%rip), %xmm0    # 0x9c8c4
jbe 0x8b709
leaq 0x1634(%r15), %rsi
xorl %edi, %edi
callq 0x35e60
movss 0x178(%r13), %xmm0
addss -0x40(%rbp), %xmm0
addss -0x60(%rbp), %xmm0
xorps %xmm1, %xmm1
addss -0x80(%rbp), %xmm1
unpcklps %xmm1, %xmm0            # xmm0 = xmm0[0],xmm1[0],xmm0[1],xmm1[1]
movq %rbx, %rdi
xorl %esi, %esi
xorl %edx, %edx
callq 0x36156
pushq $0x1
popq %rdi
callq 0x35eb4
cmpb $0x0, -0x30(%rbp)
je 0x8b845
movaps -0x40(%rbp), %xmm2
addss 0x17c(%r13), %xmm2
movq 0x2b8(%r13), %rbx
movss 0x1980(%r15), %xmm0
movss 0x16ad4(%rip), %xmm1    # 0xa220c
mulss %xmm0, %xmm1
mulss 0x2c9f0(%rip), %xmm0    # 0xb8134
mulss 0x108cc(%rip), %xmm0    # 0x9c018
addss %xmm2, %xmm1
movaps -0x60(%rbp), %xmm2
addss %xmm1, %xmm2
movaps -0x80(%rbp), %xmm1
addss %xmm0, %xmm1
unpcklps %xmm1, %xmm2            # xmm2 = xmm2[0],xmm1[0],xmm2[1],xmm1[1]
movaps %xmm2, -0x60(%rbp)
movss 0x10889(%rip), %xmm0    # 0x9bff8
movq -0x68(%rbp), %rdi
callq 0x35d33
movss 0x1980(%r15), %xmm1
mulss 0x22517(%rip), %xmm1    # 0xadca0
movq %rbx, %rdi
movaps -0x60(%rbp), %xmm0
movl %eax, %esi
callq 0x6ba45
jmp 0x8b845
movss 0x15a8(%r15), %xmm0
movaps %xmm3, -0x40(%rbp)
movss 0x10867(%rip), %xmm1    # 0x9c018
mulss %xmm0, %xmm1
cvttps2dq %xmm1, %xmm1
cvtdq2ps %xmm1, %xmm1
addss 0xd8(%r13), %xmm1
movss %xmm1, 0xd8(%r13)
addss %xmm0, %xmm0
movss 0x15ac(%r15), %xmm1
leaq -0x48(%rbp), %rbx
movss %xmm0, (%rbx)
movss %xmm1, 0x4(%rbx)
pushq $0xd
popq %rdi
movq %rbx, %rsi
callq 0x35fca
movaps -0x40(%rbp), %xmm0
movss %xmm0, (%rbx)
andl $0x0, 0x4(%rbx)
leaq -0x48(%rbp), %rcx
movq %r12, %rdi
xorl %esi, %esi
movl %r14d, %edx
callq 0x7d81c
movl %eax, %r12d
pushq $0x1
popq %rdi
callq 0x3605c
movss 0x15a8(%r15), %xmm0
mulss 0x110c8(%rip), %xmm0    # 0x9c8f4
cvttps2dq %xmm0, %xmm0
cvtdq2ps %xmm0, %xmm0
addss 0xd8(%r13), %xmm0
movss %xmm0, 0xd8(%r13)
movl %r12d, %eax
addq $0x68, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq