// File: /workspace/github_cpp_makefile_star2_O3/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 $0xa8, %rsp
movq %r8, %r15
movq %rcx, %rbx
movaps %xmm1, -0xb0(%rbp)
movss %xmm0, -0x48(%rbp)
movq %rdx, %r14
movq %rsi, %r12
testq %r8, %r8
jne 0x44bcc
cmpq $-0x1, %rbx
je 0x44bc5
movq %rbx, %r15
movzbl (%r15), %eax
cmpl $0x23, %eax
je 0x44bb5
testl %eax, %eax
jne 0x44bbc
jmp 0x44bcc
cmpb $0x23, 0x1(%r15)
je 0x44bcc
incq %r15
cmpq $-0x1, %r15
jne 0x44ba6
movq $-0x1, %r15
movq 0xb70fd(%rip), %r13     # 0xfbcd0
testq %r9, %r9
je 0x44bdd
movq (%r9), %rax
jmp 0x44c3b
movss 0x1980(%r13), %xmm0
cmpq %rbx, %r15
je 0x44c2b
movq %rdi, -0x50(%rbp)
movq 0x1978(%r13), %rdi
movss 0x70c42(%rip), %xmm1    # 0xb5840
xorps %xmm2, %xmm2
movq %rbx, %rsi
movq %r15, %rdx
xorl %ecx, %ecx
callq 0x81a68
movq -0x50(%rbp), %rdi
movss 0x70c42(%rip), %xmm1    # 0xb585c
addss %xmm0, %xmm1
cvttps2dq %xmm1, %xmm1
cvtdq2ps %xmm1, %xmm1
movss %xmm1, %xmm0            # xmm0 = xmm1[0],xmm0[1,2,3]
jmp 0x44c36
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, -0x98(%rbp)
movd %eax, %xmm0
movss (%r14), %xmm1
subss (%r12), %xmm1
ucomiss %xmm1, %xmm0
jbe 0x44cc0
movq %r12, -0xb8(%rbp)
movq %r14, -0x58(%rbp)
movq %r13, -0xc0(%rbp)
movq 0x38(%rdi), %rax
movq 0x8(%rax), %r13
movss 0x10(%rax), %xmm0
movss %xmm0, -0x2c(%rbp)
movq $0x0, -0x38(%rbp)
movl 0x54(%r13), %r14d
cmpw $-0x1, %r14w
movl $0x2e, %eax
cmovnel %r14d, %eax
movzwl %ax, %esi
movq %rdi, %r12
movq %r13, %rdi
movl %esi, -0x60(%rbp)
callq 0x816e8
movss 0x10(%rax), %xmm3
movl %r14d, -0x64(%rbp)
cmpw $-0x1, %r14w
movq %r12, -0x50(%rbp)
je 0x44d05
movss %xmm3, -0x3c(%rbp)
jmp 0x44d36
movss 0x4(%r14), %xmm0
leaq -0x90(%rbp), %rdx
movss -0x48(%rbp), %xmm1
movss %xmm1, (%rdx)
movss %xmm0, 0x4(%rdx)
xorl %eax, %eax
leaq -0x38(%rbp), %r10
movq %rax, (%r10)
leaq -0x98(%rbp), %r9
movq %r12, %rsi
movq %rbx, %rcx
movq %r15, %r8
pushq %rax
pushq %r10
callq 0x447fc
addq $0x10, %rsp
jmp 0x44f3f
movq 0x38(%r12), %rcx
movss 0x10(%rcx), %xmm0
divss 0x14(%r13), %xmm0
subss 0x8(%rax), %xmm3
movaps %xmm3, %xmm1
addss %xmm0, %xmm1
movss 0x702c7(%rip), %xmm3    # 0xb4ff0
movss %xmm1, -0x3c(%rbp)
mulss %xmm1, %xmm3
subss %xmm0, %xmm3
movq -0x58(%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, -0x5c(%rbp)
subss %xmm3, %xmm1
movq -0xb8(%rbp), %rax
movq %rax, %r14
subss (%rax), %xmm1
maxss 0x7026f(%rip), %xmm1    # 0xb4fe4
leaq -0x38(%rbp), %r12
xorps %xmm2, %xmm2
movq %r13, %rdi
movss -0x2c(%rbp), %xmm0
movq %rbx, %rsi
movq %r15, %rdx
movq %r12, %rcx
callq 0x81a68
movq (%r12), %r8
cmpq %rbx, %r8
setne %al
cmpq %r15, %r8
setae %cl
orb %al, %cl
jne 0x44de3
leaq -0x90(%rbp), %rdi
movq %rbx, %rsi
movq %r15, %rdx
callq 0x40f80
movslq %eax, %rdx
addq %rbx, %rdx
movq %rdx, -0x38(%rbp)
movss 0x70a76(%rip), %xmm1    # 0xb5840
xorps %xmm2, %xmm2
movq %r13, %rdi
movss -0x2c(%rbp), %xmm0
movq %rbx, %rsi
xorl %ecx, %ecx
callq 0x81a68
movq -0x38(%rbp), %r8
movaps %xmm0, -0x80(%rbp)
cmpq %rbx, %r8
movq %r14, %r12
jbe 0x44e38
movzbl -0x1(%r8), %eax
cmpl $0x20, %eax
je 0x44dfe
cmpl $0x9, %eax
jne 0x44e38
leaq -0x1(%r8), %rsi
movq %rsi, -0x38(%rbp)
xorps %xmm2, %xmm2
movq %r13, %rdi
movss -0x2c(%rbp), %xmm0
movss 0x70a27(%rip), %xmm1    # 0xb5840
movq %r8, %rdx
xorl %ecx, %ecx
callq 0x81a68
movaps -0x80(%rbp), %xmm1
subss %xmm0, %xmm1
movaps %xmm1, -0x80(%rbp)
movq -0x38(%rbp), %r8
cmpq %rbx, %r8
ja 0x44def
movq -0x58(%rbp), %rax
movss 0x4(%rax), %xmm0
leaq -0x90(%rbp), %rdx
movss -0x48(%rbp), %xmm1
movss %xmm1, (%rdx)
movss %xmm0, 0x4(%rdx)
movq %rbx, %rcx
xorl %ebx, %ebx
leaq -0xc8(%rbp), %rax
movq %rbx, (%rax)
leaq -0x98(%rbp), %r9
movq -0x50(%rbp), %rdi
movq %r12, %rsi
movq %rcx, -0x48(%rbp)
pushq %rbx
pushq %rax
callq 0x447fc
addq $0x10, %rsp
movaps -0x80(%rbp), %xmm2
addss (%r12), %xmm2
movss -0x5c(%rbp), %xmm1
addss %xmm2, %xmm1
movaps -0xb0(%rbp), %xmm0
ucomiss %xmm1, %xmm0
jb 0x44f31
leaq -0x90(%rbp), %r12
movaps %xmm2, -0x80(%rbp)
movq 0xb6e19(%rip), %rax     # 0xfbcd0
movss 0x4(%r14), %xmm0
movaps %xmm0, -0xb0(%rbp)
movups 0x1624(%rax), %xmm0
movaps %xmm0, -0x90(%rbp)
movss 0x1560(%rax), %xmm0
mulss -0x84(%rbp), %xmm0
movss %xmm0, -0x84(%rbp)
movq %r12, %rdi
callq 0x42601
movaps -0x80(%rbp), %xmm1
unpcklps -0xb0(%rbp), %xmm1      # xmm1 = xmm1[0],mem[0],xmm1[1],mem[1]
movq %r13, %rdi
movq -0x50(%rbp), %rsi
movss -0x2c(%rbp), %xmm0
movl %eax, %edx
movl -0x60(%rbp), %ecx
callq 0x81ca2
movaps -0x80(%rbp), %xmm2
cmpw $-0x1, -0x64(%rbp)
jne 0x44f31
leal 0x1(%rbx), %eax
addss -0x3c(%rbp), %xmm2
cmpl $0x2, %ebx
movl %eax, %ebx
jb 0x44eac
movq -0x48(%rbp), %rbx
movq %r14, %r12
movq -0xc0(%rbp), %r13
cmpb $0x1, 0x3138(%r13)
jne 0x44f57
movq %r12, %rdi
movq %rbx, %rsi
movq %r15, %rdx
callq 0x4458c
addq $0xa8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq