// File: /workspace/github_c_makefile_star2_O3/stetre[P]moonnuklear/src/./nuklear/nuklear.h
// Function: nk_text_calculate_text_bounds
NK_LIB struct nk_vec2
nk_text_calculate_text_bounds(const struct nk_user_font *font,
    const char *begin, int byte_len, float row_height, const char **remaining,
    struct nk_vec2 *out_offset, int *glyphs, int op)
{
    float line_height = row_height;
    struct nk_vec2 text_size = nk_vec2(0,0);
    float line_width = 0.0f;

    float glyph_width;
    int glyph_len = 0;
    nk_rune unicode = 0;
    int text_len = 0;
    if (!begin || byte_len <= 0 || !font)
        return nk_vec2(0,row_height);

    glyph_len = nk_utf_decode(begin, &unicode, byte_len);
    if (!glyph_len) return text_size;
    glyph_width = font->width(font->userdata, font->height, begin, glyph_len);

    *glyphs = 0;
    while ((text_len < byte_len) && glyph_len) {
        if (unicode == '\n') {
            text_size.x = NK_MAX(text_size.x, line_width);
            text_size.y += line_height;
            line_width = 0;
            *glyphs+=1;
            if (op == NK_STOP_ON_NEW_LINE)
                break;

            text_len++;
            glyph_len = nk_utf_decode(begin + text_len, &unicode, byte_len-text_len);
            continue;
        }

        if (unicode == '\r') {
            text_len++;
            *glyphs+=1;
            glyph_len = nk_utf_decode(begin + text_len, &unicode, byte_len-text_len);
            continue;
        }

        *glyphs = *glyphs + 1;
        text_len += glyph_len;
        line_width += (float)glyph_width;
        glyph_len = nk_utf_decode(begin + text_len, &unicode, byte_len-text_len);
        glyph_width = font->width(font->userdata, font->height, begin+text_len, glyph_len);
        continue;
    }

    if (text_size.x < line_width)
        text_size.x = line_width;
    if (out_offset)
        *out_offset = nk_vec2(line_width, text_size.y + line_height);
    if (line_width > 0 || text_size.y == 0.0f)
        text_size.y += line_height;
    if (remaining)
        *remaining = begin+text_len;
    return text_size;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x98, %rsp
movq %r9, 0x20(%rsp)
movl $0x0, 0xc(%rsp)
testq %rdi, %rdi
je 0x58d14
movq %rsi, %r12
testq %rsi, %rsi
je 0x58d14
testl %edx, %edx
jle 0x58d14
movq %r8, %r14
movq %rcx, %rbx
movq %rdi, %rbp
movaps %xmm0, 0x80(%rsp)
leaq 0xc(%rsp), %rsi
movq %r12, %rdi
movl %edx, %r13d
callq 0x12ef0
testl %eax, %eax
je 0x58d24
movl %eax, %r15d
movq %r14, 0x28(%rsp)
movq %rbx, 0x30(%rsp)
movss 0x8(%rbp), %xmm0
movq (%rbp), %rdi
movq %r12, %rsi
movl %eax, %edx
movq %rbp, 0x68(%rsp)
callq *0x10(%rbp)
movss %xmm0, 0x1c(%rsp)
movq 0x20(%rsp), %rax
movl $0x0, (%rax)
movl %r13d, %eax
movq %rax, 0x78(%rsp)
leaq 0x1(%r12), %rax
movq %rax, 0x70(%rsp)
xorps %xmm4, %xmm4
xorl %ebp, %ebp
movl %r13d, %eax
movq %r12, 0x38(%rsp)
movl %r13d, 0x44(%rsp)
movq %rbp, 0x10(%rsp)
movslq %ebp, %rbx
subl %ebx, %eax
movq %rax, 0x48(%rsp)
movq 0x70(%rsp), %rax
leaq (%rax,%rbx), %r12
incq %rbx
movq $-0x1, %rbp
xorl %r13d, %r13d
movaps %xmm4, 0x50(%rsp)
movl 0xc(%rsp), %eax
cmpl $0xd, %eax
jne 0x58c82
movq 0x20(%rsp), %rax
incl (%rax)
leaq (%rbx,%r13), %r14
leaq (%r12,%r13), %rdi
movq 0x48(%rsp), %rax
leal (%rax,%rbp), %edx
leaq 0xc(%rsp), %rsi
callq 0x12ef0
movaps 0x50(%rsp), %xmm4
incq %r13
cmpq 0x78(%rsp), %r14
jge 0x58d59
movl %eax, %r15d
decq %rbp
testl %eax, %eax
jne 0x58c36
jmp 0x58d59
cmpl $0xa, %eax
je 0x58d2c
movq 0x20(%rsp), %rax
incl (%rax)
movq 0x10(%rsp), %rbx
addl %r15d, %ebx
leal (%rbx,%r13), %ebp
addss 0x1c(%rsp), %xmm4
movaps %xmm4, 0x50(%rsp)
movslq %ebp, %r14
movq 0x38(%rsp), %r12
leaq (%r12,%r14), %rdi
movq %rdi, 0x10(%rsp)
movq 0x48(%rsp), %rdx
subl %r15d, %edx
subl %r13d, %edx
leaq 0xc(%rsp), %rsi
callq 0x12ef0
movl %eax, %r15d
movq 0x68(%rsp), %rax
movss 0x8(%rax), %xmm0
movq (%rax), %rdi
movq 0x10(%rsp), %rsi
movl %r15d, %edx
callq *0x10(%rax)
movaps 0x50(%rsp), %xmm4
movss %xmm0, 0x1c(%rsp)
movl 0x44(%rsp), %eax
cmpl %eax, %r14d
jge 0x58d07
testl %r15d, %r15d
jne 0x58c0c
addl %r13d, %ebx
xorps %xmm0, %xmm0
movq 0x30(%rsp), %rcx
jmp 0x58d6e
movq %xmm0, %xmm0            # xmm0 = xmm0[0],zero
xorps %xmm1, %xmm1
shufps $0xe2, %xmm1, %xmm0     # xmm0 = xmm0[2,0],xmm1[2,3]
jmp 0x58dcb
xorps %xmm0, %xmm0
jmp 0x58dcb
movq 0x10(%rsp), %rbx
addl %r13d, %ebx
xorps %xmm0, %xmm0
maxss %xmm0, %xmm4
movaps 0x80(%rsp), %xmm1
movq 0x20(%rsp), %rax
incl (%rax)
addss %xmm0, %xmm1
unpcklps %xmm1, %xmm4            # xmm4 = xmm4[0],xmm1[0],xmm4[1],xmm1[1]
movaps %xmm4, %xmm0
xorps %xmm4, %xmm4
jmp 0x58d64
movq 0x10(%rsp), %rbx
addl %r13d, %ebx
xorps %xmm0, %xmm0
movq 0x30(%rsp), %rcx
movq 0x38(%rsp), %r12
movq 0x28(%rsp), %rax
ucomiss %xmm0, %xmm4
jbe 0x58d7c
movss %xmm4, %xmm0            # xmm0 = xmm4[0],xmm0[1,2,3]
movaps %xmm0, %xmm2
shufps $0x55, %xmm0, %xmm2     # xmm2 = xmm2[1,1],xmm0[1,1]
movaps %xmm2, %xmm1
addss 0x80(%rsp), %xmm1
testq %rax, %rax
je 0x58d9d
movaps %xmm4, %xmm3
unpcklps %xmm1, %xmm3            # xmm3 = xmm3[0],xmm1[0],xmm3[1],xmm1[1]
movlps %xmm3, (%rax)
xorps %xmm3, %xmm3
cmpeqps %xmm3, %xmm2
cmpltps %xmm4, %xmm3
orps %xmm2, %xmm3
movd %xmm3, %eax
testb $0x1, %al
je 0x58dbd
movlhps %xmm0, %xmm1            # xmm1 = xmm1[0],xmm0[0]
shufps $0xe2, %xmm0, %xmm1     # xmm1 = xmm1[2,0],xmm0[2,3]
movaps %xmm1, %xmm0
testq %rcx, %rcx
je 0x58dcb
movslq %ebx, %rax
addq %rax, %r12
movq %r12, (%rcx)
addq $0x98, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq