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

    ImGuiTable* table = g.CurrentTable;
    IM_ASSERT(table != NULL && "Need to call TableHeader() after BeginTable()!");
    IM_ASSERT(table->CurrentColumn != -1);
    const int column_n = table->CurrentColumn;
    ImGuiTableColumn* column = &table->Columns[column_n];

    // Label
    if (label == NULL)
        label = "";
    const char* label_end = FindRenderedTextEnd(label);
    ImVec2 label_size = CalcTextSize(label, label_end, true);
    ImVec2 label_pos = window->DC.CursorPos;

    // If we already got a row height, there's use that.
    // FIXME-TABLE: Padding problem if the correct outer-padding CellBgRect strays off our ClipRect?
    ImRect cell_r = TableGetCellBgRect(table, column_n);
    float label_height = ImMax(label_size.y, table->RowMinHeight - table->CellPaddingY * 2.0f);

    // Calculate ideal size for sort order arrow
    float w_arrow = 0.0f;
    float w_sort_text = 0.0f;
    char sort_order_suf[4] = "";
    const float ARROW_SCALE = 0.65f;
    if ((table->Flags & ImGuiTableFlags_Sortable) && !(column->Flags & ImGuiTableColumnFlags_NoSort))
    {
        w_arrow = ImFloor(g.FontSize * ARROW_SCALE + g.Style.FramePadding.x);
        if (column->SortOrder > 0)
        {
            ImFormatString(sort_order_suf, IM_ARRAYSIZE(sort_order_suf), "%d", column->SortOrder + 1);
            w_sort_text = g.Style.ItemInnerSpacing.x + CalcTextSize(sort_order_suf).x;
        }
    }

    // We feed our unclipped width to the column without writing on CursorMaxPos, so that column is still considering for merging.
    float max_pos_x = label_pos.x + label_size.x + w_sort_text + w_arrow;
    column->ContentMaxXHeadersUsed = ImMax(column->ContentMaxXHeadersUsed, column->WorkMaxX);
    column->ContentMaxXHeadersIdeal = ImMax(column->ContentMaxXHeadersIdeal, max_pos_x);

    // Keep header highlighted when context menu is open.
    const bool selected = (table->IsContextPopupOpen && table->ContextPopupColumn == column_n && table->InstanceInteracted == table->InstanceCurrent);
    ImGuiID id = window->GetID(label);
    ImRect bb(cell_r.Min.x, cell_r.Min.y, cell_r.Max.x, ImMax(cell_r.Max.y, cell_r.Min.y + label_height + g.Style.CellPadding.y * 2.0f));
    ItemSize(ImVec2(0.0f, label_height)); // Don't declare unclipped width, it'll be fed ContentMaxPosHeadersIdeal
    if (!ItemAdd(bb, id))
        return;

    //GetForegroundDrawList()->AddRect(cell_r.Min, cell_r.Max, IM_COL32(255, 0, 0, 255)); // [DEBUG]
    //GetForegroundDrawList()->AddRect(bb.Min, bb.Max, IM_COL32(255, 0, 0, 255)); // [DEBUG]

    // Using AllowItemOverlap mode because we cover the whole cell, and we want user to be able to submit subsequent items.
    bool hovered, held;
    bool pressed = ButtonBehavior(bb, id, &hovered, &held, ImGuiButtonFlags_AllowItemOverlap);
    if (g.ActiveId != id)
        SetItemAllowOverlap();
    if (held || hovered || selected)
    {
        const ImU32 col = GetColorU32(held ? ImGuiCol_HeaderActive : hovered ? ImGuiCol_HeaderHovered : ImGuiCol_Header);
        //RenderFrame(bb.Min, bb.Max, col, false, 0.0f);
        TableSetBgColor(ImGuiTableBgTarget_CellBg, col, table->CurrentColumn);
        RenderNavHighlight(bb, id, ImGuiNavHighlightFlags_TypeThin | ImGuiNavHighlightFlags_NoRounding);
    }
    else
    {
        // Submit single cell bg color in the case we didn't submit a full header row
        if ((table->RowFlags & ImGuiTableRowFlags_Headers) == 0)
            TableSetBgColor(ImGuiTableBgTarget_CellBg, GetColorU32(ImGuiCol_TableHeaderBg), table->CurrentColumn);
    }
    if (held)
        table->HeldHeaderColumn = (ImGuiTableColumnIdx)column_n;
    window->DC.CursorPos.y -= g.Style.ItemSpacing.y * 0.5f;

    // Drag and drop to re-order columns.
    // FIXME-TABLE: Scroll request while reordering a column and it lands out of the scrolling zone.
    if (held && (table->Flags & ImGuiTableFlags_Reorderable) && IsMouseDragging(0) && !g.DragDropActive)
    {
        // While moving a column it will jump on the other side of the mouse, so we also test for MouseDelta.x
        table->ReorderColumn = (ImGuiTableColumnIdx)column_n;
        table->InstanceInteracted = table->InstanceCurrent;

        // We don't reorder: through the frozen<>unfrozen line, or through a column that is marked with ImGuiTableColumnFlags_NoReorder.
        if (g.IO.MouseDelta.x < 0.0f && g.IO.MousePos.x < cell_r.Min.x)
            if (ImGuiTableColumn* prev_column = (column->PrevEnabledColumn != -1) ? &table->Columns[column->PrevEnabledColumn] : NULL)
                if (!((column->Flags | prev_column->Flags) & ImGuiTableColumnFlags_NoReorder))
                    if ((column->IndexWithinEnabledSet < table->FreezeColumnsRequest) == (prev_column->IndexWithinEnabledSet < table->FreezeColumnsRequest))
                        table->ReorderColumnDir = -1;
        if (g.IO.MouseDelta.x > 0.0f && g.IO.MousePos.x > cell_r.Max.x)
            if (ImGuiTableColumn* next_column = (column->NextEnabledColumn != -1) ? &table->Columns[column->NextEnabledColumn] : NULL)
                if (!((column->Flags | next_column->Flags) & ImGuiTableColumnFlags_NoReorder))
                    if ((column->IndexWithinEnabledSet < table->FreezeColumnsRequest) == (next_column->IndexWithinEnabledSet < table->FreezeColumnsRequest))
                        table->ReorderColumnDir = +1;
    }

    // Sort order arrow
    const float ellipsis_max = cell_r.Max.x - w_arrow - w_sort_text;
    if ((table->Flags & ImGuiTableFlags_Sortable) && !(column->Flags & ImGuiTableColumnFlags_NoSort))
    {
        if (column->SortOrder != -1)
        {
            float x = ImMax(cell_r.Min.x, cell_r.Max.x - w_arrow - w_sort_text);
            float y = label_pos.y;
            if (column->SortOrder > 0)
            {
                PushStyleColor(ImGuiCol_Text, GetColorU32(ImGuiCol_Text, 0.70f));
                RenderText(ImVec2(x + g.Style.ItemInnerSpacing.x, y), sort_order_suf);
                PopStyleColor();
                x += w_sort_text;
            }
            RenderArrow(window->DrawList, ImVec2(x, y), GetColorU32(ImGuiCol_Text), column->SortDirection == ImGuiSortDirection_Ascending ? ImGuiDir_Up : ImGuiDir_Down, ARROW_SCALE);
        }

        // Handle clicking on column header to adjust Sort Order
        if (pressed && table->ReorderColumn != column_n)
        {
            ImGuiSortDirection sort_direction = TableGetColumnNextSortDirection(column);
            TableSetColumnSortDirection(column_n, sort_direction, g.IO.KeyShift);
        }
    }

    // Render clipped label. Clipping here ensure that in the majority of situations, all our header cells will
    // be merged into a single draw call.
    //window->DrawList->AddCircleFilled(ImVec2(ellipsis_max, label_pos.y), 40, IM_COL32_WHITE);
    RenderTextEllipsis(window->DrawList, label_pos, ImVec2(ellipsis_max, label_pos.y + label_height + g.Style.FramePadding.y), ellipsis_max, ellipsis_max, label, label_end, &label_size);

    const bool text_clipped = label_size.x > (ellipsis_max - label_pos.x);
    if (text_clipped && hovered && g.HoveredIdNotActiveTimer > g.TooltipSlowDelay)
        SetTooltip("%.*s", (int)(label_end - label), label);

    // We don't use BeginPopupContextItem() because we want the popup to stay up even after the column is hidden
    if (IsMouseReleased(1) && IsItemHovered())
        TableOpenContextMenu(column_n);
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0xa8, %rsp
leaq 0x6f6a8(%rip), %rax     # 0xfdcd0
movq (%rax), %r12
movq 0x1ae0(%r12), %rax
movq %rax, -0x40(%rbp)
cmpb $0x0, 0x93(%rax)
jne 0x8ec9f
movq 0x20a8(%r12), %r13
testq %r13, %r13
je 0x8ed63
movslq 0x74(%r13), %r14
cmpq $-0x1, %r14
je 0x8ed82
testl %r14d, %r14d
js 0x8eda1
imulq $0x68, %r14, %r15
addq 0x10(%r13), %r15
cmpq 0x18(%r13), %r15
jae 0x8eda1
testq %rdi, %rdi
leaq 0x28895(%rip), %rbx     # 0xb6f1d
cmovneq %rdi, %rbx
movq %rbx, %rdi
xorl %esi, %esi
callq 0x44e8b
movss 0x28932(%rip), %xmm0    # 0xb6fd0
movq %rbx, %rdi
movq %rax, -0xa0(%rbp)
movq %rax, %rsi
movl $0x1, %edx
callq 0x4548d
movlps %xmm0, -0x80(%rbp)
movq -0x40(%rbp), %rax
movq 0xd8(%rax), %rax
movq %rax, -0x78(%rbp)
movq %r13, %rdi
movl %r14d, %esi
callq 0x8d307
movaps %xmm0, -0x50(%rbp)
movaps %xmm1, -0x70(%rbp)
movss -0x7c(%rbp), %xmm0
movss 0x84(%r13), %xmm1
movss 0xc0(%r13), %xmm2
addss %xmm2, %xmm2
subss %xmm2, %xmm1
movaps %xmm1, %xmm3
cmpless %xmm0, %xmm3
movaps %xmm3, %xmm2
andnps %xmm1, %xmm2
andps %xmm0, %xmm3
orps %xmm2, %xmm3
movaps %xmm3, -0xc0(%rbp)
movl $0x0, -0x34(%rbp)
xorps %xmm0, %xmm0
testb $0x8, 0x4(%r13)
je 0x8e7af
testb $0x1, 0x1(%r15)
jne 0x8e7af
movss 0x1980(%r12), %xmm1
mulss 0x29171(%rip), %xmm1    # 0xb78b4
addss 0x1598(%r12), %xmm1
cvttps2dq %xmm1, %xmm1
cvtdq2ps %xmm1, %xmm1
movzbl 0x56(%r15), %ecx
testb %cl, %cl
jle 0x8e7b2
incl %ecx
leaq 0x2fd1c(%rip), %rdx     # 0xbe482
leaq -0x34(%rbp), %rdi
movl $0x4, %esi
xorl %eax, %eax
movaps %xmm1, -0x90(%rbp)
callq 0x427cb
movss 0x15b0(%r12), %xmm0
movss %xmm0, -0x60(%rbp)
movss 0x2883c(%rip), %xmm0    # 0xb6fd0
leaq -0x34(%rbp), %rdi
xorl %esi, %esi
xorl %edx, %edx
callq 0x4548d
movaps -0x90(%rbp), %xmm1
addss -0x60(%rbp), %xmm0
jmp 0x8e7b2
xorps %xmm1, %xmm1
movss -0x78(%rbp), %xmm4
addss -0x80(%rbp), %xmm4
addss %xmm0, %xmm4
movaps %xmm1, -0x90(%rbp)
addss %xmm1, %xmm4
movss 0x38(%r15), %xmm1
movss 0x48(%r15), %xmm2
movaps %xmm1, %xmm3
cmpless %xmm2, %xmm3
andps %xmm3, %xmm2
andnps %xmm1, %xmm3
orps %xmm2, %xmm3
movss %xmm3, 0x48(%r15)
movss 0x4c(%r15), %xmm1
movaps %xmm4, %xmm2
cmpless %xmm1, %xmm2
movaps %xmm2, %xmm3
andnps %xmm4, %xmm3
andps %xmm1, %xmm2
orps %xmm3, %xmm2
movss %xmm2, 0x4c(%r15)
cmpb $0x1, 0x24d(%r13)
movq %r14, -0xa8(%rbp)
movaps %xmm0, -0x60(%rbp)
jne 0x8e842
movsbl 0x23f(%r13), %eax
cmpl %eax, %r14d
jne 0x8e842
movzwl 0x7a(%r13), %eax
cmpw 0x78(%r13), %ax
sete %al
movl %eax, -0x30(%rbp)
jmp 0x8e849
movl $0x0, -0x30(%rbp)
movq -0x40(%rbp), %rdi
movq %rbx, -0x98(%rbp)
movq %rbx, %rsi
xorl %edx, %edx
callq 0x46258
movl %eax, %ebx
movaps -0x50(%rbp), %xmm3
movaps %xmm3, %xmm0
shufps $0x55, %xmm3, %xmm0     # xmm0 = xmm0[1,1],xmm3[1,1]
movaps -0x70(%rbp), %xmm4
movaps %xmm4, %xmm1
shufps $0x55, %xmm4, %xmm1     # xmm1 = xmm1[1,1],xmm4[1,1]
movss 0x15bc(%r12), %xmm2
leaq -0xd0(%rbp), %r14
movss %xmm3, (%r14)
movss %xmm0, 0x4(%r14)
movaps -0xc0(%rbp), %xmm5
addss %xmm5, %xmm0
addss %xmm2, %xmm2
addss %xmm0, %xmm2
movaps %xmm2, %xmm0
cmpless %xmm1, %xmm0
movaps %xmm0, %xmm3
andnps %xmm2, %xmm3
andps %xmm1, %xmm0
orps %xmm3, %xmm0
movss %xmm4, 0x8(%r14)
movss %xmm0, 0xc(%r14)
leaq -0xb0(%rbp), %rdi
movl $0x0, (%rdi)
movss %xmm5, 0x4(%rdi)
movss 0x286f1(%rip), %xmm0    # 0xb6fd0
callq 0x532de
movq %r14, %rdi
movl %ebx, %esi
xorl %edx, %edx
callq 0x5346f
testb %al, %al
je 0x8ec9f
leaq -0xd0(%rbp), %rdi
leaq -0x2a(%rbp), %rdx
leaq -0x29(%rbp), %rcx
movl %ebx, %esi
movl $0x1000, %r8d           # imm = 0x1000
callq 0x92870
movb %al, -0x2b(%rbp)
cmpl %ebx, 0x1b30(%r12)
je 0x8e926
callq 0x52c1e
movb -0x29(%rbp), %al
movb -0x2a(%rbp), %cl
movl %eax, %edx
orb %cl, %dl
orb -0x30(%rbp), %dl
testb $0x1, %dl
movq -0xa8(%rbp), %r14
je 0x8e984
movzbl %cl, %ecx
andl $0x1, %ecx
orl $0x18, %ecx
testb %al, %al
movl $0x1a, %edi
cmovel %ecx, %edi
movss 0x2868a(%rip), %xmm0    # 0xb6fe4
callq 0x445bd
movl 0x74(%r13), %edx
movl $0x3, %edi
movl %eax, %esi
callq 0x8d3a3
leaq -0xd0(%rbp), %rdi
movl %ebx, %esi
movl $0xa, %edx
callq 0x45ca4
jmp 0x8e9b0
testb $0x1, 0x90(%r13)
jne 0x8e9b0
movss 0x2864e(%rip), %xmm0    # 0xb6fe4
movl $0x2a, %edi
callq 0x445bd
movl 0x74(%r13), %edx
movl $0x3, %edi
movl %eax, %esi
callq 0x8d3a3
cmpb $0x1, -0x29(%rbp)
movaps -0x60(%rbp), %xmm3
jne 0x8ea7c
movb %r14b, 0x239(%r13)
movss 0x15ac(%r12), %xmm0
mulss 0x28eed(%rip), %xmm0    # 0xb78c4
movq -0x40(%rbp), %rax
addss 0xdc(%rax), %xmm0
movss %xmm0, 0xdc(%rax)
testb $0x2, 0x4(%r13)
je 0x8eaa2
movss 0x285d2(%rip), %xmm0    # 0xb6fd0
xorl %edi, %edi
callq 0x5278b
movaps -0x60(%rbp), %xmm3
testb %al, %al
je 0x8eaa2
cmpb $0x0, 0x2004(%r12)
jne 0x8eaa2
leaq 0x10(%r13), %rbx
movb %r14b, 0x23a(%r13)
movzwl 0x78(%r13), %eax
movw %ax, 0x7a(%r13)
xorps %xmm1, %xmm1
ucomiss 0x3b8(%r12), %xmm1
jbe 0x8ece2
movaps -0x50(%rbp), %xmm0
ucomiss 0x128(%r12), %xmm0
jbe 0x8ece2
movsbl 0x54(%r15), %esi
cmpl $-0x1, %esi
je 0x8ecb1
movq %rbx, %rdi
callq 0x91766
xorps %xmm1, %xmm1
movaps -0x60(%rbp), %xmm3
jmp 0x8ecb3
movss 0x15ac(%r12), %xmm0
mulss 0x28e36(%rip), %xmm0    # 0xb78c4
movq -0x40(%rbp), %rax
addss 0xdc(%rax), %xmm0
movss %xmm0, 0xdc(%rax)
movaps -0x70(%rbp), %xmm0
subss -0x90(%rbp), %xmm0
subss %xmm3, %xmm0
movaps %xmm0, -0x70(%rbp)
testb $0x8, 0x4(%r13)
je 0x8ebd4
testb $0x1, 0x1(%r15)
jne 0x8ebd4
movb 0x56(%r15), %al
cmpb $-0x1, %al
je 0x8eba6
movaps -0x70(%rbp), %xmm1
movaps %xmm1, %xmm4
movaps -0x50(%rbp), %xmm2
cmpless %xmm2, %xmm4
movaps %xmm4, %xmm0
andps %xmm2, %xmm0
andnps %xmm1, %xmm4
orps %xmm0, %xmm4
movss -0x74(%rbp), %xmm0
movaps %xmm0, -0x90(%rbp)
testb %al, %al
movaps %xmm4, -0x50(%rbp)
jle 0x8eb5d
movss 0x28dc4(%rip), %xmm0    # 0xb78d4
xorl %edi, %edi
callq 0x445bd
xorl %edi, %edi
movl %eax, %esi
callq 0x44690
movss 0x15b0(%r12), %xmm0
addss -0x50(%rbp), %xmm0
unpcklps -0x90(%rbp), %xmm0      # xmm0 = xmm0[0],mem[0],xmm0[1],mem[1]
leaq -0x34(%rbp), %rdi
xorl %esi, %esi
movl $0x1, %edx
callq 0x44ec4
movl $0x1, %edi
callq 0x44964
movaps -0x50(%rbp), %xmm0
addss -0x60(%rbp), %xmm0
movaps %xmm0, -0x50(%rbp)
movq -0x40(%rbp), %rax
movq 0x2b8(%rax), %rbx
movss 0x28474(%rip), %xmm0    # 0xb6fe4
xorl %edi, %edi
callq 0x445bd
movb 0x64(%r15), %cl
andb $0x3, %cl
xorl %edx, %edx
cmpb $0x1, %cl
sete %dl
xorl $0x3, %edx
movaps -0x50(%rbp), %xmm0
unpcklps -0x90(%rbp), %xmm0      # xmm0 = xmm0[0],mem[0],xmm0[1],mem[1]
movss 0x28d18(%rip), %xmm1    # 0xb78b4
movq %rbx, %rdi
movl %eax, %esi
callq 0x8391b
cmpb $0x0, -0x2b(%rbp)
je 0x8ebd4
movsbl 0x23a(%r13), %eax
cmpl %eax, %r14d
je 0x8ebd4
movq %r15, %rdi
callq 0x8de91
movzbl 0x141(%r12), %edx
movl %r14d, %edi
movl %eax, %esi
callq 0x8df72
movq %r14, %r15
leaq -0x78(%rbp), %rbx
movss 0x4(%rbx), %xmm0
addss -0xc0(%rbp), %xmm0
addss 0x159c(%r12), %xmm0
movq -0x40(%rbp), %rax
movq 0x2b8(%rax), %rdi
leaq -0xb0(%rbp), %rdx
movaps -0x70(%rbp), %xmm1
movss %xmm1, (%rdx)
movss %xmm0, 0x4(%rdx)
leaq -0x80(%rbp), %r14
movq %rbx, %rsi
movaps %xmm1, %xmm0
movq -0x98(%rbp), %rcx
movq -0xa0(%rbp), %r13
movq %r13, %r8
movq %r14, %r9
callq 0x455d4
movss (%r14), %xmm0
movaps -0x70(%rbp), %xmm1
subss (%rbx), %xmm1
ucomiss %xmm1, %xmm0
jbe 0x8ec7c
cmpb $0x1, -0x2a(%rbp)
jne 0x8ec7c
movss 0x1b2c(%r12), %xmm0
ucomiss 0x30ac(%r12), %xmm0
jbe 0x8ec7c
movq -0x98(%rbp), %rdx
subl %edx, %r13d
leaq 0x2bb0d(%rip), %rdi     # 0xba77f
movl %r13d, %esi
xorl %eax, %eax
callq 0x51d41
movl $0x1, %edi
callq 0x526c7
testb %al, %al
je 0x8ec9f
movq %r15, %rbx
xorl %edi, %edi
callq 0x46d03
testb %al, %al
je 0x8ec9f
movl %ebx, %edi
callq 0x8befe
addq $0xa8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
xorl %eax, %eax
testq %rax, %rax
je 0x8ece2
movl (%rax), %ecx
orl (%r15), %ecx
testb $0x20, %cl
jne 0x8ece2
movb 0x242(%r13), %cl
cmpb %cl, 0x53(%r15)
setl %dl
cmpb %cl, 0x53(%rax)
setge %al
cmpb %al, %dl
je 0x8ece2
movb $-0x1, 0x23b(%r13)
movss 0x3b8(%r12), %xmm0
ucomiss %xmm1, %xmm0
jbe 0x8eaa2
movss 0x128(%r12), %xmm0
ucomiss -0x70(%rbp), %xmm0
jbe 0x8eaa2
movsbl 0x55(%r15), %esi
cmpl $-0x1, %esi
je 0x8ed21
movq %rbx, %rdi
callq 0x91766
movaps -0x60(%rbp), %xmm3
jmp 0x8ed23
xorl %eax, %eax
testq %rax, %rax
je 0x8eaa2
movl (%rax), %ecx
orl (%r15), %ecx
testb $0x20, %cl
jne 0x8eaa2
movb 0x242(%r13), %cl
cmpb %cl, 0x53(%r15)
setl %dl
cmpb %cl, 0x53(%rax)
setge %al
cmpb %al, %dl
je 0x8eaa2
movb $0x1, 0x23b(%r13)
jmp 0x8eaa2
leaq 0x431cd(%rip), %rdi     # 0xd1f37
leaq 0x42149(%rip), %rsi     # 0xd0eba
leaq 0x43203(%rip), %rcx     # 0xd1f7b
movl $0xabc, %edx            # imm = 0xABC
callq 0xc140
leaq 0x43218(%rip), %rdi     # 0xd1fa1
leaq 0x4212a(%rip), %rsi     # 0xd0eba
leaq 0x431e4(%rip), %rcx     # 0xd1f7b
movl $0xabd, %edx            # imm = 0xABD
callq 0xc140
leaq 0x2d910(%rip), %rdi     # 0xbc6b8
leaq 0x2c890(%rip), %rsi     # 0xbb63f
leaq 0x2d91b(%rip), %rcx     # 0xbc6d1
movl $0x20e, %edx            # imm = 0x20E
callq 0xc140