// File: /workspace/github_c_makefile_star2_O3/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 $0x38, %rsp
movq %r8, %r14
movl %edx, %ebp
movq %rsi, %r15
movq %rdi, %rbx
movl 0x90(%rsi), %eax
xorps %xmm1, %xmm1
movaps %xmm1, 0x10(%rsp)
movq $0x0, 0x20(%rsp)
cmpl %edx, %eax
movss %xmm0, 0x8(%rsp)
jne 0x5957c
movl %ecx, %r12d
leaq 0x10(%rsp), %rdi
xorl %r13d, %r13d
movq %r15, %rsi
xorl %edx, %edx
movq %r14, %rcx
callq 0x593dd
testl %r12d, %r12d
je 0x59662
movl $0x0, 0xc(%rbx)
jmp 0x5969f
movl $0x0, 0x4(%rbx)
leaq 0x10(%rsp), %r13
xorl %r12d, %r12d
movq %r13, %rdi
movq %r15, %rsi
xorl %edx, %edx
movq %r14, %rcx
callq 0x593dd
movl 0x14(%r13), %eax
cmpl %ebp, %eax
jle 0x595aa
xorl %r13d, %r13d
movl %eax, %ecx
jmp 0x595e7
xorl %r12d, %r12d
movl %r12d, %r13d
movl %eax, %r12d
movss 0x18(%rsp), %xmm0
addss 0x4(%rbx), %xmm0
movss %xmm0, 0x4(%rbx)
leaq 0x10(%rsp), %rdi
movq %r15, %rsi
movl %eax, %edx
movss 0x8(%rsp), %xmm0
movq %r14, %rcx
callq 0x593dd
movl 0x24(%rsp), %ecx
leal (%rcx,%r12), %eax
cmpl %ebp, %eax
jle 0x595ad
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)
cmpl %ebp, %r12d
jge 0x596ca
addq $0x18, %r15
xorl %r13d, %r13d
movl %r13d, 0xc(%rsp)
movl %r13d, 0x34(%rsp)
movq %r15, %rdi
movl %r12d, %esi
leaq 0x34(%rsp), %rdx
leaq 0xc(%rsp), %rcx
callq 0x13f60
movss 0x8(%r14), %xmm0
movl 0xc(%rsp), %edx
movq (%r14), %rdi
movq %rax, %rsi
callq *0x10(%r14)
addss (%rbx), %xmm0
movss %xmm0, (%rbx)
incl %r12d
cmpl %r12d, %ebp
jne 0x5961d
jmp 0x596ca
xorl %r12d, %r12d
testl %ebp, %ebp
jle 0x59694
movl %r12d, %r13d
movl 0x24(%rsp), %r12d
addl %r13d, %r12d
leaq 0x10(%rsp), %rdi
movq %r15, %rsi
movl %r12d, %edx
movss 0x8(%rsp), %xmm0
movq %r14, %rcx
callq 0x593dd
cmpl %ebp, %r12d
jl 0x59669
jmp 0x59697
xorl %r13d, %r13d
movl %r12d, 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 %r13d, 0x14(%rbx)
addq $0x38, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq