// File: /workspace/github_cpp_makefile_star2_O2/donfreiday[P]gb/./imgui/imgui.cpp
// Function: InputTextCalcTextSizeW(unsigned short const*, unsigned short const*, unsigned short const**, ImVec2*, bool)
static ImVec2 InputTextCalcTextSizeW(const ImWchar* text_begin, const ImWchar* text_end, const ImWchar** remaining, ImVec2* out_offset, bool stop_on_new_line)
{
    ImFont* font = GImGui->Font;
    const float line_height = GImGui->FontSize;
    const float scale = line_height / font->FontSize;

    ImVec2 text_size = ImVec2(0,0);
    float line_width = 0.0f;

    const ImWchar* s = text_begin;
    while (s < text_end)
    {
        unsigned int c = (unsigned int)(*s++);
        if (c == '\n')
        {
            text_size.x = ImMax(text_size.x, line_width);
            text_size.y += line_height;
            line_width = 0.0f;
            if (stop_on_new_line)
                break;
            continue;
        }
        if (c == '\r')
            continue;

        const float char_width = font->GetCharAdvance((unsigned short)c) * scale;
        line_width += char_width;
    }

    if (text_size.x < line_width)
        text_size.x = line_width;

    if (out_offset)
        *out_offset = ImVec2(line_width, text_size.y + line_height);  // offset allow for the possibility of sitting after a trailing \n

    if (line_width > 0 || text_size.y == 0.0f)                        // whereas size.y will ignore the trailing \n
        text_size.y += line_height;

    if (remaining)
        *remaining = s;

    return text_size;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x38, %rsp
movl %ecx, %r15d
movq %rdx, %rbx
movq %rsi, %r12
movq %rdi, %r14
movq 0x3673a(%rip), %rax     # 0x50480
movq 0x1710(%rax), %r13
movss 0x1718(%rax), %xmm3
movaps %xmm3, %xmm2
divss (%r13), %xmm2
xorps %xmm4, %xmm4
xorps %xmm5, %xmm5
cmpq %r12, %r14
jae 0x19ddf
movzwl (%r14), %eax
addq $0x2, %r14
cmpl $0xd, %eax
je 0x19d64
cmpl $0xa, %eax
je 0x19db2
movzwl %ax, %esi
movq %r13, %rdi
movaps %xmm3, -0x60(%rbp)
movaps %xmm4, -0x50(%rbp)
movaps %xmm5, -0x40(%rbp)
movss %xmm2, -0x2c(%rbp)
callq 0x1f502
movss -0x2c(%rbp), %xmm2
movaps -0x40(%rbp), %xmm5
movaps -0x50(%rbp), %xmm4
movaps -0x60(%rbp), %xmm3
mulss %xmm2, %xmm0
addss %xmm0, %xmm5
jmp 0x19d64
movaps %xmm5, %xmm0
cmpless %xmm4, %xmm0
movaps %xmm0, %xmm1
andps %xmm4, %xmm1
andnps %xmm5, %xmm0
orps %xmm1, %xmm0
shufps $0x55, %xmm4, %xmm4     # xmm4 = xmm4[1,1,1,1]
movaps %xmm4, %xmm1
addss %xmm3, %xmm1
movaps %xmm0, %xmm4
unpcklps %xmm1, %xmm4            # xmm4 = xmm4[0],xmm1[0],xmm4[1],xmm1[1]
testb %r15b, %r15b
je 0x19d61
xorps %xmm5, %xmm5
testq %rbx, %rbx
je 0x19de7
movq %r14, (%rbx)
ucomiss %xmm4, %xmm5
jbe 0x19df0
movss %xmm5, %xmm4            # xmm4 = xmm5[0],xmm4[1,2,3]
movaps %xmm4, %xmm0
shufps $0x55, %xmm4, %xmm0     # xmm0 = xmm0[1,1],xmm4[1,1]
xorps %xmm1, %xmm1
movaps %xmm0, %xmm2
cmpeqps %xmm1, %xmm2
cmpltps %xmm5, %xmm1
orps %xmm2, %xmm1
movd %xmm1, %eax
testb $0x1, %al
jne 0x19e15
movaps %xmm4, %xmm3
jmp 0x19e20
addss %xmm0, %xmm3
movlhps %xmm4, %xmm3            # xmm3 = xmm3[0],xmm4[0]
shufps $0xe2, %xmm4, %xmm3     # xmm3 = xmm3[2,0],xmm4[2,3]
movaps %xmm3, %xmm0
addq $0x38, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq