// File: donfreiday[P]gb/./imgui/imgui.cpp
// Function: CreateNewWindow(char const*, ImVec2, int)
static ImGuiWindow* CreateNewWindow(const char* name, ImVec2 size, ImGuiWindowFlags flags)
{
    ImGuiState& g = *GImGui;

    // Create window the first time
    ImGuiWindow* window = (ImGuiWindow*)ImGui::MemAlloc(sizeof(ImGuiWindow));
    new(window) ImGuiWindow(name);
    window->Flags = flags;

    if (flags & ImGuiWindowFlags_NoSavedSettings)
    {
        // User can disable loading and saving of settings. Tooltip and child windows also don't store settings.
        window->Size = window->SizeFull = size;
    }
    else
    {
        // Retrieve settings from .ini file
        // Use SetWindowPos() or SetNextWindowPos() with the appropriate condition flag to change the initial position of a window.
        window->PosFloat = ImVec2(60, 60);
        window->Pos = ImVec2((float)(int)window->PosFloat.x, (float)(int)window->PosFloat.y);

        ImGuiIniData* settings = FindWindowSettings(name);
        if (!settings)
        {
            settings = AddWindowSettings(name);
        }
        else
        {
            window->SetWindowPosAllowFlags &= ~ImGuiSetCond_FirstUseEver;
            window->SetWindowSizeAllowFlags &= ~ImGuiSetCond_FirstUseEver;
            window->SetWindowCollapsedAllowFlags &= ~ImGuiSetCond_FirstUseEver;
        }

        if (settings->Pos.x != FLT_MAX)
        {
            window->PosFloat = settings->Pos;
            window->Pos = ImVec2((float)(int)window->PosFloat.x, (float)(int)window->PosFloat.y);
            window->Collapsed = settings->Collapsed;
        }

        if (ImLengthSqr(settings->Size) > 0.00001f && !(flags & ImGuiWindowFlags_NoResize))
            size = settings->Size;
        window->Size = window->SizeFull = size;
    }

    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.Windows.push_back(window);
    return window;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x50, %rsp
movlpd %xmm0, -0x8(%rbp)
movq %rdi, -0x10(%rbp)
movl %esi, -0x14(%rbp)
movq 0x631d5(%rip), %rax     # 0x794c0
movq %rax, -0x20(%rbp)
movl $0x2a0, %edi            # imm = 0x2A0
callq 0x93d0
movq %rax, -0x28(%rbp)
movq -0x28(%rbp), %rdi
movq -0x10(%rbp), %rsi
callq 0xb830
movl -0x14(%rbp), %ecx
movq -0x28(%rbp), %rax
movl %ecx, 0xc(%rax)
movl -0x14(%rbp), %eax
andl $0x100, %eax            # imm = 0x100
cmpl $0x0, %eax
je 0x1633e
movq -0x28(%rbp), %rcx
movq -0x8(%rbp), %rax
movq %rax, 0x28(%rcx)
movq -0x28(%rbp), %rax
movq 0x28(%rcx), %rcx
movq %rcx, 0x20(%rax)
jmp 0x1649c
leaq -0x30(%rbp), %rdi
movss 0x44da2(%rip), %xmm1    # 0x5b0ec
movaps %xmm1, %xmm0
callq 0x2d280
movq -0x28(%rbp), %rax
movq -0x30(%rbp), %rcx
movq %rcx, 0x10(%rax)
movq -0x28(%rbp), %rax
cvttss2si 0x10(%rax), %eax
cvtsi2ss %eax, %xmm0
movq -0x28(%rbp), %rax
cvttss2si 0x14(%rax), %eax
cvtsi2ss %eax, %xmm1
leaq -0x38(%rbp), %rdi
callq 0x2d280
movq -0x28(%rbp), %rax
movq -0x38(%rbp), %rcx
movq %rcx, 0x18(%rax)
movq -0x10(%rbp), %rdi
callq 0x2af40
movq %rax, -0x40(%rbp)
cmpq $0x0, -0x40(%rbp)
jne 0x163b0
movq -0x10(%rbp), %rdi
callq 0x2afd0
movq %rax, -0x40(%rbp)
jmp 0x163e9
movq -0x28(%rbp), %rax
movl 0x94(%rax), %ecx
andl $-0x5, %ecx
movl %ecx, 0x94(%rax)
movq -0x28(%rbp), %rax
movl 0x98(%rax), %ecx
andl $-0x5, %ecx
movl %ecx, 0x98(%rax)
movq -0x28(%rbp), %rax
movl 0x9c(%rax), %ecx
andl $-0x5, %ecx
movl %ecx, 0x9c(%rax)
movq -0x40(%rbp), %rax
movss 0xc(%rax), %xmm0
movss 0x44ca2(%rip), %xmm1    # 0x5b09c
ucomiss %xmm1, %xmm0
jne 0x16403
jp 0x16403
jmp 0x16453
movq -0x40(%rbp), %rcx
movq -0x28(%rbp), %rax
movq 0xc(%rcx), %rcx
movq %rcx, 0x10(%rax)
movq -0x28(%rbp), %rax
cvttss2si 0x10(%rax), %eax
cvtsi2ss %eax, %xmm0
movq -0x28(%rbp), %rax
cvttss2si 0x14(%rax), %eax
cvtsi2ss %eax, %xmm1
leaq -0x48(%rbp), %rdi
callq 0x2d280
movq -0x28(%rbp), %rax
movq -0x48(%rbp), %rcx
movq %rcx, 0x18(%rax)
movq -0x40(%rbp), %rax
movb 0x1c(%rax), %cl
movq -0x28(%rbp), %rax
andb $0x1, %cl
movb %cl, 0x73(%rax)
movq -0x40(%rbp), %rdi
addq $0x14, %rdi
callq 0xdf70
movss 0x44c3c(%rip), %xmm1    # 0x5b0a4
ucomiss %xmm1, %xmm0
jbe 0x16484
movl -0x14(%rbp), %eax
andl $0x2, %eax
cmpl $0x0, %eax
jne 0x16484
movq -0x40(%rbp), %rax
movq 0x14(%rax), %rax
movq %rax, -0x8(%rbp)
movq -0x28(%rbp), %rcx
movq -0x8(%rbp), %rax
movq %rax, 0x28(%rcx)
movq -0x28(%rbp), %rax
movq 0x28(%rcx), %rcx
movq %rcx, 0x20(%rax)
movl -0x14(%rbp), %eax
andl $0x40, %eax
cmpl $0x0, %eax
je 0x164d0
movq -0x28(%rbp), %rax
movl $0x2, 0x84(%rax)
movq -0x28(%rbp), %rax
movl $0x2, 0x80(%rax)
movq -0x28(%rbp), %rax
movb $0x0, 0x88(%rax)
jmp 0x16539
movq -0x28(%rbp), %rax
xorps %xmm0, %xmm0
ucomiss 0x20(%rax), %xmm0
jb 0x164eb
movq -0x28(%rbp), %rax
movl $0x2, 0x80(%rax)
movq -0x28(%rbp), %rax
xorps %xmm0, %xmm0
ucomiss 0x24(%rax), %xmm0
jb 0x16506
movq -0x28(%rbp), %rax
movl $0x2, 0x84(%rax)
movq -0x28(%rbp), %rcx
movb $0x1, %al
cmpl $0x0, 0x80(%rcx)
movb %al, -0x49(%rbp)
jg 0x16529
movq -0x28(%rbp), %rax
cmpl $0x0, 0x84(%rax)
setg %al
movb %al, -0x49(%rbp)
movb -0x49(%rbp), %cl
movq -0x28(%rbp), %rax
andb $0x1, %cl
movb %cl, 0x88(%rax)
movq -0x20(%rbp), %rdi
addq $0x1738, %rdi           # imm = 0x1738
leaq -0x28(%rbp), %rsi
callq 0x2ef90
movq -0x28(%rbp), %rax
addq $0x50, %rsp
popq %rbp
retq
nopw (%rax,%rax)