// File: Ciaxur[P]yagb-emu/include/imgui/imgui_tables.cpp
// Function: ImGui::TableSetupDrawChannels(ImGuiTable*)
void ImGui::TableSetupDrawChannels(ImGuiTable* table)
{
    const int freeze_row_multiplier = (table->FreezeRowsCount > 0) ? 2 : 1;
    const int channels_for_row = (table->Flags & ImGuiTableFlags_NoClip) ? 1 : table->ColumnsEnabledCount;
    const int channels_for_bg = 1 + 1 * freeze_row_multiplier;
    const int channels_for_dummy = (table->ColumnsEnabledCount < table->ColumnsCount || table->VisibleMaskByIndex != table->EnabledMaskByIndex) ? +1 : 0;
    const int channels_total = channels_for_bg + (channels_for_row * freeze_row_multiplier) + channels_for_dummy;
    table->DrawSplitter.Split(table->InnerWindow->DrawList, channels_total);
    table->DummyDrawChannel = (ImGuiTableDrawChannelIdx)((channels_for_dummy > 0) ? channels_total - 1 : -1);
    table->Bg2DrawChannelCurrent = TABLE_DRAW_CHANNEL_BG2_FROZEN;
    table->Bg2DrawChannelUnfrozen = (ImGuiTableDrawChannelIdx)((table->FreezeRowsCount > 0) ? 2 + channels_for_row : TABLE_DRAW_CHANNEL_BG2_FROZEN);

    int draw_channel_current = 2;
    for (int column_n = 0; column_n < table->ColumnsCount; column_n++)
    {
        ImGuiTableColumn* column = &table->Columns[column_n];
        if (column->IsVisibleX && column->IsVisibleY)
        {
            column->DrawChannelFrozen = (ImGuiTableDrawChannelIdx)(draw_channel_current);
            column->DrawChannelUnfrozen = (ImGuiTableDrawChannelIdx)(draw_channel_current + (table->FreezeRowsCount > 0 ? channels_for_row + 1 : 0));
            if (!(table->Flags & ImGuiTableFlags_NoClip))
                draw_channel_current++;
        }
        else
        {
            column->DrawChannelFrozen = column->DrawChannelUnfrozen = table->DummyDrawChannel;
        }
        column->DrawChannelCurrent = column->DrawChannelFrozen;
    }

    // Initial draw cmd starts with a BgClipRect that matches the one of its host, to facilitate merge draw commands by default.
    // All our cell highlight are manually clipped with BgClipRect. When unfreezing it will be made smaller to fit scrolling rect.
    // (This technically isn't part of setting up draw channels, but is reasonably related to be done here)
    table->BgClipRect = table->InnerClipRect;
    table->Bg0ClipRectForDrawCmd = table->OuterWindow->ClipRect;
    table->Bg2ClipRectForDrawCmd = table->HostClipRect;
    IM_ASSERT(table->BgClipRect.Min.y <= table->BgClipRect.Max.y);
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x50, %rsp
movq %rdi, -0x8(%rbp)
movq -0x8(%rbp), %rax
movsbl 0x241(%rax), %edx
movl $0x1, %eax
movl $0x2, %ecx
cmpl $0x0, %edx
cmovgl %ecx, %eax
movl %eax, -0xc(%rbp)
movq -0x8(%rbp), %rax
movl 0x4(%rax), %eax
andl $0x100000, %eax         # imm = 0x100000
cmpl $0x0, %eax
je 0x12d075
movl $0x1, %eax
movl %eax, -0x34(%rbp)
jmp 0x12d083
movq -0x8(%rbp), %rax
movsbl 0x231(%rax), %eax
movl %eax, -0x34(%rbp)
movl -0x34(%rbp), %eax
movl %eax, -0x10(%rbp)
movl -0xc(%rbp), %eax
shll $0x0, %eax
addl $0x1, %eax
movl %eax, -0x14(%rbp)
movq -0x8(%rbp), %rax
movsbl 0x231(%rax), %ecx
movq -0x8(%rbp), %rdx
movb $0x1, %al
cmpl 0x6c(%rdx), %ecx
movb %al, -0x35(%rbp)
jl 0x12d0c4
movq -0x8(%rbp), %rax
movq 0x50(%rax), %rax
movq -0x8(%rbp), %rcx
cmpq 0x48(%rcx), %rax
setne %al
movb %al, -0x35(%rbp)
movb -0x35(%rbp), %dl
xorl %eax, %eax
movl $0x1, %ecx
testb $0x1, %dl
cmovnel %ecx, %eax
movl %eax, -0x18(%rbp)
movl -0x14(%rbp), %eax
movl -0x10(%rbp), %ecx
imull -0xc(%rbp), %ecx
addl %ecx, %eax
addl -0x18(%rbp), %eax
movl %eax, -0x1c(%rbp)
movq -0x8(%rbp), %rdi
addq $0x1e8, %rdi            # imm = 0x1E8
movq -0x8(%rbp), %rax
movq 0x1d0(%rax), %rax
movq 0x2b8(%rax), %rsi
movl -0x1c(%rbp), %edx
callq 0x114c90
cmpl $0x0, -0x18(%rbp)
jle 0x12d11f
movl -0x1c(%rbp), %eax
subl $0x1, %eax
movl %eax, -0x3c(%rbp)
jmp 0x12d129
movl $0xffffffff, %eax       # imm = 0xFFFFFFFF
movl %eax, -0x3c(%rbp)
jmp 0x12d129
movl -0x3c(%rbp), %eax
movb %al, %cl
movq -0x8(%rbp), %rax
movb %cl, 0x245(%rax)
movq -0x8(%rbp), %rax
movb $0x1, 0x246(%rax)
movq -0x8(%rbp), %rax
movsbl 0x241(%rax), %eax
cmpl $0x0, %eax
jle 0x12d15e
movl -0x10(%rbp), %eax
addl $0x2, %eax
movl %eax, -0x40(%rbp)
jmp 0x12d168
movl $0x1, %eax
movl %eax, -0x40(%rbp)
jmp 0x12d168
movl -0x40(%rbp), %eax
movb %al, %cl
movq -0x8(%rbp), %rax
movb %cl, 0x247(%rax)
movl $0x2, -0x20(%rbp)
movl $0x0, -0x24(%rbp)
movl -0x24(%rbp), %eax
movq -0x8(%rbp), %rcx
cmpl 0x6c(%rcx), %eax
jge 0x12d252
movq -0x8(%rbp), %rdi
addq $0x10, %rdi
movl -0x24(%rbp), %esi
callq 0xeea20
movq %rax, -0x30(%rbp)
movq -0x30(%rbp), %rax
testb $0x1, 0x5c(%rax)
je 0x12d21e
movq -0x30(%rbp), %rax
testb $0x1, 0x5d(%rax)
je 0x12d21e
movl -0x20(%rbp), %eax
movb %al, %cl
movq -0x30(%rbp), %rax
movb %cl, 0x58(%rax)
movl -0x20(%rbp), %eax
movl %eax, -0x44(%rbp)
movq -0x8(%rbp), %rax
movsbl 0x241(%rax), %eax
cmpl $0x0, %eax
jle 0x12d1ea
movl -0x10(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x48(%rbp)
jmp 0x12d1f1
xorl %eax, %eax
movl %eax, -0x48(%rbp)
jmp 0x12d1f1
movl -0x44(%rbp), %eax
movl -0x48(%rbp), %ecx
addl %ecx, %eax
movb %al, %cl
movq -0x30(%rbp), %rax
movb %cl, 0x59(%rax)
movq -0x8(%rbp), %rax
movl 0x4(%rax), %eax
andl $0x100000, %eax         # imm = 0x100000
cmpl $0x0, %eax
jne 0x12d21c
movl -0x20(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x20(%rbp)
jmp 0x12d236
movq -0x8(%rbp), %rax
movb 0x245(%rax), %cl
movq -0x30(%rbp), %rax
movb %cl, 0x59(%rax)
movq -0x30(%rbp), %rax
movb %cl, 0x58(%rax)
movq -0x30(%rbp), %rax
movb 0x58(%rax), %cl
movq -0x30(%rbp), %rax
movb %cl, 0x57(%rax)
movl -0x24(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x24(%rbp)
jmp 0x12d185
movq -0x8(%rbp), %rcx
movq -0x8(%rbp), %rax
movq 0x11c(%rcx), %rdx
movq %rdx, 0x12c(%rax)
movq 0x124(%rcx), %rcx
movq %rcx, 0x134(%rax)
movq -0x8(%rbp), %rax
movq 0x1c8(%rax), %rcx
movq -0x8(%rbp), %rax
movq 0x258(%rcx), %rdx
movq %rdx, 0x13c(%rax)
movq 0x260(%rcx), %rcx
movq %rcx, 0x144(%rax)
movq -0x8(%rbp), %rcx
movq -0x8(%rbp), %rax
movq 0x15c(%rcx), %rdx
movq %rdx, 0x14c(%rax)
movq 0x164(%rcx), %rcx
movq %rcx, 0x154(%rax)
movq -0x8(%rbp), %rax
movss 0x130(%rax), %xmm1
movq -0x8(%rbp), %rax
movss 0x138(%rax), %xmm0
ucomiss %xmm1, %xmm0
jb 0x12d2e4
jmp 0x12d303
leaq 0x5fabf(%rip), %rdi     # 0x18cdaa
leaq 0x5ecb0(%rip), %rsi     # 0x18bfa2
movl $0x887, %edx            # imm = 0x887
leaq 0x5fadf(%rip), %rcx     # 0x18cddd
callq 0xd180
addq $0x50, %rsp
popq %rbp
retq
nopl (%rax)