// File: /workspace/github_c_makefile_star2_O2/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 $0x78, %rsp
movq %r9, 0x10(%rsp)
andl $0x0, 0x8(%rsp)
testq %rdi, %rdi
je 0x53681
movq %rsi, %r14
testq %rsi, %rsi
je 0x53681
movl %edx, %ebp
testl %edx, %edx
jle 0x53681
movq %r8, %r12
movq %rcx, %rbx
movq %rdi, %r13
movaps %xmm0, 0x60(%rsp)
leaq 0x8(%rsp), %rsi
movq %r14, %rdi
movl %ebp, %edx
callq 0x13020
testl %eax, %eax
je 0x53691
movl %eax, %r15d
movq %r12, 0x48(%rsp)
movq %rbx, 0x50(%rsp)
movss 0x8(%r13), %xmm0
movq (%r13), %rdi
movq %r14, %rsi
movl %eax, %edx
movq %r13, 0x38(%rsp)
callq *0x10(%r13)
movq 0x10(%rsp), %rax
andl $0x0, (%rax)
movss %xmm0, 0xc(%rsp)
movl %ebp, %r13d
movq %rbp, 0x40(%rsp)
leal -0x1(%rbp), %eax
movq %rax, 0x58(%rsp)
movq %r14, 0x18(%rsp)
leaq 0x1(%r14), %rbx
xorl %ebp, %ebp
xorps %xmm4, %xmm4
movslq %ebp, %r14
movq %r14, %rbp
shlq $0x20, %rbp
movl %r14d, %r12d
negl %r12d
movaps %xmm4, 0x20(%rsp)
xorps %xmm0, %xmm0
cmpq %r13, %r14
jge 0x536b9
testl %r15d, %r15d
je 0x536b9
movl 0x8(%rsp), %eax
cmpl $0xd, %eax
jne 0x53619
movq 0x10(%rsp), %rax
incl (%rax)
leaq (%rbx,%r14), %rdi
incq %r14
movq 0x58(%rsp), %rax
leal (%rax,%r12), %edx
leaq 0x8(%rsp), %rsi
callq 0x13020
movaps 0x20(%rsp), %xmm4
movl %eax, %r15d
movabsq $0x100000000, %rax      # imm = 0x100000000
addq %rax, %rbp
decl %r12d
jmp 0x535c0
cmpl $0xa, %eax
je 0x53699
movq 0x10(%rsp), %rax
incl (%rax)
movq 0x40(%rsp), %rax
movl %eax, %edx
subl %r15d, %edx
movl %r15d, %ebp
subl %r12d, %ebp
addss 0xc(%rsp), %xmm4
movaps %xmm4, 0x20(%rsp)
movslq %ebp, %r14
addq 0x18(%rsp), %r14
addl %r12d, %edx
movq %r14, %rdi
leaq 0x8(%rsp), %rsi
callq 0x13020
movl %eax, %r15d
movq 0x38(%rsp), %rax
movss 0x8(%rax), %xmm0
movq (%rax), %rdi
movq %r14, %rsi
movl %r15d, %edx
callq *0x10(%rax)
movaps 0x20(%rsp), %xmm4
movss %xmm0, 0xc(%rsp)
jmp 0x535ab
movq %xmm0, %xmm0            # xmm0 = xmm0[0],zero
xorps %xmm1, %xmm1
shufps $0xe2, %xmm1, %xmm0     # xmm0 = xmm0[2,0],xmm1[2,3]
jmp 0x5371e
xorps %xmm0, %xmm0
jmp 0x5371e
xorps %xmm0, %xmm0
maxss %xmm0, %xmm4
movaps 0x60(%rsp), %xmm1
movq 0x10(%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
ucomiss %xmm0, %xmm4
movq 0x50(%rsp), %rcx
movq 0x48(%rsp), %rax
jbe 0x536cc
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 0x60(%rsp), %xmm1
testq %rax, %rax
je 0x536ea
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 0x5370a
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 0x5371e
sarq $0x20, %rbp
movq 0x18(%rsp), %rax
addq %rbp, %rax
movq %rax, (%rcx)
addq $0x78, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq