// File: /workspace/github_cpp_makefile_star2_O3/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
movq 0x34367(%rip), %rbx     # 0x55480
movq 0x1758(%rbx), %r14
movb $0x1, 0x72(%r14)
cmpb $0x0, 0x74(%r14)
je 0x21140
xorl %eax, %eax
addq $0x88, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movl %esi, %r13d
movq %rdi, %r15
movq $0x0, -0x48(%rbp)
movq %r14, %rdi
movq %r15, %rsi
xorl %edx, %edx
callq 0xa766
movl %eax, -0x30(%rbp)
movss 0x1c236(%rip), %xmm0    # 0x3d39c
movq %r15, %rdi
xorl %esi, %esi
movl $0x1, %edx
callq 0xe505
movaps %xmm0, %xmm3
movq 0x34301(%rip), %rax     # 0x55480
movslq 0x1808(%rax), %rcx
cmpl %ecx, 0x17f8(%rax)
jle 0x211a6
movq 0x1800(%rax), %rax
leaq (%rcx,%rcx,4), %rcx
movl -0x30(%rbp), %edx
cmpl %edx, (%rax,%rcx,8)
sete %al
movq %rax, -0x48(%rbp)
movq 0x1770(%rbx), %rax
movq %rax, -0x98(%rbp)
testb $0x2, 0xf(%r14)
movq %r15, -0x40(%rbp)
jne 0x2120d
movslq 0x1808(%rbx), %rax
cmpl %eax, 0x17f8(%rbx)
jle 0x2120d
movq 0x1800(%rbx), %rcx
leaq (%rax,%rax,4), %rax
movl 0x18(%rcx,%rax,8), %r15d
leaq 0x1ca95(%rip), %rsi     # 0x3dc7a
movq %r14, %rdi
xorl %edx, %edx
movaps %xmm3, -0x60(%rbp)
callq 0xa766
movaps -0x60(%rbp), %xmm3
xorl %ecx, %ecx
cmpl %eax, %r15d
movq -0x48(%rbp), %rax
jne 0x21213
movq %r14, 0x1770(%rbx)
movb $0x1, %cl
jmp 0x21213
xorl %ecx, %ecx
movq -0x48(%rbp), %rax
movss 0xa8(%r14), %xmm0
movss %xmm0, -0x2c(%rbp)
movss 0xac(%r14), %xmm1
cmpl $0x1, 0x118(%r14)
movzbl %al, %r12d
movq %rcx, -0x68(%rbp)
jne 0x213c9
movaps %xmm3, -0x60(%rbp)
xorps %xmm2, %xmm2
testb $0x4, 0xd(%r14)
je 0x21276
movq 0x3422b(%rip), %rax     # 0x55480
movss 0x171c(%rax), %xmm0
mulss 0x268(%r14), %xmm0
movss 0x140c(%rax), %xmm2
addss %xmm2, %xmm2
addss %xmm0, %xmm2
movss %xmm2, -0x34(%rbp)
subss 0x140c(%rbx), %xmm1
movaps %xmm1, -0x90(%rbp)
movss -0x2c(%rbp), %xmm1
movaps %xmm1, %xmm0
subss 0x40(%r14), %xmm0
movss %xmm0, -0x80(%rbp)
movss 0x1414(%rbx), %xmm0
mulss 0x1c11f(%rip), %xmm0    # 0x3d3cc
cvttps2dq %xmm0, %xmm0
cvtdq2ps %xmm0, %xmm0
addss %xmm1, %xmm0
movss %xmm0, 0xa8(%r14)
movss 0x1414(%rbx), %xmm0
movss 0x1418(%rbx), %xmm1
addss %xmm0, %xmm0
addss %xmm1, %xmm1
unpcklps %xmm1, %xmm0            # xmm0 = xmm0[0],xmm1[0],xmm0[1],xmm1[1]
leaq -0x50(%rbp), %r15
movlps %xmm0, (%r15)
movl $0x7, %edi
movq %r15, %rsi
callq 0x14ee8
movl %r13d, %eax
xorb $0x1, %al
movzbl %al, %edx
shll $0x4, %edx
orl $0x5, %edx
movaps -0x60(%rbp), %xmm0
movss %xmm0, (%r15)
movl $0x0, 0x4(%r15)
leaq -0x50(%rbp), %rcx
movq -0x40(%rbp), %rdi
movl %r12d, %esi
callq 0x201b9
movl %eax, %r12d
movl $0x1, %edi
callq 0x12c6e
movq 0x3414c(%rip), %rcx     # 0x55480
movq 0x1758(%rcx), %rax
movb $0x1, 0x72(%rax)
cmpb $0x0, 0x74(%rax)
jne 0x21377
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 -0x34(%rbp), %xmm1
movss 0x1414(%rbx), %xmm0
mulss 0x1c039(%rip), %xmm0    # 0x3d3cc
cvttps2dq %xmm0, %xmm0
cvtdq2ps %xmm0, %xmm0
addss 0xa8(%r14), %xmm0
movss %xmm0, 0xa8(%r14)
testb %r13b, %r13b
je 0x214e0
movss %xmm1, -0x60(%rbp)
movss -0x80(%rbp), %xmm0
movss %xmm0, -0x2c(%rbp)
jmp 0x214ca
movaps %xmm1, %xmm0
subss 0x13f0(%rbx), %xmm0
movss %xmm0, -0x60(%rbp)
leaq 0x208(%r14), %rdi
movss 0x1718(%rbx), %xmm0
mulss 0x1c050(%rip), %xmm0    # 0x3d440
cvttps2dq %xmm0, %xmm0
cvtdq2ps %xmm0, %xmm2
movaps %xmm1, -0x90(%rbp)
xorps %xmm1, %xmm1
movaps %xmm3, %xmm0
callq 0xa364
movss %xmm0, -0x34(%rbp)
movq 0x3406b(%rip), %rax     # 0x55480
movq 0x1758(%rax), %r15
callq 0xaf8c
movss 0xa8(%r15), %xmm1
subss 0x18(%r15), %xmm1
subss %xmm1, %xmm0
movss -0x34(%rbp), %xmm2
subss %xmm2, %xmm0
movaps %xmm0, %xmm1
cmpless 0x1bf8f(%rip), %xmm1    # 0x3d3d8
andnps %xmm0, %xmm1
movaps %xmm1, -0x80(%rbp)
movl %r13d, %eax
xorb $0x1, %al
movzbl %al, %edx
shll $0x4, %edx
orl $0x25, %edx
leaq -0x50(%rbp), %rcx
movss %xmm2, (%rcx)
movl $0x0, 0x4(%rcx)
movq -0x40(%rbp), %rdi
movl %r12d, %esi
callq 0x201b9
movl %eax, %r12d
testb %r13b, %r13b
je 0x214f4
movaps -0x80(%rbp), %xmm1
addss 0x220(%r14), %xmm1
movss 0x1718(%rbx), %xmm0
mulss 0x1bf72(%rip), %xmm0    # 0x3d410
addss %xmm1, %xmm0
addss -0x2c(%rbp), %xmm0
movaps -0x90(%rbp), %xmm1
addss 0x1bf22(%rip), %xmm1    # 0x3d3d8
unpcklps %xmm1, %xmm0            # xmm0 = xmm0[0],xmm1[0],xmm0[1],xmm1[1]
movss 0x1becf(%rip), %xmm1    # 0x3d390
xorl %edi, %edi
xorl %esi, %esi
callq 0xe6eb
leaq 0xe4(%r14), %rdi
movl -0x30(%rbp), %esi
xorl %edx, %edx
callq 0xad1f
movl %eax, %r13d
jmp 0x21558
xorl %r13d, %r13d
movss %xmm1, -0x60(%rbp)
movss -0x80(%rbp), %xmm0
movss %xmm0, -0x2c(%rbp)
jmp 0x21558
leaq 0x1470(%rbx), %rsi
xorl %r13d, %r13d
xorl %edi, %edi
callq 0x132dd
movaps -0x80(%rbp), %xmm1
addss 0x220(%r14), %xmm1
movss 0x1718(%rbx), %xmm0
mulss 0x1beee(%rip), %xmm0    # 0x3d410
addss %xmm1, %xmm0
addss -0x2c(%rbp), %xmm0
movaps -0x90(%rbp), %xmm1
addss 0x1be9e(%rip), %xmm1    # 0x3d3d8
unpcklps %xmm1, %xmm0            # xmm0 = xmm0[0],xmm1[0],xmm0[1],xmm1[1]
movss 0x1be4b(%rip), %xmm1    # 0x3d390
xorl %edi, %edi
xorl %esi, %esi
callq 0xe6eb
movl $0x1, %edi
callq 0x13561
movq -0x68(%rbp), %rcx
testb %cl, %cl
movq -0x48(%rbp), %r8
je 0x21572
movq -0x98(%rbp), %rax
movq %rax, 0x1770(%rbx)
testb $0xa, 0xf(%r14)
je 0x21586
cmpq %r14, 0x1778(%rbx)
je 0x215a0
xorl %eax, %eax
jmp 0x215d2
movl %r8d, %eax
andb %r12b, %al
testb %al, %cl
je 0x21633
xorl %r15d, %r15d
xorl %r8d, %r8d
movq -0x40(%rbp), %r12
jmp 0x215fd
movslq 0x1808(%rbx), %rax
cmpl %eax, 0x17f8(%rbx)
jle 0x215c5
movq 0x1800(%rbx), %rcx
leaq (%rax,%rax,4), %rax
cmpq %r14, 0x10(%rcx,%rax,8)
je 0x21711
xorl %eax, %eax
movl %r8d, %ecx
xorb $0x1, %cl
orb %r13b, %cl
je 0x21641
xorl %ecx, %ecx
andb %r13b, %r12b
xorb $0x1, %r13b
orb %r8b, %al
orb %r13b, %al
xorb $0x1, %al
orb %al, %r12b
movzbl %r12b, %edx
movzbl %al, %r15d
testb %r8b, %r8b
cmovel %edx, %r15d
testb %cl, %cl
movq -0x40(%rbp), %r12
je 0x21677
movq 0x33e7c(%rip), %rax     # 0x55480
movslq 0x1808(%rax), %rdi
cmpl %edi, 0x17f8(%rax)
jle 0x21677
movq 0x1800(%rax), %rax
leaq (%rdi,%rdi,4), %rcx
movl -0x30(%rbp), %edx
cmpl %edx, (%rax,%rcx,8)
jne 0x21677
movq %r8, %r13
callq 0x128a1
movq %r13, %r8
jmp 0x21677
movb $0x1, %r15b
testb %r12b, %r12b
je 0x21662
movq -0x40(%rbp), %r12
jmp 0x21677
movl 0x178c(%rbx), %ecx
testl %ecx, %ecx
setne %dl
cmpl -0x30(%rbp), %ecx
setne %sil
movl %eax, %ecx
xorb $0x1, %cl
andb %dl, %cl
andb %sil, %cl
jmp 0x215d4
andb %r13b, %cl
xorb $0x1, %cl
orb %r8b, %cl
cmpb $0x1, %cl
movq -0x40(%rbp), %r12
je 0x216ad
xorl %r8d, %r8d
testb %r8b, %r8b
jne 0x2169d
testb $0x1, %r15b
je 0x2169d
movl 0x17f8(%rbx), %eax
cmpl 0x1808(%rbx), %eax
jle 0x2169d
movq %r12, %rdi
callq 0x12594
jmp 0x2112c
testb $0x1, %r15b
je 0x216ad
movq %r12, %rdi
callq 0x12594
jmp 0x216b6
testb %r8b, %r8b
je 0x2112c
movq 0x33dc3(%rip), %rax     # 0x55480
movss -0x2c(%rbp), %xmm0
movss %xmm0, 0x1818(%rax)
movss -0x60(%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 0x129d3
leaq (%rcx,%rax,8), %rax
movq 0x8(%rax), %rax
testq %rax, %rax
je 0x215c5
movss 0x18(%rax), %xmm0
movss 0x1c(%rax), %xmm5
movss 0x20(%rax), %xmm3
movss 0x24(%rax), %xmm4
addss %xmm5, %xmm4
leaq 0xf0(%rbx), %rdi
movss 0xf0(%rbx), %xmm2
movss 0xf4(%rbx), %xmm1
subss 0x34c(%rbx), %xmm2
subss 0x350(%rbx), %xmm1
movaps %xmm2, %xmm6
unpcklps %xmm1, %xmm6            # xmm6 = xmm6[0],xmm1[0],xmm6[1],xmm1[1]
movlps %xmm6, -0x50(%rbp)
ucomiss 0x18(%r14), %xmm0
jbe 0x21785
movaps %xmm0, %xmm3
unpcklps %xmm5, %xmm3            # xmm3 = xmm3[0],xmm5[0],xmm3[1],xmm5[1]
unpcklps %xmm4, %xmm0            # xmm0 = xmm0[0],xmm4[0],xmm0[1],xmm4[1]
movss 0x1bc5d(%rip), %xmm4    # 0x3d3e0
jmp 0x2179a
addss %xmm3, %xmm0
movaps %xmm0, %xmm3
unpcklps %xmm5, %xmm3            # xmm3 = xmm3[0],xmm5[0],xmm3[1],xmm5[1]
unpcklps %xmm4, %xmm0            # xmm0 = xmm0[0],xmm4[0],xmm0[1],xmm4[1]
movss 0x1bc32(%rip), %xmm4    # 0x3d3cc
leaq -0xa8(%rbp), %rdx
movlps %xmm3, (%rdx)
leaq -0xa0(%rbp), %rcx
movlps %xmm0, (%rcx)
addss %xmm2, %xmm4
subss %xmm3, %xmm2
andps 0x1bb23(%rip), %xmm2    # 0x3d2e0
mulss 0x1bca3(%rip), %xmm2    # 0x3d468
movss 0x1bc9f(%rip), %xmm5    # 0x3d46c
minss %xmm2, %xmm5
movss 0x1bc97(%rip), %xmm6    # 0x3d470
cmpltss %xmm6, %xmm2
movaps %xmm2, %xmm7
andnps %xmm5, %xmm7
andps %xmm6, %xmm2
orps %xmm7, %xmm2
leaq -0x50(%rbp), %rsi
movss %xmm4, (%rsi)
shufps $0x55, %xmm3, %xmm3     # xmm3 = xmm3[1,1,1,1]
subss %xmm2, %xmm3
subss %xmm1, %xmm3
maxss 0x1bc6e(%rip), %xmm3    # 0x3d474
addss %xmm1, %xmm3
movss %xmm3, 0x4(%rdx)
shufps $0x55, %xmm0, %xmm0     # xmm0 = xmm0[1,1,1,1]
addss %xmm2, %xmm0
subss %xmm1, %xmm0
minss 0x1bc55(%rip), %xmm0    # 0x3d478
addss %xmm1, %xmm0
movss %xmm0, 0x4(%rcx)
callq 0x837f
movq -0x48(%rbp), %r8
jmp 0x215c7