// File: /workspace/github_cpp_makefile_star2_O3/Ciaxur[P]yagb-emu/include/imgui/imgui_tables.cpp
// Function: ImGui::TableDrawContextMenu(ImGuiTable*)
void ImGui::TableDrawContextMenu(ImGuiTable* table)
{
    ImGuiContext& g = *GImGui;
    ImGuiWindow* window = g.CurrentWindow;
    if (window->SkipItems)
        return;

    bool want_separator = false;
    const int column_n = (table->ContextPopupColumn >= 0 && table->ContextPopupColumn < table->ColumnsCount) ? table->ContextPopupColumn : -1;
    ImGuiTableColumn* column = (column_n != -1) ? &table->Columns[column_n] : NULL;

    // Sizing
    if (table->Flags & ImGuiTableFlags_Resizable)
    {
        if (column != NULL)
        {
            const bool can_resize = !(column->Flags & ImGuiTableColumnFlags_NoResize) && column->IsEnabled;
            if (MenuItem("Size column to fit###SizeOne", NULL, false, can_resize))
                TableSetColumnWidthAutoSingle(table, column_n);
        }

        const char* size_all_desc;
        if (table->ColumnsEnabledFixedCount == table->ColumnsEnabledCount && (table->Flags & ImGuiTableFlags_SizingMask_) != ImGuiTableFlags_SizingFixedSame)
            size_all_desc = "Size all columns to fit###SizeAll";        // All fixed
        else
            size_all_desc = "Size all columns to default###SizeAll";    // All stretch or mixed
        if (MenuItem(size_all_desc, NULL))
            TableSetColumnWidthAutoAll(table);
        want_separator = true;
    }

    // Ordering
    if (table->Flags & ImGuiTableFlags_Reorderable)
    {
        if (MenuItem("Reset order", NULL, false, !table->IsDefaultDisplayOrder))
            table->IsResetDisplayOrderRequest = true;
        want_separator = true;
    }

    // Reset all (should work but seems unnecessary/noisy to expose?)
    //if (MenuItem("Reset all"))
    //    table->IsResetAllRequest = true;

    // Sorting
    // (modify TableOpenContextMenu() to add _Sortable flag if enabling this)
#if 0
    if ((table->Flags & ImGuiTableFlags_Sortable) && column != NULL && (column->Flags & ImGuiTableColumnFlags_NoSort) == 0)
    {
        if (want_separator)
            Separator();
        want_separator = true;

        bool append_to_sort_specs = g.IO.KeyShift;
        if (MenuItem("Sort in Ascending Order", NULL, column->SortOrder != -1 && column->SortDirection == ImGuiSortDirection_Ascending, (column->Flags & ImGuiTableColumnFlags_NoSortAscending) == 0))
            TableSetColumnSortDirection(table, column_n, ImGuiSortDirection_Ascending, append_to_sort_specs);
        if (MenuItem("Sort in Descending Order", NULL, column->SortOrder != -1 && column->SortDirection == ImGuiSortDirection_Descending, (column->Flags & ImGuiTableColumnFlags_NoSortDescending) == 0))
            TableSetColumnSortDirection(table, column_n, ImGuiSortDirection_Descending, append_to_sort_specs);
    }
#endif

    // Hiding / Visibility
    if (table->Flags & ImGuiTableFlags_Hideable)
    {
        if (want_separator)
            Separator();
        want_separator = true;

        PushItemFlag(ImGuiItemFlags_SelectableDontClosePopup, true);
        for (int other_column_n = 0; other_column_n < table->ColumnsCount; other_column_n++)
        {
            ImGuiTableColumn* other_column = &table->Columns[other_column_n];
            const char* name = TableGetColumnName(table, other_column_n);
            if (name == NULL || name[0] == 0)
                name = "<Unknown>";

            // Make sure we can't hide the last active column
            bool menu_item_active = (other_column->Flags & ImGuiTableColumnFlags_NoHide) ? false : true;
            if (other_column->IsEnabled && table->ColumnsEnabledCount <= 1)
                menu_item_active = false;
            if (MenuItem(name, NULL, other_column->IsEnabled, menu_item_active))
                other_column->IsEnabledNextFrame = !other_column->IsEnabled;
        }
        PopItemFlag();
    }
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
pushq %rax
leaq 0x72f4f(%rip), %rax     # 0xfbcd0
movq (%rax), %rax
movq 0x1ae0(%rax), %rax
cmpb $0x0, 0x93(%rax)
jne 0x88e9e
movq %rdi, %rbx
movsbl 0x23f(%rdi), %r14d
testl %r14d, %r14d
js 0x88dde
cmpl %r14d, 0x6c(%rbx)
jle 0x88dde
movslq %r14d, %rax
imulq $0x68, %rax, %rax
addq 0x10(%rbx), %rax
cmpq 0x18(%rbx), %rax
jb 0x88de6
leaq 0x318f2(%rip), %rdi     # 0xba6b8
leaq 0x30872(%rip), %rsi     # 0xb963f
leaq 0x318fd(%rip), %rcx     # 0xba6d1
movl $0x20e, %edx            # imm = 0x20E
callq 0xc140
xorl %eax, %eax
movl $0xffffffff, %r14d      # imm = 0xFFFFFFFF
movl 0x4(%rbx), %r15d
andl $0x1, %r15d
je 0x88e6a
testq %rax, %rax
je 0x88e23
testb $0x10, (%rax)
jne 0x88dff
movb 0x5a(%rax), %al
jmp 0x88e01
xorl %eax, %eax
movzbl %al, %ecx
leaq 0x471d8(%rip), %rdi     # 0xcffe3
xorl %esi, %esi
xorl %edx, %edx
callq 0xa37af
testb %al, %al
je 0x88e23
movq %rbx, %rdi
movl %r14d, %esi
callq 0x8919a
movb 0x232(%rbx), %al
cmpb 0x231(%rbx), %al
jne 0x88e40
movl $0xe000, %eax           # imm = 0xE000
andl 0x4(%rbx), %eax
cmpl $0x4000, %eax           # imm = 0x4000
jne 0x88e49
leaq 0x471db(%rip), %rdi     # 0xd0022
jmp 0x88e50
leaq 0x471b0(%rip), %rdi     # 0xd0000
xorl %esi, %esi
xorl %edx, %edx
movl $0x1, %ecx
callq 0xa37af
testb %al, %al
je 0x88e6a
movq %rbx, %rdi
callq 0x8bf59
testb $0x2, 0x4(%rbx)
je 0x88e98
movzbl 0x250(%rbx), %ecx
xorl $0x1, %ecx
leaq 0x471c7(%rip), %rdi     # 0xd0048
xorl %esi, %esi
xorl %edx, %edx
callq 0xa37af
movb $0x1, %r15b
testb %al, %al
je 0x88e98
movb $0x1, 0x252(%rbx)
testb $0x4, 0x4(%rbx)
jne 0x88ead
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
testb %r15b, %r15b
je 0x88eb7
callq 0x93890
movl $0x20, %edi
movl $0x1, %esi
callq 0x53d92
cmpl $0x0, 0x6c(%rbx)
jle 0x88f66
xorl %r15d, %r15d
leaq 0x4717a(%rip), %r12     # 0xd0054
xorl %r14d, %r14d
movq 0x10(%rbx), %r13
leaq (%r15,%r13), %rax
cmpq 0x18(%rbx), %rax
jae 0x88dbf
movq %rbx, %rdi
movl %r14d, %esi
callq 0x8b537
testq %rax, %rax
je 0x88f04
cmpb $0x0, (%rax)
jne 0x88f07
movq %r12, %rax
movl (%r13,%r15), %edx
testb $0x40, %dl
sete %sil
movb 0x5a(%r13,%r15), %cl
cmpb $0x1, %cl
jne 0x88f31
testb $0x40, %dl
sete %dl
cmpb $0x2, 0x231(%rbx)
setge %sil
andb %dl, %sil
movzbl %cl, %edx
movzbl %sil, %ecx
movq %rax, %rdi
xorl %esi, %esi
callq 0xa37af
testb %al, %al
je 0x88f52
movb 0x5a(%r13,%r15), %al
xorb $0x1, %al
movb %al, 0x5b(%r13,%r15)
incq %r14
movslq 0x6c(%rbx), %rax
addq $0x68, %r15
cmpq %rax, %r14
jl 0x88edd
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
jmp 0x53ede