// File: /workspace/github_cpp_makefile_star2_O2/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
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x18, %rsp
leaq 0x73081(%rip), %rax     # 0xe3ce0
movq (%rax), %r14
movb $0x0, 0x24e(%rdi)
testb $0x10, 0x4(%rdi)
jne 0x70dd7
movq %rdi, %rbx
cmpl $-0x1, 0x64(%rdi)
je 0x70c89
movq %rbx, %rdi
callq 0x7653d
movq %rax, %rsi
jmp 0x70cc4
movl (%rbx), %edi
callq 0x764f6
testq %rax, %rax
je 0x70dd7
movsbl 0xc(%rax), %ecx
cmpl %ecx, 0x6c(%rbx)
je 0x70ca9
movb $0x1, 0x24f(%rbx)
addq $0x3118, %r14           # imm = 0x3118
movq %r14, %rdi
movq %rax, %r14
movq %rax, %rsi
callq 0x78b4c
movq %r14, %rsi
movl %eax, 0x64(%rbx)
movl 0x4(%rsi), %eax
movl %eax, 0x60(%rbx)
movss 0x8(%rsi), %xmm0
movss %xmm0, 0xe8(%rbx)
leaq 0x10(%rbx), %r14
leaq 0x1b(%rsi), %r13
xorl %edi, %edi
xorl %r15d, %r15d
movq %r14, -0x38(%rbp)
movq %rbx, -0x30(%rbp)
movsbl 0xc(%rsi), %ecx
cmpl %ecx, %r15d
jge 0x70d93
movsbl -0x3(%r13), %r12d
testl %r12d, %r12d
js 0x70d87
cmpl %r12d, 0x6c(%rbx)
jle 0x70d87
movq %rdi, %rbx
movq %r14, %rdi
movq %rsi, %r14
movl %r12d, %esi
callq 0x4c4c6
movq %r14, %rsi
movl 0x4(%r14), %ecx
testb $0x1, %cl
je 0x70d42
movzbl (%r13), %edx
movss -0xb(%r13), %xmm0
andl $0x8, %edx
movss %xmm0, 0x10(%rax,%rdx)
movb $0x0, 0x62(%rax)
testb $0x2, %cl
movq %rbx, %rdi
je 0x70d4e
movb -0x2(%r13), %r12b
movb %r12b, 0x52(%rax)
btsq %r12, %rdi
movb (%r13), %cl
shrb $0x2, %cl
andb $0x1, %cl
movb %cl, 0x5b(%rax)
movb %cl, 0x5a(%rax)
movb -0x1(%r13), %cl
movb %cl, 0x56(%rax)
movb (%r13), %cl
andb $0x3, %cl
movb 0x64(%rax), %dl
andb $-0x4, %dl
orb %cl, %dl
movb %dl, 0x64(%rax)
movq -0x38(%rbp), %r14
movq -0x30(%rbp), %rbx
incl %r15d
addq $0xc, %r13
jmp 0x70cec
pushq $-0x1
popq %rax
movq %rax, %rdx
shlq %cl, %rdx
cmpb $0x40, %cl
notq %rdx
cmoveq %rax, %rdx
cmpq %rdx, %rdi
jne 0x70de6
leaq 0x20(%rbx), %r15
xorl %r12d, %r12d
cmpl 0x6c(%rbx), %r12d
jge 0x70dd7
movq %r14, %rdi
movl %r12d, %esi
callq 0x4c4c6
movsbl 0x52(%rax), %esi
movq %r15, %rdi
callq 0x787be
movb %r12b, (%rax)
incl %r12d
jmp 0x70db2
addq $0x18, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
xorl %r15d, %r15d
cmpl 0x6c(%rbx), %r15d
jge 0x70dab
movq %r14, %rdi
movl %r15d, %esi
callq 0x4c4c6
movb %r15b, 0x52(%rax)
incl %r15d
jmp 0x70de9