// File: Ciaxur[P]yagb-emu/include/imgui/imgui_widgets.cpp
// Function: ImGui::EndMenuBar()
void ImGui::EndMenuBar()
{
    ImGuiWindow* window = GetCurrentWindow();
    if (window->SkipItems)
        return;
    ImGuiContext& g = *GImGui;

    // Nav: When a move request within one of our child menu failed, capture the request to navigate among our siblings.
    if (NavMoveRequestButNoResultYet() && (g.NavMoveDir == ImGuiDir_Left || g.NavMoveDir == ImGuiDir_Right) && (g.NavWindow->Flags & ImGuiWindowFlags_ChildMenu))
    {
        ImGuiWindow* nav_earliest_child = g.NavWindow;
        while (nav_earliest_child->ParentWindow && (nav_earliest_child->ParentWindow->Flags & ImGuiWindowFlags_ChildMenu))
            nav_earliest_child = nav_earliest_child->ParentWindow;
        if (nav_earliest_child->ParentWindow == window && nav_earliest_child->DC.ParentLayoutType == ImGuiLayoutType_Horizontal && g.NavMoveRequestForward == ImGuiNavForward_None)
        {
            // To do so we claim focus back, restore NavId and then process the movement request for yet another frame.
            // This involve a one-frame delay which isn't very problematic in this situation. We could remove it by scoring in advance for multiple window (probably not worth the hassle/cost)
            const ImGuiNavLayer layer = ImGuiNavLayer_Menu;
            IM_ASSERT(window->DC.NavLayerActiveMaskNext & (1 << layer)); // Sanity check
            FocusWindow(window);
            SetNavIDWithRectRel(window->NavLastIds[layer], layer, 0, window->NavRectRel[layer]);
            g.NavLayer = layer;
            g.NavDisableHighlight = true; // Hide highlight for the current frame so we don't see the intermediary selection.
            g.NavMoveRequestForward = ImGuiNavForward_ForwardQueued;
            NavMoveRequestCancel();
        }
    }

    IM_ASSERT(window->Flags & ImGuiWindowFlags_MenuBar);
    IM_ASSERT(window->DC.MenuBarAppending);
    PopClipRect();
    PopID();
    window->DC.MenuBarOffset.x = window->DC.CursorPos.x - window->MenuBarRect().Min.x; // Save horizontal position so next append can reuse it. This is kinda equivalent to a per-layer CursorPos.
    g.GroupStack.back().EmitItem = false;
    EndGroup(); // Restore position on layer 0
    window->DC.LayoutType = ImGuiLayoutType_Vertical;
    window->DC.NavLayerCurrent = ImGuiNavLayer_Main;
    window->DC.MenuBarAppending = false;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x40, %rsp
callq 0xeb270
movq %rax, -0x8(%rbp)
movq -0x8(%rbp), %rax
testb $0x1, 0x93(%rax)
je 0x154333
jmp 0x154591
leaq 0xbec06(%rip), %rax     # 0x212f40
movq (%rax), %rax
movq %rax, -0x10(%rbp)
callq 0xdf630
testb $0x1, %al
jne 0x15434f
jmp 0x1544ae
movq -0x10(%rbp), %rax
cmpl $0x0, 0x1d10(%rax)
je 0x15436d
movq -0x10(%rbp), %rax
cmpl $0x1, 0x1d10(%rax)
jne 0x1544ae
movq -0x10(%rbp), %rax
movq 0x1c90(%rax), %rax
movl 0xc(%rax), %eax
andl $0x10000000, %eax       # imm = 0x10000000
cmpl $0x0, %eax
je 0x1544ae
movq -0x10(%rbp), %rax
movq 0x1c90(%rax), %rax
movq %rax, -0x18(%rbp)
movq -0x18(%rbp), %rcx
xorl %eax, %eax
cmpq $0x0, 0x388(%rcx)
movb %al, -0x2d(%rbp)
je 0x1543c7
movq -0x18(%rbp), %rax
movq 0x388(%rax), %rax
movl 0xc(%rax), %eax
andl $0x10000000, %eax       # imm = 0x10000000
cmpl $0x0, %eax
setne %al
movb %al, -0x2d(%rbp)
movb -0x2d(%rbp), %al
testb $0x1, %al
jne 0x1543d0
jmp 0x1543e1
movq -0x18(%rbp), %rax
movq 0x388(%rax), %rax
movq %rax, -0x18(%rbp)
jmp 0x154398
movq -0x18(%rbp), %rax
movq 0x388(%rax), %rax
cmpq -0x8(%rbp), %rax
jne 0x1544ac
movq -0x18(%rbp), %rax
cmpl $0x0, 0x1c0(%rax)
jne 0x1544ac
movq -0x10(%rbp), %rax
cmpl $0x0, 0x1d08(%rax)
jne 0x1544ac
movl $0x1, -0x1c(%rbp)
movq -0x8(%rbp), %rax
movl 0x154(%rax), %eax
andl $0x2, %eax
cmpl $0x0, %eax
je 0x154433
jmp 0x154452
leaq 0x3bc3b(%rip), %rdi     # 0x190075
leaq 0x39f9f(%rip), %rsi     # 0x18e3e0
movl $0x198f, %edx           # imm = 0x198F
leaq 0x3bc59(%rip), %rcx     # 0x1900a6
callq 0xd180
movq -0x8(%rbp), %rdi
callq 0xcb380
movq -0x8(%rbp), %rax
movl 0x3b4(%rax), %edi
movq -0x8(%rbp), %rcx
addq $0x3b8, %rcx            # imm = 0x3B8
addq $0x10, %rcx
movl $0x1, %esi
xorl %edx, %edx
callq 0xdf3d0
movq -0x10(%rbp), %rax
movl $0x1, 0x1cdc(%rax)
movq -0x10(%rbp), %rax
movb $0x1, 0x1ce6(%rax)
movq -0x10(%rbp), %rax
movl $0x1, 0x1d08(%rax)
callq 0xdf680
jmp 0x1544ae
movq -0x8(%rbp), %rax
movl 0xc(%rax), %eax
andl $0x400, %eax            # imm = 0x400
cmpl $0x0, %eax
je 0x1544c1
jmp 0x1544e0
leaq 0x3bbf7(%rip), %rdi     # 0x1900bf
leaq 0x39f11(%rip), %rsi     # 0x18e3e0
movl $0x1999, %edx           # imm = 0x1999
leaq 0x3bbcb(%rip), %rcx     # 0x1900a6
callq 0xd180
movq -0x8(%rbp), %rax
testb $0x1, 0x15e(%rax)
je 0x1544ef
jmp 0x15450e
leaq 0x3bb3e(%rip), %rdi     # 0x190034
leaq 0x39ee3(%rip), %rsi     # 0x18e3e0
movl $0x199a, %edx           # imm = 0x199A
leaq 0x3bb9d(%rip), %rcx     # 0x1900a6
callq 0xd180
callq 0xd3550
callq 0xdb640
movq -0x8(%rbp), %rdi
movss 0xd8(%rdi), %xmm0
movss %xmm0, -0x34(%rbp)
callq 0xee470
movaps %xmm0, %xmm2
movss -0x34(%rbp), %xmm0
movlpd %xmm2, -0x2c(%rbp)
movlpd %xmm1, -0x24(%rbp)
subss -0x2c(%rbp), %xmm0
movq -0x8(%rbp), %rax
movss %xmm0, 0x160(%rax)
movq -0x10(%rbp), %rdi
addq $0x1c60, %rdi           # imm = 0x1C60
callq 0xebf90
movb $0x0, 0x2d(%rax)
callq 0xdbe80
movq -0x8(%rbp), %rax
movl $0x1, 0x1bc(%rax)
movq -0x8(%rbp), %rax
movl $0x0, 0x14c(%rax)
movq -0x8(%rbp), %rax
movb $0x0, 0x15e(%rax)
addq $0x40, %rsp
popq %rbp
retq
nopw (%rax,%rax)