// File: /workspace/github_cpp_makefile_star2_O1/donfreiday[P]gb/./imgui/imgui_draw.cpp
// Function: ImFont::RenderText(float, ImVec2, unsigned int, ImVec4 const&, char const*, char const*, ImDrawList*, float, bool) const
void ImFont::RenderText(float size, ImVec2 pos, ImU32 col, const ImVec4& clip_rect, const char* text_begin, const char* text_end, ImDrawList* draw_list, float wrap_width, bool cpu_fine_clip) const
{
    if (!text_end)
        text_end = text_begin + strlen(text_begin);

    // Align to be pixel perfect
    pos.x = (float)(int)pos.x + DisplayOffset.x;
    pos.y = (float)(int)pos.y + DisplayOffset.y;
    float x = pos.x;
    float y = pos.y;
    if (y > clip_rect.w)
        return;

    const float scale = size / FontSize;
    const float line_height = FontSize * scale;
    const bool word_wrap_enabled = (wrap_width > 0.0f);
    const char* word_wrap_eol = NULL;

    ImDrawVert* vtx_write = draw_list->_VtxWritePtr;
    ImDrawIdx* idx_write = draw_list->_IdxWritePtr;
    unsigned int vtx_current_idx = draw_list->_VtxCurrentIdx;

    const char* s = text_begin;
    if (!word_wrap_enabled && y + line_height < clip_rect.y)
        while (s < text_end && *s != '\n')  // Fast-forward to next line
            s++;
    while (s < text_end)
    {
        if (word_wrap_enabled)
        {
            // Calculate how far we can render. Requires two passes on the string data but keeps the code simple and not intrusive for what's essentially an uncommon feature.
            if (!word_wrap_eol)
            {
                word_wrap_eol = CalcWordWrapPositionA(scale, s, text_end, wrap_width - (x - pos.x));
                if (word_wrap_eol == s) // Wrap_width is too small to fit anything. Force displaying 1 character to minimize the height discontinuity.
                    word_wrap_eol++;    // +1 may not be a character start point in UTF-8 but it's ok because we use s >= word_wrap_eol below
            }

            if (s >= word_wrap_eol)
            {
                x = pos.x;
                y += line_height;
                word_wrap_eol = NULL;

                // Wrapping skips upcoming blanks
                while (s < text_end)
                {
                    const char c = *s;
                    if (ImCharIsSpace(c)) { s++; } else if (c == '\n') { s++; break; } else { break; }
                }
                continue;
            }
        }

        // Decode and advance source
        unsigned int c = (unsigned int)*s;
        if (c < 0x80)
        {
            s += 1;
        }
        else
        {
            s += ImTextCharFromUtf8(&c, s, text_end);
            if (c == 0)
                break;
        }

        if (c < 32)
        {
            if (c == '\n')
            {
                x = pos.x;
                y += line_height;

                if (y > clip_rect.w)
                    break;
                if (!word_wrap_enabled && y + line_height < clip_rect.y)
                    while (s < text_end && *s != '\n')  // Fast-forward to next line
                        s++;
                continue;
            }
            if (c == '\r')
                continue;
        }

        float char_width = 0.0f;
        if (const Glyph* glyph = FindGlyph((unsigned short)c))
        {
            char_width = glyph->XAdvance * scale;

            // Clipping on Y is more likely
            if (c != ' ' && c != '\t')
            {
                // We don't do a second finer clipping test on the Y axis (TODO: do some measurement see if it is worth it, probably not)
                float y1 = (float)(y + glyph->Y0 * scale);
                float y2 = (float)(y + glyph->Y1 * scale);

                float x1 = (float)(x + glyph->X0 * scale);
                float x2 = (float)(x + glyph->X1 * scale);
                if (x1 <= clip_rect.z && x2 >= clip_rect.x)
                {
                    // Render a character
                    float u1 = glyph->U0;
                    float v1 = glyph->V0;
                    float u2 = glyph->U1;
                    float v2 = glyph->V1;

                    // CPU side clipping used to fit text in their frame when the frame is too small. Only does clipping for axis aligned quads.
                    if (cpu_fine_clip)
                    {
                        if (x1 < clip_rect.x)
                        {
                            u1 = u1 + (1.0f - (x2 - clip_rect.x) / (x2 - x1)) * (u2 - u1);
                            x1 = clip_rect.x;
                        }
                        if (y1 < clip_rect.y)
                        {
                            v1 = v1 + (1.0f - (y2 - clip_rect.y) / (y2 - y1)) * (v2 - v1);
                            y1 = clip_rect.y;
                        }
                        if (x2 > clip_rect.z)
                        {
                            u2 = u1 + ((clip_rect.z - x1) / (x2 - x1)) * (u2 - u1);
                            x2 = clip_rect.z;
                        }
                        if (y2 > clip_rect.w)
                        {
                            v2 = v1 + ((clip_rect.w - y1) / (y2 - y1)) * (v2 - v1);
                            y2 = clip_rect.w;
                        }
                        if (y1 >= y2)
                        {
                            x += char_width;
                            continue;
                        }
                    }

                    // NB: we are not calling PrimRectUV() here because non-inlined causes too much overhead in a debug build.
                    // inlined:
                    {
                        idx_write[0] = (ImDrawIdx)(vtx_current_idx); idx_write[1] = (ImDrawIdx)(vtx_current_idx+1); idx_write[2] = (ImDrawIdx)(vtx_current_idx+2);
                        idx_write[3] = (ImDrawIdx)(vtx_current_idx); idx_write[4] = (ImDrawIdx)(vtx_current_idx+2); idx_write[5] = (ImDrawIdx)(vtx_current_idx+3);
                        vtx_write[0].pos.x = x1; vtx_write[0].pos.y = y1; vtx_write[0].col = col; vtx_write[0].uv.x = u1; vtx_write[0].uv.y = v1;
                        vtx_write[1].pos.x = x2; vtx_write[1].pos.y = y1; vtx_write[1].col = col; vtx_write[1].uv.x = u2; vtx_write[1].uv.y = v1;
                        vtx_write[2].pos.x = x2; vtx_write[2].pos.y = y2; vtx_write[2].col = col; vtx_write[2].uv.x = u2; vtx_write[2].uv.y = v2;
                        vtx_write[3].pos.x = x1; vtx_write[3].pos.y = y2; vtx_write[3].col = col; vtx_write[3].uv.x = u1; vtx_write[3].uv.y = v2;
                        vtx_write += 4;
                        vtx_current_idx += 4;
                        idx_write += 6;
                    }
                }
            }
        }

        x += char_width;
    }

    draw_list->_VtxWritePtr = vtx_write;
    draw_list->_VtxCurrentIdx = vtx_current_idx;
    draw_list->_IdxWritePtr = idx_write;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x88, %rsp
movq %r9, %rbx
movq %r8, %r12
movq %rcx, %r14
movq %rdx, %r15
movl %esi, -0x7c(%rbp)
movq %rdi, %r13
testq %r8, %r8
movss %xmm2, -0x34(%rbp)
jne 0x30b9f
movq %r14, %rdi
movss %xmm0, -0x30(%rbp)
movaps %xmm1, -0xb0(%rbp)
callq 0x72f0
movaps -0xb0(%rbp), %xmm1
movss -0x30(%rbp), %xmm0
movss -0x34(%rbp), %xmm2
movq %rax, %r12
addq %r14, %r12
movaps %xmm1, %xmm3
shufps $0x55, %xmm1, %xmm3     # xmm3 = xmm3[1,1],xmm1[1,1]
cvttps2dq %xmm3, %xmm3
cvtdq2ps %xmm3, %xmm3
addss 0xc(%r13), %xmm3
movaps %xmm3, -0x60(%rbp)
ucomiss 0xc(%r15), %xmm3
ja 0x31155
cvttps2dq %xmm1, %xmm1
cvtdq2ps %xmm1, %xmm15
movss (%r13), %xmm4
divss %xmm4, %xmm0
mulss %xmm0, %xmm4
xorps %xmm5, %xmm5
ucomiss %xmm5, %xmm2
ja 0x30c12
movaps -0x60(%rbp), %xmm3
addss %xmm4, %xmm3
movss 0x4(%r15), %xmm1
ucomiss %xmm3, %xmm1
seta %al
cmpq %r14, %r12
seta %cl
andb %al, %cl
cmpb $0x1, %cl
jne 0x30c12
cmpb $0xa, (%r14)
je 0x30c12
incq %r14
cmpq %r12, %r14
jne 0x30c01
movq %r12, %r14
addss 0x8(%r13), %xmm15
movq 0x40(%rbx), %rax
movq %rax, -0x70(%rbp)
movq 0x48(%rbx), %rax
movq %rax, -0x78(%rbp)
movl 0x38(%rbx), %eax
movq %rax, -0x68(%rbp)
movq $0x0, -0x98(%rbp)
movaps %xmm15, %xmm1
movss %xmm0, -0x30(%rbp)
movaps %xmm15, -0x90(%rbp)
movss %xmm4, -0x38(%rbp)
movq %r15, -0x48(%rbp)
cmpq %r12, %r14
jae 0x3113e
movq %r14, %r15
movq -0x98(%rbp), %rcx
movss %xmm1, -0x2c(%rbp)
movaps %xmm1, %xmm6
movaps -0x60(%rbp), %xmm3
ucomiss %xmm5, %xmm2
jbe 0x30d2b
testq %rcx, %rcx
jne 0x30cda
movaps %xmm15, %xmm1
subss %xmm6, %xmm1
addss %xmm2, %xmm1
movq %r13, %rdi
movq %r15, %rsi
movq %r12, %rdx
movss %xmm3, -0xb0(%rbp)
movss %xmm6, -0x80(%rbp)
callq 0x35b7e
movss -0x80(%rbp), %xmm6
movss -0xb0(%rbp), %xmm3
xorps %xmm5, %xmm5
movss -0x38(%rbp), %xmm4
movaps -0x90(%rbp), %xmm15
movss -0x30(%rbp), %xmm0
movss -0x34(%rbp), %xmm2
xorl %ecx, %ecx
cmpq %r15, %rax
sete %cl
addq %rax, %rcx
cmpq %rcx, %r15
jb 0x30d32
cmpq %r12, %r15
jae 0x30d10
movq %r15, %rcx
movzbl (%r15), %eax
cmpl $0x20, %eax
sete %dl
leal -0x9(%rax), %esi
cmpb $0x2, %sil
setb %sil
orb %dl, %sil
movzbl %sil, %r15d
addq %rcx, %r15
cmpl $0x20, %eax
je 0x30cdf
cmpl $0x9, %eax
je 0x30cdf
addss %xmm4, %xmm3
movl $0x0, %ecx
movaps %xmm15, %xmm6
cmpq %r12, %r15
jb 0x30c73
jmp 0x3113e
movss -0x2c(%rbp), %xmm1
jmp 0x30d43
movq %r15, %r14
movaps %xmm6, %xmm1
movaps %xmm3, -0x60(%rbp)
movq %rcx, -0x98(%rbp)
movsbl (%r14), %eax
movl %eax, -0x3c(%rbp)
testl %eax, %eax
movss %xmm1, -0x2c(%rbp)
js 0x30d5b
incq %r14
movq %r14, %r15
jmp 0x30d8c
leaq -0x3c(%rbp), %rdi
movq %r14, %rsi
movq %r12, %rdx
callq 0x884d
movslq %eax, %r15
addq %r14, %r15
cmpl $0x0, -0x3c(%rbp)
je 0x30e74
movaps -0x90(%rbp), %xmm15
movss -0x38(%rbp), %xmm4
movss -0x2c(%rbp), %xmm1
movl -0x3c(%rbp), %eax
cmpl $0x1f, %eax
ja 0x30dc7
cmpl $0xd, %eax
je 0x30e63
cmpl $0xa, %eax
jne 0x30dc7
movaps -0x60(%rbp), %xmm0
addss %xmm4, %xmm0
movb $0x1, %al
movq -0x48(%rbp), %rcx
movaps %xmm0, -0x60(%rbp)
ucomiss 0xc(%rcx), %xmm0
jbe 0x30e97
movaps %xmm15, %xmm1
jmp 0x30e65
movzwl %ax, %esi
movq %r13, %rdi
callq 0x35582
movb $0x1, %cl
testq %rax, %rax
je 0x30e33
movss 0x4(%rax), %xmm14
movss -0x30(%rbp), %xmm0
mulss %xmm0, %xmm14
movl -0x3c(%rbp), %edx
cmpl $0x9, %edx
movss -0x34(%rbp), %xmm2
movaps -0x90(%rbp), %xmm15
movss -0x2c(%rbp), %xmm1
je 0x30e4e
cmpl $0x20, %edx
je 0x30e4e
movss 0x8(%rax), %xmm11
mulss %xmm0, %xmm11
addss %xmm1, %xmm11
movq -0x48(%rbp), %rdx
movaps %xmm1, %xmm3
movss 0x8(%rdx), %xmm1
ucomiss %xmm11, %xmm1
jae 0x30ec3
movaps %xmm3, %xmm1
jmp 0x30e4e
xorps %xmm14, %xmm14
movss -0x34(%rbp), %xmm2
movss -0x30(%rbp), %xmm0
movaps -0x90(%rbp), %xmm15
movss -0x2c(%rbp), %xmm1
testb %cl, %cl
je 0x30e57
addss %xmm14, %xmm1
movss -0x38(%rbp), %xmm4
xorps %xmm5, %xmm5
xorl %eax, %eax
jmp 0x30eb3
xorl %eax, %eax
movss -0x34(%rbp), %xmm2
movss -0x30(%rbp), %xmm0
xorps %xmm5, %xmm5
jmp 0x30eb3
movb $0x1, %al
movss -0x34(%rbp), %xmm2
movss -0x30(%rbp), %xmm0
movaps -0x90(%rbp), %xmm15
movss -0x38(%rbp), %xmm4
xorps %xmm5, %xmm5
movss -0x2c(%rbp), %xmm1
jmp 0x30eb3
movss -0x34(%rbp), %xmm2
xorps %xmm5, %xmm5
ucomiss %xmm5, %xmm2
movss -0x30(%rbp), %xmm0
jbe 0x30f65
xorl %eax, %eax
movaps %xmm15, %xmm1
movq %r15, %r14
testb %al, %al
je 0x30c54
jmp 0x3113e
movss 0x10(%rax), %xmm9
mulss %xmm0, %xmm9
addss %xmm3, %xmm9
movss (%rdx), %xmm13
ucomiss %xmm13, %xmm9
jb 0x30e49
movss 0xc(%rax), %xmm10
mulss %xmm0, %xmm10
movaps -0x60(%rbp), %xmm3
addss %xmm3, %xmm10
movss 0x14(%rax), %xmm5
mulss %xmm0, %xmm5
addss %xmm3, %xmm5
movss 0x18(%rax), %xmm3
movss 0x1c(%rax), %xmm7
movss 0x20(%rax), %xmm6
movss 0x24(%rax), %xmm4
cmpb $0x0, 0x10(%rbp)
je 0x30fb0
ucomiss %xmm11, %xmm13
jbe 0x30fc1
movaps %xmm9, %xmm8
subss %xmm13, %xmm8
movaps %xmm9, %xmm12
subss %xmm11, %xmm12
divss %xmm12, %xmm8
movss 0xc435(%rip), %xmm11    # 0x3d380
subss %xmm8, %xmm11
movaps %xmm6, %xmm8
subss %xmm3, %xmm8
mulss %xmm11, %xmm8
addss %xmm8, %xmm3
jmp 0x30fc5
movaps %xmm4, %xmm3
addss -0x60(%rbp), %xmm3
movq -0x48(%rbp), %rax
movss 0x4(%rax), %xmm1
xorl %eax, %eax
ucomiss %xmm3, %xmm1
jbe 0x30eaf
cmpq %r12, %r15
jae 0x30eaf
movq %r12, %rcx
subq %r15, %rcx
cmpb $0xa, (%r15)
je 0x30ead
incq %r15
xorl %eax, %eax
decq %rcx
jne 0x30f90
movaps %xmm15, %xmm1
movq %r12, %r15
jmp 0x30eb3
movaps %xmm10, %xmm8
movaps %xmm11, %xmm13
movaps %xmm9, %xmm1
jmp 0x31083
movaps %xmm11, %xmm13
movq -0x48(%rbp), %rax
movss 0x4(%rax), %xmm8
ucomiss %xmm10, %xmm8
jbe 0x3100f
movaps %xmm5, %xmm11
subss %xmm8, %xmm11
movaps %xmm5, %xmm12
subss %xmm10, %xmm12
divss %xmm12, %xmm11
movss 0xc38b(%rip), %xmm10    # 0x3d380
subss %xmm11, %xmm10
movaps %xmm4, %xmm11
subss %xmm7, %xmm11
mulss %xmm10, %xmm11
addss %xmm11, %xmm7
jmp 0x31013
movaps %xmm10, %xmm8
ucomiss %xmm1, %xmm9
jbe 0x3103b
movaps %xmm1, %xmm10
subss %xmm13, %xmm10
subss %xmm13, %xmm9
divss %xmm9, %xmm10
subss %xmm3, %xmm6
mulss %xmm10, %xmm6
addss %xmm3, %xmm6
jmp 0x3103f
movaps %xmm9, %xmm1
movq -0x48(%rbp), %rax
movss 0xc(%rax), %xmm9
ucomiss %xmm9, %xmm5
jbe 0x31075
movaps %xmm9, %xmm10
subss %xmm8, %xmm10
subss %xmm8, %xmm5
divss %xmm5, %xmm10
subss %xmm7, %xmm4
mulss %xmm10, %xmm4
addss %xmm7, %xmm4
movaps %xmm9, %xmm5
jmp 0x31079
movaps %xmm5, %xmm9
ucomiss %xmm9, %xmm8
jae 0x3112d
movq -0x78(%rbp), %rdx
movq -0x68(%rbp), %rdi
movw %di, (%rdx)
leal 0x1(%rdi), %eax
movw %ax, 0x2(%rdx)
leal 0x2(%rdi), %eax
movw %ax, 0x4(%rdx)
movw %di, 0x6(%rdx)
movw %ax, 0x8(%rdx)
leal 0x3(%rdi), %eax
movw %ax, 0xa(%rdx)
movq -0x70(%rbp), %rsi
movss %xmm13, (%rsi)
movss %xmm8, 0x4(%rsi)
movl -0x7c(%rbp), %eax
movl %eax, 0x10(%rsi)
movss %xmm3, 0x8(%rsi)
movss %xmm7, 0xc(%rsi)
movss %xmm1, 0x14(%rsi)
movss %xmm8, 0x18(%rsi)
movl %eax, 0x24(%rsi)
movss %xmm6, 0x1c(%rsi)
movss %xmm7, 0x20(%rsi)
movss %xmm1, 0x28(%rsi)
movss %xmm5, 0x2c(%rsi)
movl %eax, 0x38(%rsi)
movss %xmm6, 0x30(%rsi)
movss %xmm4, 0x34(%rsi)
movss %xmm13, 0x3c(%rsi)
movss %xmm5, 0x40(%rsi)
movl %eax, 0x4c(%rsi)
movss %xmm3, 0x44(%rsi)
movss %xmm4, 0x48(%rsi)
addq $0x50, %rsi
movq %rsi, -0x70(%rbp)
addl $0x4, %edi
movq %rdi, -0x68(%rbp)
addq $0xc, %rdx
movq %rdx, -0x78(%rbp)
jmp 0x30e49
movss -0x2c(%rbp), %xmm1
addss %xmm14, %xmm1
xorl %ecx, %ecx
jmp 0x30e4e
movq -0x70(%rbp), %rax
movq %rax, 0x40(%rbx)
movq -0x68(%rbp), %rax
movl %eax, 0x38(%rbx)
movq -0x78(%rbp), %rax
movq %rax, 0x48(%rbx)
addq $0x88, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
nop