// File: /workspace/github_cpp_makefile_star2_O2/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 $0x78, %rsp
movq 0x34c68(%rip), %r15     # 0x50480
movq 0x1758(%r15), %r14
movb $0x1, 0x72(%r14)
cmpb $0x0, 0x74(%r14)
je 0x1b83c
xorl %eax, %eax
addq $0x78, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movl %esi, %r12d
movq %rdi, %rbx
movq $0x0, -0x50(%rbp)
movq %r14, %rdi
movq %rbx, %rsi
xorl %edx, %edx
callq 0x9858
movl %eax, %r13d
pushq $0x1
popq %rdx
movss 0x1ab37(%rip), %xmm0    # 0x3639c
movq %rbx, %rdi
xorl %esi, %esi
callq 0xc6e3
movaps %xmm0, -0x70(%rbp)
movq 0x1770(%r15), %rax
movq %rax, -0x88(%rbp)
movl %r13d, -0x34(%rbp)
movl %r13d, %edi
callq 0xfa41
movl %eax, %ecx
testb $0x2, 0xf(%r14)
movq %rbx, -0x40(%rbp)
jne 0x1b8f7
movl 0x1808(%r15), %esi
cmpl %esi, 0x17f8(%r15)
jle 0x1b8ef
movl %ecx, %r13d
leaq 0x17f8(%r15), %rdi
callq 0x1ebd4
movl 0x18(%rax), %ebx
leaq 0x1b36f(%rip), %rsi     # 0x36c32
movq $0x0, -0x50(%rbp)
movq %r14, %rdi
xorl %edx, %edx
callq 0x9858
movl %r13d, %ecx
cmpl %eax, %ebx
movq -0x40(%rbp), %rbx
jne 0x1b8f7
movq %r14, 0x1770(%r15)
movb $0x1, %al
movq %rax, -0x50(%rbp)
jmp 0x1b8f7
movq $0x0, -0x50(%rbp)
movss 0xa8(%r14), %xmm0
movss 0xac(%r14), %xmm1
cmpl $0x1, 0x118(%r14)
movl %ecx, -0x30(%rbp)
movzbl %cl, %r13d
jne 0x1ba25
subss 0x40(%r14), %xmm0
movss %xmm0, -0x2c(%rbp)
subss 0x140c(%r15), %xmm1
movaps %xmm1, -0x80(%rbp)
movq %r14, %rdi
callq 0x1ee1a
addss -0x80(%rbp), %xmm0
movss %xmm0, -0x44(%rbp)
movss 0x1aa80(%rip), %xmm1    # 0x363d0
movss 0x1414(%r15), %xmm0
mulss %xmm1, %xmm0
cvttps2dq %xmm0, %xmm0
cvtdq2ps %xmm0, %xmm0
addss 0xa8(%r14), %xmm0
movss %xmm0, 0xa8(%r14)
movss 0x1414(%r15), %xmm0
movss 0x1418(%r15), %xmm1
addss %xmm0, %xmm0
addss %xmm1, %xmm1
unpcklps %xmm1, %xmm0            # xmm0 = xmm0[0],xmm1[0],xmm0[1],xmm1[1]
leaq -0x58(%rbp), %rbx
movlps %xmm0, (%rbx)
pushq $0x7
popq %rdi
movq %rbx, %rsi
callq 0x116b2
movl %r12d, %eax
xorb $0x1, %al
movzbl %al, %edx
shll $0x4, %edx
orl $0x5, %edx
movaps -0x70(%rbp), %xmm0
movss %xmm0, (%rbx)
andl $0x0, 0x4(%rbx)
leaq -0x58(%rbp), %rcx
movq -0x40(%rbp), %rdi
movl %r13d, %esi
callq 0x1ab4d
movl %eax, %r13d
pushq $0x1
popq %rdi
callq 0xfb23
movss 0x1a9ba(%rip), %xmm1    # 0x3639c
xorps %xmm0, %xmm0
callq 0x1254d
movss 0x1a9de(%rip), %xmm0    # 0x363d0
mulss 0x1414(%r15), %xmm0
cvttps2dq %xmm0, %xmm0
cvtdq2ps %xmm0, %xmm0
addss 0xa8(%r14), %xmm0
movss %xmm0, 0xa8(%r14)
testb %r12b, %r12b
jne 0x1bb04
xorl %r12d, %r12d
jmp 0x1bb7a
movss %xmm0, -0x2c(%rbp)
movaps %xmm1, -0x80(%rbp)
movaps %xmm1, %xmm0
subss 0x13f0(%r15), %xmm0
movss %xmm0, -0x44(%rbp)
leaq 0x208(%r14), %rdi
movss 0x1718(%r15), %xmm0
mulss 0x1a9e5(%rip), %xmm0    # 0x3643c
cvttps2dq %xmm0, %xmm0
cvtdq2ps %xmm0, %xmm2
xorps %xmm1, %xmm1
movaps -0x70(%rbp), %xmm0
callq 0x95a2
movss %xmm0, -0x5c(%rbp)
callq 0xfdd2
movss -0x5c(%rbp), %xmm2
subss %xmm2, %xmm0
movaps %xmm0, %xmm1
cmpless 0x1a927(%rip), %xmm1    # 0x363b0
andnps %xmm0, %xmm1
movaps %xmm1, -0x70(%rbp)
movl %r12d, %eax
xorb $0x1, %al
movzbl %al, %edx
shll $0x4, %edx
orl $0x25, %edx
leaq -0x58(%rbp), %rcx
movss %xmm2, (%rcx)
andl $0x0, 0x4(%rcx)
movq %rbx, %rdi
movl %r13d, %esi
callq 0x1ab4d
movl %eax, %r13d
testb %r12b, %r12b
je 0x1bb1a
movaps -0x70(%rbp), %xmm1
addss 0x220(%r14), %xmm1
movss 0x1718(%r15), %xmm0
mulss 0x1a935(%rip), %xmm0    # 0x36410
addss %xmm1, %xmm0
addss -0x2c(%rbp), %xmm0
movaps -0x80(%rbp), %xmm1
addss 0x1a8c0(%rip), %xmm1    # 0x363b0
unpcklps %xmm1, %xmm0            # xmm0 = xmm0[0],xmm1[0],xmm0[1],xmm1[1]
movss 0x1a895(%rip), %xmm1    # 0x36390
xorl %edi, %edi
xorl %esi, %esi
callq 0xc888
leaq 0xe4(%r14), %rdi
movl -0x34(%rbp), %esi
xorl %edx, %edx
callq 0x9d62
movl %eax, %r12d
jmp 0x1bb7a
leaq 0x1470(%r15), %rsi
xorl %r12d, %r12d
xorl %edi, %edi
callq 0x10000
movaps -0x70(%rbp), %xmm1
addss 0x220(%r14), %xmm1
movss 0x1718(%r15), %xmm0
mulss 0x1a8c7(%rip), %xmm0    # 0x36410
addss %xmm1, %xmm0
addss -0x2c(%rbp), %xmm0
movaps -0x80(%rbp), %xmm1
addss 0x1a852(%rip), %xmm1    # 0x363b0
unpcklps %xmm1, %xmm0            # xmm0 = xmm0[0],xmm1[0],xmm0[1],xmm1[1]
movss 0x1a827(%rip), %xmm1    # 0x36390
xorl %edi, %edi
xorl %esi, %esi
callq 0xc888
pushq $0x1
popq %rdi
callq 0x100e8
movq -0x50(%rbp), %rcx
testb %cl, %cl
movl -0x30(%rbp), %edi
je 0x1bb93
movq -0x88(%rbp), %rax
movq %rax, 0x1770(%r15)
testb $0xa, 0xf(%r14)
movss -0x2c(%rbp), %xmm0
je 0x1bc1b
cmpq %r14, 0x1778(%r15)
jne 0x1bbd8
movl 0x1808(%r15), %esi
cmpl %esi, 0x17f8(%r15)
jle 0x1bbd8
leaq 0x17f8(%r15), %rbx
movq %rbx, %rdi
callq 0x1ebd4
cmpq %r14, 0x10(%rax)
je 0x1bd33
xorl %eax, %eax
jmp 0x1be51
xorl %eax, %eax
movl %edi, %ecx
xorb $0x1, %cl
orb %r12b, %cl
jne 0x1bbf1
cmpq %r14, 0x1778(%r15)
je 0x1bd0a
xorl %ecx, %ecx
andb %r12b, %r13b
xorb $0x1, %r12b
orb %al, %r12b
orb %dil, %r12b
xorb $0x1, %r12b
orb %r12b, %r13b
movzbl %r13b, %eax
movzbl %r12b, %ebx
testb %dil, %dil
cmovel %eax, %ebx
testb %cl, %cl
jne 0x1bc28
jmp 0x1bc51
movl %edi, %eax
andb %r13b, %al
testb %al, %cl
je 0x1bc91
xorl %ebx, %ebx
xorl %edi, %edi
movl %edi, %r12d
movl -0x34(%rbp), %edi
callq 0xfa41
testb %al, %al
je 0x1bc49
movq 0x34842(%rip), %rax     # 0x50480
movl 0x1808(%rax), %edi
callq 0xf83d
movl %r12d, %edi
movss -0x2c(%rbp), %xmm0
testb %dil, %dil
jne 0x1bc79
testb $0x1, %bl
je 0x1bc79
movl 0x17f8(%r15), %eax
cmpl 0x1808(%r15), %eax
jle 0x1bc79
movq -0x40(%rbp), %rdi
callq 0xf6de
jmp 0x1b82b
testb $0x1, %bl
je 0x1bcaa
movq -0x40(%rbp), %rbx
movq %rbx, %rdi
callq 0xf6de
movss -0x2c(%rbp), %xmm0
jmp 0x1bcb7
movb $0x1, %bl
testb %r13b, %r13b
jne 0x1bc51
andb %r12b, %cl
xorb $0x1, %cl
orb %dil, %cl
cmpb $0x1, %cl
jne 0x1bd2c
testb %dil, %dil
movq -0x40(%rbp), %rbx
je 0x1b82b
movq 0x347c2(%rip), %rax     # 0x50480
movss %xmm0, 0x1818(%rax)
movss -0x44(%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 %rbx, %rdi
addq $0x78, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
jmp 0xf89b
movl 0x178c(%r15), %ecx
testl %ecx, %ecx
setne %dl
cmpl -0x34(%rbp), %ecx
setne %sil
movl %eax, %ecx
xorb $0x1, %cl
andb %dl, %cl
andb %sil, %cl
jmp 0x1bbf3
xorl %edi, %edi
jmp 0x1bc51
movl 0x1808(%r15), %esi
movq %rbx, %rdi
callq 0x1ebd4
movq 0x8(%rax), %rbx
testq %rbx, %rbx
je 0x1bbd1
movq %rbx, %rdi
callq 0x1ee52
movss 0xf0(%r15), %xmm3
movss 0xf4(%r15), %xmm2
subss 0x34c(%r15), %xmm3
subss 0x350(%r15), %xmm2
leaq 0xf0(%r15), %rdi
movaps %xmm3, %xmm4
unpcklps %xmm2, %xmm4            # xmm4 = xmm4[0],xmm2[0],xmm4[1],xmm2[1]
movlps %xmm4, -0x58(%rbp)
movss 0x18(%rbx), %xmm4
ucomiss 0x18(%r14), %xmm4
jbe 0x1bdaa
shufps $0x1, %xmm0, %xmm1      # xmm1 = xmm1[1,0],xmm0[0,0]
shufps $0xe2, %xmm0, %xmm1     # xmm1 = xmm1[2,0],xmm0[2,3]
movss 0x1a638(%rip), %xmm4    # 0x363e0
jmp 0x1bdba
shufps $0x1, %xmm1, %xmm0      # xmm0 = xmm0[1,0],xmm1[0,0]
shufps $0xe2, %xmm1, %xmm0     # xmm0 = xmm0[2,0],xmm1[2,3]
movss 0x1a616(%rip), %xmm4    # 0x363d0
leaq -0x98(%rbp), %rdx
movlps %xmm0, (%rdx)
leaq -0x90(%rbp), %rcx
movlps %xmm1, (%rcx)
addss %xmm3, %xmm4
subss %xmm0, %xmm3
andps 0x1a503(%rip), %xmm3    # 0x362e0
mulss 0x1a67b(%rip), %xmm3    # 0x36460
movss 0x1a677(%rip), %xmm5    # 0x36464
minss %xmm3, %xmm5
movss 0x1a66f(%rip), %xmm6    # 0x36468
cmpltss %xmm6, %xmm3
movaps %xmm3, %xmm7
andnps %xmm5, %xmm7
andps %xmm6, %xmm3
orps %xmm7, %xmm3
leaq -0x58(%rbp), %rsi
movss %xmm4, (%rsi)
shufps $0x55, %xmm0, %xmm0     # xmm0 = xmm0[1,1,1,1]
subss %xmm3, %xmm0
subss %xmm2, %xmm0
maxss 0x1a646(%rip), %xmm0    # 0x3646c
addss %xmm2, %xmm0
movss %xmm0, 0x4(%rdx)
shufps $0x55, %xmm1, %xmm1     # xmm1 = xmm1[1,1,1,1]
addss %xmm3, %xmm1
subss %xmm2, %xmm1
minss 0x1a62d(%rip), %xmm1    # 0x36470
addss %xmm2, %xmm1
movss %xmm1, 0x4(%rcx)
callq 0x80ed
movl -0x30(%rbp), %edi
movss -0x2c(%rbp), %xmm0
jmp 0x1bbda