// File: Ciaxur[P]yagb-emu/include/imgui/imgui.cpp
// Function: WindowSettingsHandler_WriteAll(ImGuiContext*, ImGuiSettingsHandler*, ImGuiTextBuffer*)
static void WindowSettingsHandler_WriteAll(ImGuiContext* ctx, ImGuiSettingsHandler* handler, ImGuiTextBuffer* buf)
{
    // Gather data from windows that were active during this session
    // (if a window wasn't opened in this session we preserve its settings)
    ImGuiContext& g = *ctx;
    for (int i = 0; i != g.Windows.Size; i++)
    {
        ImGuiWindow* window = g.Windows[i];
        if (window->Flags & ImGuiWindowFlags_NoSavedSettings)
            continue;

        ImGuiWindowSettings* settings = (window->SettingsOffset != -1) ? g.SettingsWindows.ptr_from_offset(window->SettingsOffset) : ImGui::FindWindowSettings(window->ID);
        if (!settings)
        {
            settings = ImGui::CreateNewWindowSettings(window->Name);
            window->SettingsOffset = g.SettingsWindows.offset_from_ptr(settings);
        }
        IM_ASSERT(settings->ID == window->ID);
        settings->Pos = ImVec2ih((short)window->Pos.x, (short)window->Pos.y);
        settings->Size = ImVec2ih((short)window->SizeFull.x, (short)window->SizeFull.y);
        settings->Collapsed = window->Collapsed;
    }

    // Write to text buffer
    buf->reserve(buf->size() + g.SettingsWindows.size() * 6); // ballpark reserve
    for (ImGuiWindowSettings* settings = g.SettingsWindows.begin(); settings != NULL; settings = g.SettingsWindows.next_chunk(settings))
    {
        const char* settings_name = settings->GetName();
        buf->appendf("[%s][%s]\n", handler->TypeName, settings_name);
        buf->appendf("Pos=%d,%d\n", settings->Pos.x, settings->Pos.y);
        buf->appendf("Size=%d,%d\n", settings->Size.x, settings->Size.y);
        buf->appendf("Collapsed=%d\n", settings->Collapsed);
        buf->append("\n");
    }
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x70, %rsp
movq %rdi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
movq %rdx, -0x18(%rbp)
movq -0x8(%rbp), %rax
movq %rax, -0x20(%rbp)
movl $0x0, -0x24(%rbp)
movl -0x24(%rbp), %eax
movq -0x20(%rbp), %rcx
cmpl 0x1a88(%rcx), %eax
je 0xd3216
movq -0x20(%rbp), %rdi
addq $0x1a88, %rdi           # imm = 0x1A88
movl -0x24(%rbp), %esi
callq 0xea8d0
movq (%rax), %rax
movq %rax, -0x30(%rbp)
movq -0x30(%rbp), %rax
movl 0xc(%rax), %eax
andl $0x100, %eax            # imm = 0x100
cmpl $0x0, %eax
je 0xd30f6
jmp 0xd3208
movq -0x30(%rbp), %rax
cmpl $-0x1, 0x2b4(%rax)
je 0xd3123
movq -0x20(%rbp), %rdi
addq $0x3108, %rdi           # imm = 0x3108
movq -0x30(%rbp), %rax
movl 0x2b4(%rax), %esi
callq 0xee940
movq %rax, -0x58(%rbp)
jmp 0xd3133
movq -0x30(%rbp), %rax
movl 0x8(%rax), %edi
callq 0xe10b0
movq %rax, -0x58(%rbp)
movq -0x58(%rbp), %rax
movq %rax, -0x38(%rbp)
cmpq $0x0, -0x38(%rbp)
jne 0xd3172
movq -0x30(%rbp), %rax
movq (%rax), %rdi
callq 0xe0fc0
movq %rax, -0x38(%rbp)
movq -0x20(%rbp), %rdi
addq $0x3108, %rdi           # imm = 0x3108
movq -0x38(%rbp), %rsi
callq 0xee1c0
movl %eax, %ecx
movq -0x30(%rbp), %rax
movl %ecx, 0x2b4(%rax)
movq -0x38(%rbp), %rax
movl (%rax), %eax
movq -0x30(%rbp), %rcx
cmpl 0x8(%rcx), %eax
jne 0xd3183
jmp 0xd31a2
leaq 0xa4753(%rip), %rdi     # 0x1778dd
leaq 0x9fd78(%rip), %rsi     # 0x172f09
movl $0x2843, %edx           # imm = 0x2843
leaq 0xa475b(%rip), %rcx     # 0x1778f8
callq 0xd180
movq -0x30(%rbp), %rax
cvttss2si 0x10(%rax), %ecx
cvttss2si 0x14(%rax), %eax
movswl %cx, %esi
movswl %ax, %edx
leaq -0x3c(%rbp), %rdi
callq 0xee910
movq -0x38(%rbp), %rax
movl -0x3c(%rbp), %ecx
movl %ecx, 0x4(%rax)
movq -0x30(%rbp), %rax
cvttss2si 0x20(%rax), %ecx
movss 0x24(%rax), %xmm0
cvttss2si %xmm0, %eax
leaq -0x40(%rbp), %rdi
movswl %cx, %esi
movswl %ax, %edx
callq 0xee910
movq -0x38(%rbp), %rax
movl -0x40(%rbp), %ecx
movl %ecx, 0x8(%rax)
movq -0x30(%rbp), %rax
movb 0x91(%rax), %cl
movq -0x38(%rbp), %rax
andb $0x1, %cl
movb %cl, 0xc(%rax)
movl -0x24(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x24(%rbp)
jmp 0xd30b3
movq -0x18(%rbp), %rax
movq %rax, -0x60(%rbp)
movq -0x18(%rbp), %rdi
callq 0xec2b0
movl %eax, -0x64(%rbp)
movq -0x20(%rbp), %rdi
addq $0x3108, %rdi           # imm = 0x3108
callq 0xec6f0
movl -0x64(%rbp), %esi
movq -0x60(%rbp), %rdi
imull $0x6, %eax, %eax
addl %eax, %esi
callq 0xee9b0
movq -0x20(%rbp), %rdi
addq $0x3108, %rdi           # imm = 0x3108
callq 0xec430
movq %rax, -0x48(%rbp)
cmpq $0x0, -0x48(%rbp)
je 0xd3327
movq -0x48(%rbp), %rdi
callq 0xec410
movq %rax, -0x50(%rbp)
movq -0x18(%rbp), %rdi
movq -0x10(%rbp), %rax
movq (%rax), %rdx
movq -0x50(%rbp), %rcx
leaq 0xa46ca(%rip), %rsi     # 0x177957
movb $0x0, %al
callq 0xc6bd0
movq -0x18(%rbp), %rdi
movq -0x48(%rbp), %rax
movswl 0x4(%rax), %edx
movq -0x48(%rbp), %rax
movswl 0x6(%rax), %ecx
leaq 0xa46b2(%rip), %rsi     # 0x177961
movb $0x0, %al
callq 0xc6bd0
movq -0x18(%rbp), %rdi
movq -0x48(%rbp), %rax
movswl 0x8(%rax), %edx
movq -0x48(%rbp), %rax
movswl 0xa(%rax), %ecx
leaq 0xa469b(%rip), %rsi     # 0x17796c
movb $0x0, %al
callq 0xc6bd0
movq -0x18(%rbp), %rdi
movq -0x48(%rbp), %rax
movb 0xc(%rax), %al
andb $0x1, %al
movzbl %al, %edx
leaq 0xa4689(%rip), %rsi     # 0x177978
movb $0x0, %al
callq 0xc6bd0
movq -0x18(%rbp), %rdi
leaq 0xabbc3(%rip), %rsi     # 0x17eec4
xorl %eax, %eax
movl %eax, %edx
callq 0xc6ad0
movq -0x20(%rbp), %rdi
addq $0x3108, %rdi           # imm = 0x3108
movq -0x48(%rbp), %rsi
callq 0xec470
movq %rax, -0x48(%rbp)
jmp 0xd325f
addq $0x70, %rsp
popq %rbp
retq
nopl (%rax)