// File: Ciaxur[P]yagb-emu/include/imgui/imgui_tables.cpp
// Function: ImGui::TableSaveSettings(ImGuiTable*)
void ImGui::TableSaveSettings(ImGuiTable* table)
{
    table->IsSettingsDirty = false;
    if (table->Flags & ImGuiTableFlags_NoSavedSettings)
        return;

    // Bind or create settings data
    ImGuiContext& g = *GImGui;
    ImGuiTableSettings* settings = TableGetBoundSettings(table);
    if (settings == NULL)
    {
        settings = TableSettingsCreate(table->ID, table->ColumnsCount);
        table->SettingsOffset = g.SettingsTables.offset_from_ptr(settings);
    }
    settings->ColumnsCount = (ImGuiTableColumnIdx)table->ColumnsCount;

    // Serialize ImGuiTable/ImGuiTableColumn into ImGuiTableSettings/ImGuiTableColumnSettings
    IM_ASSERT(settings->ID == table->ID);
    IM_ASSERT(settings->ColumnsCount == table->ColumnsCount && settings->ColumnsCountMax >= settings->ColumnsCount);
    ImGuiTableColumn* column = table->Columns.Data;
    ImGuiTableColumnSettings* column_settings = settings->GetColumnSettings();

    bool save_ref_scale = false;
    settings->SaveFlags = ImGuiTableFlags_None;
    for (int n = 0; n < table->ColumnsCount; n++, column++, column_settings++)
    {
        const float width_or_weight = (column->Flags & ImGuiTableColumnFlags_WidthStretch) ? column->StretchWeight : column->WidthRequest;
        column_settings->WidthOrWeight = width_or_weight;
        column_settings->Index = (ImGuiTableColumnIdx)n;
        column_settings->DisplayOrder = column->DisplayOrder;
        column_settings->SortOrder = column->SortOrder;
        column_settings->SortDirection = column->SortDirection;
        column_settings->IsEnabled = column->IsEnabled;
        column_settings->IsStretch = (column->Flags & ImGuiTableColumnFlags_WidthStretch) ? 1 : 0;
        if ((column->Flags & ImGuiTableColumnFlags_WidthStretch) == 0)
            save_ref_scale = true;

        // We skip saving some data in the .ini file when they are unnecessary to restore our state.
        // Note that fixed width where initial width was derived from auto-fit will always be saved as InitStretchWeightOrWidth will be 0.0f.
        // FIXME-TABLE: We don't have logic to easily compare SortOrder to DefaultSortOrder yet so it's always saved when present.
        if (width_or_weight != column->InitStretchWeightOrWidth)
            settings->SaveFlags |= ImGuiTableFlags_Resizable;
        if (column->DisplayOrder != n)
            settings->SaveFlags |= ImGuiTableFlags_Reorderable;
        if (column->SortOrder != -1)
            settings->SaveFlags |= ImGuiTableFlags_Sortable;
        if (column->IsEnabled != ((column->Flags & ImGuiTableColumnFlags_DefaultHide) == 0))
            settings->SaveFlags |= ImGuiTableFlags_Hideable;
    }
    settings->SaveFlags &= table->Flags;
    settings->RefScale = save_ref_scale ? table->RefScale : 0.0f;

    MarkIniSettingsDirty();
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x40, %rsp
movq %rdi, -0x8(%rbp)
movq -0x8(%rbp), %rax
movb $0x0, 0x24f(%rax)
movq -0x8(%rbp), %rax
movl 0x4(%rax), %eax
andl $0x10, %eax
cmpl $0x0, %eax
je 0x13069b
jmp 0x1309a0
leaq 0xe289e(%rip), %rax     # 0x212f40
movq (%rax), %rax
movq %rax, -0x10(%rbp)
movq -0x8(%rbp), %rdi
callq 0x1338a0
movq %rax, -0x18(%rbp)
cmpq $0x0, -0x18(%rbp)
jne 0x1306f0
movq -0x8(%rbp), %rax
movl (%rax), %edi
movq -0x8(%rbp), %rax
movl 0x6c(%rax), %esi
callq 0x1336a0
movq %rax, -0x18(%rbp)
movq -0x10(%rbp), %rdi
addq $0x3118, %rdi           # imm = 0x3118
movq -0x18(%rbp), %rsi
callq 0x137870
movl %eax, %ecx
movq -0x8(%rbp), %rax
movl %ecx, 0x64(%rax)
movq -0x8(%rbp), %rax
movl 0x6c(%rax), %eax
movb %al, %cl
movq -0x18(%rbp), %rax
movb %cl, 0xc(%rax)
movq -0x18(%rbp), %rax
movl (%rax), %eax
movq -0x8(%rbp), %rcx
cmpl (%rcx), %eax
jne 0x130710
jmp 0x13072f
leaq 0x5ccce(%rip), %rdi     # 0x18d3e5
leaq 0x5b884(%rip), %rsi     # 0x18bfa2
movl $0xc1a, %edx            # imm = 0xC1A
leaq 0x5cd14(%rip), %rcx     # 0x18d43e
callq 0xd180
movq -0x18(%rbp), %rax
movsbl 0xc(%rax), %ecx
movq -0x8(%rbp), %rdx
xorl %eax, %eax
cmpl 0x6c(%rdx), %ecx
movb %al, -0x35(%rbp)
jne 0x13075d
movq -0x18(%rbp), %rax
movsbl 0xd(%rax), %eax
movq -0x18(%rbp), %rcx
movsbl 0xc(%rcx), %ecx
cmpl %ecx, %eax
setge %al
movb %al, -0x35(%rbp)
movb -0x35(%rbp), %al
testb $0x1, %al
jne 0x130766
jmp 0x130768
jmp 0x130787
leaq 0x5ccfb(%rip), %rdi     # 0x18d46a
leaq 0x5b82c(%rip), %rsi     # 0x18bfa2
movl $0xc1b, %edx            # imm = 0xC1B
leaq 0x5ccbc(%rip), %rcx     # 0x18d43e
callq 0xd180
movq -0x8(%rbp), %rax
movq 0x10(%rax), %rax
movq %rax, -0x20(%rbp)
movq -0x18(%rbp), %rdi
callq 0x137910
movq %rax, -0x28(%rbp)
movb $0x0, -0x29(%rbp)
movq -0x18(%rbp), %rax
movl $0x0, 0x4(%rax)
movl $0x0, -0x30(%rbp)
movl -0x30(%rbp), %eax
movq -0x8(%rbp), %rcx
cmpl 0x6c(%rcx), %eax
jge 0x130959
movq -0x20(%rbp), %rax
movl (%rax), %eax
andl $0x4, %eax
cmpl $0x0, %eax
je 0x1307e4
movq -0x20(%rbp), %rax
movss 0x18(%rax), %xmm0
movss %xmm0, -0x3c(%rbp)
jmp 0x1307f2
movq -0x20(%rbp), %rax
movss 0x10(%rax), %xmm0
movss %xmm0, -0x3c(%rbp)
movss -0x3c(%rbp), %xmm0
movss %xmm0, -0x34(%rbp)
movss -0x34(%rbp), %xmm0
movq -0x28(%rbp), %rax
movss %xmm0, (%rax)
movl -0x30(%rbp), %eax
movb %al, %cl
movq -0x28(%rbp), %rax
movb %cl, 0x8(%rax)
movq -0x20(%rbp), %rax
movb 0x52(%rax), %cl
movq -0x28(%rbp), %rax
movb %cl, 0x9(%rax)
movq -0x20(%rbp), %rax
movb 0x56(%rax), %cl
movq -0x28(%rbp), %rax
movb %cl, 0xa(%rax)
movq -0x20(%rbp), %rax
movb 0x64(%rax), %dl
andb $0x3, %dl
movq -0x28(%rbp), %rax
movb 0xb(%rax), %cl
andb $0x3, %dl
andb $-0x4, %cl
orb %dl, %cl
movb %cl, 0xb(%rax)
movq -0x20(%rbp), %rax
movb 0x5a(%rax), %dl
andb $0x1, %dl
movq -0x28(%rbp), %rax
movb 0xb(%rax), %cl
andb $0x1, %dl
shlb $0x2, %dl
andb $-0x5, %cl
orb %dl, %cl
movb %cl, 0xb(%rax)
movq -0x20(%rbp), %rax
movl (%rax), %edx
andl $0x4, %edx
xorl %eax, %eax
movl $0x1, %ecx
cmpl $0x0, %edx
cmovnel %ecx, %eax
movb %al, %dl
movq -0x28(%rbp), %rax
movb 0xb(%rax), %cl
andb $0x1, %dl
shlb $0x3, %dl
andb $-0x9, %cl
orb %dl, %cl
movb %cl, 0xb(%rax)
movq -0x20(%rbp), %rax
movl (%rax), %eax
andl $0x4, %eax
cmpl $0x0, %eax
jne 0x1308ab
movb $0x1, -0x29(%rbp)
movss -0x34(%rbp), %xmm0
movq -0x20(%rbp), %rax
ucomiss 0x1c(%rax), %xmm0
jne 0x1308be
jp 0x1308be
jmp 0x1308cb
movq -0x18(%rbp), %rax
movl 0x4(%rax), %ecx
orl $0x1, %ecx
movl %ecx, 0x4(%rax)
movq -0x20(%rbp), %rax
movsbl 0x52(%rax), %eax
cmpl -0x30(%rbp), %eax
je 0x1308e5
movq -0x18(%rbp), %rax
movl 0x4(%rax), %ecx
orl $0x2, %ecx
movl %ecx, 0x4(%rax)
movq -0x20(%rbp), %rax
movsbl 0x56(%rax), %eax
cmpl $-0x1, %eax
je 0x1308ff
movq -0x18(%rbp), %rax
movl 0x4(%rax), %ecx
orl $0x8, %ecx
movl %ecx, 0x4(%rax)
movq -0x20(%rbp), %rax
movb 0x5a(%rax), %al
andb $0x1, %al
movzbl %al, %eax
movq -0x20(%rbp), %rcx
movl (%rcx), %ecx
andl $0x1, %ecx
cmpl $0x0, %ecx
sete %cl
andb $0x1, %cl
movzbl %cl, %ecx
cmpl %ecx, %eax
je 0x130931
movq -0x18(%rbp), %rax
movl 0x4(%rax), %ecx
orl $0x4, %ecx
movl %ecx, 0x4(%rax)
jmp 0x130933
movl -0x30(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x30(%rbp)
movq -0x20(%rbp), %rax
addq $0x68, %rax
movq %rax, -0x20(%rbp)
movq -0x28(%rbp), %rax
addq $0xc, %rax
movq %rax, -0x28(%rbp)
jmp 0x1307b6
movq -0x8(%rbp), %rax
movl 0x4(%rax), %ecx
movq -0x18(%rbp), %rax
andl 0x4(%rax), %ecx
movl %ecx, 0x4(%rax)
testb $0x1, -0x29(%rbp)
je 0x130983
movq -0x8(%rbp), %rax
movss 0xe8(%rax), %xmm0
movss %xmm0, -0x40(%rbp)
jmp 0x13098d
xorps %xmm0, %xmm0
movss %xmm0, -0x40(%rbp)
jmp 0x13098d
movss -0x40(%rbp), %xmm0
movq -0x18(%rbp), %rax
movss %xmm0, 0x8(%rax)
callq 0xe0f80
addq $0x40, %rsp
popq %rbp
retq
nopw %cs:(%rax,%rax)