// File: /workspace/github_cpp_makefile_star2_O2/donfreiday[P]gb/./imgui/imgui_draw.cpp
// Function: ImDrawList::AddText(ImFont const*, float, ImVec2 const&, unsigned int, char const*, char const*, float, ImVec4 const*)
void ImDrawList::AddText(const ImFont* font, float font_size, const ImVec2& pos, ImU32 col, const char* text_begin, const char* text_end, float wrap_width, const ImVec4* cpu_fine_clip_rect)
{
    if ((col >> 24) == 0)
        return;

    if (text_end == NULL)
        text_end = text_begin + strlen(text_begin);
    if (text_begin == text_end)
        return;

    IM_ASSERT(font->ContainerAtlas->TexID == _TextureIdStack.back());  // Use high-level ImGui::PushFont() or low-level ImDrawList::PushTextureId() to change font.

    // reserve vertices for worse case (over-reserving is useful and easily amortized)
    const int char_count = (int)(text_end - text_begin);
    const int vtx_count_max = char_count * 4;
    const int idx_count_max = char_count * 6;
    const int vtx_begin = VtxBuffer.Size;
    const int idx_begin = IdxBuffer.Size;
    PrimReserve(idx_count_max, vtx_count_max);

    ImVec4 clip_rect = _ClipRectStack.back();
    if (cpu_fine_clip_rect)
    {
        clip_rect.x = ImMax(clip_rect.x, cpu_fine_clip_rect->x);
        clip_rect.y = ImMax(clip_rect.y, cpu_fine_clip_rect->y);
        clip_rect.z = ImMin(clip_rect.z, cpu_fine_clip_rect->z);
        clip_rect.w = ImMin(clip_rect.w, cpu_fine_clip_rect->w);
    }
    font->RenderText(font_size, pos, col, clip_rect, text_begin, text_end, this, wrap_width, cpu_fine_clip_rect != NULL);

    // give back unused vertices
    // FIXME-OPT: clean this up
    VtxBuffer.resize((int)(_VtxWritePtr - VtxBuffer.Data));
    IdxBuffer.resize((int)(_IdxWritePtr - IdxBuffer.Data));
    int vtx_unused = vtx_count_max - (VtxBuffer.Size - vtx_begin);
    int idx_unused = idx_count_max - (IdxBuffer.Size - idx_begin);
    CmdBuffer.back().ElemCount -= idx_unused;
    _VtxWritePtr -= vtx_unused;
    _IdxWritePtr -= idx_unused;
    _VtxCurrentIdx = (ImDrawIdx)VtxBuffer.Size;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x58, %rsp
cmpl $0x1000000, %ecx        # imm = 0x1000000
jb 0x29f19
movq %r9, %r12
movq %r8, %r14
movl %ecx, %r15d
movq %rsi, %r13
movq %rdi, %rbx
testq %r9, %r9
movss %xmm1, -0x54(%rbp)
movss %xmm0, -0x50(%rbp)
jne 0x29d9b
movq %r14, %rdi
movq %rdx, %r12
callq 0x7300
movq %r12, %rdx
movq %rax, %r12
addq %r14, %r12
cmpq %r14, %r12
je 0x29f19
movq %rdx, -0x70(%rbp)
movq %r13, -0x78(%rbp)
movq 0x30(%r13), %rax
movq (%rax), %r13
leaq 0x60(%rbx), %rdi
callq 0x300c6
cmpq (%rax), %r13
jne 0x29f28
movl %r12d, %r13d
subl %r14d, %r13d
imull $0x6, %r13d, %esi
shll $0x2, %r13d
leaq 0x20(%rbx), %rax
movq %rax, -0x60(%rbp)
movl 0x10(%rbx), %eax
movl %eax, -0x4c(%rbp)
movl 0x20(%rbx), %eax
movl %eax, -0x48(%rbp)
leaq 0x10(%rbx), %rax
movq %rax, -0x68(%rbp)
movq %rbx, %rdi
movl %esi, -0x44(%rbp)
movl %r13d, %edx
callq 0x2820c
leaq 0x50(%rbx), %rdi
callq 0x1fd26
movq 0x10(%rbp), %rcx
movups (%rax), %xmm0
movaps %xmm0, -0x40(%rbp)
testq %rcx, %rcx
je 0x29e73
movss (%rcx), %xmm0
movss -0x40(%rbp), %xmm1
movss -0x3c(%rbp), %xmm2
movaps %xmm0, %xmm3
cmpless %xmm1, %xmm3
andps %xmm3, %xmm1
andnps %xmm0, %xmm3
orps %xmm1, %xmm3
movss %xmm3, -0x40(%rbp)
movss 0x4(%rcx), %xmm0
movaps %xmm0, %xmm1
cmpless %xmm2, %xmm1
andps %xmm1, %xmm2
andnps %xmm0, %xmm1
orps %xmm2, %xmm1
movss %xmm1, -0x3c(%rbp)
movss -0x38(%rbp), %xmm0
minss 0x8(%rcx), %xmm0
movss %xmm0, -0x38(%rbp)
movss -0x34(%rbp), %xmm0
minss 0xc(%rcx), %xmm0
movss %xmm0, -0x34(%rbp)
xorl %eax, %eax
testq %rcx, %rcx
setne %al
movq -0x70(%rbp), %rcx
movsd (%rcx), %xmm1
movl %eax, (%rsp)
leaq -0x40(%rbp), %rdx
movq -0x78(%rbp), %rdi
movss -0x50(%rbp), %xmm0
movl %r15d, %esi
movq %r14, %rcx
movq %r12, %r8
movq %rbx, %r9
movss -0x54(%rbp), %xmm2
callq 0x29f48
movq 0x40(%rbx), %rax
subq 0x28(%rbx), %rax
pushq $0x14
popq %rcx
cqto
idivq %rcx
movq -0x60(%rbp), %rdi
movl %eax, %esi
callq 0x2ff10
movq 0x48(%rbx), %rsi
subq 0x18(%rbx), %rsi
shrq %rsi
movq -0x68(%rbp), %rdi
callq 0x1f4c4
movl -0x48(%rbp), %r15d
addl %r13d, %r15d
subl 0x20(%rbx), %r15d
movl -0x4c(%rbp), %r14d
subl 0x10(%rbx), %r14d
addl -0x44(%rbp), %r14d
movq %rbx, %rdi
callq 0x1fac8
subl %r14d, (%rax)
movslq %r15d, %rax
negq %rax
imulq $0x14, %rax, %rax
addq %rax, 0x40(%rbx)
movslq %r14d, %rax
addq %rax, %rax
subq %rax, 0x48(%rbx)
movzwl 0x20(%rbx), %eax
movl %eax, 0x38(%rbx)
addq $0x58, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
leaq 0x15b6d(%rip), %rdi     # 0x3fa9c
leaq 0x15a70(%rip), %rsi     # 0x3f9a6
leaq 0x15b95(%rip), %rcx     # 0x3fad2
movl $0x343, %edx            # imm = 0x343
callq 0x7140
nop