// File: /workspace/github_c_makefile_star2_O2/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 0x6747
cmpq $0x0, (%rax)
je 0x192c7
movq %rax, %r14
movq %rbx, %rdi
callq 0x5308
movl %eax, %ebp
movq %rbx, %rdi
callq 0x6316
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 0x28723
movzwl 0x18(%r14), %eax
andl $0x7, %eax
cmpl $0x4, %eax
ja 0x192bf
leaq 0x227d6(%rip), %rcx     # 0x3b75c
movslq (%rcx,%rax,4), %rax
addq %rcx, %rax
jmpq *%rax
movswl 0x8(%rsp), %esi
movswl 0xa(%rsp), %edx
movq %rbx, %rdi
callq 0x520e
jmp 0x192bf
movq %rbx, %rdi
callq 0x18d7f
movl %eax, %r13d
movq %rbx, 0x20(%rsp)
movb $0x2, 0x50(%rsp)
movq 0x28(%r12), %rdi
pushq $0x20
popq %rdx
movl %edx, %esi
callq 0x2603b
movzwl %ax, %eax
movswl 0x30(%r12), %ecx
addl %eax, %ecx
imull $0x3e8, %ecx, %eax      # imm = 0x3E8
movzwl 0x16(%r14), %ecx
cltd
idivl %ecx
imull $-0x3, %eax, %eax
movw %ax, 0x4a(%rsp)
andq $0x0, 0x38(%rsp)
leaq 0xe661(%rip), %rax      # 0x27659
movq %rax, 0x30(%rsp)
andl $0x0, 0x4c(%rsp)
movzwl 0x8(%rsp), %ebp
movq %rbx, %rdi
callq 0x5308
movl %eax, %r12d
cmpw %ax, %bp
movb %r13b, 0x10(%rsp)
jle 0x19158
cmpb $0x2, %r13b
jne 0x191e6
andl $0x0, 0x44(%rsp)
movswl 0x8(%rsp), %r13d
pushq $0x20
popq %rdx
movq %r15, %rdi
movl %edx, %esi
callq 0x2603b
movzwl %ax, %eax
imull $-0x3, %eax, %ecx
subl %r13d, %ecx
movl %ecx, 0x40(%rsp)
movl 0x44(%rsp), %eax
jmp 0x1920f
movzwl 0xa(%rsp), %ebp
movq %rbx, %rdi
callq 0x5332
cmpw %ax, %bp
jle 0x1907f
leaq 0x385df(%rip), %rax     # 0x51650
movq (%r14), %rdi
callq *(%rax)
cmpl $0x3, %eax
ja 0x192d6
orw $-0x1, 0x10(%r14)
jmp 0x192bf
movq %rbx, 0x20(%rsp)
movb $-0x1, 0x50(%rsp)
andl $0x0, 0x40(%rsp)
andq $0x0, 0x38(%rsp)
leaq 0xe5b3(%rip), %rax      # 0x27659
movq %rax, 0x30(%rsp)
movq 0x28(%r12), %rdi
pushq $0x20
popq %rdx
movl %edx, %esi
callq 0x2603b
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 0x5308
movl %eax, %ebp
cmpw %ax, %r13w
jle 0x19172
movq %rbx, %rdi
callq 0x5308
cwtl
movswl 0x8(%rsp), %ecx
subl %ecx, %eax
leaq 0x20(%rsp), %r12
movl %eax, 0x24(%r12)
leaq 0x538(%rip), %rcx       # 0x19656
movq %rcx, 0x8(%r12)
movzwl 0x16(%r14), %edi
movswl 0x20(%r12), %esi
movswl %ax, %edx
callq 0x277c6
movw %ax, 0x28(%r12)
movq %r12, %rdi
callq 0x27685
jmp 0x19187
movswl 0xa(%rsp), %esi
movq %rbx, %rdi
callq 0x53e6
jmp 0x192bf
leaq 0x4f7(%rip), %rsi       # 0x19656
movq %rbx, %rdi
callq 0x27715
andw $0x0, 0x12(%r14)
jmp 0x1923c
leaq 0x4dd(%rip), %rsi       # 0x19656
movq %rbx, %rdi
callq 0x27715
andw $0x0, 0x12(%r14)
movzwl 0xa(%rsp), %r12d
movq %rbx, %rdi
callq 0x5332
cmpw %bp, %r13w
jg 0x192aa
cmpw %ax, %r12w
jle 0x192aa
movq %rbx, %rdi
callq 0x5332
cwtl
movswl 0xa(%rsp), %ecx
movzbl 0x10(%r15), %edx
addl %ecx, %edx
subl %edx, %eax
leaq 0x20(%rsp), %r15
movl %eax, 0x24(%r15)
leaq 0x4a7(%rip), %rcx       # 0x19677
movq %rcx, 0x8(%r15)
movzwl 0x16(%r14), %edi
movswl 0x20(%r15), %esi
movswl %ax, %edx
jmp 0x19296
andl $0x0, 0x40(%rsp)
movswl 0x8(%rsp), %r13d
pushq $0x20
popq %rdx
movq %r15, %rdi
movl %edx, %esi
callq 0x2603b
movzwl %ax, %eax
imull $-0x3, %eax, %eax
subl %r13d, %eax
movl %eax, 0x44(%rsp)
movl 0x40(%rsp), %ecx
leaq 0x440(%rip), %rdx       # 0x19656
leaq 0x20(%rsp), %r13
movq %rdx, 0x8(%r13)
movzwl 0x16(%r14), %edi
movswl %cx, %esi
movswl %ax, %edx
callq 0x277c6
movw %ax, 0x28(%r13)
movq %r13, %rdi
callq 0x27685
movzwl 0xa(%rsp), %r13d
movq %rbx, %rdi
callq 0x5332
cmpw %r12w, %bp
jg 0x192aa
cmpw %ax, %r13w
jle 0x192aa
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 0x3f0(%rip), %rax       # 0x19677
movq %rax, 0x8(%r15)
movzwl 0x16(%r14), %edi
movswl %cx, %esi
movswl %dx, %edx
callq 0x277c6
movw %ax, 0x28(%r15)
movq %r15, %rdi
callq 0x27685
jmp 0x192bf
leaq 0x3c6(%rip), %rsi       # 0x19677
movq %rbx, %rdi
callq 0x27715
andw $0x0, 0x14(%r14)
movq %rbx, %rdi
callq 0x493a
addq $0x58, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq %rbx, %rdi
callq 0x5308
movl %eax, %ebp
movq 0x28(%r12), %rdi
pushq $0x2e
popq %rdx
movl %edx, %esi
callq 0x2603b
addw 0x30(%r12), %ax
imull $-0x3, %eax, %eax
addl %ebp, %eax
leaq 0x20(%rsp), %r15
movw %ax, (%r15)
movq %rbx, %rdi
callq 0x5332
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 0x19a81
movl %eax, 0x1c(%rsp)
movzwl %ax, %esi
leaq 0x382fc(%rip), %rax     # 0x51640
movq (%r14), %rdi
callq *(%rax)
leaq 0xc(%rsp), %rcx
movq %rax, 0x10(%rsp)
movl %eax, (%rcx)
pushq $0x4
popq %rbp
xorl %r13d, %r13d
leaq 0x382b6(%rip), %r15     # 0x51618
leaq 0x382c7(%rip), %r12     # 0x51630
subl $0x1, %ebp
jb 0x19389
movl 0xc(%rsp), %edi
addq (%r14), %rdi
callq *(%r15)
addb %al, %r13b
movq (%r14), %rdi
leaq 0xc(%rsp), %rsi
callq *(%r12)
jmp 0x19369
movq 0x10(%rsp), %r15
movl %r15d, %r12d
movq (%r14), %rsi
addq %r12, %rsi
movzbl %r13b, %edx
movq %rbx, %rdi
callq 0x18e62
testb %al, %al
je 0x192bf
xorl %eax, %eax
movq (%r14), %rcx
cmpq $0x3, %rax
je 0x193c3
leal (%r12,%rax), %edx
movb $0x2e, (%rcx,%rdx)
incq %rax
jmp 0x193ad
addl $0x3, %r15d
movb $0x0, (%rcx,%r15)
movl 0x1c(%rsp), %eax
addl $0x3, %eax
movw %ax, 0x10(%r14)
jmp 0x192bf