// File: donfreiday[P]gb/./imgui/imgui_draw.cpp
// Function: ImDrawList::ChannelsMerge()
void ImDrawList::ChannelsMerge()
{
    // Note that we never use or rely on channels.Size because it is merely a buffer that we never shrink back to 0 to keep all sub-buffers ready for use.
    if (_ChannelsCount <= 1)
        return;

    ChannelsSetCurrent(0);
    if (CmdBuffer.Size && CmdBuffer.back().ElemCount == 0)
        CmdBuffer.pop_back();

    int new_cmd_buffer_count = 0, new_idx_buffer_count = 0;
    for (int i = 1; i < _ChannelsCount; i++)
    {
        ImDrawChannel& ch = _Channels[i];
        if (ch.CmdBuffer.Size && ch.CmdBuffer.back().ElemCount == 0)
            ch.CmdBuffer.pop_back();
        new_cmd_buffer_count += ch.CmdBuffer.Size;
        new_idx_buffer_count += ch.IdxBuffer.Size;
    }
    CmdBuffer.resize(CmdBuffer.Size + new_cmd_buffer_count);
    IdxBuffer.resize(IdxBuffer.Size + new_idx_buffer_count);

    ImDrawCmd* cmd_write = CmdBuffer.Data + CmdBuffer.Size - new_cmd_buffer_count;
    _IdxWritePtr = IdxBuffer.Data + IdxBuffer.Size - new_idx_buffer_count;
    for (int i = 1; i < _ChannelsCount; i++)
    {
        ImDrawChannel& ch = _Channels[i];
        if (int sz = ch.CmdBuffer.Size) { memcpy(cmd_write, ch.CmdBuffer.Data, sz * sizeof(ImDrawCmd)); cmd_write += sz; }
        if (int sz = ch.IdxBuffer.Size) { memcpy(_IdxWritePtr, ch.IdxBuffer.Data, sz * sizeof(ImDrawIdx)); _IdxWritePtr += sz; }
    }
    AddDrawCmd();
    _ChannelsCount = 1;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x50, %rsp
movq %rdi, -0x8(%rbp)
movq -0x8(%rbp), %rax
movq %rax, -0x48(%rbp)
cmpl $0x1, 0x84(%rax)
jg 0x3d552
jmp 0x3d740
movq -0x48(%rbp), %rdi
xorl %esi, %esi
callq 0x3d750
movq -0x48(%rbp), %rax
cmpl $0x0, (%rax)
je 0x3d57d
movq -0x48(%rbp), %rdi
callq 0x31000
cmpl $0x0, (%rax)
jne 0x3d57d
movq -0x48(%rbp), %rdi
callq 0x31060
movl $0x0, -0xc(%rbp)
movl $0x0, -0x10(%rbp)
movl $0x1, -0x14(%rbp)
movq -0x48(%rbp), %rcx
movl -0x14(%rbp), %eax
cmpl 0x84(%rcx), %eax
jge 0x3d5fc
movq -0x48(%rbp), %rdi
addq $0x88, %rdi
movl -0x14(%rbp), %esi
callq 0x4c120
movq %rax, -0x20(%rbp)
movq -0x20(%rbp), %rax
cmpl $0x0, (%rax)
je 0x3d5d8
movq -0x20(%rbp), %rdi
callq 0x31000
cmpl $0x0, (%rax)
jne 0x3d5d8
movq -0x20(%rbp), %rdi
callq 0x31060
movq -0x20(%rbp), %rax
movl (%rax), %eax
addl -0xc(%rbp), %eax
movl %eax, -0xc(%rbp)
movq -0x20(%rbp), %rax
movl 0x10(%rax), %eax
addl -0x10(%rbp), %eax
movl %eax, -0x10(%rbp)
movl -0x14(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x14(%rbp)
jmp 0x3d592
movq -0x48(%rbp), %rdi
movl (%rdi), %esi
addl -0xc(%rbp), %esi
callq 0x4bea0
movq -0x48(%rbp), %rax
movq %rax, %rdi
addq $0x10, %rdi
movl 0x10(%rax), %esi
addl -0x10(%rbp), %esi
callq 0x2ff70
movq -0x48(%rbp), %rax
movq 0x8(%rax), %rcx
movslq (%rax), %rdx
imulq $0x30, %rdx, %rdx
addq %rdx, %rcx
movslq -0xc(%rbp), %rsi
xorl %edx, %edx
subq %rsi, %rdx
imulq $0x30, %rdx, %rdx
addq %rdx, %rcx
movq %rcx, -0x28(%rbp)
movq 0x18(%rax), %rcx
movslq 0x10(%rax), %rdx
shlq %rdx
addq %rdx, %rcx
movslq -0x10(%rbp), %rsi
xorl %edx, %edx
subq %rsi, %rdx
shlq %rdx
addq %rdx, %rcx
movq %rcx, 0x48(%rax)
movl $0x1, -0x2c(%rbp)
movq -0x48(%rbp), %rcx
movl -0x2c(%rbp), %eax
cmpl 0x84(%rcx), %eax
jge 0x3d729
movq -0x48(%rbp), %rdi
addq $0x88, %rdi
movl -0x2c(%rbp), %esi
callq 0x4c120
movq %rax, -0x38(%rbp)
movq -0x38(%rbp), %rax
movl (%rax), %eax
movl %eax, -0x3c(%rbp)
cmpl $0x0, -0x3c(%rbp)
je 0x3d6d5
movq -0x28(%rbp), %rdi
movq -0x38(%rbp), %rax
movq 0x8(%rax), %rsi
movslq -0x3c(%rbp), %rax
imulq $0x30, %rax, %rdx
callq 0x7080
movl -0x3c(%rbp), %ecx
movq -0x28(%rbp), %rax
movslq %ecx, %rcx
imulq $0x30, %rcx, %rcx
addq %rcx, %rax
movq %rax, -0x28(%rbp)
movq -0x38(%rbp), %rax
movl 0x10(%rax), %eax
movl %eax, -0x40(%rbp)
cmpl $0x0, -0x40(%rbp)
je 0x3d719
movq -0x48(%rbp), %rax
movq 0x48(%rax), %rdi
movq -0x38(%rbp), %rax
movq 0x18(%rax), %rsi
movslq -0x40(%rbp), %rdx
shlq %rdx
callq 0x7080
movq -0x48(%rbp), %rax
movl -0x40(%rbp), %edx
movq 0x48(%rax), %rcx
movslq %edx, %rdx
shlq %rdx
addq %rdx, %rcx
movq %rcx, 0x48(%rax)
jmp 0x3d71b
movl -0x2c(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x2c(%rbp)
jmp 0x3d66e
movq -0x48(%rbp), %rdi
callq 0x3cda0
movq -0x48(%rbp), %rax
movl $0x1, 0x84(%rax)
addq $0x50, %rsp
popq %rbp
retq
nopw %cs:(%rax,%rax)