// File: Ciaxur[P]yagb-emu/include/imgui/imgui.cpp
// Function: CreateNewWindow(char const*, int)
static ImGuiWindow* CreateNewWindow(const char* name, ImGuiWindowFlags flags)
{
    ImGuiContext& g = *GImGui;
    //IMGUI_DEBUG_LOG("CreateNewWindow '%s', flags = 0x%08X\n", name, flags);

    // Create window the first time
    ImGuiWindow* window = IM_NEW(ImGuiWindow)(&g, name);
    window->Flags = flags;
    g.WindowsById.SetVoidPtr(window->ID, window);

    // Default/arbitrary window position. Use SetNextWindowPos() with the appropriate condition flag to change the initial position of a window.
    window->Pos = ImVec2(60, 60);

    // User can disable loading and saving of settings. Tooltip and child windows also don't store settings.
    if (!(flags & ImGuiWindowFlags_NoSavedSettings))
        if (ImGuiWindowSettings* settings = ImGui::FindWindowSettings(window->ID))
        {
            // Retrieve settings from .ini file
            window->SettingsOffset = g.SettingsWindows.offset_from_ptr(settings);
            SetWindowConditionAllowFlags(window, ImGuiCond_FirstUseEver, false);
            ApplyWindowSettings(window, settings);
        }
    window->DC.CursorStartPos = window->DC.CursorMaxPos = window->Pos; // So first call to CalcContentSize() doesn't return crazy values

    if ((flags & ImGuiWindowFlags_AlwaysAutoResize) != 0)
    {
        window->AutoFitFramesX = window->AutoFitFramesY = 2;
        window->AutoFitOnlyGrows = false;
    }
    else
    {
        if (window->Size.x <= 0.0f)
            window->AutoFitFramesX = 2;
        if (window->Size.y <= 0.0f)
            window->AutoFitFramesY = 2;
        window->AutoFitOnlyGrows = (window->AutoFitFramesX > 0) || (window->AutoFitFramesY > 0);
    }

    g.WindowsFocusOrder.push_back(window);
    if (flags & ImGuiWindowFlags_NoBringToFrontOnFocus)
        g.Windows.push_front(window); // Quite slow but rare and only once
    else
        g.Windows.push_back(window);
    return window;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x70, %rsp
movq %rdi, -0x8(%rbp)
movl %esi, -0xc(%rbp)
movq 0x13c07a(%rip), %rax    # 0x212f40
movq %rax, -0x18(%rbp)
movl $0x3e8, %edi            # imm = 0x3E8
movq %rdi, -0x60(%rbp)
callq 0xc4820
movq -0x60(%rbp), %rdi
movq %rax, %rsi
movq %rsi, %rax
movq %rax, -0x58(%rbp)
callq 0xe9510
movq %rax, %rdi
movq %rdi, %rax
movq %rax, -0x50(%rbp)
movq -0x18(%rbp), %rsi
movq -0x8(%rbp), %rdx
callq 0xc94a0
jmp 0xd6f04
movq -0x50(%rbp), %rax
movq %rax, -0x20(%rbp)
movl -0xc(%rbp), %ecx
movq -0x20(%rbp), %rax
movl %ecx, 0xc(%rax)
movq -0x18(%rbp), %rdi
addq $0x1ac8, %rdi           # imm = 0x1AC8
movq -0x20(%rbp), %rax
movl 0x8(%rax), %esi
movq -0x20(%rbp), %rdx
callq 0xc64e0
leaq -0x3c(%rbp), %rdi
movss 0x9b867(%rip), %xmm1    # 0x1727a4
movaps %xmm1, %xmm0
callq 0xbf4c0
movq -0x20(%rbp), %rax
movq -0x3c(%rbp), %rcx
movq %rcx, 0x10(%rax)
movl -0xc(%rbp), %eax
andl $0x100, %eax            # imm = 0x100
cmpl $0x0, %eax
jne 0xd6fd4
movq -0x20(%rbp), %rax
movl 0x8(%rax), %edi
callq 0xe10b0
movq %rax, -0x48(%rbp)
cmpq $0x0, -0x48(%rbp)
je 0xd6fd2
movq -0x18(%rbp), %rdi
addq $0x3108, %rdi           # imm = 0x3108
movq -0x48(%rbp), %rsi
callq 0xee1c0
movl %eax, %ecx
movq -0x20(%rbp), %rax
movl %ecx, 0x2b4(%rax)
movq -0x20(%rbp), %rdi
movl $0x4, %esi
xorl %edx, %edx
callq 0xd70f0
movq -0x20(%rbp), %rdi
movq -0x48(%rbp), %rsi
callq 0xe55b0
jmp 0xd6fd2
movq -0x58(%rbp), %rsi
movq -0x50(%rbp), %rdi
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x30(%rbp)
movl %eax, -0x34(%rbp)
callq 0xea550
jmp 0xd70e5
jmp 0xd6fd4
movq -0x20(%rbp), %rax
movq -0x20(%rbp), %rcx
movq 0x10(%rax), %rax
movq %rax, 0xf0(%rcx)
movq -0x20(%rbp), %rax
movq 0xf0(%rcx), %rcx
movq %rcx, 0xe8(%rax)
movl -0xc(%rbp), %eax
andl $0x40, %eax
cmpl $0x0, %eax
je 0xd7027
movq -0x20(%rbp), %rax
movb $0x2, 0xa5(%rax)
movq -0x20(%rbp), %rax
movb $0x2, 0xa4(%rax)
movq -0x20(%rbp), %rax
movb $0x0, 0xa7(%rax)
jmp 0xd7090
movq -0x20(%rbp), %rax
xorps %xmm0, %xmm0
ucomiss 0x18(%rax), %xmm0
jb 0xd703f
movq -0x20(%rbp), %rax
movb $0x2, 0xa4(%rax)
movq -0x20(%rbp), %rax
xorps %xmm0, %xmm0
ucomiss 0x1c(%rax), %xmm0
jb 0xd7057
movq -0x20(%rbp), %rax
movb $0x2, 0xa5(%rax)
movq -0x20(%rbp), %rax
movsbl 0xa4(%rax), %ecx
movb $0x1, %al
cmpl $0x0, %ecx
movb %al, -0x61(%rbp)
jg 0xd7080
movq -0x20(%rbp), %rax
movsbl 0xa5(%rax), %eax
cmpl $0x0, %eax
setg %al
movb %al, -0x61(%rbp)
movb -0x61(%rbp), %cl
movq -0x20(%rbp), %rax
andb $0x1, %cl
movb %cl, 0xa7(%rax)
movq -0x18(%rbp), %rdi
addq $0x1a98, %rdi           # imm = 0x1A98
leaq -0x20(%rbp), %rsi
callq 0xeb620
movl -0xc(%rbp), %eax
andl $0x2000, %eax           # imm = 0x2000
cmpl $0x0, %eax
je 0xd70c7
movq -0x18(%rbp), %rdi
addq $0x1a88, %rdi           # imm = 0x1A88
leaq -0x20(%rbp), %rsi
callq 0xee260
jmp 0xd70db
movq -0x18(%rbp), %rdi
addq $0x1a88, %rdi           # imm = 0x1A88
leaq -0x20(%rbp), %rsi
callq 0xeb620
movq -0x20(%rbp), %rax
addq $0x70, %rsp
popq %rbp
retq
movq -0x30(%rbp), %rdi
callq 0xd620
nop