// File: /workspace/github_c_makefile_star2_O2/OnionIoT[P]lv_example/lvgl/src/lv_objx/lv_ta.c
// Function: refr_cursor_area
static void refr_cursor_area(lv_obj_t * ta)
{
    lv_ta_ext_t * ext = lv_obj_get_ext_attr(ta);

    const lv_style_t * label_style = lv_obj_get_style(ext->label);

    lv_style_t cur_style;
    get_cursor_style(ta, &cur_style);

    uint16_t cur_pos = lv_ta_get_cursor_pos(ta);
    const char * txt = lv_label_get_text(ext->label);

    uint32_t byte_pos;
    byte_pos = lv_txt_encoded_get_byte_id(txt, cur_pos);

    uint32_t letter = lv_txt_encoded_next(&txt[byte_pos], NULL);

    lv_coord_t letter_h = lv_font_get_line_height(label_style->text.font);

    /*Set letter_w (set not 0 on non printable but valid chars)*/
    lv_coord_t letter_w;
    if(letter == '\0' || letter == '\n' || letter == '\r') {
        letter_w = lv_font_get_glyph_width(label_style->text.font, ' ', '\0');
    } else {
        /*`letter_next` parameter is '\0' to ignore kerning*/
        letter_w = lv_font_get_glyph_width(label_style->text.font, letter, '\0');
    }

    lv_point_t letter_pos;
    lv_label_get_letter_pos(ext->label, cur_pos, &letter_pos);

    /*If the cursor is out of the text (most right) draw it to the next line*/
    if(letter_pos.x + ext->label->coords.x1 + letter_w > ext->label->coords.x2 && ext->one_line == 0 &&
       lv_label_get_align(ext->label) != LV_LABEL_ALIGN_RIGHT) {
        letter_pos.x = 0;
        letter_pos.y += letter_h + label_style->text.line_space;

        if(letter != '\0') {
            byte_pos += lv_txt_encoded_size(&txt[byte_pos]);
            letter = lv_txt_encoded_next(&txt[byte_pos], NULL);
        }

        if(letter == '\0' || letter == '\n' || letter == '\r') {
            letter_w = lv_font_get_glyph_width(label_style->text.font, ' ', '\0');
        } else {
            letter_w = lv_font_get_glyph_width(label_style->text.font, letter, '\0');
        }
    }

    /*Save the byte position. It is required to draw `LV_CURSOR_BLOCK`*/
    ext->cursor.txt_byte_pos = byte_pos;

    /*Draw he cursor according to the type*/
    lv_area_t cur_area;

    if(ext->cursor.type == LV_CURSOR_LINE) {
        cur_area.x1 =
            letter_pos.x + cur_style.body.padding.left - (cur_style.line.width >> 1) - (cur_style.line.width & 0x1);
        cur_area.y1 = letter_pos.y + cur_style.body.padding.top;
        cur_area.x2 = letter_pos.x + cur_style.body.padding.right + (cur_style.line.width >> 1);
        cur_area.y2 = letter_pos.y + cur_style.body.padding.bottom + letter_h;
    } else if(ext->cursor.type == LV_CURSOR_BLOCK) {
        cur_area.x1 = letter_pos.x - cur_style.body.padding.left;
        cur_area.y1 = letter_pos.y - cur_style.body.padding.top;
        cur_area.x2 = letter_pos.x + cur_style.body.padding.right + letter_w;
        cur_area.y2 = letter_pos.y + cur_style.body.padding.bottom + letter_h;

    } else if(ext->cursor.type == LV_CURSOR_OUTLINE) {
        cur_area.x1 = letter_pos.x - cur_style.body.padding.left;
        cur_area.y1 = letter_pos.y - cur_style.body.padding.top;
        cur_area.x2 = letter_pos.x + cur_style.body.padding.right + letter_w;
        cur_area.y2 = letter_pos.y + cur_style.body.padding.bottom + letter_h;
    } else if(ext->cursor.type == LV_CURSOR_UNDERLINE) {
        cur_area.x1 = letter_pos.x + cur_style.body.padding.left;
        cur_area.y1 = letter_pos.y + cur_style.body.padding.top + letter_h - (cur_style.line.width >> 1);
        cur_area.x2 = letter_pos.x + cur_style.body.padding.right + letter_w;
        cur_area.y2 = letter_pos.y + cur_style.body.padding.bottom + letter_h + (cur_style.line.width >> 1) +
                      (cur_style.line.width & 0x1);
    }

    /*Save the new area*/
    lv_disp_t * disp = lv_obj_get_disp(ta);
    lv_area_t area_tmp;
    lv_area_copy(&area_tmp, &ext->cursor.area);
    area_tmp.x1 += ext->label->coords.x1;
    area_tmp.y1 += ext->label->coords.y1;
    area_tmp.x2 += ext->label->coords.x1;
    area_tmp.y2 += ext->label->coords.y1;
    lv_inv_area(disp, &area_tmp);

    lv_area_copy(&ext->cursor.area, &cur_area);

    lv_area_copy(&area_tmp, &ext->cursor.area);
    area_tmp.x1 += ext->label->coords.x1;
    area_tmp.y1 += ext->label->coords.y1;
    area_tmp.x2 += ext->label->coords.x1;
    area_tmp.y2 += ext->label->coords.y1;
    lv_inv_area(disp, &area_tmp);
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x88, %rsp
movq %rdi, %r14
callq 0x6747
movq %rax, %rbx
movq 0x50(%rax), %rdi
callq 0x6316
movq %rax, %r13
leaq 0x20(%rsp), %rsi
movq %r14, %rdi
callq 0x1ea53
movq %r14, 0x78(%rsp)
movq %r14, %rdi
callq 0x1d8d0
movl %eax, %ebp
movq 0x50(%rbx), %rdi
callq 0x18db9
movq %rax, %r12
leaq 0x3364b(%rip), %rax     # 0x51640
movzwl %bp, %r15d
movq %r12, %rdi
movl %r15d, %esi
callq *(%rax)
leaq 0x33628(%rip), %rcx     # 0x51630
movq %rax, 0x10(%rsp)
movl %eax, %r14d
movq %r12, 0x68(%rsp)
addq %r12, %r14
movq %r14, %rdi
xorl %esi, %esi
callq *(%rcx)
movl %eax, %r12d
movq %r13, 0x70(%rsp)
movq 0x28(%r13), %rdi
movzbl 0x10(%rdi), %eax
movl %eax, 0x1c(%rsp)
cmpl $0xd, %r12d
ja 0x1e049
movl $0x2401, %eax           # imm = 0x2401
btl %r12d, %eax
jae 0x1e049
pushq $0x20
popq %rsi
jmp 0x1e04c
movl %r12d, %esi
xorl %edx, %edx
callq 0x2603b
movl %eax, %ebp
movq 0x50(%rbx), %rdi
leaq 0xc(%rsp), %r13
movl %r15d, %esi
movq %r13, %rdx
callq 0x197e0
movswl (%r13), %eax
movq 0x50(%rbx), %rdi
movswl 0x20(%rdi), %ecx
addl %eax, %ecx
movswl %bp, %eax
addl %ecx, %eax
movswl 0x24(%rdi), %ecx
cmpl %ecx, %eax
jle 0x1e09b
testb $0x2, 0x98(%rbx)
jne 0x1e09b
callq 0x18d7f
cmpb $0x2, %al
jne 0x1e27c
movq 0x10(%rsp), %r14
movw %r14w, 0x8e(%rbx)
movzbl 0x90(%rbx), %eax
andl $0xf, %eax
decl %eax
cmpl $0x3, %eax
ja 0x1e272
leaq 0x1d830(%rip), %rcx     # 0x3b8f4
movslq (%rcx,%rax,4), %rax
addq %rcx, %rax
jmpq *%rax
movzwl 0xc(%rsp), %eax
movswl 0x5e(%rsp), %ecx
movl %ecx, %ebp
sarl %ebp
andl $0x1, %ecx
movzwl 0x3a(%rsp), %edx
addw %ax, %dx
addl %ebp, %ecx
subl %ecx, %edx
movq %rdx, 0x10(%rsp)
movzwl 0xe(%rsp), %ecx
movzwl 0x36(%rsp), %r12d
addw %cx, %r12w
addl %eax, %ebp
addw 0x3c(%rsp), %bp
movzwl 0x1c(%rsp), %r13d
addl %ecx, %r13d
jmp 0x1e1ba
movzwl 0x1c(%rsp), %r13d
movzwl 0xc(%rsp), %eax
movzwl 0x3a(%rsp), %ecx
addl %eax, %ebp
subw %cx, %ax
movq %rax, 0x10(%rsp)
movzwl 0xe(%rsp), %r12d
movzwl 0x36(%rsp), %eax
jmp 0x1e1ae
movl 0x1c(%rsp), %edi
movzwl %di, %r12d
movzwl 0xc(%rsp), %eax
movzwl 0x3a(%rsp), %ecx
addw %ax, %cx
movq %rcx, 0x10(%rsp)
movzwl 0xe(%rsp), %ecx
movswl 0x5e(%rsp), %edx
movl %edx, %esi
sarl %esi
addl %ecx, %r12d
addw 0x36(%rsp), %r12w
subl %esi, %r12d
addl %eax, %ebp
addw 0x3c(%rsp), %bp
movl %edx, %r13d
shrl %r13d
andl $0x1, %edx
addl %ecx, %r13d
addl %edx, %r13d
addl %edi, %r13d
jmp 0x1e1ba
movzwl 0xc(%rsp), %eax
movzwl 0x3a(%rsp), %ecx
addl %eax, %ebp
subw %cx, %ax
movq %rax, 0x10(%rsp)
movzwl 0xe(%rsp), %r12d
movzwl 0x36(%rsp), %eax
movzwl 0x1c(%rsp), %r13d
addl %r12d, %r13d
subw %ax, %r12w
addw 0x3c(%rsp), %bp
addw 0x38(%rsp), %r13w
movq 0x78(%rsp), %rdi
callq 0x4d17
movq %rax, %r14
movq 0x50(%rbx), %rax
movq 0x20(%rax), %xmm0
pshufd $0x50, %xmm0, %xmm0     # xmm0 = xmm0[0,0,1,1]
movq 0x86(%rbx), %xmm1
paddw %xmm0, %xmm1
leaq 0x80(%rsp), %r15
movq %xmm1, (%r15)
movq %r14, %rdi
movq %r15, %rsi
callq 0x6cff
movzwl %r13w, %eax
shlq $0x30, %rax
movzwl %bp, %ecx
shlq $0x20, %rcx
orq %rax, %rcx
movl %r12d, %eax
shll $0x10, %eax
movq 0x10(%rsp), %rsi
movzwl %si, %edx
orq %rax, %rdx
orq %rcx, %rdx
movq %rdx, 0x86(%rbx)
movq 0x50(%rbx), %rax
movl 0x20(%rax), %ecx
leal (%rsi,%rcx), %edx
movw %dx, (%r15)
movzwl 0x22(%rax), %eax
addl %eax, %r12d
movw %r12w, 0x2(%r15)
addl %ebp, %ecx
movw %cx, 0x4(%r15)
addl %r13d, %eax
movw %ax, 0x6(%r15)
movq %r14, %rdi
movq %r15, %rsi
callq 0x6cff
addq $0x88, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq %rax, 0x10(%rsp)
jmp 0x1e1c0
andw $0x0, 0xc(%rsp)
movq 0x70(%rsp), %r15
movzwl 0x32(%r15), %eax
addw 0x1c(%rsp), %ax
addw %ax, 0xe(%rsp)
pushq $0x20
popq %rbp
testl %r12d, %r12d
je 0x1e2db
leaq 0x33373(%rip), %rax     # 0x51618
movq %r14, %rdi
callq *(%rax)
movzbl %al, %eax
movq 0x10(%rsp), %r14
addl %eax, %r14d
movq 0x68(%rsp), %rdi
addq %r14, %rdi
xorl %esi, %esi
leaq 0x3336a(%rip), %rax     # 0x51630
callq *(%rax)
cmpl $0xd, %eax
ja 0x1e2d7
movl $0x2401, %ecx           # imm = 0x2401
btl %eax, %ecx
jb 0x1e2e0
movl %eax, %ebp
jmp 0x1e2e0
movq 0x10(%rsp), %r14
movq 0x28(%r15), %rdi
movl %ebp, %esi
xorl %edx, %edx
callq 0x2603b
movl %eax, %ebp
jmp 0x1e0a0