// File: /workspace/github_c_makefile_star2_O1/stetre[P]moonnuklear/src/./nuklear/nuklear.h
// Function: nk_text_clamp
NK_LIB int
nk_text_clamp(const struct nk_user_font *font, const char *text,
    int text_len, float space, int *glyphs, float *text_width,
    nk_rune *sep_list, int sep_count)
{
    int i = 0;
    int glyph_len = 0;
    float last_width = 0;
    nk_rune unicode = 0;
    float width = 0;
    int len = 0;
    int g = 0;
    float s;

    int sep_len = 0;
    int sep_g = 0;
    float sep_width = 0;
    sep_count = NK_MAX(sep_count,0);

    glyph_len = nk_utf_decode(text, &unicode, text_len);
    while (glyph_len && (width < space) && (len < text_len)) {
        len += glyph_len;
        s = font->width(font->userdata, font->height, text, len);
        for (i = 0; i < sep_count; ++i) {
            if (unicode != sep_list[i]) continue;
            sep_width = last_width = width;
            sep_g = g+1;
            sep_len = len;
            break;
        }
        if (i == sep_count){
            last_width = sep_width = width;
            sep_g = g+1;
        }
        width = s;
        glyph_len = nk_utf_decode(&text[len], &unicode, text_len - len);
        g++;
    }
    if (len >= text_len) {
        *glyphs = g;
        *text_width = last_width;
        return len;
    } else {
        *glyphs = sep_g;
        *text_width = sep_width;
        return (!sep_len) ? len: sep_len;
    }
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x38, %rsp
movq %r9, %r15
movq %r8, 0x28(%rsp)
movq %rcx, 0x20(%rsp)
movss %xmm0, 0x14(%rsp)
movl %edx, %ebp
movq %rsi, %rax
movq %rdi, %rbx
leaq 0x1c(%rsp), %rsi
movl $0x0, (%rsi)
movq %rax, 0x30(%rsp)
movq %rax, %rdi
callq 0x12ef0
testl %eax, %eax
setne %cl
xorps %xmm1, %xmm1
xorps %xmm0, %xmm0
movss %xmm0, (%rsp)
movss 0x14(%rsp), %xmm0
ucomiss %xmm1, %xmm0
seta %dl
movl %ebp, 0x18(%rsp)
testl %ebp, %ebp
setg %r14b
andb %r14b, %cl
andb %dl, %cl
xorl %ebp, %ebp
movl $0x0, %r13d
movl $0x0, 0xc(%rsp)
movl $0x0, 0x8(%rsp)
xorps %xmm0, %xmm0
cmpb $0x1, %cl
jne 0x28ba7
movl 0x70(%rsp), %r12d
movl $0x0, 0x8(%rsp)
xorps %xmm2, %xmm2
movl $0x0, 0xc(%rsp)
xorl %r13d, %r13d
xorl %ebp, %ebp
movss %xmm0, (%rsp)
movss %xmm2, 0x10(%rsp)
movss %xmm1, 0x4(%rsp)
addl %eax, %ebp
movss 0x8(%rbx), %xmm0
movq (%rbx), %rdi
movq 0x30(%rsp), %rsi
movl %ebp, %edx
callq *0x10(%rbx)
movl 0x1c(%rsp), %ecx
xorl %edx, %edx
movl %edx, %eax
cmpl %r12d, %edx
jge 0x28b1b
movl $0x1, %edx
cmpl (%r15), %ecx
jne 0x28af4
leal 0x1(%r13), %ecx
movss 0x4(%rsp), %xmm1
movaps %xmm1, %xmm2
movl %ebp, 0xc(%rsp)
movaps %xmm1, %xmm3
jmp 0x28b30
movss (%rsp), %xmm2
movl 0x8(%rsp), %ecx
movss 0x4(%rsp), %xmm1
movss 0x10(%rsp), %xmm3
incl %r13d
movss %xmm1, (%rsp)
cmpl %r12d, %eax
je 0x28b42
movss %xmm2, (%rsp)
movss %xmm0, 0x10(%rsp)
cmovel %r13d, %ecx
movl %ecx, 0x8(%rsp)
je 0x28b55
movaps %xmm3, %xmm1
movss %xmm1, 0x4(%rsp)
movslq %ebp, %rdi
addq 0x30(%rsp), %rdi
movl 0x18(%rsp), %edx
subl %ebp, %edx
setg %r14b
leaq 0x1c(%rsp), %rsi
callq 0x12ef0
testl %eax, %eax
je 0x28ba1
movss 0x14(%rsp), %xmm0
movss 0x10(%rsp), %xmm1
ucomiss %xmm1, %xmm0
movss 0x4(%rsp), %xmm0
jbe 0x28ba7
movaps %xmm0, %xmm2
cmpl %ebp, 0x18(%rsp)
jg 0x28ace
jmp 0x28ba7
movss 0x4(%rsp), %xmm0
testb %r14b, %r14b
je 0x28bcb
movq 0x20(%rsp), %rax
movl 0x8(%rsp), %ecx
movl %ecx, (%rax)
movq 0x28(%rsp), %rax
movss %xmm0, (%rax)
movl 0xc(%rsp), %eax
testl %eax, %eax
cmovnel %eax, %ebp
jmp 0x28be1
movq 0x20(%rsp), %rax
movl %r13d, (%rax)
movq 0x28(%rsp), %rax
movss (%rsp), %xmm0
movss %xmm0, (%rax)
movl %ebp, %eax
addq $0x38, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq