// File: /workspace/github_c_makefile_star2_O0/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:
subq $0x58, %rsp
movq %rdi, 0x48(%rsp)
movss %xmm0, 0x44(%rsp)
movss %xmm1, 0x40(%rsp)
movq %rsi, 0x38(%rsp)
movss %xmm2, 0x34(%rsp)
movq 0x48(%rsp), %rax
movl 0x90(%rax), %eax
movl %eax, 0x18(%rsp)
xorps %xmm0, %xmm0
movss %xmm0, 0x14(%rsp)
movl $0x0, 0xc(%rsp)
xorps %xmm0, %xmm0
movss %xmm0, 0x20(%rsp)
xorps %xmm0, %xmm0
movss %xmm0, 0x1c(%rsp)
xorps %xmm0, %xmm0
movss %xmm0, 0x2c(%rsp)
xorps %xmm0, %xmm0
movss %xmm0, 0x28(%rsp)
movl $0x0, 0x30(%rsp)
movl 0xc(%rsp), %eax
cmpl 0x18(%rsp), %eax
jge 0x8da03
movq 0x48(%rsp), %rsi
movl 0xc(%rsp), %edx
movss 0x34(%rsp), %xmm0
movq 0x38(%rsp), %rcx
leaq 0x1c(%rsp), %rdi
callq 0x8db60
cmpl $0x0, 0x30(%rsp)
jg 0x8d99c
movl 0x18(%rsp), %eax
movl %eax, 0x54(%rsp)
jmp 0x8db50
cmpl $0x0, 0xc(%rsp)
jne 0x8d9c7
movss 0x40(%rsp), %xmm1
movss 0x14(%rsp), %xmm0
addss 0x28(%rsp), %xmm0
ucomiss %xmm1, %xmm0
jbe 0x8d9c7
movl $0x0, 0x54(%rsp)
jmp 0x8db50
movss 0x40(%rsp), %xmm1
movss 0x14(%rsp), %xmm0
addss 0x2c(%rsp), %xmm0
ucomiss %xmm1, %xmm0
jbe 0x8d9e0
jmp 0x8da03
movl 0x30(%rsp), %eax
addl 0xc(%rsp), %eax
movl %eax, 0xc(%rsp)
movss 0x24(%rsp), %xmm0
addss 0x14(%rsp), %xmm0
movss %xmm0, 0x14(%rsp)
jmp 0x8d95c
movl 0xc(%rsp), %eax
cmpl 0x18(%rsp), %eax
jl 0x8da1a
movl 0x18(%rsp), %eax
movl %eax, 0x54(%rsp)
jmp 0x8db50
movss 0x44(%rsp), %xmm1
movss 0x1c(%rsp), %xmm0
ucomiss %xmm1, %xmm0
jbe 0x8da38
movl 0xc(%rsp), %eax
movl %eax, 0x54(%rsp)
jmp 0x8db50
movss 0x44(%rsp), %xmm1
movss 0x20(%rsp), %xmm0
ucomiss %xmm1, %xmm0
jbe 0x8db15
movl 0xc(%rsp), %eax
movl %eax, 0x8(%rsp)
movss 0x1c(%rsp), %xmm0
movss %xmm0, 0x10(%rsp)
movl $0x0, 0xc(%rsp)
movl 0xc(%rsp), %eax
cmpl 0x30(%rsp), %eax
jge 0x8db13
movq 0x48(%rsp), %rdi
movl 0x8(%rsp), %esi
movl 0xc(%rsp), %edx
movq 0x38(%rsp), %rcx
callq 0x8dc70
movss %xmm0, 0x4(%rsp)
movss 0x44(%rsp), %xmm1
movss 0x10(%rsp), %xmm0
addss 0x4(%rsp), %xmm0
ucomiss %xmm1, %xmm0
jbe 0x8daf1
movss 0x44(%rsp), %xmm1
movss 0x10(%rsp), %xmm0
movss 0x4(%rsp), %xmm2
movss 0x1fa1f(%rip), %xmm3    # 0xad4e4
divss %xmm3, %xmm2
addss %xmm2, %xmm0
ucomiss %xmm1, %xmm0
jbe 0x8dae0
movl 0x8(%rsp), %eax
addl 0xc(%rsp), %eax
movl %eax, 0x54(%rsp)
jmp 0x8db50
movl 0x8(%rsp), %eax
addl 0xc(%rsp), %eax
addl $0x1, %eax
movl %eax, 0x54(%rsp)
jmp 0x8db50
movss 0x4(%rsp), %xmm0
addss 0x10(%rsp), %xmm0
movss %xmm0, 0x10(%rsp)
movl 0xc(%rsp), %eax
addl $0x1, %eax
movl %eax, 0xc(%rsp)
jmp 0x8da69
jmp 0x8db15
movq 0x48(%rsp), %rdi
addq $0x18, %rdi
movl 0xc(%rsp), %esi
addl 0x30(%rsp), %esi
subl $0x1, %esi
callq 0x13a90
cmpl $0xa, %eax
jne 0x8db44
movl 0xc(%rsp), %eax
addl 0x30(%rsp), %eax
subl $0x1, %eax
movl %eax, 0x54(%rsp)
jmp 0x8db50
movl 0xc(%rsp), %eax
addl 0x30(%rsp), %eax
movl %eax, 0x54(%rsp)
movl 0x54(%rsp), %eax
addq $0x58, %rsp
retq
nopl (%rax)