// File: donfreiday[P]gb/./imgui/imgui_draw.cpp
// Function: ImDrawList::ChannelsSplit(int)
void ImDrawList::ChannelsSplit(int channels_count)
{
    IM_ASSERT(_ChannelsCurrent == 0 && _ChannelsCount == 1);
    int old_channels_count = _Channels.Size;
    if (old_channels_count < channels_count)
        _Channels.resize(channels_count);
    _ChannelsCount = channels_count;

    // _Channels[] (24 bytes each) hold storage that we'll swap with this->_CmdBuffer/_IdxBuffer
    // The content of _Channels[0] at this point doesn't matter. We clear it to make state tidy in a debugger but we don't strictly need to.
    // When we switch to the next channel, we'll copy _CmdBuffer/_IdxBuffer into _Channels[0] and then _Channels[1] into _CmdBuffer/_IdxBuffer
    memset(&_Channels[0], 0, sizeof(ImDrawChannel));
    for (int i = 1; i < channels_count; i++)
    {
        if (i >= old_channels_count)
        {
            new(&_Channels[i]) ImDrawChannel();
        }
        else
        {
            _Channels[i].CmdBuffer.resize(0);
            _Channels[i].IdxBuffer.resize(0);
        }
        if (_Channels[i].CmdBuffer.Size == 0)
        {
            ImDrawCmd draw_cmd;
            draw_cmd.ClipRect = _ClipRectStack.back();
            draw_cmd.TextureId = _TextureIdStack.back();
            _Channels[i].CmdBuffer.push_back(draw_cmd);
        }
    }
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x60, %rsp
movq %rdi, -0x8(%rbp)
movl %esi, -0xc(%rbp)
movq -0x8(%rbp), %rcx
movq %rcx, -0x58(%rbp)
xorl %eax, %eax
cmpl $0x0, 0x80(%rcx)
movb %al, -0x49(%rbp)
jne 0x3d396
movq -0x58(%rbp), %rax
cmpl $0x1, 0x84(%rax)
sete %al
movb %al, -0x49(%rbp)
movb -0x49(%rbp), %al
testb $0x1, %al
jne 0x3d39f
jmp 0x3d3a1
jmp 0x3d3c0
leaq 0x271f3(%rip), %rdi     # 0x6459b
leaq 0x27147(%rip), %rsi     # 0x644f6
movl $0xe3, %edx
leaq 0x2720d(%rip), %rcx     # 0x645c8
callq 0x7160
movq -0x58(%rbp), %rax
movl 0x88(%rax), %eax
movl %eax, -0x10(%rbp)
movl -0x10(%rbp), %eax
cmpl -0xc(%rbp), %eax
jge 0x3d3e8
movq -0x58(%rbp), %rdi
addq $0x88, %rdi
movl -0xc(%rbp), %esi
callq 0x4c490
movq -0x58(%rbp), %rdi
movl -0xc(%rbp), %eax
movl %eax, 0x84(%rdi)
addq $0x88, %rdi
xorl %esi, %esi
callq 0x4c120
movq %rax, %rdi
xorl %esi, %esi
movl $0x20, %edx
callq 0x7240
movl $0x1, -0x14(%rbp)
movl -0x14(%rbp), %eax
cmpl -0xc(%rbp), %eax
jge 0x3d51c
movl -0x14(%rbp), %eax
cmpl -0x10(%rbp), %eax
jl 0x3d45e
movq -0x58(%rbp), %rdi
addq $0x88, %rdi
movl -0x14(%rbp), %esi
callq 0x4c120
movq %rax, %rdi
movq %rdi, -0x60(%rbp)
xorl %esi, %esi
movl $0x20, %edx
callq 0x7240
movq -0x60(%rbp), %rdi
callq 0x4c4e0
jmp 0x3d49c
movq -0x58(%rbp), %rdi
addq $0x88, %rdi
movl -0x14(%rbp), %esi
callq 0x4c120
movq %rax, %rdi
xorl %esi, %esi
callq 0x4bea0
movq -0x58(%rbp), %rdi
addq $0x88, %rdi
movl -0x14(%rbp), %esi
callq 0x4c120
movq %rax, %rdi
addq $0x10, %rdi
xorl %esi, %esi
callq 0x2ff70
movq -0x58(%rbp), %rdi
addq $0x88, %rdi
movl -0x14(%rbp), %esi
callq 0x4c120
cmpl $0x0, (%rax)
jne 0x3d50c
leaq -0x48(%rbp), %rdi
callq 0x4c1d0
movq -0x58(%rbp), %rdi
addq $0x50, %rdi
callq 0x314a0
movq -0x58(%rbp), %rdi
movq (%rax), %rcx
movq %rcx, -0x44(%rbp)
movq 0x8(%rax), %rax
movq %rax, -0x3c(%rbp)
addq $0x60, %rdi
callq 0x4c250
movq -0x58(%rbp), %rdi
movq (%rax), %rax
movq %rax, -0x30(%rbp)
addq $0x88, %rdi
movl -0x14(%rbp), %esi
callq 0x4c120
movq %rax, %rdi
leaq -0x48(%rbp), %rsi
callq 0x4c2b0
jmp 0x3d50e
movl -0x14(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x14(%rbp)
jmp 0x3d419
addq $0x60, %rsp
popq %rbp
retq
nopw %cs:(%rax,%rax)