// File: /workspace/github_c_makefile_star2_O2/stetre[P]moonnuklear/src/./nuklear/nuklear.h
// Function: nk_textedit_find_charpos
NK_INTERN void
nk_textedit_find_charpos(struct nk_text_find *find, struct nk_text_edit *state,
    int n, int single_line, const struct nk_user_font *font, float row_height)
{
    /* find the x/y location of a character, and remember info about the previous
     * row in case we get a move-up event (for page up, we'll have to rescan) */
    struct nk_text_edit_row r;
    int prev_start = 0;
    int z = state->string.len;
    int i=0, first;

    nk_zero_struct(r);
    if (n == z) {
        /* if it's at the end, then find the last line -- simpler than trying to
        explicitly handle this case in the regular code */
        nk_textedit_layout_row(&r, state, 0, row_height, font);
        if (single_line) {
            find->first_char = 0;
            find->length = z;
        } else {
            while (i < z) {
                prev_start = i;
                i += r.num_chars;
                nk_textedit_layout_row(&r, state, i, row_height, font);
            }

            find->first_char = i;
            find->length = r.num_chars;
        }
        find->x = r.x1;
        find->y = r.ymin;
        find->height = r.ymax - r.ymin;
        find->prev_first = prev_start;
        return;
    }

    /* search rows to find the one that straddles character n */
    find->y = 0;

    for(;;) {
        nk_textedit_layout_row(&r, state, i, row_height, font);
        if (n < i + r.num_chars) break;
        prev_start = i;
        i += r.num_chars;
        find->y += r.baseline_y_delta;
    }

    find->first_char = first = i;
    find->length = r.num_chars;
    find->height = r.ymax - r.ymin;
    find->prev_first = prev_start;

    /* now scan to find xpos */
    find->x = r.x0;
    for (i=0; first+i < n; ++i)
        find->x += nk_textedit_get_width(state, first, i, font);
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x28, %rsp
movss %xmm0, 0xc(%rsp)
movq %r8, %r14
movl %ecx, %r13d
movl %edx, %ebp
movq %rsi, %r15
movq %rdi, %rbx
movl 0x90(%rsi), %r12d
leaq 0x10(%rsp), %rdi
pushq $0x18
popq %rsi
callq 0x23ed0
cmpl %ebp, %r12d
jne 0x53ef2
leaq 0x10(%rsp), %rdi
movq %r15, %rsi
xorl %edx, %edx
movss 0xc(%rsp), %xmm0
movq %r14, %rcx
callq 0x53c96
testl %r13d, %r13d
je 0x53f89
andl $0x0, 0xc(%rbx)
xorl %eax, %eax
jmp 0x53fc4
xorl %eax, %eax
xorps %xmm0, %xmm0
xorl %r13d, %r13d
movl %eax, %r12d
movss %xmm0, 0x4(%rbx)
leaq 0x10(%rsp), %rdi
movq %r15, %rsi
movl %eax, %edx
movss 0xc(%rsp), %xmm0
movq %r14, %rcx
callq 0x53c96
movl 0x24(%rsp), %ecx
leal (%rcx,%r12), %eax
cmpl %ebp, %eax
jg 0x53f36
movss 0x18(%rsp), %xmm0
addss 0x4(%rbx), %xmm0
movl %r12d, %r13d
jmp 0x53efa
movl %r12d, 0xc(%rbx)
movl %ecx, 0x10(%rbx)
movss 0x20(%rsp), %xmm0
subss 0x1c(%rsp), %xmm0
movss %xmm0, 0x8(%rbx)
movl %r13d, 0x14(%rbx)
movss 0x10(%rsp), %xmm0
movss %xmm0, (%rbx)
xorl %r13d, %r13d
leal (%r12,%r13), %eax
cmpl %ebp, %eax
jge 0x53fee
movq %r15, %rdi
movl %r12d, %esi
movl %r13d, %edx
movq %r14, %rcx
callq 0x53d3b
addss (%rbx), %xmm0
movss %xmm0, (%rbx)
incl %r13d
jmp 0x53f5f
xorl %r12d, %r12d
xorl %eax, %eax
movl %r12d, %r13d
cmpl %ebp, %r12d
movss 0xc(%rsp), %xmm0
jge 0x53fbc
movl 0x24(%rsp), %r12d
addl %r13d, %r12d
leaq 0x10(%rsp), %rdi
movq %r15, %rsi
movl %r12d, %edx
movq %r14, %rcx
callq 0x53c96
movl %r13d, %eax
jmp 0x53f8e
movl %r13d, 0xc(%rbx)
movl 0x24(%rsp), %ebp
movl %ebp, 0x10(%rbx)
movss 0x14(%rsp), %xmm0
movss %xmm0, (%rbx)
movss 0x1c(%rsp), %xmm0
movss %xmm0, 0x4(%rbx)
movss 0x20(%rsp), %xmm1
subss %xmm0, %xmm1
movss %xmm1, 0x8(%rbx)
movl %eax, 0x14(%rbx)
addq $0x28, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq