// File: 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
subq $0xe0, %rsp
movb %cl, %al
movb %dl, %cl
movq %rdi, -0x10(%rbp)
movq %rsi, -0x18(%rbp)
andb $0x1, %cl
movb %cl, -0x19(%rbp)
andb $0x1, %al
movb %al, -0x1a(%rbp)
callq 0xeb270
movq %rax, -0x28(%rbp)
movq -0x28(%rbp), %rax
testb $0x1, 0x93(%rax)
je 0x1553a1
movb $0x0, -0x1(%rbp)
jmp 0x155754
leaq 0xbdb98(%rip), %rax     # 0x212f40
movq (%rax), %rax
movq %rax, -0x30(%rbp)
movq -0x30(%rbp), %rax
addq $0x1560, %rax           # imm = 0x1560
movq %rax, -0x38(%rbp)
movq -0x28(%rbp), %rax
movq 0xd8(%rax), %rax
movq %rax, -0x40(%rbp)
movq -0x10(%rbp), %rdi
xorl %eax, %eax
movl %eax, %esi
movl $0x1, %edx
movss 0x1cb9f(%rip), %xmm0    # 0x171f80
callq 0xc87e0
movlpd %xmm0, -0x48(%rbp)
movb -0x1a(%rbp), %dl
movl $0x8, %eax
xorl %ecx, %ecx
testb $0x1, %dl
cmovnel %ecx, %eax
orl $0x2400000, %eax        # imm = 0x2400000
movl %eax, -0x4c(%rbp)
movq -0x28(%rbp), %rax
cmpl $0x0, 0x1bc(%rax)
jne 0x1554fa
movss -0x48(%rbp), %xmm0
movss %xmm0, -0x54(%rbp)
movq -0x38(%rbp), %rax
movss 0x1cbae(%rip), %xmm0    # 0x171fd8
mulss 0x48(%rax), %xmm0
cvttss2si %xmm0, %eax
cvtsi2ss %eax, %xmm0
movq -0x28(%rbp), %rax
addss 0xd8(%rax), %xmm0
movss %xmm0, 0xd8(%rax)
movq -0x38(%rbp), %rax
movss 0x1cb75(%rip), %xmm0    # 0x171fcc
mulss 0x48(%rax), %xmm0
movq -0x38(%rbp), %rax
movss 0x4c(%rax), %xmm1
leaq -0x5c(%rbp), %rdi
callq 0xbf4c0
movl $0xd, %edi
leaq -0x5c(%rbp), %rsi
callq 0xc7b50
movq -0x10(%rbp), %rax
movq %rax, -0xb8(%rbp)
movl -0x4c(%rbp), %eax
movl %eax, -0xac(%rbp)
movss -0x54(%rbp), %xmm0
leaq -0x64(%rbp), %rdi
xorps %xmm1, %xmm1
callq 0xbf4c0
movq -0xb8(%rbp), %rdi
movl -0xac(%rbp), %edx
xorl %esi, %esi
leaq -0x64(%rbp), %rcx
callq 0x13f2b0
andb $0x1, %al
movb %al, -0x4d(%rbp)
movl $0x1, %edi
callq 0xc7c10
movq -0x38(%rbp), %rax
movss 0x38d28(%rip), %xmm0    # 0x18e1fc
mulss 0x48(%rax), %xmm0
cvttss2si %xmm0, %eax
cvtsi2ss %eax, %xmm0
movq -0x28(%rbp), %rax
addss 0xd8(%rax), %xmm0
movss %xmm0, 0xd8(%rax)
jmp 0x155748
cmpq $0x0, -0x18(%rbp)
je 0x15552a
movq -0x18(%rbp), %rdi
xorl %edx, %edx
movl %edx, %esi
movss 0x1ca6f(%rip), %xmm0    # 0x171f80
callq 0xc87e0
movlpd %xmm0, -0x70(%rbp)
movss -0x70(%rbp), %xmm0
movss %xmm0, -0xbc(%rbp)
jmp 0x155537
xorps %xmm0, %xmm0
movss %xmm0, -0xbc(%rbp)
jmp 0x155537
movss -0xbc(%rbp), %xmm0
movss %xmm0, -0x68(%rbp)
movq -0x28(%rbp), %rdi
addq $0x168, %rdi            # imm = 0x168
movss -0x48(%rbp), %xmm0
movss -0x68(%rbp), %xmm1
movq -0x30(%rbp), %rax
movss 0x1980(%rax), %xmm2
movss 0x38c87(%rip), %xmm3    # 0x18e1f4
mulss %xmm3, %xmm2
cvttps2dq %xmm2, %xmm2
cvtdq2ps %xmm2, %xmm2
callq 0x153fb0
movss %xmm0, -0x74(%rbp)
callq 0xd5b40
movlpd %xmm0, -0x80(%rbp)
movss -0x80(%rbp), %xmm1
subss -0x74(%rbp), %xmm1
xorps %xmm0, %xmm0
callq 0x139050
movss %xmm0, -0x78(%rbp)
movq -0x10(%rbp), %rax
movq %rax, -0xc8(%rbp)
movl -0x4c(%rbp), %eax
orl $0x800000, %eax         # imm = 0x800000
movl %eax, -0xc0(%rbp)
movss -0x74(%rbp), %xmm0
leaq -0x88(%rbp), %rdi
xorps %xmm1, %xmm1
callq 0xbf4c0
movq -0xc8(%rbp), %rdi
movl -0xc0(%rbp), %edx
xorl %esi, %esi
leaq -0x88(%rbp), %rcx
callq 0x13f2b0
andb $0x1, %al
movb %al, -0x4d(%rbp)
movss -0x68(%rbp), %xmm0
xorps %xmm1, %xmm1
ucomiss %xmm1, %xmm0
jbe 0x155671
movq -0x30(%rbp), %rsi
addq $0x1634, %rsi           # imm = 0x1634
xorl %edi, %edi
callq 0xc78f0
movq -0x28(%rbp), %rax
movss 0x178(%rax), %xmm0
movss -0x78(%rbp), %xmm1
addss %xmm1, %xmm0
leaq -0x98(%rbp), %rdi
movq %rdi, -0xd0(%rbp)
xorps %xmm1, %xmm1
callq 0xbf4c0
movq -0xd0(%rbp), %rsi
leaq -0x40(%rbp), %rdi
callq 0x139090
movlpd %xmm0, -0x90(%rbp)
movq -0x18(%rbp), %rdi
movsd -0x90(%rbp), %xmm0
xorl %edx, %edx
movl %edx, %esi
callq 0xc8120
movl $0x1, %edi
callq 0xc7990
testb $0x1, -0x19(%rbp)
je 0x155746
movq -0x28(%rbp), %rax
movq 0x2b8(%rax), %rcx
movq %rcx, -0xd8(%rbp)
movss 0x17c(%rax), %xmm2
movss -0x78(%rbp), %xmm0
addss %xmm0, %xmm2
movq -0x30(%rbp), %rax
movss 0x1980(%rax), %xmm1
movss 0x1d132(%rip), %xmm3    # 0x1727e4
movaps %xmm1, %xmm0
mulss %xmm3, %xmm0
addss %xmm2, %xmm0
movss 0x38b5f(%rip), %xmm2    # 0x18e224
mulss %xmm2, %xmm1
movss 0x1c907(%rip), %xmm2    # 0x171fd8
mulss %xmm2, %xmm1
leaq -0xa8(%rbp), %rdi
movq %rdi, -0xe0(%rbp)
callq 0xbf4c0
movq -0xe0(%rbp), %rsi
leaq -0x40(%rbp), %rdi
callq 0x139090
movlpd %xmm0, -0xa0(%rbp)
movb -0x1a(%rbp), %al
notb %al
movzbl %al, %edi
andl $0x1, %edi
movss 0x1b529(%rip), %xmm0    # 0x170c3c
callq 0xc76e0
movq -0xd8(%rbp), %rdi
movl %eax, %esi
movq -0x30(%rbp), %rax
movss 0x1980(%rax), %xmm1
movss 0x2e30b(%rip), %xmm0    # 0x183a40
mulss %xmm0, %xmm1
movsd -0xa0(%rbp), %xmm0
callq 0x11cde0
jmp 0x155748
jmp 0x15574a
jmp 0x15574c
movb -0x4d(%rbp), %al
andb $0x1, %al
movb %al, -0x1(%rbp)
movb -0x1(%rbp), %al
andb $0x1, %al
addq $0xe0, %rsp
popq %rbp
retq
nopw %cs:(%rax,%rax)