// File: /workspace/github_c_makefile_star2_O1/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
movq %rsi, %r15
movq %rdi, %rbx
movl 0x90(%rsi), %r13d
xorps %xmm1, %xmm1
movaps %xmm1, 0x10(%rsp)
movq $0x0, 0x20(%rsp)
cmpl %edx, %r13d
movss %xmm0, 0x8(%rsp)
jne 0x5a2f5
leaq 0x10(%rsp), %rdi
xorl %r12d, %r12d
movq %r15, %rsi
xorl %edx, %edx
movl %ecx, %ebp
movq %r14, %rcx
callq 0x5a151
testl %ebp, %ebp
je 0x5a3dd
movl $0x0, 0xc(%rbx)
jmp 0x5a418
movl %edx, %ebp
movl $0x0, 0x4(%rbx)
leaq 0x10(%rsp), %r13
xorl %r12d, %r12d
movq %r13, %rdi
movq %r15, %rsi
xorl %edx, %edx
movq %r14, %rcx
callq 0x5a151
movl 0x14(%r13), %eax
cmpl %ebp, %eax
jle 0x5a325
xorl %r13d, %r13d
movl %eax, %ecx
jmp 0x5a362
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 0x5a151
movl 0x24(%rsp), %ecx
leal (%rcx,%r12), %eax
cmpl %ebp, %eax
jle 0x5a328
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 0x5a444
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 0x5a398
jmp 0x5a444
xorl %ebp, %ebp
testl %r13d, %r13d
jle 0x5a40d
movl %ebp, %r12d
movl 0x24(%rsp), %ebp
addl %r12d, %ebp
leaq 0x10(%rsp), %rdi
movq %r15, %rsi
movl %ebp, %edx
movss 0x8(%rsp), %xmm0
movq %r14, %rcx
callq 0x5a151
cmpl %r13d, %ebp
jl 0x5a3e4
jmp 0x5a410
xorl %r12d, %r12d
movl %ebp, 0xc(%rbx)
movl 0x24(%rsp), %r13d
movl %r13d, 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 %r12d, 0x14(%rbx)
addq $0x38, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq