// File: /workspace/github_cpp_makefile_star2_O2/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:
cmpl $0x2, 0x84(%rdi)
jl 0x28199
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
pushq %rax
movq %rdi, %rbx
xorl %r14d, %r14d
xorl %esi, %esi
callq 0x2819a
cmpl $0x0, (%rbx)
je 0x2807c
movq %rbx, %rdi
callq 0x1fac8
cmpl $0x0, (%rax)
jne 0x2807c
movq %rbx, %rdi
callq 0x1fb04
leaq 0x88(%rbx), %rax
movq %rax, -0x30(%rbp)
pushq $0x1
popq %r15
xorl %r13d, %r13d
cmpl 0x84(%rbx), %r15d
jge 0x280ce
movq -0x30(%rbp), %rdi
movl %r15d, %esi
callq 0x3006a
movq %rax, %r12
cmpl $0x0, (%rax)
je 0x280c0
movq %r12, %rdi
callq 0x1fac8
cmpl $0x0, (%rax)
jne 0x280c0
movq %r12, %rdi
callq 0x1fb04
addl (%r12), %r13d
addl 0x10(%r12), %r14d
incl %r15d
jmp 0x2808e
movl (%rbx), %esi
addl %r13d, %esi
movq %rbx, %rdi
callq 0x2fed2
leaq 0x10(%rbx), %rdi
movl 0x10(%rbx), %esi
addl %r14d, %esi
callq 0x1f4c4
movslq (%rbx), %rax
imulq $0x30, %rax, %rax
addq 0x8(%rbx), %rax
movslq %r13d, %rcx
negq %rcx
imulq $0x30, %rcx, %r15
addq %rax, %r15
movslq 0x10(%rbx), %rax
addq %rax, %rax
addq 0x18(%rbx), %rax
movslq %r14d, %rcx
addq %rcx, %rcx
subq %rcx, %rax
movq %rax, 0x48(%rbx)
pushq $0x1
popq %r12
cmpl 0x84(%rbx), %r12d
jge 0x28179
movq -0x30(%rbp), %rdi
movl %r12d, %esi
callq 0x3006a
movq %rax, %r13
movslq (%rax), %rax
testq %rax, %rax
je 0x28154
movq 0x8(%r13), %rsi
imulq $0x30, %rax, %r14
movq %r15, %rdi
movq %r14, %rdx
callq 0x7080
addq %r14, %r15
movslq 0x10(%r13), %r14
testq %r14, %r14
je 0x28174
movq 0x48(%rbx), %rdi
movq 0x18(%r13), %rsi
addq %r14, %r14
movq %r14, %rdx
callq 0x7080
addq %r14, 0x48(%rbx)
incl %r12d
jmp 0x2811e
movq %rbx, %rdi
callq 0x27baa
movl $0x1, 0x84(%rbx)
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq