// File: 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
subq $0x150, %rsp            # imm = 0x150
movq %rdi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
movq %rdx, -0x18(%rbp)
movss %xmm0, -0x1c(%rbp)
movss %xmm1, -0x20(%rbp)
movq %rcx, -0x28(%rbp)
movq %r8, -0x30(%rbp)
movq %r9, -0x38(%rbp)
movq 0x14a54c(%rip), %rax    # 0x212f40
movq %rax, -0x40(%rbp)
cmpq $0x0, -0x30(%rbp)
jne 0xc8a10
movq -0x28(%rbp), %rdi
xorl %eax, %eax
movl %eax, %esi
callq 0xc8090
movq %rax, -0x30(%rbp)
cmpq $0x0, -0x38(%rbp)
je 0xc8a24
movq -0x38(%rbp), %rax
movq (%rax), %rax
movq %rax, -0x48(%rbp)
jmp 0xc8a3b
movq -0x28(%rbp), %rdi
movq -0x30(%rbp), %rsi
xorl %edx, %edx
xorps %xmm0, %xmm0
callq 0xc87e0
movlpd %xmm0, -0x48(%rbp)
movss -0x48(%rbp), %xmm0
movq -0x18(%rbp), %rax
movss (%rax), %xmm1
movq -0x10(%rbp), %rax
subss (%rax), %xmm1
ucomiss %xmm1, %xmm0
jbe 0xc8e54
movq -0x8(%rbp), %rax
movq 0x38(%rax), %rax
movq 0x8(%rax), %rax
movq %rax, -0x50(%rbp)
movq -0x8(%rbp), %rax
movq 0x38(%rax), %rax
movss 0x10(%rax), %xmm0
movss %xmm0, -0x54(%rbp)
movq $0x0, -0x60(%rbp)
movq -0x50(%rbp), %rax
movw 0x54(%rax), %ax
movw %ax, -0x62(%rbp)
movl $0x1, -0x68(%rbp)
movzwl -0x62(%rbp), %eax
cmpl $0xffff, %eax           # imm = 0xFFFF
jne 0xc8aae
movw $0x2e, -0x62(%rbp)
movl $0x3, -0x68(%rbp)
movq -0x50(%rbp), %rdi
movzwl -0x62(%rbp), %esi
callq 0x11bf50
movq %rax, -0x70(%rbp)
movq -0x70(%rbp), %rax
movss 0x10(%rax), %xmm0
movss %xmm0, -0x74(%rbp)
movss -0x74(%rbp), %xmm0
movss %xmm0, -0x78(%rbp)
cmpl $0x1, -0x68(%rbp)
jle 0xc8b49
movq -0x8(%rbp), %rax
movq 0x38(%rax), %rax
movss 0x10(%rax), %xmm1
movq -0x50(%rbp), %rax
divss 0x14(%rax), %xmm1
movss 0xa8141(%rip), %xmm0    # 0x170c3c
mulss %xmm1, %xmm0
movss %xmm0, -0x7c(%rbp)
movq -0x70(%rbp), %rax
movss 0x10(%rax), %xmm0
movq -0x70(%rbp), %rax
subss 0x8(%rax), %xmm0
addss -0x7c(%rbp), %xmm0
movss %xmm0, -0x74(%rbp)
movss -0x74(%rbp), %xmm0
cvtsi2ssl -0x68(%rbp), %xmm2
movss -0x7c(%rbp), %xmm1
movd %xmm1, %eax
xorl $0x80000000, %eax       # imm = 0x80000000
movd %eax, %xmm1
mulss %xmm2, %xmm0
addss %xmm1, %xmm0
movss %xmm0, -0x78(%rbp)
movq -0x18(%rbp), %rax
movss (%rax), %xmm0
movss -0x20(%rbp), %xmm1
callq 0xc88c0
movss -0x78(%rbp), %xmm1
subss %xmm1, %xmm0
movq -0x10(%rbp), %rax
movss (%rax), %xmm1
subss %xmm1, %xmm0
movss 0xa80c4(%rip), %xmm1    # 0x170c3c
callq 0xc88c0
movss %xmm0, -0x80(%rbp)
movq -0x50(%rbp), %rdi
movss -0x54(%rbp), %xmm0
movss -0x80(%rbp), %xmm1
movq -0x28(%rbp), %rsi
movq -0x30(%rbp), %rdx
xorps %xmm2, %xmm2
leaq -0x60(%rbp), %rcx
callq 0x11c520
movlpd %xmm0, -0x8c(%rbp)
movss -0x8c(%rbp), %xmm0
movss %xmm0, -0x84(%rbp)
movq -0x28(%rbp), %rax
cmpq -0x60(%rbp), %rax
jne 0xc8c34
movq -0x60(%rbp), %rax
cmpq -0x30(%rbp), %rax
jae 0xc8c34
movq -0x28(%rbp), %rdi
movq %rdi, -0xd8(%rbp)
movq -0x30(%rbp), %rsi
callq 0xc54d0
movl %eax, %ecx
movq -0xd8(%rbp), %rax
movslq %ecx, %rcx
addq %rcx, %rax
movq %rax, -0x60(%rbp)
movq -0x50(%rbp), %rdi
movss -0x54(%rbp), %xmm0
movq -0x28(%rbp), %rsi
movq -0x60(%rbp), %rdx
xorl %eax, %eax
movl %eax, %ecx
movss 0xa93a0(%rip), %xmm1    # 0x171fb4
xorps %xmm2, %xmm2
callq 0x11c520
movlpd %xmm0, -0x94(%rbp)
movss -0x94(%rbp), %xmm0
movss %xmm0, -0x84(%rbp)
jmp 0xc8c36
movq -0x60(%rbp), %rcx
xorl %eax, %eax
cmpq -0x28(%rbp), %rcx
movb %al, -0xd9(%rbp)
jbe 0xc8c5b
movq -0x60(%rbp), %rax
movsbl -0x1(%rax), %edi
callq 0xc6970
movb %al, -0xd9(%rbp)
movb -0xd9(%rbp), %al
testb $0x1, %al
jne 0xc8c67
jmp 0xc8cc2
movq -0x60(%rbp), %rax
decq %rax
movq %rax, -0x60(%rbp)
movq -0x50(%rbp), %rdi
movss -0x54(%rbp), %xmm0
movq -0x60(%rbp), %rsi
movq %rsi, %rdx
incq %rdx
xorl %eax, %eax
movl %eax, %ecx
movss 0xa9323(%rip), %xmm1    # 0x171fb4
xorps %xmm2, %xmm2
callq 0x11c520
movlpd %xmm0, -0x9c(%rbp)
movss -0x9c(%rbp), %xmm1
movss -0x84(%rbp), %xmm0
subss %xmm1, %xmm0
movss %xmm0, -0x84(%rbp)
jmp 0xc8c36
movq -0x8(%rbp), %rax
movq %rax, -0x100(%rbp)
movq -0x10(%rbp), %rax
movq %rax, -0xf8(%rbp)
movss -0x1c(%rbp), %xmm0
movq -0x18(%rbp), %rax
movss 0x4(%rax), %xmm1
leaq -0xa4(%rbp), %rdi
callq 0xbf4c0
movq -0x28(%rbp), %rax
movq %rax, -0xf0(%rbp)
movq -0x60(%rbp), %rax
movq %rax, -0xe8(%rbp)
leaq -0xac(%rbp), %rdi
xorps %xmm1, %xmm1
movaps %xmm1, %xmm0
callq 0xbf4c0
movq -0x100(%rbp), %rdi
movq -0xf8(%rbp), %rsi
movq -0xf0(%rbp), %rcx
movq -0xe8(%rbp), %r8
leaq -0xa4(%rbp), %rdx
leaq -0x48(%rbp), %r9
leaq -0xac(%rbp), %rax
xorl %r10d, %r10d
movq %rax, (%rsp)
movq $0x0, 0x8(%rsp)
callq 0xc8550
movq -0x10(%rbp), %rax
movss (%rax), %xmm0
addss -0x84(%rbp), %xmm0
movss %xmm0, -0xb0(%rbp)
movss -0xb0(%rbp), %xmm1
addss -0x78(%rbp), %xmm1
movss -0x20(%rbp), %xmm0
ucomiss %xmm1, %xmm0
jb 0xc8e4f
movl $0x0, -0xb4(%rbp)
movl -0xb4(%rbp), %eax
cmpl -0x68(%rbp), %eax
jge 0xc8e4d
movq -0x50(%rbp), %rax
movq %rax, -0x118(%rbp)
movq -0x8(%rbp), %rax
movq %rax, -0x110(%rbp)
movss -0x54(%rbp), %xmm0
movss %xmm0, -0x104(%rbp)
movss -0xb0(%rbp), %xmm0
movq -0x10(%rbp), %rax
movss 0x4(%rax), %xmm1
leaq -0xbc(%rbp), %rdi
callq 0xbf4c0
xorl %edi, %edi
movss 0xa7e49(%rip), %xmm0    # 0x170c3c
callq 0xc76e0
movq -0x118(%rbp), %rdi
movq -0x110(%rbp), %rsi
movss -0x104(%rbp), %xmm0
movl %eax, %edx
movw -0x62(%rbp), %ax
movsd -0xbc(%rbp), %xmm1
movzwl %ax, %ecx
callq 0x11c870
movss -0x74(%rbp), %xmm0
addss -0xb0(%rbp), %xmm0
movss %xmm0, -0xb0(%rbp)
movl -0xb4(%rbp), %eax
addl $0x1, %eax
movl %eax, -0xb4(%rbp)
jmp 0xc8d9a
jmp 0xc8e4f
jmp 0xc8eef
movq -0x8(%rbp), %rax
movq %rax, -0x138(%rbp)
movq -0x10(%rbp), %rax
movq %rax, -0x130(%rbp)
movss -0x1c(%rbp), %xmm0
movq -0x18(%rbp), %rax
movss 0x4(%rax), %xmm1
leaq -0xc4(%rbp), %rdi
callq 0xbf4c0
movq -0x28(%rbp), %rax
movq %rax, -0x128(%rbp)
movq -0x30(%rbp), %rax
movq %rax, -0x120(%rbp)
leaq -0xcc(%rbp), %rdi
xorps %xmm1, %xmm1
movaps %xmm1, %xmm0
callq 0xbf4c0
movq -0x138(%rbp), %rdi
movq -0x130(%rbp), %rsi
movq -0x128(%rbp), %rcx
movq -0x120(%rbp), %r8
leaq -0xc4(%rbp), %rdx
leaq -0x48(%rbp), %r9
leaq -0xcc(%rbp), %rax
xorl %r10d, %r10d
movq %rax, (%rsp)
movq $0x0, 0x8(%rsp)
callq 0xc8550
movq -0x40(%rbp), %rax
testb $0x1, 0x3138(%rax)
je 0xc8f0d
movq -0x10(%rbp), %rdi
movq -0x28(%rbp), %rsi
movq -0x30(%rbp), %rdx
callq 0xc8240
addq $0x150, %rsp            # imm = 0x150
popq %rbp
retq
nopw %cs:(%rax,%rax)