// File: /workspace/github_cpp_makefile_star2_O1/Ciaxur[P]yagb-emu/include/imgui/imgui.cpp
// Function: ImGui::RenderTextEllipsis(ImDrawList*, ImVec2 const&, ImVec2 const&, float, float, char const*, char const*, ImVec2 const*)
void ImGui::RenderTextEllipsis(ImDrawList* draw_list, const ImVec2& pos_min, const ImVec2& pos_max, float clip_max_x, float ellipsis_max_x, const char* text, const char* text_end_full, const ImVec2* text_size_if_known)
{
    ImGuiContext& g = *GImGui;
    if (text_end_full == NULL)
        text_end_full = FindRenderedTextEnd(text);
    const ImVec2 text_size = text_size_if_known ? *text_size_if_known : CalcTextSize(text, text_end_full, false, 0.0f);

    //draw_list->AddLine(ImVec2(pos_max.x, pos_min.y - 4), ImVec2(pos_max.x, pos_max.y + 4), IM_COL32(0, 0, 255, 255));
    //draw_list->AddLine(ImVec2(ellipsis_max_x, pos_min.y-2), ImVec2(ellipsis_max_x, pos_max.y+2), IM_COL32(0, 255, 0, 255));
    //draw_list->AddLine(ImVec2(clip_max_x, pos_min.y), ImVec2(clip_max_x, pos_max.y), IM_COL32(255, 0, 0, 255));
    // FIXME: We could technically remove (last_glyph->AdvanceX - last_glyph->X1) from text_size.x here and save a few pixels.
    if (text_size.x > pos_max.x - pos_min.x)
    {
        // Hello wo...
        // |       |   |
        // min   max   ellipsis_max
        //          <-> this is generally some padding value

        const ImFont* font = draw_list->_Data->Font;
        const float font_size = draw_list->_Data->FontSize;
        const char* text_end_ellipsis = NULL;

        ImWchar ellipsis_char = font->EllipsisChar;
        int ellipsis_char_count = 1;
        if (ellipsis_char == (ImWchar)-1)
        {
            ellipsis_char = (ImWchar)'.';
            ellipsis_char_count = 3;
        }
        const ImFontGlyph* glyph = font->FindGlyph(ellipsis_char);

        float ellipsis_glyph_width = glyph->X1;                 // Width of the glyph with no padding on either side
        float ellipsis_total_width = ellipsis_glyph_width;      // Full width of entire ellipsis

        if (ellipsis_char_count > 1)
        {
            // Full ellipsis size without free spacing after it.
            const float spacing_between_dots = 1.0f * (draw_list->_Data->FontSize / font->FontSize);
            ellipsis_glyph_width = glyph->X1 - glyph->X0 + spacing_between_dots;
            ellipsis_total_width = ellipsis_glyph_width * (float)ellipsis_char_count - spacing_between_dots;
        }

        // We can now claim the space between pos_max.x and ellipsis_max.x
        const float text_avail_width = ImMax((ImMax(pos_max.x, ellipsis_max_x) - ellipsis_total_width) - pos_min.x, 1.0f);
        float text_size_clipped_x = font->CalcTextSizeA(font_size, text_avail_width, 0.0f, text, text_end_full, &text_end_ellipsis).x;
        if (text == text_end_ellipsis && text_end_ellipsis < text_end_full)
        {
            // Always display at least 1 character if there's no room for character + ellipsis
            text_end_ellipsis = text + ImTextCountUtf8BytesFromChar(text, text_end_full);
            text_size_clipped_x = font->CalcTextSizeA(font_size, FLT_MAX, 0.0f, text, text_end_ellipsis).x;
        }
        while (text_end_ellipsis > text && ImCharIsBlankA(text_end_ellipsis[-1]))
        {
            // Trim trailing space before ellipsis (FIXME: Supporting non-ascii blanks would be nice, for this we need a function to backtrack in UTF-8 text)
            text_end_ellipsis--;
            text_size_clipped_x -= font->CalcTextSizeA(font_size, FLT_MAX, 0.0f, text_end_ellipsis, text_end_ellipsis + 1).x; // Ascii blanks are always 1 byte
        }

        // Render text, render ellipsis
        RenderTextClippedEx(draw_list, pos_min, ImVec2(clip_max_x, pos_max.y), text, text_end_ellipsis, &text_size, ImVec2(0.0f, 0.0f));
        float ellipsis_x = pos_min.x + text_size_clipped_x;
        if (ellipsis_x + ellipsis_total_width <= ellipsis_max_x)
            for (int i = 0; i < ellipsis_char_count; i++)
            {
                font->RenderChar(draw_list, font_size, ImVec2(ellipsis_x, pos_min.y), GetColorU32(ImGuiCol_Text), ellipsis_char);
                ellipsis_x += ellipsis_glyph_width;
            }
    }
    else
    {
        RenderTextClippedEx(draw_list, pos_min, ImVec2(clip_max_x, pos_max.y), text, text_end_full, &text_size, ImVec2(0.0f, 0.0f));
    }

    if (g.LogEnabled)
        LogRenderedText(&pos_min, text, text_end_full);
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x98, %rsp
movq %r8, %r14
movq %rcx, %rbx
movaps %xmm1, -0xb0(%rbp)
movss %xmm0, -0x3c(%rbp)
movq %rdx, %r13
movq %rsi, %r15
testq %r8, %r8
je 0x45619
movq 0xb86c4(%rip), %r12     # 0xfdcd0
testq %r9, %r9
je 0x4564d
movq (%r9), %rax
jmp 0x456ad
movq %rbx, %r14
cmpq $-0x1, %rbx
je 0x45605
movq %rbx, %r14
movzbl (%r14), %eax
cmpl $0x23, %eax
je 0x45634
testl %eax, %eax
jne 0x4563b
jmp 0x45605
cmpb $0x23, 0x1(%r14)
je 0x45605
incq %r14
cmpq $-0x1, %r14
jne 0x45625
movq $-0x1, %r14
jmp 0x45605
movss 0x1980(%r12), %xmm0
cmpq %rbx, %r14
je 0x4569d
movq %rdi, -0x48(%rbp)
movq 0x1978(%r12), %rdi
movss 0x721d0(%rip), %xmm1    # 0xb7840
xorps %xmm2, %xmm2
movq %rbx, %rsi
movq %r14, %rdx
xorl %ecx, %ecx
callq 0x8359c
movq -0x48(%rbp), %rdi
movss 0x721d0(%rip), %xmm1    # 0xb785c
addss %xmm0, %xmm1
cvttps2dq %xmm1, %xmm1
cvtdq2ps %xmm1, %xmm1
movss %xmm1, %xmm0            # xmm0 = xmm1[0],xmm0[1,2,3]
jmp 0x456a8
movq %xmm0, %xmm0            # xmm0 = xmm0[0],zero
xorps %xmm1, %xmm1
shufps $0xe2, %xmm1, %xmm0     # xmm0 = xmm0[2,0],xmm1[2,3]
movq %xmm0, %rax
movq %rax, -0x58(%rbp)
movss -0x58(%rbp), %xmm0
movss (%r13), %xmm1
subss (%r15), %xmm1
ucomiss %xmm1, %xmm0
jbe 0x45741
movq %r14, -0x88(%rbp)
movq %r13, -0x50(%rbp)
movq %r12, -0xb8(%rbp)
movq %r15, -0x90(%rbp)
movq %rbx, -0x98(%rbp)
movq 0x38(%rdi), %rax
movq %rdi, %r12
movq 0x8(%rax), %r13
movss 0x10(%rax), %xmm0
movss %xmm0, -0x30(%rbp)
movq $0x0, -0x38(%rbp)
movl 0x54(%r13), %ebx
cmpw $-0x1, %bx
movl $0x2e, %eax
cmovnel %ebx, %eax
movzwl %ax, %esi
movq %r13, %rdi
movl %esi, -0x5c(%rbp)
callq 0x8322a
xorl %ecx, %ecx
movss 0x10(%rax), %xmm3
cmpw $-0x1, %bx
sete %cl
leal 0x1(%rcx,%rcx), %r15d
movq %r12, -0x48(%rbp)
je 0x45780
movss %xmm3, -0x2c(%rbp)
jmp 0x457b1
movss 0x4(%r13), %xmm0
leaq -0x80(%rbp), %rdx
movss -0x3c(%rbp), %xmm1
movss %xmm1, (%rdx)
movss %xmm0, 0x4(%rdx)
xorl %eax, %eax
leaq -0x38(%rbp), %r10
movq %rax, (%r10)
leaq -0x58(%rbp), %r9
movq %r15, %rsi
movq %rbx, %rcx
movq %r14, %r8
pushq %rax
pushq %r10
callq 0x4526d
addq $0x10, %rsp
jmp 0x459ba
movq 0x38(%r12), %rcx
movss 0x10(%rcx), %xmm0
divss 0x14(%r13), %xmm0
subss 0x8(%rax), %xmm3
movaps %xmm3, %xmm1
xorps %xmm3, %xmm3
cvtsi2ss %r15d, %xmm3
addss %xmm0, %xmm1
movss %xmm1, -0x2c(%rbp)
mulss %xmm1, %xmm3
subss %xmm0, %xmm3
movq -0x50(%rbp), %rax
movss (%rax), %xmm0
movaps -0xb0(%rbp), %xmm2
movaps %xmm2, %xmm1
cmpless %xmm0, %xmm1
andps %xmm1, %xmm0
andnps %xmm2, %xmm1
orps %xmm0, %xmm1
movss %xmm3, -0x60(%rbp)
subss %xmm3, %xmm1
movq -0x90(%rbp), %rax
subss (%rax), %xmm1
maxss 0x717f7(%rip), %xmm1    # 0xb6fe4
leaq -0x38(%rbp), %r14
xorps %xmm2, %xmm2
movq %r13, %rdi
movss -0x30(%rbp), %xmm0
movq -0x98(%rbp), %rbx
movq %rbx, %rsi
movq -0x88(%rbp), %r12
movq %r12, %rdx
movq %r14, %rcx
callq 0x8359c
movq (%r14), %rax
cmpq %rbx, %rax
setne %cl
cmpq %r12, %rax
setae %al
orb %cl, %al
jne 0x45867
leaq -0x80(%rbp), %rdi
movl $0x0, (%rdi)
movq %rbx, %rsi
movq %r12, %rdx
callq 0x41855
movslq %eax, %rdx
addq %rbx, %rdx
movq %rdx, -0x38(%rbp)
movss 0x71fee(%rip), %xmm1    # 0xb7840
xorps %xmm2, %xmm2
movq %r13, %rdi
movss -0x30(%rbp), %xmm0
movq %rbx, %rsi
xorl %ecx, %ecx
callq 0x8359c
movaps %xmm0, -0x70(%rbp)
movq -0x38(%rbp), %r8
cmpq %rbx, %r8
jbe 0x458b6
movzbl -0x1(%r8), %eax
cmpl $0x20, %eax
je 0x45883
cmpl $0x9, %eax
jne 0x458b6
leaq -0x1(%r8), %rsi
movq %rsi, -0x38(%rbp)
xorps %xmm2, %xmm2
movq %r13, %rdi
movss -0x30(%rbp), %xmm0
movss 0x71fa2(%rip), %xmm1    # 0xb7840
movq %r8, %rdx
xorl %ecx, %ecx
callq 0x8359c
movaps -0x70(%rbp), %xmm1
subss %xmm0, %xmm1
movaps %xmm1, -0x70(%rbp)
jmp 0x4586b
movq -0x50(%rbp), %rax
movss 0x4(%rax), %xmm0
leaq -0x80(%rbp), %rdx
movss -0x3c(%rbp), %xmm1
movss %xmm1, (%rdx)
movss %xmm0, 0x4(%rdx)
xorl %eax, %eax
leaq -0xc0(%rbp), %r10
movq %rax, (%r10)
leaq -0x58(%rbp), %r9
movq %rbx, %rcx
movq %r13, %rbx
movq -0x48(%rbp), %r13
movq %r13, %rdi
movq -0x90(%rbp), %r12
movq %r12, %rsi
pushq %rax
pushq %r10
callq 0x4526d
addq $0x10, %rsp
movaps -0x70(%rbp), %xmm2
addss (%r12), %xmm2
movss -0x60(%rbp), %xmm1
addss %xmm2, %xmm1
movaps -0xb0(%rbp), %xmm0
ucomiss %xmm1, %xmm0
movl -0x5c(%rbp), %r14d
movss -0x2c(%rbp), %xmm0
jb 0x459a2
movss %xmm0, -0x2c(%rbp)
movaps %xmm2, -0x70(%rbp)
movq 0xb8394(%rip), %rax     # 0xfdcd0
movss 0x4(%r12), %xmm0
movaps %xmm0, -0xb0(%rbp)
movups 0x1624(%rax), %xmm0
movaps %xmm0, -0x80(%rbp)
movss 0x1560(%rax), %xmm0
mulss -0x74(%rbp), %xmm0
movss %xmm0, -0x74(%rbp)
leaq -0x80(%rbp), %rdi
callq 0x42e9e
movaps -0x70(%rbp), %xmm1
unpcklps -0xb0(%rbp), %xmm1      # xmm1 = xmm1[0],mem[0],xmm1[1],mem[1]
movq %rbx, %rdi
movq %r13, %rsi
movss -0x30(%rbp), %xmm0
movl %eax, %edx
movl %r14d, %ecx
callq 0x837f2
movss -0x2c(%rbp), %xmm0
movaps -0x70(%rbp), %xmm2
addss %xmm0, %xmm2
decl %r15d
jne 0x45931
movq -0x98(%rbp), %rbx
movq %r12, %r15
movq -0xb8(%rbp), %r12
movq -0x88(%rbp), %r14
cmpb $0x1, 0x3138(%r12)
jne 0x459d3
movq %r15, %rdi
movq %rbx, %rsi
movq %r14, %rdx
callq 0x44fd9
addq $0x98, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq