// File: donfreiday[P]gb/./imgui/imgui.cpp
// Function: BeginPopupEx(char const*, int)
static bool BeginPopupEx(const char* str_id, ImGuiWindowFlags extra_flags)
{
    ImGuiState& g = *GImGui;
    ImGuiWindow* window = g.CurrentWindow;
    const ImGuiID id = window->GetID(str_id);
    if (!IsPopupOpen(id))
    {
        ClearSetNextWindowData(); // We behave like Begin() and need to consume those values
        return false;
    }

    ImGui::PushStyleVar(ImGuiStyleVar_WindowRounding, 0.0f);
    ImGuiWindowFlags flags = extra_flags|ImGuiWindowFlags_Popup|ImGuiWindowFlags_NoTitleBar|ImGuiWindowFlags_NoMove|ImGuiWindowFlags_NoResize|ImGuiWindowFlags_NoSavedSettings|ImGuiWindowFlags_AlwaysAutoResize;

    char name[32];
    if (flags & ImGuiWindowFlags_ChildMenu)
        ImFormatString(name, 20, "##menu_%d", g.CurrentPopupStack.Size);    // Recycle windows based on depth
    else
        ImFormatString(name, 20, "##popup_%08x", id); // Not recycling, so we can close/open during the same frame
    float alpha = 1.0f;

    bool opened = ImGui::Begin(name, NULL, ImVec2(0.0f, 0.0f), alpha, flags);
    if (!(window->Flags & ImGuiWindowFlags_ShowBorders))
        g.CurrentWindow->Flags &= ~ImGuiWindowFlags_ShowBorders;
    if (!opened) // opened can be 'false' when the popup is completely clipped (e.g. zero size display)
        ImGui::EndPopup();

    return opened;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x70, %rsp
movq %rdi, -0x10(%rbp)
movl %esi, -0x14(%rbp)
movq 0x63eca(%rip), %rax     # 0x794c0
movq %rax, -0x20(%rbp)
movq -0x20(%rbp), %rax
movq 0x1758(%rax), %rax
movq %rax, -0x28(%rbp)
movq -0x28(%rbp), %rdi
movq -0x10(%rbp), %rsi
xorl %eax, %eax
movl %eax, %edx
callq 0xbc60
movl %eax, -0x2c(%rbp)
movl -0x2c(%rbp), %edi
callq 0x15840
testb $0x1, %al
jne 0x15637
callq 0x158b0
movb $0x0, -0x1(%rbp)
jmp 0x15727
movl $0x2, %edi
xorps %xmm0, %xmm0
callq 0x160e0
movl -0x14(%rbp), %eax
orl $0x2000000, %eax        # imm = 0x2000000
orl $0x1, %eax
orl $0x4, %eax
orl $0x2, %eax
orl $0x100, %eax            # imm = 0x100
orl $0x40, %eax
movl %eax, -0x30(%rbp)
movl -0x30(%rbp), %eax
andl $0x8000000, %eax        # imm = 0x8000000
cmpl $0x0, %eax
je 0x15690
leaq -0x50(%rbp), %rdi
movq -0x20(%rbp), %rax
movl 0x1808(%rax), %ecx
movl $0x14, %esi
leaq 0x47261(%rip), %rdx     # 0x5c8e8
movb $0x0, %al
callq 0x95a0
jmp 0x156aa
leaq -0x50(%rbp), %rdi
movl -0x2c(%rbp), %ecx
movl $0x14, %esi
leaq 0x4724f(%rip), %rdx     # 0x5c8f2
movb $0x0, %al
callq 0x95a0
movss 0x45966(%rip), %xmm0    # 0x5b018
movss %xmm0, -0x54(%rbp)
leaq -0x50(%rbp), %rax
movq %rax, -0x68(%rbp)
leaq -0x60(%rbp), %rdi
xorps %xmm1, %xmm1
movaps %xmm1, %xmm0
callq 0x2d280
movq -0x68(%rbp), %rdi
movss -0x54(%rbp), %xmm0
movl -0x30(%rbp), %ecx
xorl %eax, %eax
movl %eax, %esi
leaq -0x60(%rbp), %rdx
callq 0x12020
andb $0x1, %al
movb %al, -0x55(%rbp)
movq -0x28(%rbp), %rax
movl 0xc(%rax), %eax
andl $0x80, %eax
cmpl $0x0, %eax
jne 0x15714
movq -0x20(%rbp), %rax
movq 0x1758(%rax), %rax
movl 0xc(%rax), %ecx
andl $0xffffff7f, %ecx       # imm = 0xFFFFFF7F
movl %ecx, 0xc(%rax)
testb $0x1, -0x55(%rbp)
jne 0x1571f
callq 0x15910
movb -0x55(%rbp), %al
andb $0x1, %al
movb %al, -0x1(%rbp)
movb -0x1(%rbp), %al
andb $0x1, %al
addq $0x70, %rsp
popq %rbp
retq
nopw %cs:(%rax,%rax)