// File: Ciaxur[P]yagb-emu/include/imgui/imgui_widgets.cpp
// Function: ImGui::BeginMenuBar()
bool ImGui::BeginMenuBar()
{
    ImGuiWindow* window = GetCurrentWindow();
    if (window->SkipItems)
        return false;
    if (!(window->Flags & ImGuiWindowFlags_MenuBar))
        return false;

    IM_ASSERT(!window->DC.MenuBarAppending);
    BeginGroup(); // Backup position on layer 0 // FIXME: Misleading to use a group for that backup/restore
    PushID("##menubar");

    // We don't clip with current window clipping rectangle as it is already set to the area below. However we clip with window full rect.
    // We remove 1 worth of rounding to Max.x to that text in long menus and small windows don't tend to display over the lower-right rounded area, which looks particularly glitchy.
    ImRect bar_rect = window->MenuBarRect();
    ImRect clip_rect(IM_ROUND(bar_rect.Min.x + window->WindowBorderSize), IM_ROUND(bar_rect.Min.y + window->WindowBorderSize), IM_ROUND(ImMax(bar_rect.Min.x, bar_rect.Max.x - ImMax(window->WindowRounding, window->WindowBorderSize))), IM_ROUND(bar_rect.Max.y));
    clip_rect.ClipWith(window->OuterRectClipped);
    PushClipRect(clip_rect.Min, clip_rect.Max, false);

    // We overwrite CursorMaxPos because BeginGroup sets it to CursorPos (essentially the .EmitItem hack in EndMenuBar() would need something analoguous here, maybe a BeginGroupEx() with flags).
    window->DC.CursorPos = window->DC.CursorMaxPos = ImVec2(bar_rect.Min.x + window->DC.MenuBarOffset.x, bar_rect.Min.y + window->DC.MenuBarOffset.y);
    window->DC.LayoutType = ImGuiLayoutType_Horizontal;
    window->DC.NavLayerCurrent = ImGuiNavLayer_Menu;
    window->DC.MenuBarAppending = true;
    AlignTextToFramePadding();
    return true;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x50, %rsp
callq 0xeb270
movq %rax, -0x10(%rbp)
movq -0x10(%rbp), %rax
testb $0x1, 0x93(%rax)
je 0x154117
movb $0x0, -0x1(%rbp)
jmp 0x1542f9
movq -0x10(%rbp), %rax
movl 0xc(%rax), %eax
andl $0x400, %eax            # imm = 0x400
cmpl $0x0, %eax
jne 0x154131
movb $0x0, -0x1(%rbp)
jmp 0x1542f9
movq -0x10(%rbp), %rax
movb 0x15e(%rax), %al
xorb $-0x1, %al
testb $0x1, %al
jne 0x154143
jmp 0x154145
jmp 0x154164
leaq 0x3bee7(%rip), %rdi     # 0x190033
leaq 0x3a28d(%rip), %rsi     # 0x18e3e0
movl $0x1969, %edx           # imm = 0x1969
leaq 0x3bef1(%rip), %rcx     # 0x190050
callq 0xd180
callq 0xdd220
leaq 0x3befb(%rip), %rdi     # 0x19006b
callq 0xdb440
movq -0x10(%rbp), %rdi
callq 0xee470
movlpd %xmm0, -0x20(%rbp)
movlpd %xmm1, -0x18(%rbp)
movss -0x20(%rbp), %xmm0
movq -0x10(%rbp), %rax
addss 0x4c(%rax), %xmm0
movss 0x1de3a(%rip), %xmm1    # 0x171fd8
addss %xmm1, %xmm0
cvttss2si %xmm0, %eax
cvtsi2ss %eax, %xmm0
movss %xmm0, -0x3c(%rbp)
movss -0x1c(%rbp), %xmm0
movq -0x10(%rbp), %rax
addss 0x4c(%rax), %xmm0
movss 0x1de13(%rip), %xmm1    # 0x171fd8
addss %xmm1, %xmm0
cvttss2si %xmm0, %eax
cvtsi2ss %eax, %xmm0
movss %xmm0, -0x40(%rbp)
movss -0x20(%rbp), %xmm0
movss %xmm0, -0x44(%rbp)
movss -0x18(%rbp), %xmm0
movss %xmm0, -0x48(%rbp)
movq -0x10(%rbp), %rax
movss 0x48(%rax), %xmm0
movq -0x10(%rbp), %rax
movss 0x4c(%rax), %xmm1
callq 0x139050
movss -0x48(%rbp), %xmm1
movaps %xmm0, %xmm2
movss -0x44(%rbp), %xmm0
subss %xmm2, %xmm1
callq 0x139050
movss -0x40(%rbp), %xmm1
movaps %xmm0, %xmm2
movss -0x3c(%rbp), %xmm0
movss 0x1ddac(%rip), %xmm3    # 0x171fd8
addss %xmm3, %xmm2
cvttss2si %xmm2, %eax
cvtsi2ss %eax, %xmm2
movss 0x1dd98(%rip), %xmm3    # 0x171fd8
addss -0x14(%rbp), %xmm3
cvttss2si %xmm3, %eax
cvtsi2ss %eax, %xmm3
leaq -0x30(%rbp), %rdi
callq 0xec090
movq -0x10(%rbp), %rsi
addq $0x208, %rsi            # imm = 0x208
leaq -0x30(%rbp), %rdi
callq 0xe8970
leaq -0x30(%rbp), %rdi
leaq -0x30(%rbp), %rsi
addq $0x8, %rsi
xorl %edx, %edx
callq 0xd34b0
movss -0x20(%rbp), %xmm0
movq -0x10(%rbp), %rax
addss 0x160(%rax), %xmm0
movss -0x1c(%rbp), %xmm1
movq -0x10(%rbp), %rax
addss 0x164(%rax), %xmm1
leaq -0x38(%rbp), %rdi
callq 0xbf4c0
movq -0x10(%rbp), %rcx
movq -0x38(%rbp), %rax
movq %rax, 0xf0(%rcx)
movq -0x10(%rbp), %rax
movq 0xf0(%rcx), %rcx
movq %rcx, 0xd8(%rax)
movq -0x10(%rbp), %rax
movl $0x0, 0x1bc(%rax)
movq -0x10(%rbp), %rax
movl $0x1, 0x14c(%rax)
movq -0x10(%rbp), %rax
movb $0x1, 0x15e(%rax)
callq 0x13da10
movb $0x1, -0x1(%rbp)
movb -0x1(%rbp), %al
andb $0x1, %al
addq $0x50, %rsp
popq %rbp
retq
nopw %cs:(%rax,%rax)