// File: /workspace/github_c_makefile_star2_O3/OnionIoT[P]lv_example/lvgl/src/lv_objx/lv_tabview.c
// Function: tabview_realign
static void tabview_realign(lv_obj_t * tabview)
{
    lv_tabview_ext_t * ext = lv_obj_get_ext_attr(tabview);

    lv_obj_set_width(ext->btns, lv_obj_get_width(tabview));

    if(ext->btns_hide) {
        lv_obj_set_hidden(ext->btns, true);
        lv_obj_set_hidden(ext->indic, true);
        lv_obj_set_height(ext->content, lv_obj_get_height(tabview));
        lv_obj_align(ext->content, NULL, LV_ALIGN_IN_TOP_LEFT, 0, 0);
    } else if(ext->tab_cnt != 0) {
        lv_obj_set_hidden(ext->btns, false);
        lv_obj_set_hidden(ext->indic, false);

        const lv_style_t * style_btn_bg  = lv_tabview_get_style(tabview, LV_TABVIEW_STYLE_BTN_BG);
        const lv_style_t * style_btn_rel = lv_tabview_get_style(tabview, LV_TABVIEW_STYLE_BTN_REL);

        /*Set the indicator width/height*/
        lv_coord_t indic_size;
        lv_coord_t max_h;

        switch(ext->btns_pos) {
            case LV_TABVIEW_BTNS_POS_TOP:
            case LV_TABVIEW_BTNS_POS_BOTTOM:
                indic_size = (lv_obj_get_width(tabview) - style_btn_bg->body.padding.inner * (ext->tab_cnt - 1) -
                              style_btn_bg->body.padding.left - style_btn_bg->body.padding.right) /
                             ext->tab_cnt;
                lv_obj_set_width(ext->indic, indic_size);
                break;
            case LV_TABVIEW_BTNS_POS_LEFT:
            case LV_TABVIEW_BTNS_POS_RIGHT:
                lv_obj_set_height(ext->btns, lv_obj_get_height(tabview));

                max_h =
                    lv_obj_get_height(ext->btns) - style_btn_bg->body.padding.top - style_btn_bg->body.padding.bottom;
                indic_size = max_h - ((ext->tab_cnt - 1) * style_btn_bg->body.padding.inner);
                indic_size = indic_size / ext->tab_cnt;
                indic_size--; /*-1 because e.g. height = 100 means 101 pixels (0..100)*/
                lv_obj_set_height(ext->indic, indic_size);
                break;
        }

        /*Set the tabs height/width*/
        lv_coord_t btns_size;

        switch(ext->btns_pos) {
            case LV_TABVIEW_BTNS_POS_TOP:
            case LV_TABVIEW_BTNS_POS_BOTTOM:
                btns_size = lv_font_get_line_height(style_btn_rel->text.font) + style_btn_rel->body.padding.top +
                            style_btn_rel->body.padding.bottom + style_btn_bg->body.padding.top +
                            style_btn_bg->body.padding.bottom;
                lv_obj_set_height(ext->btns, btns_size);
                break;
            case LV_TABVIEW_BTNS_POS_LEFT:
            case LV_TABVIEW_BTNS_POS_RIGHT:
                btns_size = lv_font_get_glyph_width(style_btn_rel->text.font, 'A', '\0') +
                            style_btn_rel->body.padding.left + style_btn_rel->body.padding.right +
                            style_btn_bg->body.padding.left + style_btn_bg->body.padding.right;
                lv_obj_set_width(ext->btns, btns_size);
                break;
        }

        switch(ext->btns_pos) {
            case LV_TABVIEW_BTNS_POS_TOP:
            case LV_TABVIEW_BTNS_POS_BOTTOM:
                lv_obj_set_height(ext->content, lv_obj_get_height(tabview) - lv_obj_get_height(ext->btns));
                break;
            case LV_TABVIEW_BTNS_POS_LEFT:
            case LV_TABVIEW_BTNS_POS_RIGHT: lv_obj_set_height(ext->content, lv_obj_get_height(tabview)); break;
        }

        switch(ext->btns_pos) {
            case LV_TABVIEW_BTNS_POS_TOP:
                lv_obj_align(ext->btns, NULL, LV_ALIGN_IN_TOP_LEFT, 0, 0);
                lv_obj_align(ext->content, ext->btns, LV_ALIGN_OUT_BOTTOM_LEFT, 0, 0);
                lv_obj_align(ext->indic, ext->btns, LV_ALIGN_IN_BOTTOM_LEFT, 0, 0);

                lv_cont_set_fit2(ext->content, LV_FIT_TIGHT, LV_FIT_NONE);
                lv_cont_set_layout(ext->content, LV_LAYOUT_ROW_T);
                lv_obj_set_height(ext->content, lv_obj_get_height(tabview) - lv_obj_get_height(ext->btns));
                break;
            case LV_TABVIEW_BTNS_POS_BOTTOM:
                lv_obj_align(ext->content, NULL, LV_ALIGN_IN_TOP_LEFT, 0, 0);
                lv_obj_align(ext->btns, ext->content, LV_ALIGN_OUT_BOTTOM_LEFT, 0, 0);
                lv_obj_align(ext->indic, ext->btns, LV_ALIGN_IN_TOP_LEFT, 0, 0);

                lv_cont_set_fit2(ext->content, LV_FIT_TIGHT, LV_FIT_NONE);
                lv_cont_set_layout(ext->content, LV_LAYOUT_ROW_T);
                lv_obj_set_height(ext->content, lv_obj_get_height(tabview) - lv_obj_get_height(ext->btns));
                break;
            case LV_TABVIEW_BTNS_POS_LEFT:
                lv_obj_align(ext->btns, NULL, LV_ALIGN_IN_TOP_LEFT, 0, 0);
                lv_obj_align(ext->content, tabview, LV_ALIGN_IN_TOP_LEFT, lv_obj_get_width(ext->btns), 0);
                lv_obj_align(ext->indic, ext->btns, LV_ALIGN_IN_TOP_RIGHT, 0, 0);

                lv_cont_set_fit2(ext->content, LV_FIT_TIGHT, LV_FIT_NONE);
                lv_cont_set_layout(ext->content, LV_LAYOUT_ROW_T);
                lv_obj_set_width(ext->content, lv_obj_get_width(tabview) - lv_obj_get_width(ext->btns));

                lv_obj_set_height(ext->btns, lv_obj_get_height(tabview));
                lv_obj_set_width(ext->indic, style_btn_bg->body.padding.inner);
                break;
            case LV_TABVIEW_BTNS_POS_RIGHT:
                lv_obj_align(ext->btns, NULL, LV_ALIGN_IN_TOP_RIGHT, 0, 0);
                lv_obj_align(ext->content, tabview, LV_ALIGN_IN_TOP_LEFT, 0, 0);
                lv_obj_align(ext->indic, ext->btns, LV_ALIGN_IN_TOP_LEFT, 0, 0);

                lv_cont_set_fit2(ext->content, LV_FIT_TIGHT, LV_FIT_NONE);
                lv_cont_set_layout(ext->content, LV_LAYOUT_ROW_T);
                lv_obj_set_width(ext->content, lv_obj_get_width(tabview) - lv_obj_get_width(ext->btns));

                lv_obj_set_height(ext->btns, lv_obj_get_height(tabview));
                lv_obj_set_width(ext->indic, style_btn_bg->body.padding.inner);
                break;
        }
    }

    lv_obj_t * pages = lv_obj_get_child(ext->content, NULL);
    while(pages != NULL) {
        if(lv_obj_get_signal_cb(pages) == tabpage_signal) { /*Be sure adjust only the pages (user can other things)*/
            switch(ext->btns_pos) {
                case LV_TABVIEW_BTNS_POS_TOP:
                case LV_TABVIEW_BTNS_POS_BOTTOM:
                    lv_obj_set_size(pages, lv_obj_get_width(tabview), lv_obj_get_height(ext->content));
                    break;
                case LV_TABVIEW_BTNS_POS_LEFT:
                case LV_TABVIEW_BTNS_POS_RIGHT:
                    lv_obj_set_size(pages, lv_obj_get_width(tabview) - lv_obj_get_width(ext->btns),
                                    lv_obj_get_height(ext->content));
                    break;
            }
        }
        pages = lv_obj_get_child(ext->content, pages);
    }

    if(!ext->btns_hide) {
        switch(ext->btns_pos) {
            case LV_TABVIEW_BTNS_POS_TOP: lv_obj_align(ext->indic, ext->btns, LV_ALIGN_IN_BOTTOM_LEFT, 0, 0); break;
            case LV_TABVIEW_BTNS_POS_BOTTOM: lv_obj_align(ext->indic, ext->btns, LV_ALIGN_IN_TOP_LEFT, 0, 0); break;
            case LV_TABVIEW_BTNS_POS_LEFT: lv_obj_align(ext->indic, ext->btns, LV_ALIGN_IN_TOP_RIGHT, 0, 0); break;
            case LV_TABVIEW_BTNS_POS_RIGHT: lv_obj_align(ext->indic, ext->btns, LV_ALIGN_IN_TOP_LEFT, 0, 0); break;
        }
    }

    lv_tabview_set_tab_act(tabview, ext->tab_cur, LV_ANIM_OFF);
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
pushq %rax
movq %rdi, %rbx
callq 0x6af7
movq %rax, %r14
movq (%rax), %r15
movq %rbx, %rdi
callq 0x566d
movswl %ax, %esi
movq %r15, %rdi
callq 0x570d
testb $0x10, 0x2a(%r14)
jne 0x118cc
cmpw $0x0, 0x26(%r14)
je 0x11bcb
movq (%r14), %rdi
xorl %esi, %esi
callq 0x5f84
movq 0x8(%r14), %rdi
xorl %esi, %esi
callq 0x5f84
movq %rbx, %rdi
movl $0x2, %esi
callq 0x11f71
movq %rax, %r15
movq %rbx, %rdi
movl $0x3, %esi
callq 0x11f71
movq %rax, %r12
testb $0x40, 0x2a(%r14)
jne 0x11918
movq %rbx, %rdi
callq 0x566d
cwtl
movswl 0x1e(%r15), %ecx
movzwl 0x26(%r14), %esi
movl $0x1, %edx
subl %esi, %edx
imull %ecx, %edx
movswl 0x1a(%r15), %ecx
movswl 0x1c(%r15), %edi
addl %ecx, %edi
subl %edi, %eax
addl %edx, %eax
cltd
idivl %esi
movq 0x8(%r14), %rdi
movswl %ax, %esi
callq 0x570d
jmp 0x11968
movq (%r14), %rdi
movl $0x1, %esi
callq 0x5f84
movq 0x8(%r14), %rdi
movl $0x1, %esi
callq 0x5f84
movq 0x10(%r14), %r15
movq %rbx, %rdi
callq 0x5697
movswl %ax, %esi
movq %r15, %rdi
callq 0x574b
movq 0x10(%r14), %rdi
xorl %esi, %esi
movl $0x1, %edx
xorl %ecx, %ecx
xorl %r8d, %r8d
callq 0x5789
jmp 0x11bcb
movq (%r14), %r13
movq %rbx, %rdi
callq 0x5697
movswl %ax, %esi
movq %r13, %rdi
callq 0x574b
movq (%r14), %rdi
callq 0x5697
movzwl 0x16(%r15), %ecx
movzwl 0x26(%r14), %esi
movl $0x1, %edx
subl %esi, %edx
imulw 0x1e(%r15), %dx
addw 0x18(%r15), %cx
subl %ecx, %eax
addl %edx, %eax
cwtl
cltd
idivl %esi
decl %eax
movq 0x8(%r14), %rdi
movswl %ax, %esi
callq 0x574b
testb $0x40, 0x2a(%r14)
movq 0x28(%r12), %rdi
jne 0x1199b
movzbl 0x10(%rdi), %eax
addw 0x16(%r12), %ax
addw 0x18(%r12), %ax
addw 0x16(%r15), %ax
addw 0x18(%r15), %ax
movq (%r14), %rdi
movswl %ax, %esi
callq 0x574b
jmp 0x119c8
movl $0x41, %esi
xorl %edx, %edx
callq 0x28487
addw 0x1a(%r12), %ax
addw 0x1c(%r12), %ax
addw 0x1a(%r15), %ax
addw 0x1c(%r15), %ax
movq (%r14), %rdi
movswl %ax, %esi
callq 0x570d
movb 0x2a(%r14), %r13b
movq 0x10(%r14), %r12
movq %rbx, %rdi
callq 0x5697
movl %eax, %ebp
testb $0x40, %r13b
jne 0x119ea
movq (%r14), %rdi
callq 0x5697
subl %eax, %ebp
movswl %bp, %esi
movq %r12, %rdi
callq 0x574b
movzbl 0x2a(%r14), %eax
shrl $0x5, %eax
andl $0x3, %eax
leaq 0x2dc89(%rip), %rcx     # 0x3f690
movslq (%rcx,%rax,4), %rax
addq %rcx, %rax
jmpq *%rax
movq (%r14), %rdi
xorl %esi, %esi
movl $0x1, %edx
xorl %ecx, %ecx
xorl %r8d, %r8d
callq 0x5789
movq (%r14), %rsi
movq 0x10(%r14), %rdi
movl $0xc, %edx
xorl %ecx, %ecx
xorl %r8d, %r8d
callq 0x5789
movq (%r14), %rsi
movq 0x8(%r14), %rdi
movl $0x4, %edx
jmp 0x11b78
movq (%r14), %rdi
xorl %esi, %esi
movl $0x1, %edx
xorl %ecx, %ecx
xorl %r8d, %r8d
callq 0x5789
movq (%r14), %rdi
movq 0x10(%r14), %r12
callq 0x566d
movswl %ax, %ecx
movq %r12, %rdi
movq %rbx, %rsi
movl $0x1, %edx
xorl %r8d, %r8d
callq 0x5789
movq (%r14), %rsi
movq 0x8(%r14), %rdi
movl $0x3, %edx
jmp 0x11ac5
movq (%r14), %rdi
xorl %esi, %esi
movl $0x3, %edx
xorl %ecx, %ecx
xorl %r8d, %r8d
callq 0x5789
movq 0x10(%r14), %rdi
movq %rbx, %rsi
movl $0x1, %edx
xorl %ecx, %ecx
xorl %r8d, %r8d
callq 0x5789
movq (%r14), %rsi
movq 0x8(%r14), %rdi
movl $0x1, %edx
xorl %ecx, %ecx
xorl %r8d, %r8d
callq 0x5789
movq 0x10(%r14), %rdi
movl $0x1, %esi
movl $0x1, %edx
xorl %ecx, %ecx
xorl %r8d, %r8d
callq 0x22d84
movq 0x10(%r14), %rdi
movl $0x5, %esi
callq 0x22d1c
movq 0x10(%r14), %r12
movq %rbx, %rdi
callq 0x566d
movl %eax, %ebp
movq (%r14), %rdi
callq 0x566d
subl %eax, %ebp
movswl %bp, %esi
movq %r12, %rdi
callq 0x570d
movq (%r14), %r12
movq %rbx, %rdi
callq 0x5697
movswl %ax, %esi
movq %r12, %rdi
callq 0x574b
movq 0x8(%r14), %rdi
movswl 0x1e(%r15), %esi
callq 0x570d
jmp 0x11bcb
movq 0x10(%r14), %rdi
xorl %esi, %esi
movl $0x1, %edx
xorl %ecx, %ecx
xorl %r8d, %r8d
callq 0x5789
movq (%r14), %rdi
movq 0x10(%r14), %rsi
movl $0xc, %edx
xorl %ecx, %ecx
xorl %r8d, %r8d
callq 0x5789
movq (%r14), %rsi
movq 0x8(%r14), %rdi
movl $0x1, %edx
xorl %ecx, %ecx
xorl %r8d, %r8d
callq 0x5789
movq 0x10(%r14), %rdi
movl $0x1, %esi
movl $0x1, %edx
xorl %ecx, %ecx
xorl %r8d, %r8d
callq 0x22d84
movq 0x10(%r14), %rdi
movl $0x5, %esi
callq 0x22d1c
movq 0x10(%r14), %r15
movq %rbx, %rdi
callq 0x5697
movl %eax, %ebp
movq (%r14), %rdi
callq 0x5697
subl %eax, %ebp
movswl %bp, %esi
movq %r15, %rdi
callq 0x574b
movq 0x10(%r14), %rdi
xorl %esi, %esi
callq 0x51a7
testq %rax, %rax
je 0x11c3b
movq %rax, %r15
leaq -0x564(%rip), %r12      # 0x11681
movq %r15, %rdi
callq 0x6a8b
cmpq %r12, %rax
jne 0x11c27
movb 0x2a(%r14), %r13b
movq %rbx, %rdi
callq 0x566d
movl %eax, %ebp
testb $0x40, %r13b
je 0x11c10
movq (%r14), %rdi
callq 0x566d
subl %eax, %ebp
movq 0x10(%r14), %rdi
callq 0x5697
movswl %bp, %esi
movswl %ax, %edx
movq %r15, %rdi
callq 0x5557
movq 0x10(%r14), %rdi
movq %r15, %rsi
callq 0x51a7
movq %rax, %r15
testq %rax, %rax
jne 0x11be5
movzbl 0x2a(%r14), %ecx
testb $0x10, %cl
jne 0x11c66
shrb $0x2, %cl
andb $0x18, %cl
movl $0x1030104, %eax        # imm = 0x1030104
shrl %cl, %eax
movq (%r14), %rsi
movq 0x8(%r14), %rdi
movzbl %al, %edx
xorl %ecx, %ecx
xorl %r8d, %r8d
callq 0x5789
movzwl 0x24(%r14), %esi
movq %rbx, %rdi
xorl %edx, %edx
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
jmp 0x11c83