// File: /workspace/github_cpp_makefile_star2_O1/donfreiday[P]gb/./imgui/imgui.cpp
// Function: ImGui::BeginMenu(char const*, bool)
bool ImGui::BeginMenu(const char* label, bool enabled)
{
    ImGuiWindow* window = GetCurrentWindow();
    if (window->SkipItems)
        return false;

    ImGuiState& g = *GImGui;
    const ImGuiStyle& style = g.Style;
    const ImGuiID id = window->GetID(label);

    ImVec2 label_size = CalcTextSize(label, NULL, true);
    ImGuiWindow* backed_focused_window = g.FocusedWindow;

    bool pressed;
    bool opened = IsPopupOpen(id);
    bool menuset_opened = !(window->Flags & ImGuiWindowFlags_Popup) && (g.OpenedPopupStack.Size > g.CurrentPopupStack.Size && g.OpenedPopupStack[g.CurrentPopupStack.Size].ParentMenuSet == window->GetID("##menus"));
    if (menuset_opened)
        g.FocusedWindow = window;

    ImVec2 popup_pos, pos = window->DC.CursorPos;
    if (window->DC.LayoutType == ImGuiLayoutType_Horizontal)
    {
        popup_pos = ImVec2(pos.x - window->WindowPadding.x, pos.y - style.FramePadding.y + window->MenuBarHeight());
        window->DC.CursorPos.x += (float)(int)(style.ItemSpacing.x * 0.5f);
        ImGui::PushStyleVar(ImGuiStyleVar_ItemSpacing, style.ItemSpacing * 2.0f);
        float w = label_size.x;
        pressed = ImGui::Selectable(label, opened, ImGuiSelectableFlags_Menu | ImGuiSelectableFlags_DontClosePopups | (!enabled ? ImGuiSelectableFlags_Disabled : 0), ImVec2(w, 0.0f));
        ImGui::PopStyleVar();
        ImGui::SameLine();
        window->DC.CursorPos.x += (float)(int)(style.ItemSpacing.x * 0.5f);
    }
    else
    {
        popup_pos = ImVec2(pos.x, pos.y - style.WindowPadding.y);
        float w = window->MenuColumns.DeclColumns(label_size.x, 0.0f, (float)(int)(g.FontSize * 1.20f)); // Feedback to next frame
        float extra_w = ImMax(0.0f, ImGui::GetContentRegionAvail().x - w);
        pressed = ImGui::Selectable(label, opened, ImGuiSelectableFlags_Menu | ImGuiSelectableFlags_DontClosePopups | ImGuiSelectableFlags_DrawFillAvailWidth | (!enabled ? ImGuiSelectableFlags_Disabled : 0), ImVec2(w, 0.0f));
        if (!enabled) ImGui::PushStyleColor(ImGuiCol_Text, g.Style.Colors[ImGuiCol_TextDisabled]);
        RenderCollapseTriangle(pos + ImVec2(window->MenuColumns.Pos[2] + extra_w + g.FontSize * 0.20f, 0.0f), false);
        if (!enabled) ImGui::PopStyleColor();
    }

    bool hovered = enabled && IsHovered(window->DC.LastItemRect, id);
    if (menuset_opened)
        g.FocusedWindow = backed_focused_window;

    bool want_open = false, want_close = false;
    if (window->Flags & (ImGuiWindowFlags_Popup|ImGuiWindowFlags_ChildMenu))
    {
        // Implement http://bjk5.com/post/44698559168/breaking-down-amazons-mega-dropdown to avoid using timers so menus feel more reactive.
        bool moving_within_opened_triangle = false;
        if (g.HoveredWindow == window && g.OpenedPopupStack.Size > g.CurrentPopupStack.Size && g.OpenedPopupStack[g.CurrentPopupStack.Size].ParentWindow == window)
        {
            if (ImGuiWindow* next_window = g.OpenedPopupStack[g.CurrentPopupStack.Size].Window)
            {
                ImRect next_window_rect = next_window->Rect();
                ImVec2 ta = g.IO.MousePos - g.IO.MouseDelta;
                ImVec2 tb = (window->Pos.x < next_window->Pos.x) ? next_window_rect.GetTL() : next_window_rect.GetTR();
                ImVec2 tc = (window->Pos.x < next_window->Pos.x) ? next_window_rect.GetBL() : next_window_rect.GetBR();
                float extra = ImClamp(fabsf(ta.x - tb.x) * 0.30f, 5.0f, 30.0f); // add a bit of extra slack.
                ta.x += (window->Pos.x < next_window->Pos.x) ? -0.5f : +0.5f;   // to avoid numerical issues
                tb.y = ta.y + ImMax((tb.y - extra) - ta.y, -100.0f);            // triangle is maximum 200 high to limit the slope and the bias toward large sub-menus
                tc.y = ta.y + ImMin((tc.y + extra) - ta.y, +100.0f);
                moving_within_opened_triangle = ImIsPointInTriangle(g.IO.MousePos, ta, tb, tc);
                //window->DrawList->PushClipRectFullScreen(); window->DrawList->AddTriangleFilled(ta, tb, tc, moving_within_opened_triangle ? 0x80008000 : 0x80000080); window->DrawList->PopClipRect(); // Debug
            }
        }

        want_close = (opened && !hovered && g.HoveredWindow == window && g.HoveredIdPreviousFrame != 0 && g.HoveredIdPreviousFrame != id && !moving_within_opened_triangle);
        want_open = (!opened && hovered && !moving_within_opened_triangle) || (!opened && hovered && pressed);
    }
    else if (opened && pressed && menuset_opened) // menu-bar: click open menu to close
    {
        want_close = true;
        want_open = opened = false;
    }
    else if (pressed || (hovered && menuset_opened && !opened)) // menu-bar: first click to open, then hover to open others
        want_open = true;

    if (want_close && IsPopupOpen(id))
        ClosePopupToLevel(GImGui->CurrentPopupStack.Size);

    if (!opened && want_open && g.OpenedPopupStack.Size > g.CurrentPopupStack.Size)
    {
        // Don't recycle same menu level in the same frame, first close the other menu and yield for a frame.
        ImGui::OpenPopup(label);
        return false;
    }

    opened |= want_open;
    if (want_open)
        ImGui::OpenPopup(label);

    if (opened)
    {
        ImGui::SetNextWindowPos(popup_pos, ImGuiSetCond_Always);
        ImGuiWindowFlags flags = ImGuiWindowFlags_ShowBorders | ((window->Flags & (ImGuiWindowFlags_Popup|ImGuiWindowFlags_ChildMenu)) ? ImGuiWindowFlags_ChildMenu|ImGuiWindowFlags_ChildWindow : ImGuiWindowFlags_ChildMenu);
        opened = BeginPopupEx(label, flags); // opened can be 'false' when the popup is completely clipped (e.g. zero size display)
    }

    return opened;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x88, %rsp
movl %esi, -0x38(%rbp)
movq 0x340c3(%rip), %r13     # 0x55490
movq 0x1758(%r13), %r14
movb $0x1, 0x72(%r14)
cmpb $0x0, 0x74(%r14)
je 0x213e8
xorl %r15d, %r15d
jmp 0x21971
movq %rdi, %r12
xorl %r15d, %r15d
movq %r14, %rdi
movq %r12, %rsi
xorl %edx, %edx
callq 0xa872
movl %eax, -0x30(%rbp)
movss 0x1bf86(%rip), %xmm0    # 0x3d38c
movq %r12, %rdi
xorl %esi, %esi
movl $0x1, %edx
callq 0xe720
movaps %xmm0, %xmm3
movq 0x34071(%rip), %rax     # 0x55490
movslq 0x1808(%rax), %rcx
cmpl %ecx, 0x17f8(%rax)
jle 0x21443
movq 0x1800(%rax), %rax
leaq (%rcx,%rcx,4), %rcx
movl -0x30(%rbp), %edx
cmpl %edx, (%rax,%rcx,8)
sete %r15b
movq 0x1770(%r13), %rax
movq %rax, -0x98(%rbp)
testb $0x2, 0xf(%r14)
jne 0x21497
movslq 0x1808(%r13), %rax
cmpl %eax, 0x17f8(%r13)
jle 0x21497
movq 0x1800(%r13), %rcx
leaq (%rax,%rax,4), %rax
movl 0x18(%rcx,%rax,8), %ebx
leaq 0x1c7cc(%rip), %rsi     # 0x3dc4a
movq %r14, %rdi
xorl %edx, %edx
movaps %xmm3, -0x70(%rbp)
callq 0xa872
movaps -0x70(%rbp), %xmm3
cmpl %eax, %ebx
sete %al
jmp 0x21499
xorl %eax, %eax
movq %r12, -0x50(%rbp)
testb %al, %al
je 0x214a8
movq %r14, 0x1770(%r13)
movss 0xa8(%r14), %xmm0
movss %xmm0, -0x2c(%rbp)
movss 0xac(%r14), %xmm1
cmpl $0x1, 0x118(%r14)
movzbl %r15b, %r12d
movl %eax, -0x3c(%rbp)
jne 0x2164d
movaps %xmm3, -0x70(%rbp)
xorps %xmm2, %xmm2
testb $0x4, 0xd(%r14)
je 0x2150a
movq 0x33fa7(%rip), %rax     # 0x55490
movss 0x171c(%rax), %xmm0
mulss 0x268(%r14), %xmm0
movss 0x140c(%rax), %xmm2
addss %xmm2, %xmm2
addss %xmm0, %xmm2
movss %xmm2, -0x80(%rbp)
subss 0x140c(%r13), %xmm1
movaps %xmm1, -0x90(%rbp)
movss -0x2c(%rbp), %xmm0
subss 0x40(%r14), %xmm0
movss %xmm0, -0x2c(%rbp)
movss 0x1414(%r13), %xmm0
mulss 0x1be7c(%rip), %xmm0    # 0x3d3bc
cvttps2dq %xmm0, %xmm0
cvtdq2ps %xmm0, %xmm0
addss 0xa8(%r14), %xmm0
movss %xmm0, 0xa8(%r14)
movss 0x1414(%r13), %xmm0
movss 0x1418(%r13), %xmm1
addss %xmm0, %xmm0
addss %xmm1, %xmm1
unpcklps %xmm1, %xmm0            # xmm0 = xmm0[0],xmm1[0],xmm0[1],xmm1[1]
leaq -0x48(%rbp), %rbx
movlps %xmm0, (%rbx)
movl $0x7, %edi
movq %rbx, %rsi
callq 0x15319
movl -0x38(%rbp), %eax
xorb $0x1, %al
movzbl %al, %edx
shll $0x4, %edx
orl $0x5, %edx
movaps -0x70(%rbp), %xmm0
movss %xmm0, (%rbx)
movl $0x0, 0x4(%rbx)
leaq -0x48(%rbp), %rcx
movq -0x50(%rbp), %rdi
movl %r12d, %esi
callq 0x20486
movl %eax, %ebx
movl $0x1, %edi
callq 0x12ffd
movq 0x33ec6(%rip), %rcx     # 0x55490
movq 0x1758(%rcx), %rax
movb $0x1, 0x72(%rax)
cmpb $0x0, 0x74(%rax)
jne 0x2160d
movss 0x1414(%rcx), %xmm0
addss 0xb0(%rax), %xmm0
movl 0xb4(%rax), %ecx
movq 0xd0(%rax), %rdx
movq %rdx, 0xc8(%rax)
movss %xmm0, 0xa8(%rax)
movl %ecx, 0xac(%rax)
movaps -0x90(%rbp), %xmm1
addss -0x80(%rbp), %xmm1
movss 0x1414(%r13), %xmm0
mulss 0x1bd92(%rip), %xmm0    # 0x3d3bc
cvttps2dq %xmm0, %xmm0
cvtdq2ps %xmm0, %xmm0
addss 0xa8(%r14), %xmm0
movss %xmm0, 0xa8(%r14)
movss %xmm1, -0x70(%rbp)
jmp 0x217b7
movaps %xmm1, %xmm0
subss 0x13f0(%r13), %xmm0
movss %xmm0, -0x70(%rbp)
leaq 0x208(%r14), %rdi
movss 0x1718(%r13), %xmm0
mulss 0x1bdba(%rip), %xmm0    # 0x3d430
cvttps2dq %xmm0, %xmm0
cvtdq2ps %xmm0, %xmm2
movaps %xmm1, -0x90(%rbp)
xorps %xmm1, %xmm1
movaps %xmm3, %xmm0
callq 0xa4fe
movss %xmm0, -0x54(%rbp)
movq 0x33df5(%rip), %rax     # 0x55490
movq 0x1758(%rax), %rbx
callq 0xb0a3
movss 0xa8(%rbx), %xmm1
subss 0x18(%rbx), %xmm1
subss %xmm1, %xmm0
movss -0x54(%rbp), %xmm2
subss %xmm2, %xmm0
movaps %xmm0, %xmm1
cmpless 0x1bcd3(%rip), %xmm1    # 0x3d3a0
andnps %xmm0, %xmm1
movaps %xmm1, -0x80(%rbp)
movl -0x38(%rbp), %ebx
movl %ebx, %eax
xorb $0x1, %al
movzbl %al, %edx
shll $0x4, %edx
orl $0x25, %edx
leaq -0x48(%rbp), %rcx
movss %xmm2, (%rcx)
movl $0x0, 0x4(%rcx)
movq -0x50(%rbp), %rdi
movl %r12d, %esi
callq 0x20486
movl %eax, %r12d
testb %bl, %bl
je 0x21752
movaps -0x80(%rbp), %xmm1
addss 0x220(%r14), %xmm1
movss 0x1718(%r13), %xmm0
mulss 0x1bcd8(%rip), %xmm0    # 0x3d3fc
addss %xmm1, %xmm0
addss -0x2c(%rbp), %xmm0
movaps -0x90(%rbp), %xmm1
addss 0x1bc64(%rip), %xmm1    # 0x3d3a0
unpcklps %xmm1, %xmm0            # xmm0 = xmm0[0],xmm1[0],xmm0[1],xmm1[1]
movss 0x1bc39(%rip), %xmm1    # 0x3d380
xorl %edi, %edi
xorl %esi, %esi
callq 0xe906
jmp 0x217b4
leaq 0x1470(%r13), %rsi
xorl %edi, %edi
callq 0x1367a
movaps -0x80(%rbp), %xmm1
addss 0x220(%r14), %xmm1
movss 0x1718(%r13), %xmm0
mulss 0x1bc7e(%rip), %xmm0    # 0x3d3fc
addss %xmm1, %xmm0
addss -0x2c(%rbp), %xmm0
movaps -0x90(%rbp), %xmm1
addss 0x1bc0a(%rip), %xmm1    # 0x3d3a0
unpcklps %xmm1, %xmm0            # xmm0 = xmm0[0],xmm1[0],xmm0[1],xmm1[1]
movss 0x1bbdf(%rip), %xmm1    # 0x3d380
xorl %edi, %edi
xorl %esi, %esi
callq 0xe906
movl $0x1, %edi
callq 0x13916
movl %r12d, %ebx
cmpb $0x0, -0x38(%rbp)
je 0x217d3
leaq 0xe4(%r14), %rdi
movl -0x30(%rbp), %esi
xorl %edx, %edx
callq 0xae36
movl %eax, %r12d
jmp 0x217d6
xorl %r12d, %r12d
movl -0x3c(%rbp), %ecx
testb %cl, %cl
je 0x217eb
movq -0x98(%rbp), %rax
movq %rax, 0x1770(%r13)
testb $0xa, 0xf(%r14)
je 0x2183d
movq 0x1778(%r13), %rdx
cmpq %r14, %rdx
jne 0x21824
movslq 0x1808(%r13), %rax
cmpl %eax, 0x17f8(%r13)
jle 0x21824
movq 0x1800(%r13), %rcx
leaq (%rax,%rax,4), %rax
cmpq %r14, 0x10(%rcx,%rax,8)
je 0x2198a
xorl %eax, %eax
cmpq %r14, %rdx
setne %cl
movl %r15d, %edx
xorb $0x1, %dl
orb %r12b, %dl
orb %cl, %dl
je 0x2184f
xorl %ecx, %ecx
jmp 0x2186c
movl %r15d, %eax
andb %bl, %al
testb %al, %cl
je 0x2188b
movb $0x1, %cl
xorl %r15d, %r15d
xorl %ebx, %ebx
jmp 0x218a2
movl 0x178c(%r13), %ecx
testl %ecx, %ecx
setne %dl
cmpl -0x30(%rbp), %ecx
setne %sil
movl %eax, %ecx
xorb $0x1, %cl
andb %dl, %cl
andb %sil, %cl
andb %r12b, %bl
xorb $0x1, %r12b
orb %r15b, %al
orb %r12b, %al
xorb $0x1, %al
orb %al, %bl
movzbl %bl, %edx
movzbl %al, %ebx
testb %r15b, %r15b
cmovel %edx, %ebx
jmp 0x218a2
testb %bl, %bl
jne 0x2189e
andb %r12b, %cl
xorb $0x1, %cl
orb %r15b, %cl
je 0x2189e
xorl %ebx, %ebx
jmp 0x218a0
movb $0x1, %bl
xorl %ecx, %ecx
testb %cl, %cl
movq -0x50(%rbp), %r12
je 0x218d8
movq 0x33bdf(%rip), %rax     # 0x55490
movslq 0x1808(%rax), %rdi
cmpl %edi, 0x17f8(%rax)
jle 0x218d8
movq 0x1800(%rax), %rax
leaq (%rdi,%rdi,4), %rcx
movl -0x30(%rbp), %edx
cmpl %edx, (%rax,%rcx,8)
jne 0x218d8
callq 0x12c1e
movl %ebx, %eax
notb %al
orb %r15b, %al
testb $0x1, %al
jne 0x21900
movl 0x17f8(%r13), %eax
cmpl 0x1808(%r13), %eax
jle 0x21900
movq %r12, %rdi
callq 0x128f4
jmp 0x213e0
orb %bl, %r15b
testb $0x1, %bl
je 0x21910
movq %r12, %rdi
callq 0x128f4
testb $0x1, %r15b
je 0x21971
movq 0x33b73(%rip), %rax     # 0x55490
movss -0x2c(%rbp), %xmm0
movss %xmm0, 0x1818(%rax)
movss -0x70(%rbp), %xmm0
movss %xmm0, 0x181c(%rax)
movl $0x1, 0x1834(%rax)
xorl %esi, %esi
testl $0xa000000, 0xc(%r14)   # imm = 0xA000000
setne %sil
shll $0x14, %esi
orl $0x8000080, %esi        # imm = 0x8000080
movq %r12, %rdi
addq $0x88, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
jmp 0x12d5c
andb $0x1, %r15b
movl %r15d, %eax
addq $0x88, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
leaq (%rcx,%rax,8), %rax
movq 0x8(%rax), %rax
testq %rax, %rax
je 0x21824
movss 0x18(%rax), %xmm0
movss 0x1c(%rax), %xmm3
movss 0x20(%rax), %xmm1
addss %xmm0, %xmm1
movss 0x24(%rax), %xmm2
movsd 0x18(%rax), %xmm4
movss 0xf0(%r13), %xmm5
movss 0xf4(%r13), %xmm6
subss 0x34c(%r13), %xmm5
subss 0x350(%r13), %xmm6
unpcklps %xmm6, %xmm5            # xmm5 = xmm5[0],xmm6[0],xmm5[1],xmm6[1]
movlps %xmm5, -0x48(%rbp)
xorl %eax, %eax
ucomiss 0x18(%r14), %xmm0
addss %xmm3, %xmm2
leaq 0xf0(%r13), %rdi
seta %r8b
ja 0x21a01
movaps %xmm1, %xmm4
unpcklps %xmm3, %xmm4            # xmm4 = xmm4[0],xmm3[0],xmm4[1],xmm3[1]
movlps %xmm4, -0xa0(%rbp)
movq %rdx, -0x38(%rbp)
ja 0x21a16
unpcklps %xmm2, %xmm1            # xmm1 = xmm1[0],xmm2[0],xmm1[1],xmm2[1]
movaps %xmm1, %xmm0
jmp 0x21a19
unpcklps %xmm2, %xmm0            # xmm0 = xmm0[0],xmm2[0],xmm0[1],xmm2[1]
leaq -0xa8(%rbp), %rcx
movlps %xmm0, (%rcx)
leaq -0x48(%rbp), %rsi
movss (%rsi), %xmm2
leaq -0xa0(%rbp), %rdx
movaps %xmm2, %xmm1
subss (%rdx), %xmm1
andps 0x1b890(%rip), %xmm1    # 0x3d2d0
mulss 0x1ba10(%rip), %xmm1    # 0x3d458
movss 0x4(%rsi), %xmm0
movss 0x1ba07(%rip), %xmm3    # 0x3d45c
minss %xmm1, %xmm3
movss 0x1b9ff(%rip), %xmm4    # 0x3d460
cmpltss %xmm4, %xmm1
movaps %xmm1, %xmm5
andnps %xmm3, %xmm5
andps %xmm4, %xmm1
movb %r8b, %al
leaq 0x1bbe7(%rip), %r8      # 0x3d660
addss (%r8,%rax,4), %xmm2
orps %xmm5, %xmm1
movss %xmm2, (%rsi)
movss 0x4(%rdx), %xmm2
subss %xmm1, %xmm2
subss %xmm0, %xmm2
maxss 0x1b9c9(%rip), %xmm2    # 0x3d464
addss %xmm0, %xmm2
movss %xmm2, 0x4(%rdx)
movss 0x4(%rcx), %xmm2
addss %xmm1, %xmm2
subss %xmm0, %xmm2
minss 0x1b9af(%rip), %xmm2    # 0x3d468
addss %xmm0, %xmm2
movss %xmm2, 0x4(%rcx)
callq 0x83cf
movq -0x38(%rbp), %rdx
jmp 0x21826