// File: /workspace/github_c_makefile_star2_O1/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 $0x88, %rsp
movq %r9, 0x20(%rsp)
movl $0x0, 0xc(%rsp)
testq %rdi, %rdi
je 0x599ee
movq %rsi, %r12
testq %rsi, %rsi
je 0x599ee
testl %edx, %edx
jle 0x599ee
movq %r8, %r14
movq %rcx, %rbx
movq %rdi, %rbp
movaps %xmm0, 0x50(%rsp)
leaq 0xc(%rsp), %rsi
movq %r12, %rdi
movl %edx, %r13d
callq 0x12ef0
testl %eax, %eax
je 0x599fe
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, 0x70(%rsp)
callq *0x10(%rbp)
movss %xmm0, 0x1c(%rsp)
movq 0x20(%rsp), %rax
movl $0x0, (%rax)
movl %r13d, %eax
movq %rax, 0x80(%rsp)
leaq 0x1(%r12), %rax
movq %rax, 0x78(%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 0x78(%rsp), %rax
leaq (%rax,%rbx), %r12
incq %rbx
movq $-0x1, %rbp
xorl %r13d, %r13d
movaps %xmm4, 0x60(%rsp)
movl 0xc(%rsp), %eax
cmpl $0xd, %eax
jne 0x5995c
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 0x60(%rsp), %xmm4
incq %r13
cmpq 0x80(%rsp), %r14
jge 0x59a30
movl %eax, %r15d
decq %rbp
testl %eax, %eax
jne 0x5990d
jmp 0x59a30
cmpl $0xa, %eax
je 0x59a06
movq 0x20(%rsp), %rax
incl (%rax)
movq 0x10(%rsp), %rbx
addl %r15d, %ebx
leal (%rbx,%r13), %ebp
addss 0x1c(%rsp), %xmm4
movaps %xmm4, 0x60(%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 0x70(%rsp), %rax
movss 0x8(%rax), %xmm0
movq (%rax), %rdi
movq 0x10(%rsp), %rsi
movl %r15d, %edx
callq *0x10(%rax)
movaps 0x60(%rsp), %xmm4
movss %xmm0, 0x1c(%rsp)
movl 0x44(%rsp), %eax
cmpl %eax, %r14d
jge 0x599e1
testl %r15d, %r15d
jne 0x598e3
addl %r13d, %ebx
xorps %xmm0, %xmm0
movq 0x30(%rsp), %rcx
jmp 0x59a45
movq %xmm0, %xmm0            # xmm0 = xmm0[0],zero
xorps %xmm1, %xmm1
shufps $0xe2, %xmm1, %xmm0     # xmm0 = xmm0[2,0],xmm1[2,3]
jmp 0x59aa8
xorps %xmm0, %xmm0
jmp 0x59aa8
movq 0x10(%rsp), %rbx
addl %r13d, %ebx
xorps %xmm0, %xmm0
maxss %xmm0, %xmm4
movaps 0x50(%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 0x59a3b
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 0x59a53
movss %xmm4, %xmm0            # xmm0 = xmm4[0],xmm0[1,2,3]
movaps %xmm0, %xmm1
shufps $0x55, %xmm0, %xmm1     # xmm1 = xmm1[1,1],xmm0[1,1]
testq %rax, %rax
je 0x59a71
movaps %xmm1, %xmm2
addss 0x50(%rsp), %xmm2
movaps %xmm4, %xmm3
unpcklps %xmm2, %xmm3            # xmm3 = xmm3[0],xmm2[0],xmm3[1],xmm2[1]
movlps %xmm3, (%rax)
xorps %xmm2, %xmm2
movaps %xmm1, %xmm3
cmpeqps %xmm2, %xmm3
cmpltps %xmm4, %xmm2
orps %xmm3, %xmm2
movd %xmm2, %eax
testb $0x1, %al
je 0x59a9a
addss 0x50(%rsp), %xmm1
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 0x59aa8
movslq %ebx, %rax
addq %rax, %r12
movq %r12, (%rcx)
addq $0x88, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq