// File: /workspace/github_c_makefile_star2_O1/stetre[P]moonnuklear/src/./nuklear/nuklear.h
// Function: nk_textedit_locate_coord
NK_INTERN int
nk_textedit_locate_coord(struct nk_text_edit *edit, float x, float y,
    const struct nk_user_font *font, float row_height)
{
    struct nk_text_edit_row r;
    int n = edit->string.len;
    float base_y = 0, prev_x;
    int i=0, k;

    r.x0 = r.x1 = 0;
    r.ymin = r.ymax = 0;
    r.num_chars = 0;

    /* search rows to find one that straddles 'y' */
    while (i < n) {
        nk_textedit_layout_row(&r, edit, i, row_height, font);
        if (r.num_chars <= 0)
            return n;

        if (i==0 && y < base_y + r.ymin)
            return 0;

        if (y < base_y + r.ymax)
            break;

        i += r.num_chars;
        base_y += r.baseline_y_delta;
    }

    /* below all text, return 'after' last character */
    if (i >= n)
        return n;

    /* check if it's before the beginning of the line */
    if (x < r.x0)
        return i;

    /* check if it's before the end of the line */
    if (x < r.x1) {
        /* search characters in row for one that straddles 'x' */
        k = i;
        prev_x = r.x0;
        for (i=0; i < r.num_chars; ++i) {
            float w = nk_textedit_get_width(edit, k, i, font);
            if (x < prev_x+w) {
                if (x < prev_x+w/2)
                    return k+i;
                else return k+i+1;
            }
            prev_x += w;
        }
        /* shouldn't happen, but if it does, fall through to end-of-line case */
    }

    /* if the last character is a newline, return that.
     * otherwise return 'after' the last character */
    if (nk_str_rune_at(&edit->string, i+r.num_chars-1) == '\n')
        return i+r.num_chars-1;
    else return i+r.num_chars;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x48, %rsp
movss %xmm2, 0x3c(%rsp)
movss %xmm1, 0xc(%rsp)
movl 0x90(%rdi), %ebp
xorl %r14d, %r14d
movq %r14, 0x20(%rsp)
movq %r14, 0x2c(%rsp)
movl $0x0, 0x34(%rsp)
testl %ebp, %ebp
setg %bl
jle 0x5a140
movq %rsi, %r15
movq %rdi, %r12
movss %xmm0, 0x18(%rsp)
leaq 0x18(%rdi), %rax
movq %rax, 0x40(%rsp)
xorps %xmm1, %xmm1
leaq 0x20(%rsp), %r13
movss %xmm1, 0x10(%rsp)
movq %r13, %rdi
movq %r12, %rsi
movl %r14d, %edx
movss 0x3c(%rsp), %xmm0
movq %r15, %rcx
callq 0x5a151
movl 0x34(%rsp), %eax
testl %eax, %eax
jle 0x5a140
testl %r14d, %r14d
movss 0x10(%rsp), %xmm1
jne 0x59ffa
movss 0x2c(%rsp), %xmm0
addss %xmm1, %xmm0
ucomiss 0xc(%rsp), %xmm0
ja 0x5a045
movss 0x30(%rsp), %xmm0
addss %xmm1, %xmm0
ucomiss 0xc(%rsp), %xmm0
ja 0x5a023
addss 0x28(%rsp), %xmm1
addl %r14d, %eax
movl %eax, %r14d
cmpl %ebp, %eax
setl %bl
jl 0x59fb5
jmp 0x5a140
testb $0x1, %bl
je 0x5a140
movss 0x20(%rsp), %xmm2
movss 0x18(%rsp), %xmm1
ucomiss %xmm1, %xmm2
jbe 0x5a04c
movl %r14d, %ebp
jmp 0x5a140
xorl %ebp, %ebp
jmp 0x5a140
movss 0x24(%rsp), %xmm0
ucomiss %xmm1, %xmm0
jbe 0x5a101
movl 0x34(%rsp), %eax
movl %eax, 0xc(%rsp)
testl %eax, %eax
movq 0x40(%rsp), %rbx
jle 0x5a108
xorl %r13d, %r13d
movss %xmm2, 0x10(%rsp)
xorl %eax, %eax
movl %eax, 0x14(%rsp)
movl %eax, 0x1c(%rsp)
leal (%r14,%r13), %r12d
movq %rbx, %rdi
movl %r12d, %esi
leaq 0x1c(%rsp), %rdx
leaq 0x14(%rsp), %rcx
callq 0x13f60
movss 0x8(%r15), %xmm0
movl 0x14(%rsp), %edx
movq (%r15), %rdi
movq %rax, %rsi
callq *0x10(%r15)
movss 0x10(%rsp), %xmm4
movss 0x18(%rsp), %xmm3
movaps %xmm4, %xmm1
addss %xmm0, %xmm1
ucomiss %xmm3, %xmm1
movaps %xmm1, %xmm2
jbe 0x5a0e5
mulss 0x147dd(%rip), %xmm0    # 0x6e8b0
addss %xmm4, %xmm0
ucomiss %xmm3, %xmm0
ja 0x5a0df
incl %r12d
movaps %xmm4, %xmm2
movl %r12d, %ebp
ucomiss %xmm3, %xmm1
ja 0x5a140
incl %r13d
cmpl %r13d, 0xc(%rsp)
jne 0x5a073
movl 0xc(%rsp), %eax
movl %eax, %r14d
jmp 0x5a10b
movq 0x40(%rsp), %rbx
jmp 0x5a10b
xorl %r14d, %r14d
movl 0x34(%rsp), %eax
leal (%rax,%r14), %ebp
addl %eax, %r14d
decl %r14d
leaq 0x1c(%rsp), %r15
movl $0x0, (%r15)
leaq 0x14(%rsp), %rcx
movq %rbx, %rdi
movl %r14d, %esi
movq %r15, %rdx
callq 0x13f60
cmpl $0xa, (%r15)
cmovel %r14d, %ebp
movl %ebp, %eax
addq $0x48, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq