// File: /workspace/github_c_makefile_star2_O0/OnionIoT[P]lv_example/lvgl/src/lv_objx/lv_ta.c
// Function: lv_ta_set_cursor_pos
void lv_ta_set_cursor_pos(lv_obj_t * ta, int16_t pos)
{
    LV_ASSERT_OBJ(ta, LV_OBJX_NAME);

    lv_ta_ext_t * ext = lv_obj_get_ext_attr(ta);
    if(ext->cursor.pos == pos) return;

    uint16_t len = lv_txt_get_encoded_length(lv_label_get_text(ext->label));

    if(pos < 0) pos = len + pos;

    if(pos > len || pos == LV_TA_CURSOR_LAST) pos = len;

    ext->cursor.pos = pos;

    /*Position the label to make the cursor visible*/
    lv_obj_t * label_par = lv_obj_get_parent(ext->label);
    lv_point_t cur_pos;
    const lv_style_t * style = lv_obj_get_style(ta);
    const lv_font_t * font_p = style->text.font;
    lv_area_t label_cords;
    lv_area_t ta_cords;
    lv_label_get_letter_pos(ext->label, pos, &cur_pos);
    lv_obj_get_coords(ta, &ta_cords);
    lv_obj_get_coords(ext->label, &label_cords);

    /*Check the top*/
    lv_coord_t font_h = lv_font_get_line_height(font_p);
    if(lv_obj_get_y(label_par) + cur_pos.y < 0) {
        lv_obj_set_y(label_par, -cur_pos.y + style->body.padding.top);
    }

    /*Check the bottom*/
    if(label_cords.y1 + cur_pos.y + font_h + style->body.padding.bottom > ta_cords.y2) {
        lv_obj_set_y(label_par, -(cur_pos.y - lv_obj_get_height(ta) + font_h + style->body.padding.top +
                                  style->body.padding.bottom));
    }
    /*Check the left (use the font_h as general unit)*/
    if(lv_obj_get_x(label_par) + cur_pos.x < font_h) {
        lv_obj_set_x(label_par, -cur_pos.x + font_h);
    }

    /*Check the right (use the font_h as general unit)*/
    if(label_cords.x1 + cur_pos.x + font_h + style->body.padding.right > ta_cords.x2) {
        lv_obj_set_x(label_par, -(cur_pos.x - lv_obj_get_width(ta) + font_h + style->body.padding.left +
                                  style->body.padding.right));
    }

    ext->cursor.valid_x = cur_pos.x;

#if LV_USE_ANIMATION
    if(ext->cursor.blink_time) {
        /*Reset cursor blink animation*/
        lv_anim_t a;
        a.var            = ta;
        a.exec_cb        = (lv_anim_exec_xcb_t)cursor_blink_anim;
        a.time           = ext->cursor.blink_time;
        a.act_time       = 0;
        a.ready_cb       = NULL;
        a.start          = 1;
        a.end            = 0;
        a.repeat         = 1;
        a.repeat_pause   = 0;
        a.playback       = 1;
        a.playback_pause = 0;
        a.path_cb        = lv_anim_path_step;
        lv_anim_create(&a);
    }
#endif

    refr_cursor_area(ta);
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0xc0, %rsp
movw %si, %ax
movq %rdi, -0x8(%rbp)
movw %ax, -0xa(%rbp)
movq -0x8(%rbp), %rdi
callq 0xd120
testb $0x1, %al
jne 0x327a5
movq -0x8(%rbp), %rsi
leaq 0x3595e(%rip), %rdi     # 0x680fc
callq 0xd410
jmp 0x327a3
movq -0x8(%rbp), %rdi
callq 0xa8f0
movq %rax, -0x18(%rbp)
movq -0x18(%rbp), %rax
movzwl 0x82(%rax), %eax
movswl -0xa(%rbp), %ecx
cmpl %ecx, %eax
jne 0x327ca
jmp 0x32a9c
leaq 0x49f0f(%rip), %rax     # 0x7c6e0
movq (%rax), %rax
movq %rax, -0x98(%rbp)
movq -0x18(%rbp), %rax
movq 0x50(%rax), %rdi
callq 0x2abc0
movq %rax, %rdi
movq -0x98(%rbp), %rax
callq *%rax
movw %ax, -0x1a(%rbp)
movswl -0xa(%rbp), %eax
cmpl $0x0, %eax
jge 0x3280f
movzwl -0x1a(%rbp), %eax
movswl -0xa(%rbp), %ecx
addl %ecx, %eax
movw %ax, -0xa(%rbp)
movswl -0xa(%rbp), %eax
movzwl -0x1a(%rbp), %ecx
cmpl %ecx, %eax
jg 0x32826
movswl -0xa(%rbp), %eax
cmpl $0x7fff, %eax           # imm = 0x7FFF
jne 0x3282e
movw -0x1a(%rbp), %ax
movw %ax, -0xa(%rbp)
movw -0xa(%rbp), %cx
movq -0x18(%rbp), %rax
movw %cx, 0x82(%rax)
movq -0x18(%rbp), %rax
movq 0x50(%rax), %rdi
callq 0x71b0
movq %rax, -0x28(%rbp)
movq -0x8(%rbp), %rdi
callq 0xa080
movq %rax, -0x38(%rbp)
movq -0x38(%rbp), %rax
movq 0x28(%rax), %rax
movq %rax, -0x40(%rbp)
movq -0x18(%rbp), %rax
movq 0x50(%rax), %rdi
leaq -0x2c(%rbp), %rdx
movzwl -0xa(%rbp), %esi
callq 0x2bca0
movq -0x8(%rbp), %rdi
leaq -0x50(%rbp), %rsi
callq 0x7fb0
movq -0x18(%rbp), %rax
movq 0x50(%rax), %rdi
leaq -0x48(%rbp), %rsi
callq 0x7fb0
movq -0x40(%rbp), %rdi
callq 0x33480
movzbl %al, %eax
movw %ax, -0x52(%rbp)
movq -0x28(%rbp), %rdi
callq 0x73c0
cwtl
movswl -0x2a(%rbp), %ecx
addl %ecx, %eax
cmpl $0x0, %eax
jge 0x328dd
movq -0x28(%rbp), %rdi
movswl -0x2a(%rbp), %ecx
xorl %eax, %eax
subl %ecx, %eax
movq -0x38(%rbp), %rcx
movswl 0x16(%rcx), %ecx
addl %ecx, %eax
movswl %ax, %esi
callq 0x8120
movswl -0x46(%rbp), %eax
movswl -0x2a(%rbp), %ecx
addl %ecx, %eax
movswl -0x52(%rbp), %ecx
addl %ecx, %eax
movq -0x38(%rbp), %rcx
movswl 0x18(%rcx), %ecx
addl %ecx, %eax
movswl -0x4a(%rbp), %ecx
cmpl %ecx, %eax
jle 0x32953
movq -0x28(%rbp), %rax
movq %rax, -0xa0(%rbp)
movswl -0x2a(%rbp), %eax
movl %eax, -0xa4(%rbp)
movq -0x8(%rbp), %rdi
callq 0x8350
movl -0xa4(%rbp), %ecx
movq -0xa0(%rbp), %rdi
cwtl
subl %eax, %ecx
movswl -0x52(%rbp), %eax
addl %eax, %ecx
movq -0x38(%rbp), %rax
movswl 0x16(%rax), %eax
addl %eax, %ecx
movq -0x38(%rbp), %rax
movswl 0x18(%rax), %eax
addl %eax, %ecx
xorl %eax, %eax
subl %ecx, %eax
movswl %ax, %esi
callq 0x8120
movq -0x28(%rbp), %rdi
callq 0x7350
cwtl
movswl -0x2c(%rbp), %ecx
addl %ecx, %eax
movswl -0x52(%rbp), %ecx
cmpl %ecx, %eax
jge 0x32985
movq -0x28(%rbp), %rdi
movswl -0x2c(%rbp), %ecx
xorl %eax, %eax
subl %ecx, %eax
movswl -0x52(%rbp), %ecx
addl %ecx, %eax
movswl %ax, %esi
callq 0x80b0
movswl -0x48(%rbp), %eax
movswl -0x2c(%rbp), %ecx
addl %ecx, %eax
movswl -0x52(%rbp), %ecx
addl %ecx, %eax
movq -0x38(%rbp), %rcx
movswl 0x1c(%rcx), %ecx
addl %ecx, %eax
movswl -0x4c(%rbp), %ecx
cmpl %ecx, %eax
jle 0x329fb
movq -0x28(%rbp), %rax
movq %rax, -0xb0(%rbp)
movswl -0x2c(%rbp), %eax
movl %eax, -0xb4(%rbp)
movq -0x8(%rbp), %rdi
callq 0x8310
movl -0xb4(%rbp), %ecx
movq -0xb0(%rbp), %rdi
cwtl
subl %eax, %ecx
movswl -0x52(%rbp), %eax
addl %eax, %ecx
movq -0x38(%rbp), %rax
movswl 0x1a(%rax), %eax
addl %eax, %ecx
movq -0x38(%rbp), %rax
movswl 0x1c(%rax), %eax
addl %eax, %ecx
xorl %eax, %eax
subl %ecx, %eax
movswl %ax, %esi
callq 0x80b0
movw -0x2c(%rbp), %cx
movq -0x18(%rbp), %rax
movw %cx, 0x80(%rax)
movq -0x18(%rbp), %rax
cmpw $0x0, 0x84(%rax)
je 0x32a93
movq -0x8(%rbp), %rax
movq %rax, -0x90(%rbp)
leaq -0xbba(%rip), %rax      # 0x31e70
movq %rax, -0x88(%rbp)
movq -0x18(%rbp), %rax
movw 0x84(%rax), %ax
movw %ax, -0x68(%rbp)
movw $0x0, -0x66(%rbp)
movq $0x0, -0x78(%rbp)
movl $0x1, -0x70(%rbp)
movl $0x0, -0x6c(%rbp)
movb -0x60(%rbp), %al
andb $-0x3, %al
orb $0x2, %al
movb %al, -0x60(%rbp)
movw $0x0, -0x62(%rbp)
movb -0x60(%rbp), %al
andb $-0x2, %al
orb $0x1, %al
movb %al, -0x60(%rbp)
movw $0x0, -0x64(%rbp)
leaq 0x120ad(%rip), %rax     # 0x44b30
movq %rax, -0x80(%rbp)
leaq -0x90(%rbp), %rdi
callq 0x444a0
movq -0x8(%rbp), %rdi
callq 0x334a0
addq $0xc0, %rsp
popq %rbp
retq
nopw %cs:(%rax,%rax)