// File: /workspace/github_c_makefile_star2_O3/OnionIoT[P]lv_example/lvgl/src/lv_objx/lv_label.c
// Function: lv_label_refr_text
static void lv_label_refr_text(lv_obj_t * label)
{
    lv_label_ext_t * ext = lv_obj_get_ext_attr(label);

    if(ext->text == NULL) return;
#if LV_LABEL_LONG_TXT_HINT
    ext->hint.line_start = -1; /*The hint is invalid if the text changes*/
#endif

    lv_coord_t max_w         = lv_obj_get_width(label);
    const lv_style_t * style = lv_obj_get_style(label);
    const lv_font_t * font   = style->text.font;

    /*If the width will be expanded set the max length to very big */
    if(ext->long_mode == LV_LABEL_LONG_EXPAND) {
        max_w = LV_COORD_MAX;
    }

    /*Calc. the height and longest line*/
    lv_point_t size;
    lv_txt_flag_t flag = LV_TXT_FLAG_NONE;
    if(ext->recolor != 0) flag |= LV_TXT_FLAG_RECOLOR;
    if(ext->expand != 0) flag |= LV_TXT_FLAG_EXPAND;
    lv_txt_get_size(&size, ext->text, font, style->text.letter_space, style->text.line_space, max_w, flag);

    /*Set the full size in expand mode*/
    if(ext->long_mode == LV_LABEL_LONG_EXPAND) {
        lv_obj_set_size(label, size.x, size.y);
    }
    /*In roll mode keep the size but start offset animations*/
    else if(ext->long_mode == LV_LABEL_LONG_SROLL) {
#if LV_USE_ANIMATION
        lv_anim_t anim;
        anim.var      = label;
        anim.repeat   = 1;
        anim.playback = 1;
        anim.start    = 0;
        anim.ready_cb = NULL;
        anim.path_cb  = lv_anim_path_linear;
        anim.playback_pause =
            (((lv_font_get_glyph_width(style->text.font, ' ', ' ') + style->text.letter_space) * 1000) /
             ext->anim_speed) *
            LV_LABEL_WAIT_CHAR_COUNT;
        anim.repeat_pause = anim.playback_pause;
        anim.act_time     = -anim.playback_pause;

        bool hor_anim = false;
        if(size.x > lv_obj_get_width(label)) {
            anim.end     = lv_obj_get_width(label) - size.x;
            anim.exec_cb = (lv_anim_exec_xcb_t)lv_label_set_offset_x;
            anim.time    = lv_anim_speed_to_time(ext->anim_speed, anim.start, anim.end);
            lv_anim_create(&anim);
            hor_anim = true;
        } else {
            /*Delete the offset animation if not required*/
            lv_anim_del(label, (lv_anim_exec_xcb_t)lv_label_set_offset_x);
            ext->offset.x = 0;
        }

        if(size.y > lv_obj_get_height(label) && hor_anim == false) {
            anim.end     = lv_obj_get_height(label) - size.y - (lv_font_get_line_height(font));
            anim.exec_cb = (lv_anim_exec_xcb_t)lv_label_set_offset_y;

            anim.time = lv_anim_speed_to_time(ext->anim_speed, anim.start, anim.end);
            lv_anim_create(&anim);
        } else {
            /*Delete the offset animation if not required*/
            lv_anim_del(label, (lv_anim_exec_xcb_t)lv_label_set_offset_y);
            ext->offset.y = 0;
        }
#endif
    }
    /*In roll inf. mode keep the size but start offset animations*/
    else if(ext->long_mode == LV_LABEL_LONG_SROLL_CIRC) {
#if LV_USE_ANIMATION
        lv_label_align_t align = lv_label_get_align(label);

        lv_anim_t anim;
        anim.var      = label;
        anim.repeat   = 1;
        anim.playback = 0;
        anim.act_time = -(((lv_font_get_glyph_width(style->text.font, ' ', ' ') + style->text.letter_space) * 1000) /
                          ext->anim_speed) *
                        LV_LABEL_WAIT_CHAR_COUNT;
        anim.ready_cb       = NULL;
        anim.path_cb        = lv_anim_path_linear;
        anim.playback_pause = 0;
        anim.repeat_pause   = 0;

        bool hor_anim = false;
        if(size.x > lv_obj_get_width(label)) {
            if(align == LV_LABEL_ALIGN_RIGHT) {
                anim.end    = 0;
                anim.start     = -size.x - lv_font_get_glyph_width(font, ' ', ' ') * LV_LABEL_WAIT_CHAR_COUNT;
            } else {
                anim.start    = 0;
                anim.end     = -size.x - lv_font_get_glyph_width(font, ' ', ' ') * LV_LABEL_WAIT_CHAR_COUNT;
            }

            anim.exec_cb = (lv_anim_exec_xcb_t)lv_label_set_offset_x;
            anim.time    = lv_anim_speed_to_time(ext->anim_speed, anim.start, anim.end);
            lv_anim_create(&anim);
            hor_anim = true;
        } else {
            /*Delete the offset animation if not required*/
            lv_anim_del(label, (lv_anim_exec_xcb_t)lv_label_set_offset_x);
            ext->offset.x = 0;
        }

        if(size.y > lv_obj_get_height(label) && hor_anim == false) {
            if(align == LV_LABEL_ALIGN_RIGHT) {
                  anim.end    = 0;
                  anim.start     = -size.y - (lv_font_get_line_height(font));
              } else {
                  anim.start    = 0;
                  anim.end     = -size.y - (lv_font_get_line_height(font));
              }

            anim.exec_cb = (lv_anim_exec_xcb_t)lv_label_set_offset_y;
            anim.time    = lv_anim_speed_to_time(ext->anim_speed, anim.start, anim.end);
            lv_anim_create(&anim);
        } else {
            /*Delete the offset animation if not required*/
            lv_anim_del(label, (lv_anim_exec_xcb_t)lv_label_set_offset_y);
            ext->offset.y = 0;
        }
#endif
    } else if(ext->long_mode == LV_LABEL_LONG_DOT) {
        if(size.y <= lv_obj_get_height(label)) { /*No dots are required, the text is short enough*/
            ext->dot_end = LV_LABEL_DOT_END_INV;
        } else if(lv_txt_get_encoded_length(ext->text) <= LV_LABEL_DOT_NUM) { /*Don't turn to dots all the characters*/
            ext->dot_end = LV_LABEL_DOT_END_INV;
        } else {
            lv_point_t p;
            p.x = lv_obj_get_width(label) -
                  (lv_font_get_glyph_width(style->text.font, '.', '.') + style->text.letter_space) *
                      LV_LABEL_DOT_NUM; /*Shrink with dots*/
            p.y = lv_obj_get_height(label);
            p.y -= p.y %
                   (lv_font_get_line_height(style->text.font) + style->text.line_space); /*Round down to the last line*/
            p.y -= style->text.line_space;                                               /*Trim the last line space*/
            uint32_t letter_id = lv_label_get_letter_on(label, &p);

            /*Save letters under the dots and replace them with dots*/
            uint32_t i;
            uint32_t byte_id     = lv_txt_encoded_get_byte_id(ext->text, letter_id);
            uint32_t byte_id_ori = byte_id;
            uint8_t len          = 0;
            for(i = 0; i <= LV_LABEL_DOT_NUM; i++) {
                len += lv_txt_encoded_size(&ext->text[byte_id]);
                lv_txt_encoded_next(ext->text, &byte_id);
            }

            if(lv_label_set_dot_tmp(label, &ext->text[byte_id_ori], len)) {
                for(i = 0; i < LV_LABEL_DOT_NUM; i++) {
                    ext->text[byte_id_ori + i] = '.';
                }
                ext->text[byte_id_ori + LV_LABEL_DOT_NUM] = '\0';
                ext->dot_end                              = letter_id + LV_LABEL_DOT_NUM;
            }
        }
    }
    /*In break mode only the height can change*/
    else if(ext->long_mode == LV_LABEL_LONG_BREAK) {
        lv_obj_set_height(label, size.y);
    }
    /*Do not set the size in Clip mode*/
    else if(ext->long_mode == LV_LABEL_LONG_CROP) {
        /*Do nothing*/
    }

    lv_obj_invalidate(label);
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x58, %rsp
movq %rdi, %rbx
callq 0x6af7
cmpq $0x0, (%rax)
je 0x1af41
movq %rax, %r14
movq %rbx, %rdi
callq 0x566d
movl %eax, %ebp
movq %rbx, %rdi
callq 0x66b6
movq %rax, %r12
movq 0x28(%rax), %r15
movzwl 0x18(%r14), %eax
testb $0x7, %al
movl $0x7c18, %edx           # imm = 0x7C18
cmovnel %ebp, %edx
movl %eax, %ecx
shrb $0x6, %cl
movl %ecx, %esi
andb $0x1, %sil
orb $0x2, %cl
testb %al, %al
movzbl %sil, %eax
movzbl %cl, %edi
cmovnsl %eax, %edi
movq (%r14), %rsi
movswl 0x30(%r12), %ecx
movswl 0x32(%r12), %r8d
movzbl %dil, %eax
movl %eax, (%rsp)
movswl %dx, %r9d
leaq 0x8(%rsp), %rdi
movq %r15, %rdx
callq 0x2acd4
movzwl 0x18(%r14), %eax
andl $0x7, %eax
cmpl $0x4, %eax
ja 0x1af39
leaq 0x24c98(%rip), %rcx     # 0x3f868
movslq (%rcx,%rax,4), %rax
addq %rcx, %rax
jmpq *%rax
movswl 0x8(%rsp), %esi
movswl 0xa(%rsp), %edx
movq %rbx, %rdi
callq 0x5557
jmp 0x1af39
movq %rbx, %rdi
callq 0x1a9c6
movl %eax, %r13d
movq %rbx, 0x20(%rsp)
movb $0x2, 0x50(%rsp)
movq 0x28(%r12), %rdi
movl $0x20, %esi
movl $0x20, %edx
callq 0x28487
movzwl %ax, %eax
movswl 0x30(%r12), %ecx
addl %eax, %ecx
imull $0x3e8, %ecx, %eax      # imm = 0x3E8
movzwl 0x16(%r14), %ecx
cltd
idivl %ecx
leal (%rax,%rax,2), %eax
negl %eax
movw %ax, 0x4a(%rsp)
movq $0x0, 0x38(%rsp)
leaq 0xef3c(%rip), %rax      # 0x29b88
movq %rax, 0x30(%rsp)
movl $0x0, 0x4c(%rsp)
movzwl 0x8(%rsp), %ebp
movq %rbx, %rdi
callq 0x566d
movl %eax, %r12d
cmpw %ax, %bp
movb %r13b, 0x10(%rsp)
jle 0x1adc5
cmpb $0x2, %r13b
jne 0x1ae55
movl $0x0, 0x44(%rsp)
movswl 0x8(%rsp), %r13d
movq %r15, %rdi
movl $0x20, %esi
movl $0x20, %edx
callq 0x28487
movzwl %ax, %eax
leal (%rax,%rax,2), %ecx
addl %r13d, %ecx
negl %ecx
movl %ecx, 0x40(%rsp)
movl 0x44(%rsp), %eax
jmp 0x1ae88
movzwl 0xa(%rsp), %ebp
movq %rbx, %rdi
callq 0x5697
cmpw %ax, %bp
jle 0x1ace0
leaq 0x3897e(%rip), %rax     # 0x53650
movq (%r14), %rdi
callq *(%rax)
cmpl $0x3, %eax
ja 0x1af50
movw $0xffff, 0x10(%r14)     # imm = 0xFFFF
jmp 0x1af39
movq %rbx, 0x20(%rsp)
movb $-0x1, 0x50(%rsp)
movl $0x0, 0x40(%rsp)
movq $0x0, 0x38(%rsp)
leaq 0xee7a(%rip), %rax      # 0x29b88
movq %rax, 0x30(%rsp)
movq 0x28(%r12), %rdi
movl $0x20, %esi
movl $0x20, %edx
callq 0x28487
movzwl %ax, %eax
movswl 0x30(%r12), %ecx
addl %eax, %ecx
imull $0x3e8, %ecx, %eax      # imm = 0x3E8
movzwl 0x16(%r14), %ecx
cltd
idivl %ecx
leal (%rax,%rax,2), %eax
movw %ax, 0x4c(%rsp)
movw %ax, 0x4e(%rsp)
negl %eax
movw %ax, 0x4a(%rsp)
movzwl 0x8(%rsp), %r13d
movq %rbx, %rdi
callq 0x566d
movl %eax, %ebp
cmpw %ax, %r13w
jle 0x1ade0
movq %rbx, %rdi
callq 0x566d
cwtl
movswl 0x8(%rsp), %ecx
subl %ecx, %eax
leaq 0x20(%rsp), %r12
movl %eax, 0x24(%r12)
leaq 0x550(%rip), %rcx       # 0x1b2db
movq %rcx, 0x8(%r12)
movzwl 0x16(%r14), %edi
movswl 0x20(%r12), %esi
movswl %ax, %edx
callq 0x29d0a
movw %ax, 0x28(%r12)
movq %r12, %rdi
callq 0x29bb4
jmp 0x1adf6
movswl 0xa(%rsp), %esi
movq %rbx, %rdi
callq 0x574b
jmp 0x1af39
leaq 0x50f(%rip), %rsi       # 0x1b2db
movq %rbx, %rdi
callq 0x29c44
movw $0x0, 0x12(%r14)
jmp 0x1aeb5
leaq 0x4f4(%rip), %rsi       # 0x1b2db
movq %rbx, %rdi
callq 0x29c44
movw $0x0, 0x12(%r14)
movzwl 0xa(%rsp), %r12d
movq %rbx, %rdi
callq 0x5697
cmpw %bp, %r13w
jg 0x1af23
cmpw %ax, %r12w
jle 0x1af23
movq %rbx, %rdi
callq 0x5697
cwtl
movswl 0xa(%rsp), %ecx
movzbl 0x10(%r15), %edx
addl %ecx, %edx
subl %edx, %eax
leaq 0x20(%rsp), %r15
movl %eax, 0x24(%r15)
leaq 0x4bd(%rip), %rcx       # 0x1b2fc
movq %rcx, 0x8(%r15)
movzwl 0x16(%r14), %edi
movswl 0x20(%r15), %esi
movswl %ax, %edx
jmp 0x1af0f
movl $0x0, 0x40(%rsp)
movswl 0x8(%rsp), %r13d
movq %r15, %rdi
movl $0x20, %esi
movl $0x20, %edx
callq 0x28487
movzwl %ax, %eax
leal (%rax,%rax,2), %eax
addl %r13d, %eax
negl %eax
movl %eax, 0x44(%rsp)
movl 0x40(%rsp), %ecx
leaq 0x44c(%rip), %rdx       # 0x1b2db
leaq 0x20(%rsp), %r13
movq %rdx, 0x8(%r13)
movzwl 0x16(%r14), %edi
movswl %cx, %esi
movswl %ax, %edx
callq 0x29d0a
movw %ax, 0x28(%r13)
movq %r13, %rdi
callq 0x29bb4
movzwl 0xa(%rsp), %r13d
movq %rbx, %rdi
callq 0x5697
cmpw %r12w, %bp
jg 0x1af23
cmpw %ax, %r13w
jle 0x1af23
movswl 0xa(%rsp), %eax
movzbl 0x10(%r15), %ecx
addl %eax, %ecx
negl %ecx
xorl %eax, %eax
cmpb $0x2, 0x10(%rsp)
movl %ecx, %edx
cmovel %eax, %edx
cmovnel %eax, %ecx
leaq 0x20(%rsp), %r15
movl %edx, 0x24(%r15)
movl %ecx, 0x20(%r15)
leaq 0x3fc(%rip), %rax       # 0x1b2fc
movq %rax, 0x8(%r15)
movzwl 0x16(%r14), %edi
movswl %cx, %esi
movswl %dx, %edx
callq 0x29d0a
movw %ax, 0x28(%r15)
movq %r15, %rdi
callq 0x29bb4
jmp 0x1af39
leaq 0x3d2(%rip), %rsi       # 0x1b2fc
movq %rbx, %rdi
callq 0x29c44
movw $0x0, 0x14(%r14)
movq %rbx, %rdi
callq 0x4c4d
addq $0x58, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq %rbx, %rdi
callq 0x566d
movl %eax, %ebp
movq 0x28(%r12), %rdi
movl $0x2e, %esi
movl $0x2e, %edx
callq 0x28487
addw 0x30(%r12), %ax
leal (%rax,%rax,2), %eax
subl %eax, %ebp
leaq 0x20(%rsp), %r15
movw %bp, (%r15)
movq %rbx, %rdi
callq 0x5697
movl %eax, %ecx
cwtl
movq 0x28(%r12), %rdx
movzbl 0x10(%rdx), %esi
movswl 0x32(%r12), %edi
addl %edi, %esi
cltd
idivl %esi
addl %edi, %edx
subl %edx, %ecx
movw %cx, 0x2(%r15)
movq %rbx, %rdi
movq %r15, %rsi
callq 0x1b78e
movl %eax, 0x1c(%rsp)
movzwl %ax, %esi
leaq 0x3867d(%rip), %rax     # 0x53640
movq (%r14), %rdi
callq *(%rax)
leaq 0xc(%rsp), %rcx
movq %rax, 0x10(%rsp)
movl %eax, (%rcx)
movl $0x4, %ebp
xorl %r13d, %r13d
leaq 0x38635(%rip), %r15     # 0x53618
leaq 0x38646(%rip), %r12     # 0x53630
movl 0xc(%rsp), %edi
addq (%r14), %rdi
callq *(%r15)
addb %al, %r13b
movq (%r14), %rdi
leaq 0xc(%rsp), %rsi
callq *(%r12)
decl %ebp
jne 0x1afea
movq 0x10(%rsp), %r15
movl %r15d, %r12d
movq (%r14), %rsi
addq %r12, %rsi
movzbl %r13b, %edx
movq %rbx, %rdi
callq 0x1aaac
testb %al, %al
je 0x1af39
xorl %eax, %eax
movq (%r14), %rcx
leal (%r12,%rax), %edx
movb $0x2e, (%rcx,%rdx)
incq %rax
cmpq $0x3, %rax
jne 0x1b02b
movq (%r14), %rax
addl $0x3, %r15d
movb $0x0, (%rax,%r15)
movl 0x1c(%rsp), %eax
addl $0x3, %eax
movw %ax, 0x10(%r14)
jmp 0x1af39