// File: donfreiday[P]gb/./imgui/imgui.cpp
// Function: CloseInactivePopups()
static void CloseInactivePopups()
{
    ImGuiState& g = *GImGui;
    if (g.OpenedPopupStack.empty())
        return;

    // When popups are stacked, clicking on a lower level popups puts focus back to it and close popups above it.
    // Don't close our own child popup windows
    int n = 0;
    if (g.FocusedWindow)
    {
        for (n = 0; n < g.OpenedPopupStack.Size; n++)
        {
            ImGuiPopupRef& popup = g.OpenedPopupStack[n];
            if (!popup.Window)
                continue;
            IM_ASSERT((popup.Window->Flags & ImGuiWindowFlags_Popup) != 0);
            if (popup.Window->Flags & ImGuiWindowFlags_ChildWindow)
                continue;

            bool has_focus = false;
            for (int m = n; m < g.OpenedPopupStack.Size && !has_focus; m++)
                has_focus = (g.OpenedPopupStack[m].Window && g.OpenedPopupStack[m].Window->RootWindow == g.FocusedWindow->RootWindow);
            if (!has_focus)
                break;
        }
    }
    if (n < g.OpenedPopupStack.Size)   // This test is not required but it allows to set a useful breakpoint on the line below
        g.OpenedPopupStack.resize(n);
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x30, %rsp
movq 0x6aee1(%rip), %rax     # 0x794c0
movq %rax, -0x8(%rbp)
movq -0x8(%rbp), %rdi
addq $0x17f8, %rdi           # imm = 0x17F8
callq 0x2e420
testb $0x1, %al
jne 0xe5f9
jmp 0xe5fe
jmp 0xe781
movl $0x0, -0xc(%rbp)
movq -0x8(%rbp), %rax
cmpq $0x0, 0x1770(%rax)
je 0xe75f
movl $0x0, -0xc(%rbp)
movl -0xc(%rbp), %eax
movq -0x8(%rbp), %rcx
cmpl 0x17f8(%rcx), %eax
jge 0xe75d
movq -0x8(%rbp), %rdi
addq $0x17f8, %rdi           # imm = 0x17F8
movl -0xc(%rbp), %esi
callq 0x2eca0
movq %rax, -0x18(%rbp)
movq -0x18(%rbp), %rax
cmpq $0x0, 0x8(%rax)
jne 0xe658
jmp 0xe74f
movq -0x18(%rbp), %rax
movq 0x8(%rax), %rax
movl 0xc(%rax), %eax
andl $0x2000000, %eax        # imm = 0x2000000
cmpl $0x0, %eax
je 0xe66f
jmp 0xe68e
leaq 0x4e1e3(%rip), %rdi     # 0x5c859
leaq 0x4cc48(%rip), %rsi     # 0x5b2c5
movl $0xbf6, %edx            # imm = 0xBF6
leaq 0x4e204(%rip), %rcx     # 0x5c88d
callq 0x7160
movq -0x18(%rbp), %rax
movq 0x8(%rax), %rax
movl 0xc(%rax), %eax
andl $0x100000, %eax         # imm = 0x100000
cmpl $0x0, %eax
je 0xe6a8
jmp 0xe74f
movb $0x0, -0x19(%rbp)
movl -0xc(%rbp), %eax
movl %eax, -0x20(%rbp)
movl -0x20(%rbp), %ecx
movq -0x8(%rbp), %rdx
xorl %eax, %eax
cmpl 0x17f8(%rdx), %ecx
movb %al, -0x21(%rbp)
jge 0xe6ce
movb -0x19(%rbp), %al
xorb $-0x1, %al
movb %al, -0x21(%rbp)
movb -0x21(%rbp), %al
testb $0x1, %al
jne 0xe6d7
jmp 0xe745
movq -0x8(%rbp), %rdi
addq $0x17f8, %rdi           # imm = 0x17F8
movl -0x20(%rbp), %esi
callq 0x2eca0
movq %rax, %rcx
xorl %eax, %eax
cmpq $0x0, 0x8(%rcx)
movb %al, -0x22(%rbp)
je 0xe72f
movq -0x8(%rbp), %rdi
addq $0x17f8, %rdi           # imm = 0x17F8
movl -0x20(%rbp), %esi
callq 0x2eca0
movq 0x8(%rax), %rax
movq 0x278(%rax), %rax
movq -0x8(%rbp), %rcx
movq 0x1770(%rcx), %rcx
cmpq 0x278(%rcx), %rax
sete %al
movb %al, -0x22(%rbp)
movb -0x22(%rbp), %al
andb $0x1, %al
movb %al, -0x19(%rbp)
movl -0x20(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x20(%rbp)
jmp 0xe6b2
testb $0x1, -0x19(%rbp)
jne 0xe74d
jmp 0xe75d
jmp 0xe74f
movl -0xc(%rbp), %eax
addl $0x1, %eax
movl %eax, -0xc(%rbp)
jmp 0xe61e
jmp 0xe75f
movl -0xc(%rbp), %eax
movq -0x8(%rbp), %rcx
cmpl 0x17f8(%rcx), %eax
jge 0xe781
movq -0x8(%rbp), %rdi
addq $0x17f8, %rdi           # imm = 0x17F8
movl -0xc(%rbp), %esi
callq 0x2e4c0
addq $0x30, %rsp
popq %rbp
retq
nopw (%rax,%rax)