// File: Ciaxur[P]yagb-emu/include/imgui/imgui_tables.cpp
// Function: ImGui::TableBeginCell(ImGuiTable*, int)
void ImGui::TableBeginCell(ImGuiTable* table, int column_n)
{
    ImGuiTableColumn* column = &table->Columns[column_n];
    ImGuiWindow* window = table->InnerWindow;
    table->CurrentColumn = column_n;

    // Start position is roughly ~~ CellRect.Min + CellPadding + Indent
    float start_x = column->WorkMinX;
    if (column->Flags & ImGuiTableColumnFlags_IndentEnable)
        start_x += table->RowIndentOffsetX; // ~~ += window.DC.Indent.x - table->HostIndentX, except we locked it for the row.

    window->DC.CursorPos.x = start_x;
    window->DC.CursorPos.y = table->RowPosY1 + table->CellPaddingY;
    window->DC.CursorMaxPos.x = window->DC.CursorPos.x;
    window->DC.ColumnsOffset.x = start_x - window->Pos.x - window->DC.Indent.x; // FIXME-WORKRECT
    window->DC.CurrLineTextBaseOffset = table->RowTextBaseline;
    window->DC.NavLayerCurrent = (ImGuiNavLayer)column->NavLayerCurrent;

    window->WorkRect.Min.y = window->DC.CursorPos.y;
    window->WorkRect.Min.x = column->WorkMinX;
    window->WorkRect.Max.x = column->WorkMaxX;
    window->DC.ItemWidth = column->ItemWidth;

    // To allow ImGuiListClipper to function we propagate our row height
    if (!column->IsEnabled)
        window->DC.CursorPos.y = ImMax(window->DC.CursorPos.y, table->RowPosY2);

    window->SkipItems = column->IsSkipItems;
    if (column->IsSkipItems)
    {
        window->DC.LastItemId = 0;
        window->DC.LastItemStatusFlags = 0;
    }

    if (table->Flags & ImGuiTableFlags_NoClip)
    {
        // FIXME: if we end up drawing all borders/bg in EndTable, could remove this and just assert that channel hasn't changed.
        table->DrawSplitter.SetCurrentChannel(window->DrawList, TABLE_DRAW_CHANNEL_NOCLIP);
        //IM_ASSERT(table->DrawSplitter._Current == TABLE_DRAW_CHANNEL_NOCLIP);
    }
    else
    {
        // FIXME-TABLE: Could avoid this if draw channel is dummy channel?
        SetWindowClipRectBeforeSetChannel(window, column->ClipRect);
        table->DrawSplitter.SetCurrentChannel(window->DrawList, column->DrawChannelCurrent);
    }
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x30, %rsp
movq %rdi, -0x8(%rbp)
movl %esi, -0xc(%rbp)
movq -0x8(%rbp), %rdi
addq $0x10, %rdi
movl -0xc(%rbp), %esi
callq 0xeea20
movq %rax, -0x18(%rbp)
movq -0x8(%rbp), %rax
movq 0x1d0(%rax), %rax
movq %rax, -0x20(%rbp)
movl -0xc(%rbp), %ecx
movq -0x8(%rbp), %rax
movl %ecx, 0x74(%rax)
movq -0x18(%rbp), %rax
movss 0x34(%rax), %xmm0
movss %xmm0, -0x24(%rbp)
movq -0x18(%rbp), %rax
movl (%rax), %eax
andl $0x4000, %eax           # imm = 0x4000
cmpl $0x0, %eax
je 0x131b70
movq -0x8(%rbp), %rax
movss 0x8c(%rax), %xmm0
addss -0x24(%rbp), %xmm0
movss %xmm0, -0x24(%rbp)
movss -0x24(%rbp), %xmm0
movq -0x20(%rbp), %rax
movss %xmm0, 0xd8(%rax)
movq -0x8(%rbp), %rax
movss 0x7c(%rax), %xmm0
movq -0x8(%rbp), %rax
addss 0xc0(%rax), %xmm0
movq -0x20(%rbp), %rax
movss %xmm0, 0xdc(%rax)
movq -0x20(%rbp), %rax
movss 0xd8(%rax), %xmm0
movq -0x20(%rbp), %rax
movss %xmm0, 0xf0(%rax)
movss -0x24(%rbp), %xmm0
movq -0x20(%rbp), %rax
subss 0x10(%rax), %xmm0
movq -0x20(%rbp), %rax
subss 0x118(%rax), %xmm0
movq -0x20(%rbp), %rax
movss %xmm0, 0x11c(%rax)
movq -0x8(%rbp), %rax
movss 0x88(%rax), %xmm0
movq -0x20(%rbp), %rax
movss %xmm0, 0x110(%rax)
movq -0x18(%rbp), %rax
movsbl 0x61(%rax), %ecx
movq -0x20(%rbp), %rax
movl %ecx, 0x14c(%rax)
movq -0x20(%rbp), %rax
movss 0xdc(%rax), %xmm0
movq -0x20(%rbp), %rax
movss %xmm0, 0x23c(%rax)
movq -0x18(%rbp), %rax
movss 0x34(%rax), %xmm0
movq -0x20(%rbp), %rax
movss %xmm0, 0x238(%rax)
movq -0x18(%rbp), %rax
movss 0x38(%rax), %xmm0
movq -0x20(%rbp), %rax
movss %xmm0, 0x240(%rax)
movq -0x18(%rbp), %rax
movss 0x3c(%rax), %xmm0
movq -0x20(%rbp), %rax
movss %xmm0, 0x1d0(%rax)
movq -0x18(%rbp), %rax
testb $0x1, 0x5a(%rax)
jne 0x131c94
movq -0x20(%rbp), %rax
movss 0xdc(%rax), %xmm0
movq -0x8(%rbp), %rax
movss 0x80(%rax), %xmm1
callq 0x12a620
movq -0x20(%rbp), %rax
movss %xmm0, 0xdc(%rax)
movq -0x18(%rbp), %rax
movb 0x5f(%rax), %cl
movq -0x20(%rbp), %rax
andb $0x1, %cl
movb %cl, 0x93(%rax)
movq -0x18(%rbp), %rax
testb $0x1, 0x5f(%rax)
je 0x131cce
movq -0x20(%rbp), %rax
movl $0x0, 0x124(%rax)
movq -0x20(%rbp), %rax
movl $0x0, 0x128(%rax)
movq -0x8(%rbp), %rax
movl 0x4(%rax), %eax
andl $0x100000, %eax         # imm = 0x100000
cmpl $0x0, %eax
je 0x131d01
movq -0x8(%rbp), %rdi
addq $0x1e8, %rdi            # imm = 0x1E8
movq -0x20(%rbp), %rax
movq 0x2b8(%rax), %rsi
movl $0x2, %edx
callq 0x115220
jmp 0x131d35
movq -0x20(%rbp), %rdi
movq -0x18(%rbp), %rsi
addq $0x20, %rsi
callq 0x131940
movq -0x8(%rbp), %rdi
addq $0x1e8, %rdi            # imm = 0x1E8
movq -0x20(%rbp), %rax
movq 0x2b8(%rax), %rsi
movq -0x18(%rbp), %rax
movzbl 0x57(%rax), %edx
callq 0x115220
addq $0x30, %rsp
popq %rbp
retq
nopl (%rax,%rax)