// File: /workspace/github_c_makefile_star2_O3/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 $0x38, %rsp
movss %xmm2, 0x14(%rsp)
movss %xmm1, 0x4(%rsp)
movl 0x90(%rdi), %ebp
xorl %ebx, %ebx
movq %rbx, 0x18(%rsp)
movq %rbx, 0x24(%rsp)
movl $0x0, 0x2c(%rsp)
testl %ebp, %ebp
jle 0x593a9
movq %rsi, %r15
movq %rdi, %r12
movss %xmm0, (%rsp)
leaq 0x18(%rdi), %rax
movq %rax, 0x30(%rsp)
xorps %xmm1, %xmm1
leaq 0x18(%rsp), %r13
movss %xmm1, 0x8(%rsp)
movq %r13, %rdi
movq %r12, %rsi
movl %ebx, %edx
movss 0x14(%rsp), %xmm0
movq %r15, %rcx
callq 0x593dd
movl 0x2c(%rsp), %r14d
testl %r14d, %r14d
jle 0x593a9
testl %ebx, %ebx
movss 0x8(%rsp), %xmm1
jne 0x592cd
movss 0x24(%rsp), %xmm0
addss %xmm1, %xmm0
ucomiss 0x4(%rsp), %xmm0
ja 0x593a7
movss 0x28(%rsp), %xmm0
addss %xmm1, %xmm0
ucomiss 0x4(%rsp), %xmm0
ja 0x592f0
addl %r14d, %ebx
addss 0x20(%rsp), %xmm1
cmpl %ebp, %ebx
jl 0x59284
jmp 0x593a9
movss 0x18(%rsp), %xmm1
ucomiss (%rsp), %xmm1
jbe 0x59303
movl %ebx, %ebp
jmp 0x593a9
movss 0x1c(%rsp), %xmm0
ucomiss (%rsp), %xmm0
jbe 0x59375
xorl %ebp, %ebp
leaq 0xc(%rsp), %r13
movl %r14d, %r12d
movaps %xmm1, %xmm2
movss %xmm2, 0x8(%rsp)
movss %xmm1, 0x4(%rsp)
movl %ebp, 0xc(%rsp)
movl %ebp, 0x10(%rsp)
movq 0x30(%rsp), %rdi
movl %ebx, %esi
leaq 0x10(%rsp), %rdx
movq %r13, %rcx
callq 0x13f60
movss 0x8(%r15), %xmm0
movl 0xc(%rsp), %edx
movq (%r15), %rdi
movq %rax, %rsi
callq *0x10(%r15)
movss 0x8(%rsp), %xmm2
addss %xmm0, %xmm2
ucomiss (%rsp), %xmm2
ja 0x593ba
incl %ebx
movaps %xmm2, %xmm1
decl %r12d
jne 0x5931c
movl %r14d, %ebx
leal (%r14,%rbx), %ebp
addl %r14d, %ebx
decl %ebx
leaq 0x10(%rsp), %r15
movl $0x0, (%r15)
leaq 0xc(%rsp), %rcx
movq 0x30(%rsp), %rdi
movl %ebx, %esi
movq %r15, %rdx
callq 0x13f60
cmpl $0xa, (%r15)
cmovel %ebx, %ebp
jmp 0x593a9
xorl %ebp, %ebp
movl %ebp, %eax
addq $0x38, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
mulss 0x144de(%rip), %xmm0    # 0x6d8a0
movss 0x4(%rsp), %xmm1
addss %xmm0, %xmm1
ucomiss (%rsp), %xmm1
ja 0x592fc
incl %ebx
jmp 0x592fc