// File: /workspace/github_c_makefile_star2_O2/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)
movq %rdi, %r15
movl 0x90(%rdi), %ebp
leaq 0x18(%rsp), %r13
andq $0x0, (%r13)
movq %rsi, %r12
andq $0x0, 0xc(%r13)
movss %xmm1, 0x10(%rsp)
andl $0x0, 0x14(%r13)
leaq 0x18(%rdi), %rax
movq %rax, 0x30(%rsp)
xorps %xmm2, %xmm2
xorl %r14d, %r14d
movss %xmm0, 0xc(%rsp)
cmpl %ebp, %r14d
jge 0x53c65
movss %xmm2, 0x8(%rsp)
movq %r13, %rdi
movq %r15, %rsi
movl %r14d, %edx
movss 0x14(%rsp), %xmm0
movq %r12, %rcx
callq 0x53c96
movl 0x2c(%rsp), %ebx
testl %ebx, %ebx
jle 0x53c65
testl %r14d, %r14d
movss 0xc(%rsp), %xmm0
movss 0x8(%rsp), %xmm2
jne 0x53bc5
movss 0x24(%rsp), %xmm1
addss %xmm2, %xmm1
ucomiss 0x10(%rsp), %xmm1
ja 0x53c43
movss 0x28(%rsp), %xmm1
addss %xmm2, %xmm1
ucomiss 0x10(%rsp), %xmm1
ja 0x53be1
addl %ebx, %r14d
addss 0x20(%rsp), %xmm2
jmp 0x53b71
movss 0x18(%rsp), %xmm2
ucomiss %xmm0, %xmm2
jbe 0x53bf1
movl %r14d, %ebp
jmp 0x53c65
movss 0x1c(%rsp), %xmm1
ucomiss %xmm0, %xmm1
jbe 0x53c4a
movss %xmm2, 0x8(%rsp)
xorl %r13d, %r13d
xorl %ebp, %ebp
movl %ebx, %eax
addl %r13d, %eax
je 0x53c47
movq %r15, %rdi
movl %r14d, %esi
movl %ebp, %edx
movq %r12, %rcx
callq 0x53d3b
movss 0xc(%rsp), %xmm2
movss 0x8(%rsp), %xmm3
movaps %xmm3, %xmm1
addss %xmm0, %xmm1
ucomiss %xmm2, %xmm1
ja 0x53c76
incl %ebp
decl %r13d
movss %xmm1, 0x8(%rsp)
jmp 0x53c07
xorl %ebp, %ebp
jmp 0x53c65
movl %ebx, %r14d
leal (%rbx,%r14), %ebp
addl %r14d, %ebx
decl %ebx
movq 0x30(%rsp), %rdi
movl %ebx, %esi
callq 0x12a60
cmpl $0xa, %eax
cmovel %ebx, %ebp
movl %ebp, %eax
addq $0x38, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
mulss 0x12bb2(%rip), %xmm0    # 0x66830
addss %xmm0, %xmm3
subl %r13d, %r14d
ucomiss %xmm2, %xmm3
ja 0x53bec
incl %r14d
jmp 0x53bec