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

    // Bind settings
    ImGuiTableSettings* settings;
    if (table->SettingsOffset == -1)
    {
        settings = TableSettingsFindByID(table->ID);
        if (settings == NULL)
            return;
        if (settings->ColumnsCount != table->ColumnsCount) // Allow settings if columns count changed. We could otherwise decide to return...
            table->IsSettingsDirty = true;
        table->SettingsOffset = g.SettingsTables.offset_from_ptr(settings);
    }
    else
    {
        settings = TableGetBoundSettings(table);
    }

    table->SettingsLoadedFlags = settings->SaveFlags;
    table->RefScale = settings->RefScale;

    // Serialize ImGuiTableSettings/ImGuiTableColumnSettings into ImGuiTable/ImGuiTableColumn
    ImGuiTableColumnSettings* column_settings = settings->GetColumnSettings();
    ImU64 display_order_mask = 0;
    for (int data_n = 0; data_n < settings->ColumnsCount; data_n++, column_settings++)
    {
        int column_n = column_settings->Index;
        if (column_n < 0 || column_n >= table->ColumnsCount)
            continue;

        ImGuiTableColumn* column = &table->Columns[column_n];
        if (settings->SaveFlags & ImGuiTableFlags_Resizable)
        {
            if (column_settings->IsStretch)
                column->StretchWeight = column_settings->WidthOrWeight;
            else
                column->WidthRequest = column_settings->WidthOrWeight;
            column->AutoFitQueue = 0x00;
        }
        if (settings->SaveFlags & ImGuiTableFlags_Reorderable)
            column->DisplayOrder = column_settings->DisplayOrder;
        else
            column->DisplayOrder = (ImGuiTableColumnIdx)column_n;
        display_order_mask |= (ImU64)1 << column->DisplayOrder;
        column->IsEnabled = column->IsEnabledNextFrame = column_settings->IsEnabled;
        column->SortOrder = column_settings->SortOrder;
        column->SortDirection = column_settings->SortDirection;
    }

    // Validate and fix invalid display order data
    const ImU64 expected_display_order_mask = (settings->ColumnsCount == 64) ? ~0 : ((ImU64)1 << settings->ColumnsCount) - 1;
    if (display_order_mask != expected_display_order_mask)
        for (int column_n = 0; column_n < table->ColumnsCount; column_n++)
            table->Columns[column_n].DisplayOrder = (ImGuiTableColumnIdx)column_n;

    // Rebuild index
    for (int column_n = 0; column_n < table->ColumnsCount; column_n++)
        table->DisplayOrderToIndex[table->Columns[column_n].DisplayOrder] = (ImGuiTableColumnIdx)column_n;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x60, %rsp
movq %rdi, -0x8(%rbp)
leaq 0xe86fd(%rip), %rax     # 0x212f40
movq (%rax), %rax
movq %rax, -0x10(%rbp)
movq -0x8(%rbp), %rax
movb $0x0, 0x24e(%rax)
movq -0x8(%rbp), %rax
movl 0x4(%rax), %eax
andl $0x10, %eax
cmpl $0x0, %eax
je 0x12a869
jmp 0x12ab31
movq -0x8(%rbp), %rax
cmpl $-0x1, 0x64(%rax)
jne 0x12a8c9
movq -0x8(%rbp), %rax
movl (%rax), %edi
callq 0x133820
movq %rax, -0x18(%rbp)
cmpq $0x0, -0x18(%rbp)
jne 0x12a88e
jmp 0x12ab31
movq -0x18(%rbp), %rax
movsbl 0xc(%rax), %eax
movq -0x8(%rbp), %rcx
cmpl 0x6c(%rcx), %eax
je 0x12a8aa
movq -0x8(%rbp), %rax
movb $0x1, 0x24f(%rax)
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)
jmp 0x12a8d6
movq -0x8(%rbp), %rdi
callq 0x1338a0
movq %rax, -0x18(%rbp)
movq -0x18(%rbp), %rax
movl 0x4(%rax), %ecx
movq -0x8(%rbp), %rax
movl %ecx, 0x60(%rax)
movq -0x18(%rbp), %rax
movss 0x8(%rax), %xmm0
movq -0x8(%rbp), %rax
movss %xmm0, 0xe8(%rax)
movq -0x18(%rbp), %rdi
callq 0x137910
movq %rax, -0x20(%rbp)
movq $0x0, -0x28(%rbp)
movl $0x0, -0x2c(%rbp)
movl -0x2c(%rbp), %eax
movq -0x18(%rbp), %rcx
movsbl 0xc(%rcx), %ecx
cmpl %ecx, %eax
jge 0x12aa5b
movq -0x20(%rbp), %rax
movsbl 0x8(%rax), %eax
movl %eax, -0x30(%rbp)
cmpl $0x0, -0x30(%rbp)
jl 0x12a945
movl -0x30(%rbp), %eax
movq -0x8(%rbp), %rcx
cmpl 0x6c(%rcx), %eax
jl 0x12a94a
jmp 0x12aa41
movq -0x8(%rbp), %rdi
addq $0x10, %rdi
movl -0x30(%rbp), %esi
callq 0xeea20
movq %rax, -0x38(%rbp)
movq -0x18(%rbp), %rax
movl 0x4(%rax), %eax
andl $0x1, %eax
cmpl $0x0, %eax
je 0x12a9a9
movq -0x20(%rbp), %rax
movb 0xb(%rax), %al
shrb $0x3, %al
andb $0x1, %al
cmpb $0x0, %al
je 0x12a990
movq -0x20(%rbp), %rax
movss (%rax), %xmm0
movq -0x38(%rbp), %rax
movss %xmm0, 0x18(%rax)
jmp 0x12a9a1
movq -0x20(%rbp), %rax
movss (%rax), %xmm0
movq -0x38(%rbp), %rax
movss %xmm0, 0x10(%rax)
movq -0x38(%rbp), %rax
movb $0x0, 0x62(%rax)
movq -0x18(%rbp), %rax
movl 0x4(%rax), %eax
andl $0x2, %eax
cmpl $0x0, %eax
je 0x12a9c8
movq -0x20(%rbp), %rax
movb 0x9(%rax), %cl
movq -0x38(%rbp), %rax
movb %cl, 0x52(%rax)
jmp 0x12a9d4
movl -0x30(%rbp), %eax
movb %al, %cl
movq -0x38(%rbp), %rax
movb %cl, 0x52(%rax)
movq -0x38(%rbp), %rax
movsbl 0x52(%rax), %eax
movl %eax, %eax
movl %eax, %ecx
movl $0x1, %eax
shlq %cl, %rax
orq -0x28(%rbp), %rax
movq %rax, -0x28(%rbp)
movq -0x20(%rbp), %rax
movb 0xb(%rax), %al
shrb $0x2, %al
andb $0x1, %al
cmpb $0x0, %al
setne %cl
movq -0x38(%rbp), %rax
movb %cl, %dl
andb $0x1, %dl
movb %dl, 0x5b(%rax)
movq -0x38(%rbp), %rax
andb $0x1, %cl
movb %cl, 0x5a(%rax)
movq -0x20(%rbp), %rax
movb 0xa(%rax), %cl
movq -0x38(%rbp), %rax
movb %cl, 0x56(%rax)
movq -0x20(%rbp), %rax
movb 0xb(%rax), %dl
andb $0x3, %dl
movq -0x38(%rbp), %rax
movb 0x64(%rax), %cl
andb $0x3, %dl
andb $-0x4, %cl
orb %dl, %cl
movb %cl, 0x64(%rax)
movl -0x2c(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x2c(%rbp)
movq -0x20(%rbp), %rax
addq $0xc, %rax
movq %rax, -0x20(%rbp)
jmp 0x12a915
movq -0x18(%rbp), %rax
movsbl 0xc(%rax), %eax
cmpl $0x40, %eax
jne 0x12aa75
movq $-0x1, %rax
movq %rax, -0x50(%rbp)
jmp 0x12aa91
movq -0x18(%rbp), %rax
movsbl 0xc(%rax), %eax
movl %eax, %eax
movl %eax, %ecx
movl $0x1, %eax
shlq %cl, %rax
subq $0x1, %rax
movq %rax, -0x50(%rbp)
movq -0x50(%rbp), %rax
movq %rax, -0x40(%rbp)
movq -0x28(%rbp), %rax
cmpq -0x40(%rbp), %rax
je 0x12aadf
movl $0x0, -0x44(%rbp)
movl -0x44(%rbp), %eax
movq -0x8(%rbp), %rcx
cmpl 0x6c(%rcx), %eax
jge 0x12aadd
movl -0x44(%rbp), %eax
movb %al, -0x51(%rbp)
movq -0x8(%rbp), %rdi
addq $0x10, %rdi
movl -0x44(%rbp), %esi
callq 0xeea20
movb -0x51(%rbp), %cl
movb %cl, 0x52(%rax)
movl -0x44(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x44(%rbp)
jmp 0x12aaaa
jmp 0x12aadf
movl $0x0, -0x48(%rbp)
movl -0x48(%rbp), %eax
movq -0x8(%rbp), %rcx
cmpl 0x6c(%rcx), %eax
jge 0x12ab31
movl -0x48(%rbp), %eax
movb %al, -0x52(%rbp)
movq -0x8(%rbp), %rax
addq $0x20, %rax
movq %rax, -0x60(%rbp)
movq -0x8(%rbp), %rdi
addq $0x10, %rdi
movl -0x48(%rbp), %esi
callq 0xeea20
movq -0x60(%rbp), %rdi
movsbl 0x52(%rax), %esi
callq 0x1370a0
movb -0x52(%rbp), %cl
movb %cl, (%rax)
movl -0x48(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x48(%rbp)
jmp 0x12aae6
addq $0x60, %rsp
popq %rbp
retq
nopw (%rax,%rax)