// File: Ciaxur[P]yagb-emu/include/imgui/imgui_widgets.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)
{
    ImGuiContext& g = *GImGui;
    ImFont* font = g.Font;
    const float line_height = g.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((ImWchar)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
subq $0x70, %rsp
movb %r8b, %al
movq %rdi, -0x10(%rbp)
movq %rsi, -0x18(%rbp)
movq %rdx, -0x20(%rbp)
movq %rcx, -0x28(%rbp)
andb $0x1, %al
movb %al, -0x29(%rbp)
leaq 0xc72d9(%rip), %rax     # 0x212f40
movq (%rax), %rax
movq %rax, -0x38(%rbp)
movq -0x38(%rbp), %rax
movq 0x1978(%rax), %rax
movq %rax, -0x40(%rbp)
movq -0x38(%rbp), %rax
movss 0x1980(%rax), %xmm0
movss %xmm0, -0x44(%rbp)
movss -0x44(%rbp), %xmm0
movq -0x40(%rbp), %rax
divss 0x14(%rax), %xmm0
movss %xmm0, -0x48(%rbp)
leaq -0x8(%rbp), %rdi
xorps %xmm1, %xmm1
movaps %xmm1, %xmm0
callq 0xbf4c0
xorps %xmm0, %xmm0
movss %xmm0, -0x4c(%rbp)
movq -0x10(%rbp), %rax
movq %rax, -0x58(%rbp)
movq -0x58(%rbp), %rax
cmpq -0x18(%rbp), %rax
jae 0x14bd53
movq -0x58(%rbp), %rax
movq %rax, %rcx
addq $0x2, %rcx
movq %rcx, -0x58(%rbp)
movzwl (%rax), %eax
movl %eax, -0x5c(%rbp)
cmpl $0xa, -0x5c(%rbp)
jne 0x14bd1e
movss -0x8(%rbp), %xmm0
movss -0x4c(%rbp), %xmm1
callq 0x139050
movss %xmm0, -0x8(%rbp)
movss -0x44(%rbp), %xmm0
addss -0x4(%rbp), %xmm0
movss %xmm0, -0x4(%rbp)
xorps %xmm0, %xmm0
movss %xmm0, -0x4c(%rbp)
testb $0x1, -0x29(%rbp)
je 0x14bd1c
jmp 0x14bd53
jmp 0x14bcc0
cmpl $0xd, -0x5c(%rbp)
jne 0x14bd26
jmp 0x14bcc0
movq -0x40(%rbp), %rdi
movl -0x5c(%rbp), %eax
movzwl %ax, %esi
callq 0x162500
mulss -0x48(%rbp), %xmm0
movss %xmm0, -0x60(%rbp)
movss -0x60(%rbp), %xmm0
addss -0x4c(%rbp), %xmm0
movss %xmm0, -0x4c(%rbp)
jmp 0x14bcc0
movss -0x8(%rbp), %xmm1
movss -0x4c(%rbp), %xmm0
ucomiss %xmm1, %xmm0
jbe 0x14bd6c
movss -0x4c(%rbp), %xmm0
movss %xmm0, -0x8(%rbp)
cmpq $0x0, -0x28(%rbp)
je 0x14bd96
movss -0x4c(%rbp), %xmm0
movss -0x4(%rbp), %xmm1
addss -0x44(%rbp), %xmm1
leaq -0x68(%rbp), %rdi
callq 0xbf4c0
movq -0x28(%rbp), %rax
movq -0x68(%rbp), %rcx
movq %rcx, (%rax)
movss -0x4c(%rbp), %xmm0
xorps %xmm1, %xmm1
ucomiss %xmm1, %xmm0
ja 0x14bdb2
movss -0x4(%rbp), %xmm0
xorps %xmm1, %xmm1
ucomiss %xmm1, %xmm0
jne 0x14bdc1
jp 0x14bdc1
movss -0x44(%rbp), %xmm0
addss -0x4(%rbp), %xmm0
movss %xmm0, -0x4(%rbp)
cmpq $0x0, -0x20(%rbp)
je 0x14bdd3
movq -0x58(%rbp), %rcx
movq -0x20(%rbp), %rax
movq %rcx, (%rax)
movsd -0x8(%rbp), %xmm0
addq $0x70, %rsp
popq %rbp
retq
nop