// File: /workspace/github_cpp_makefile_star2_O1/Ciaxur[P]yagb-emu/include/imgui/imgui_draw.cpp
// Function: ImDrawList::PrimReserve(int, int)
void ImDrawList::PrimReserve(int idx_count, int vtx_count)
{
    // Large mesh support (when enabled)
    IM_ASSERT_PARANOID(idx_count >= 0 && vtx_count >= 0);
    if (sizeof(ImDrawIdx) == 2 && (_VtxCurrentIdx + vtx_count >= (1 << 16)) && (Flags & ImDrawListFlags_AllowVtxOffset))
    {
        // FIXME: In theory we should be testing that vtx_count <64k here.
        // In practice, RenderText() relies on reserving ahead for a worst case scenario so it is currently useful for us
        // to not make that check until we rework the text functions to handle clipping and large horizontal lines better.
        _CmdHeader.VtxOffset = VtxBuffer.Size;
        _OnChangedVtxOffset();
    }

    ImDrawCmd* draw_cmd = &CmdBuffer.Data[CmdBuffer.Size - 1];
    draw_cmd->ElemCount += idx_count;

    int vtx_buffer_old_size = VtxBuffer.Size;
    VtxBuffer.resize(vtx_buffer_old_size + vtx_count);
    _VtxWritePtr = VtxBuffer.Data + vtx_buffer_old_size;

    int idx_buffer_old_size = IdxBuffer.Size;
    IdxBuffer.resize(idx_buffer_old_size + idx_count);
    _IdxWritePtr = IdxBuffer.Data + idx_buffer_old_size;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
pushq %rax
movl %edx, %r15d
movl %esi, %r14d
movq %rdi, %rbx
movl 0x34(%rdi), %eax
addl %edx, %eax
cmpl $0x10000, %eax          # imm = 0x10000
jb 0x77472
testb $0x8, 0x30(%rbx)
je 0x77472
movl 0x20(%rbx), %eax
movl %eax, 0xa0(%rbx)
movq %rbx, %rdi
callq 0x7710e
movq 0x8(%rbx), %rax
movslq (%rbx), %rcx
imulq $0x38, %rcx, %rcx
addl %r14d, -0x18(%rax,%rcx)
movslq 0x20(%rbx), %r13
addl %r13d, %r15d
movl 0x24(%rbx), %eax
cmpl %r15d, %eax
jge 0x77500
testl %eax, %eax
je 0x774a7
movl %eax, %r12d
shrl $0x1f, %r12d
addl %eax, %r12d
sarl %r12d
addl %eax, %r12d
jmp 0x774ad
movl $0x8, %r12d
cmpl %r15d, %r12d
cmovlel %r15d, %r12d
cmpl %r12d, %eax
jge 0x77500
movslq %r12d, %rax
shlq $0x2, %rax
leaq (%rax,%rax,4), %rdi
callq 0x424fb
movq 0x28(%rbx), %rsi
testq %rsi, %rsi
je 0x774f8
movslq 0x20(%rbx), %rcx
shlq $0x2, %rcx
leaq (%rcx,%rcx,4), %rdx
movq %rax, -0x30(%rbp)
movq -0x30(%rbp), %rdi
callq 0xc080
movq 0x28(%rbx), %rdi
callq 0x425d4
movq -0x30(%rbp), %rax
movq %rax, 0x28(%rbx)
movl %r12d, 0x24(%rbx)
movl %r15d, 0x20(%rbx)
leaq (,%r13,4), %rax
addq %r13, %rax
shlq $0x2, %rax
addq 0x28(%rbx), %rax
movq %rax, 0x48(%rbx)
movslq 0x10(%rbx), %r12
addl %r12d, %r14d
movl 0x14(%rbx), %eax
cmpl %r14d, %eax
jge 0x77589
testl %eax, %eax
je 0x77540
movl %eax, %r13d
shrl $0x1f, %r13d
addl %eax, %r13d
sarl %r13d
addl %eax, %r13d
jmp 0x77546
movl $0x8, %r13d
cmpl %r14d, %r13d
cmovlel %r14d, %r13d
cmpl %r13d, %eax
jge 0x77589
movslq %r13d, %rdi
addq %rdi, %rdi
callq 0x424fb
movq %rax, %r15
movq 0x18(%rbx), %rsi
testq %rsi, %rsi
je 0x77581
movslq 0x10(%rbx), %rdx
addq %rdx, %rdx
movq %r15, %rdi
callq 0xc080
movq 0x18(%rbx), %rdi
callq 0x425d4
movq %r15, 0x18(%rbx)
movl %r13d, 0x14(%rbx)
movl %r14d, 0x10(%rbx)
addq %r12, %r12
addq 0x18(%rbx), %r12
movq %r12, 0x50(%rbx)
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
nop