// File: Ciaxur[P]yagb-emu/include/imgui/imgui_draw.cpp
// Function: ImDrawListSplitter::SetCurrentChannel(ImDrawList*, int)
void ImDrawListSplitter::SetCurrentChannel(ImDrawList* draw_list, int idx)
{
    IM_ASSERT(idx >= 0 && idx < _Count);
    if (_Current == idx)
        return;

    // Overwrite ImVector (12/16 bytes), four times. This is merely a silly optimization instead of doing .swap()
    memcpy(&_Channels.Data[_Current]._CmdBuffer, &draw_list->CmdBuffer, sizeof(draw_list->CmdBuffer));
    memcpy(&_Channels.Data[_Current]._IdxBuffer, &draw_list->IdxBuffer, sizeof(draw_list->IdxBuffer));
    _Current = idx;
    memcpy(&draw_list->CmdBuffer, &_Channels.Data[idx]._CmdBuffer, sizeof(draw_list->CmdBuffer));
    memcpy(&draw_list->IdxBuffer, &_Channels.Data[idx]._IdxBuffer, sizeof(draw_list->IdxBuffer));
    draw_list->_IdxWritePtr = draw_list->IdxBuffer.Data + draw_list->IdxBuffer.Size;

    // If current command is used with different settings we need to add a new command
    ImDrawCmd* curr_cmd = (draw_list->CmdBuffer.Size == 0) ? NULL : &draw_list->CmdBuffer.Data[draw_list->CmdBuffer.Size - 1];
    if (curr_cmd == NULL)
        draw_list->AddDrawCmd();
    else if (curr_cmd->ElemCount == 0)
        ImDrawCmd_HeaderCopy(curr_cmd, &draw_list->_CmdHeader); // Copy ClipRect, TextureId, VtxOffset
    else if (ImDrawCmd_HeaderCompare(curr_cmd, &draw_list->_CmdHeader) != 0)
        draw_list->AddDrawCmd();
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x40, %rsp
movq %rdi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
movl %edx, -0x14(%rbp)
movq -0x8(%rbp), %rax
movq %rax, -0x30(%rbp)
xorl %eax, %eax
cmpl $0x0, -0x14(%rbp)
movb %al, -0x21(%rbp)
jl 0x115256
movq -0x30(%rbp), %rcx
movl -0x14(%rbp), %eax
cmpl 0x4(%rcx), %eax
setl %al
movb %al, -0x21(%rbp)
movb -0x21(%rbp), %al
testb $0x1, %al
jne 0x11525f
jmp 0x115261
jmp 0x115280
leaq 0x751d5(%rip), %rdi     # 0x18a43d
leaq 0x74f07(%rip), %rsi     # 0x18a176
movl $0x639, %edx            # imm = 0x639
leaq 0x751db(%rip), %rcx     # 0x18a456
callq 0xd180
movq -0x30(%rbp), %rax
movl (%rax), %eax
cmpl -0x14(%rbp), %eax
jne 0x115290
jmp 0x1153ef
movq -0x30(%rbp), %rcx
movq 0x10(%rcx), %rax
movslq (%rcx), %rdx
shlq $0x5, %rdx
addq %rdx, %rax
movq -0x10(%rbp), %rdx
movq (%rdx), %rsi
movq %rsi, (%rax)
movq 0x8(%rdx), %rdx
movq %rdx, 0x8(%rax)
movq 0x10(%rcx), %rax
movslq (%rcx), %rdx
shlq $0x5, %rdx
addq %rdx, %rax
movq -0x10(%rbp), %rdx
movq 0x10(%rdx), %rsi
movq %rsi, 0x10(%rax)
movq 0x18(%rdx), %rdx
movq %rdx, 0x18(%rax)
movl -0x14(%rbp), %eax
movl %eax, (%rcx)
movq -0x10(%rbp), %rax
movq 0x10(%rcx), %rdx
movslq -0x14(%rbp), %rsi
shlq $0x5, %rsi
addq %rsi, %rdx
movq (%rdx), %rsi
movq %rsi, (%rax)
movq 0x8(%rdx), %rdx
movq %rdx, 0x8(%rax)
movq -0x10(%rbp), %rax
movq 0x10(%rcx), %rcx
movslq -0x14(%rbp), %rdx
shlq $0x5, %rdx
addq %rdx, %rcx
movq 0x10(%rcx), %rdx
movq %rdx, 0x10(%rax)
movq 0x18(%rcx), %rcx
movq %rcx, 0x18(%rax)
movq -0x10(%rbp), %rax
movq 0x18(%rax), %rcx
movq -0x10(%rbp), %rax
movslq 0x10(%rax), %rax
shlq %rax
addq %rax, %rcx
movq -0x10(%rbp), %rax
movq %rcx, 0x50(%rax)
movq -0x10(%rbp), %rax
cmpl $0x0, (%rax)
jne 0x11534e
xorl %eax, %eax
movq %rax, -0x38(%rbp)
jmp 0x11536d
movq -0x10(%rbp), %rax
movq 0x8(%rax), %rax
movq -0x10(%rbp), %rcx
movl (%rcx), %ecx
subl $0x1, %ecx
movslq %ecx, %rcx
imulq $0x38, %rcx, %rcx
addq %rcx, %rax
movq %rax, -0x38(%rbp)
movq -0x38(%rbp), %rax
movq %rax, -0x20(%rbp)
cmpq $0x0, -0x20(%rbp)
jne 0x115387
movq -0x10(%rbp), %rdi
callq 0x10f070
jmp 0x1153ef
movq -0x20(%rbp), %rax
cmpl $0x0, 0x20(%rax)
jne 0x1153c4
movq -0x20(%rbp), %rax
movq -0x10(%rbp), %rcx
movq 0x88(%rcx), %rdx
movq %rdx, (%rax)
movq 0x90(%rcx), %rdx
movq %rdx, 0x8(%rax)
movq 0x98(%rcx), %rdx
movq %rdx, 0x10(%rax)
movl 0xa0(%rcx), %ecx
movl %ecx, 0x18(%rax)
jmp 0x1153ed
movq -0x20(%rbp), %rdi
movq -0x10(%rbp), %rsi
addq $0x88, %rsi
movl $0x1c, %edx
callq 0xd9f0
cmpl $0x0, %eax
je 0x1153eb
movq -0x10(%rbp), %rdi
callq 0x10f070
jmp 0x1153ed
jmp 0x1153ef
addq $0x40, %rsp
popq %rbp
retq
nopw %cs:(%rax,%rax)