// File: /workspace/github_cpp_makefile_star2_O2/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 0x714b4(%rip), %rax     # 0xe3ce0
movq (%rax), %rax
movq 0x1ae0(%rax), %rax
cmpb $0x0, 0x93(%rax)
jne 0x72926
movq %rdi, %rbx
movsbl 0x23f(%rdi), %r15d
pushq $-0x1
popq %r14
testl %r15d, %r15d
js 0x7286e
cmpl %r15d, 0x6c(%rbx)
jle 0x7286e
leaq 0x10(%rbx), %rdi
movl %r15d, %esi
callq 0x4c4c6
movl %r15d, %r14d
jmp 0x72870
xorl %eax, %eax
movl 0x4(%rbx), %r15d
andl $0x1, %r15d
je 0x728f2
testq %rax, %rax
je 0x728ad
testb $0x10, (%rax)
jne 0x72889
movb 0x5a(%rax), %al
jmp 0x7288b
xorl %eax, %eax
movzbl %al, %ecx
leaq 0x449ca(%rip), %rdi     # 0xb725f
xorl %esi, %esi
xorl %edx, %edx
callq 0x8b583
testb %al, %al
je 0x728ad
movq %rbx, %rdi
movl %r14d, %esi
callq 0x72b4b
movb 0x232(%rbx), %al
cmpb 0x231(%rbx), %al
jne 0x728ca
movl $0xe000, %eax           # imm = 0xE000
andl 0x4(%rbx), %eax
cmpl $0x4000, %eax           # imm = 0x4000
jne 0x728d3
leaq 0x449cd(%rip), %rdi     # 0xb729e
jmp 0x728da
leaq 0x449a2(%rip), %rdi     # 0xb727c
pushq $0x1
popq %rcx
xorl %esi, %esi
xorl %edx, %edx
callq 0x8b583
testb %al, %al
je 0x728f2
movq %rbx, %rdi
callq 0x753fa
testb $0x2, 0x4(%rbx)
je 0x72920
movzbl 0x250(%rbx), %ecx
xorl $0x1, %ecx
leaq 0x449bb(%rip), %rdi     # 0xb72c4
xorl %esi, %esi
xorl %edx, %edx
callq 0x8b583
movb $0x1, %r15b
testb %al, %al
je 0x72920
movb $0x1, 0x252(%rbx)
testb $0x4, 0x4(%rbx)
jne 0x72935
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
testb %r15b, %r15b
je 0x7293f
callq 0x7cad7
pushq $0x20
popq %rdi
pushq $0x1
popq %rsi
callq 0x423da
leaq 0x10(%rbx), %r14
xorl %r15d, %r15d
leaq 0x44978(%rip), %r13     # 0xb72d0
cmpl 0x6c(%rbx), %r15d
jge 0x729c9
movq %r14, %rdi
movl %r15d, %esi
callq 0x4c4c6
movq %rax, %r12
movq %rbx, %rdi
movl %r15d, %esi
callq 0x74ab7
cmpb $0x0, (%rax)
movq %r13, %rdi
je 0x72982
movq %rax, %rdi
movl (%r12), %edx
testb $0x40, %dl
sete %cl
movb 0x5a(%r12), %al
cmpb $0x1, %al
jne 0x729a7
testb $0x40, %dl
sete %dl
cmpb $0x2, 0x231(%rbx)
setge %cl
andb %dl, %cl
movzbl %al, %edx
movzbl %cl, %ecx
xorl %esi, %esi
callq 0x8b583
testb %al, %al
je 0x729c4
movb 0x5a(%r12), %al
xorb $0x1, %al
movb %al, 0x5b(%r12)
incl %r15d
jmp 0x72958
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
jmp 0x4246f