// File: /workspace/github_cpp_makefile_star2_O1/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 0x7331a(%rip), %rax     # 0xfdcd0
movq (%rax), %rax
movq 0x1ae0(%rax), %rax
cmpb $0x0, 0x93(%rax)
jne 0x8aae5
movq %rdi, %rbx
movsbl 0x23f(%rdi), %eax
testl %eax, %eax
js 0x8a9ea
cmpl %eax, 0x6c(%rbx)
movl $0xffffffff, %r14d      # imm = 0xFFFFFFFF
cmovgl %eax, %r14d
jmp 0x8a9f0
movl $0xffffffff, %r14d      # imm = 0xFFFFFFFF
cmpl $-0x1, %r14d
je 0x8aa2b
testl %r14d, %r14d
js 0x8aa0c
movslq %r14d, %rax
imulq $0x68, %rax, %rax
addq 0x10(%rbx), %rax
cmpq 0x18(%rbx), %rax
jb 0x8aa2d
leaq 0x31ca5(%rip), %rdi     # 0xbc6b8
leaq 0x30c25(%rip), %rsi     # 0xbb63f
leaq 0x31cb0(%rip), %rcx     # 0xbc6d1
movl $0x20e, %edx            # imm = 0x20E
callq 0xc140
xorl %eax, %eax
movl 0x4(%rbx), %r15d
andl $0x1, %r15d
je 0x8aab1
testq %rax, %rax
je 0x8aa6a
testb $0x10, (%rax)
jne 0x8aa46
movb 0x5a(%rax), %al
jmp 0x8aa48
xorl %eax, %eax
movzbl %al, %ecx
leaq 0x475c1(%rip), %rdi     # 0xd2013
xorl %esi, %esi
xorl %edx, %edx
callq 0xa5164
testb %al, %al
je 0x8aa6a
movq %rbx, %rdi
movl %r14d, %esi
callq 0x8addf
movb 0x232(%rbx), %al
cmpb 0x231(%rbx), %al
jne 0x8aa87
movl $0xe000, %eax           # imm = 0xE000
andl 0x4(%rbx), %eax
cmpl $0x4000, %eax           # imm = 0x4000
jne 0x8aa90
leaq 0x475c4(%rip), %rdi     # 0xd2052
jmp 0x8aa97
leaq 0x47599(%rip), %rdi     # 0xd2030
xorl %esi, %esi
xorl %edx, %edx
movl $0x1, %ecx
callq 0xa5164
testb %al, %al
je 0x8aab1
movq %rbx, %rdi
callq 0x8dc3d
testb $0x2, 0x4(%rbx)
je 0x8aadf
movzbl 0x250(%rbx), %ecx
xorl $0x1, %ecx
leaq 0x475b0(%rip), %rdi     # 0xd2078
xorl %esi, %esi
xorl %edx, %edx
callq 0xa5164
movb $0x1, %r15b
testb %al, %al
je 0x8aadf
movb $0x1, 0x252(%rbx)
testb $0x4, 0x4(%rbx)
jne 0x8aaf4
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
testb %r15b, %r15b
je 0x8aafe
callq 0x9552a
movl $0x20, %edi
movl $0x1, %esi
callq 0x54e0c
cmpl $0x0, 0x6c(%rbx)
jle 0x8abad
xorl %r15d, %r15d
leaq 0x47563(%rip), %r12     # 0xd2084
xorl %r14d, %r14d
movq 0x10(%rbx), %r13
leaq (%r15,%r13), %rax
cmpq 0x18(%rbx), %rax
jae 0x8aa0c
movq %rbx, %rdi
movl %r14d, %esi
callq 0x8d202
testq %rax, %rax
je 0x8ab4b
cmpb $0x0, (%rax)
jne 0x8ab4e
movq %r12, %rax
movl (%r13,%r15), %edx
testb $0x40, %dl
sete %sil
movb 0x5a(%r13,%r15), %cl
cmpb $0x1, %cl
jne 0x8ab78
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 0xa5164
testb %al, %al
je 0x8ab99
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 0x8ab24
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
jmp 0x54f76