// File: /workspace/github_cpp_makefile_star2_O3/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 %rbx
pushq %rax
leaq 0x74de9(%rip), %rax     # 0xfbcd0
movq (%rax), %r15
movb $0x0, 0x24e(%rdi)
testb $0x10, 0x4(%rdi)
jne 0x870a6
movq %rdi, %rbx
cmpl $-0x1, 0x64(%rdi)
je 0x86f11
movq %rbx, %rdi
callq 0x8d14d
movq %rax, %r14
jmp 0x86f49
movl (%rbx), %edi
callq 0x8d108
testq %rax, %rax
je 0x870a6
movq %rax, %r14
movsbl 0xc(%rax), %eax
cmpl %eax, 0x6c(%rbx)
je 0x86f34
movb $0x1, 0x24f(%rbx)
addq $0x3118, %r15           # imm = 0x3118
movq %r15, %rdi
movq %r14, %rsi
callq 0x8fc3a
movl %eax, 0x64(%rbx)
movl 0x4(%r14), %eax
movl %eax, 0x60(%rbx)
movss 0x8(%r14), %xmm0
movss %xmm0, 0xe8(%rbx)
movsbq 0xc(%r14), %rcx
testq %rcx, %rcx
jle 0x87031
leaq 0x1b(%r14), %rdx
xorl %esi, %esi
xorl %eax, %eax
movsbl -0x3(%rdx), %edi
testl %edi, %edi
js 0x87003
cmpl %edi, 0x6c(%rbx)
jle 0x87003
movslq %edi, %rcx
imulq $0x68, %rcx, %rcx
addq 0x10(%rbx), %rcx
cmpq 0x18(%rbx), %rcx
jae 0x870b1
movl 0x4(%r14), %r8d
testb $0x1, %r8b
je 0x86fbc
movzbl (%rdx), %r9d
movss -0xb(%rdx), %xmm0
andl $0x8, %r9d
movss %xmm0, 0x10(%rcx,%r9)
movb $0x0, 0x62(%rcx)
testb $0x2, %r8b
je 0x86fc6
movb -0x2(%rdx), %dil
movb %dil, 0x52(%rcx)
btsq %rdi, %rax
movb (%rdx), %dil
shrb $0x2, %dil
andb $0x1, %dil
movb %dil, 0x5b(%rcx)
movb %dil, 0x5a(%rcx)
movb -0x1(%rdx), %dil
movb %dil, 0x56(%rcx)
movb (%rdx), %dil
andb $0x3, %dil
movb 0x64(%rcx), %r8b
andb $-0x4, %r8b
orb %dil, %r8b
movb %r8b, 0x64(%rcx)
movb 0xc(%r14), %cl
incl %esi
movsbl %cl, %edi
addq $0xc, %rdx
cmpl %edi, %esi
jl 0x86f74
movq $-0x1, %rsi
movq $-0x1, %rdx
shlq %cl, %rdx
cmpb $0x40, %cl
notq %rdx
cmoveq %rsi, %rdx
jmp 0x87040
movq $-0x1, %rdx
shlq %cl, %rdx
notq %rdx
xorl %eax, %eax
movl 0x6c(%rbx), %ecx
cmpq %rdx, %rax
jne 0x8704e
testl %ecx, %ecx
jg 0x8706d
jmp 0x870a6
testl %ecx, %ecx
jle 0x870a6
movq 0x10(%rbx), %rax
xorl %edx, %edx
cmpq 0x18(%rbx), %rax
jae 0x870b1
movb %dl, 0x52(%rax)
incq %rdx
addq $0x68, %rax
cmpq %rdx, %rcx
jne 0x87058
xorl %eax, %eax
xorl %ecx, %ecx
movq 0x10(%rbx), %rdx
leaq (%rdx,%rax), %rsi
cmpq 0x18(%rbx), %rsi
jae 0x870b1
movsbq 0x52(%rdx,%rax), %rdx
testq %rdx, %rdx
js 0x870c8
addq 0x20(%rbx), %rdx
cmpq 0x28(%rbx), %rdx
jae 0x870c8
movb %cl, (%rdx)
incq %rcx
movslq 0x6c(%rbx), %rdx
addq $0x68, %rax
cmpq %rdx, %rcx
jl 0x87071
addq $0x8, %rsp
popq %rbx
popq %r14
popq %r15
popq %rbp
retq
leaq 0x33600(%rip), %rdi     # 0xba6b8
leaq 0x32580(%rip), %rsi     # 0xb963f
leaq 0x3360b(%rip), %rcx     # 0xba6d1
jmp 0x870dd
leaq 0x335e9(%rip), %rdi     # 0xba6b8
leaq 0x32569(%rip), %rsi     # 0xb963f
leaq 0x4995c(%rip), %rcx     # 0xd0a39
movl $0x20e, %edx            # imm = 0x20E
callq 0xc140