// File: donfreiday[P]gb/./imgui/imgui.cpp
// Function: SaveSettings()
static void SaveSettings()
{
    ImGuiState& g = *GImGui;
    const char* filename = g.IO.IniFilename;
    if (!filename)
        return;

    // Gather data from windows that were active during this session
    for (int i = 0; i != g.Windows.Size; i++)
    {
        ImGuiWindow* window = g.Windows[i];
        if (window->Flags & ImGuiWindowFlags_NoSavedSettings)
            continue;
        ImGuiIniData* settings = FindWindowSettings(window->Name);
        settings->Pos = window->Pos;
        settings->Size = window->SizeFull;
        settings->Collapsed = window->Collapsed;
    }

    // Write .ini file
    // If a window wasn't opened in this session we preserve its settings
    FILE* f = fopen(filename, "wt");
    if (!f)
        return;
    for (int i = 0; i != g.Settings.Size; i++)
    {
        const ImGuiIniData* settings = &g.Settings[i];
        if (settings->Pos.x == FLT_MAX)
            continue;
        const char* name = settings->Name;
        if (const char* p = strstr(name, "###"))  // Skip to the "###" marker if any. We don't skip past to match the behavior of GetID()
            name = p;
        fprintf(f, "[%s]\n", name);
        fprintf(f, "Pos=%d,%d\n", (int)settings->Pos.x, (int)settings->Pos.y);
        fprintf(f, "Size=%d,%d\n", (int)settings->Size.x, (int)settings->Size.y);
        fprintf(f, "Collapsed=%d\n", settings->Collapsed);
        fprintf(f, "\n");
    }

    fclose(f);
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x50, %rsp
movq 0x6b501(%rip), %rax     # 0x794c0
movq %rax, -0x8(%rbp)
movq -0x8(%rbp), %rax
movq 0x18(%rax), %rax
movq %rax, -0x10(%rbp)
cmpq $0x0, -0x10(%rbp)
jne 0xdfdb
jmp 0xe1ae
movl $0x0, -0x14(%rbp)
movl -0x14(%rbp), %eax
movq -0x8(%rbp), %rcx
cmpl 0x1738(%rcx), %eax
je 0xe06d
movq -0x8(%rbp), %rdi
addq $0x1738, %rdi           # imm = 0x1738
movl -0x14(%rbp), %esi
callq 0x2e1c0
movq (%rax), %rax
movq %rax, -0x20(%rbp)
movq -0x20(%rbp), %rax
movl 0xc(%rax), %eax
andl $0x100, %eax            # imm = 0x100
cmpl $0x0, %eax
je 0xe01e
jmp 0xe05f
movq -0x20(%rbp), %rax
movq (%rax), %rdi
callq 0x2af40
movq %rax, -0x28(%rbp)
movq -0x20(%rbp), %rcx
movq -0x28(%rbp), %rax
movq 0x18(%rcx), %rcx
movq %rcx, 0xc(%rax)
movq -0x20(%rbp), %rcx
movq -0x28(%rbp), %rax
movq 0x28(%rcx), %rcx
movq %rcx, 0x14(%rax)
movq -0x20(%rbp), %rax
movb 0x73(%rax), %cl
movq -0x28(%rbp), %rax
andb $0x1, %cl
movb %cl, 0x1c(%rax)
movl -0x14(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x14(%rbp)
jmp 0xdfe2
movq -0x10(%rbp), %rdi
leaq 0x4e6ad(%rip), %rsi     # 0x5c725
callq 0x7910
movq %rax, -0x30(%rbp)
cmpq $0x0, -0x30(%rbp)
jne 0xe08d
jmp 0xe1ae
movl $0x0, -0x34(%rbp)
movl -0x34(%rbp), %eax
movq -0x8(%rbp), %rcx
cmpl 0x17b0(%rcx), %eax
je 0xe1a5
movq -0x8(%rbp), %rdi
addq $0x17b0, %rdi           # imm = 0x17B0
movl -0x34(%rbp), %esi
callq 0x2e560
movq %rax, -0x40(%rbp)
movq -0x40(%rbp), %rax
movss 0xc(%rax), %xmm0
movss 0x4cfcd(%rip), %xmm1    # 0x5b09c
ucomiss %xmm1, %xmm0
jne 0xe0db
jp 0xe0db
jmp 0xe197
movq -0x40(%rbp), %rax
movq (%rax), %rax
movq %rax, -0x48(%rbp)
movq -0x48(%rbp), %rdi
leaq 0x4e637(%rip), %rsi     # 0x5c728
callq 0x73b0
movq %rax, -0x50(%rbp)
cmpq $0x0, -0x50(%rbp)
je 0xe109
movq -0x50(%rbp), %rax
movq %rax, -0x48(%rbp)
movq -0x30(%rbp), %rdi
movq -0x48(%rbp), %rdx
leaq 0x4e614(%rip), %rsi     # 0x5c72c
movb $0x0, %al
callq 0x71a0
movq -0x30(%rbp), %rdi
movq -0x40(%rbp), %rax
cvttss2si 0xc(%rax), %edx
movq -0x40(%rbp), %rax
cvttss2si 0x10(%rax), %ecx
leaq 0x4e5f6(%rip), %rsi     # 0x5c732
movb $0x0, %al
callq 0x71a0
movq -0x30(%rbp), %rdi
movq -0x40(%rbp), %rax
cvttss2si 0x14(%rax), %edx
movq -0x40(%rbp), %rax
cvttss2si 0x18(%rax), %ecx
leaq 0x4e5dd(%rip), %rsi     # 0x5c73d
movb $0x0, %al
callq 0x71a0
movq -0x30(%rbp), %rdi
movq -0x40(%rbp), %rax
movb 0x1c(%rax), %al
andb $0x1, %al
movzbl %al, %edx
leaq 0x4e5cb(%rip), %rsi     # 0x5c749
movb $0x0, %al
callq 0x71a0
movq -0x30(%rbp), %rdi
leaq 0x510bd(%rip), %rsi     # 0x5f24d
movb $0x0, %al
callq 0x71a0
movl -0x34(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x34(%rbp)
jmp 0xe094
movq -0x30(%rbp), %rdi
callq 0x7390
addq $0x50, %rsp
popq %rbp
retq
nopw %cs:(%rax,%rax)