// File: /workspace/github_c_makefile_star2_O2/OnionIoT[P]lv_example/lvgl/src/lv_objx/lv_tabview.c
// Function: lv_tabview_set_tab_act
void lv_tabview_set_tab_act(lv_obj_t * tabview, uint16_t id, lv_anim_enable_t anim)
{
    LV_ASSERT_OBJ(tabview, LV_OBJX_NAME);

#if LV_USE_ANIMATION == 0
    anim = LV_ANIM_OFF;
#endif
    lv_tabview_ext_t * ext = lv_obj_get_ext_attr(tabview);

    const lv_style_t * style = lv_obj_get_style(ext->content);

    if(id >= ext->tab_cnt) id = ext->tab_cnt - 1;

    lv_btnm_clear_btn_ctrl(ext->btns, ext->tab_cur, LV_BTNM_CTRL_TGL_STATE);

    ext->tab_cur = id;

    if(lv_obj_get_base_dir(tabview) == LV_BIDI_DIR_RTL) {
        id = (ext->tab_cnt - (id + 1));
    }

    lv_coord_t cont_x;

    switch(ext->btns_pos) {
        case LV_TABVIEW_BTNS_POS_TOP:
        case LV_TABVIEW_BTNS_POS_BOTTOM:
            cont_x = -(lv_obj_get_width(tabview) * id + style->body.padding.inner * id + style->body.padding.left);
            break;
        case LV_TABVIEW_BTNS_POS_LEFT:
            cont_x = -((lv_obj_get_width(tabview) - lv_obj_get_width(ext->btns)) * id + style->body.padding.inner * id +
                       style->body.padding.left) +
                     lv_obj_get_width(ext->btns);
            break;
        case LV_TABVIEW_BTNS_POS_RIGHT:
            cont_x = -((lv_obj_get_width(tabview) - lv_obj_get_width(ext->btns)) * id + style->body.padding.inner * id +
                       style->body.padding.left);
            break;
    }

    if(anim == LV_ANIM_OFF || lv_tabview_get_anim_time(tabview) == 0) {
        lv_obj_set_x(ext->content, cont_x);
    }
#if LV_USE_ANIMATION
    else {
        lv_anim_t a;
        a.var            = ext->content;
        a.start          = lv_obj_get_x(ext->content);
        a.end            = cont_x;
        a.exec_cb        = (lv_anim_exec_xcb_t)lv_obj_set_x;
        a.path_cb        = lv_anim_path_linear;
        a.ready_cb       = NULL;
        a.act_time       = 0;
        a.time           = ext->anim_time;
        a.playback       = 0;
        a.playback_pause = 0;
        a.repeat         = 0;
        a.repeat_pause   = 0;
        lv_anim_create(&a);
    }
#endif

    /*Move the indicator*/
    const lv_style_t * tabs_style = lv_obj_get_style(ext->btns);
    lv_coord_t indic_size;
    lv_coord_t indic_pos;

    switch(ext->btns_pos) {
        case LV_TABVIEW_BTNS_POS_TOP:
        case LV_TABVIEW_BTNS_POS_BOTTOM:
            indic_size = lv_obj_get_width(ext->indic);
            indic_pos  = indic_size * id + tabs_style->body.padding.inner * id + tabs_style->body.padding.left;
            break;
        case LV_TABVIEW_BTNS_POS_LEFT:
        case LV_TABVIEW_BTNS_POS_RIGHT:
            indic_size = lv_obj_get_height(ext->indic);
            const lv_style_t * style_tabs = lv_tabview_get_style(tabview, LV_TABVIEW_STYLE_BTN_BG);
            lv_coord_t max_h = lv_obj_get_height(ext->btns) - style_tabs->body.padding.top - style_tabs->body.padding.bottom;

            if(ext->tab_cnt) indic_pos = (max_h * ext->tab_cur) / ext->tab_cnt;
            else  indic_pos = 0;
            break;
    }

#if LV_USE_ANIMATION
    if(anim == LV_ANIM_OFF || ext->anim_time == 0)
#endif
    {
        switch(ext->btns_pos) {
            case LV_TABVIEW_BTNS_POS_TOP:
            case LV_TABVIEW_BTNS_POS_BOTTOM: lv_obj_set_x(ext->indic, indic_pos); break;
            case LV_TABVIEW_BTNS_POS_LEFT:
            case LV_TABVIEW_BTNS_POS_RIGHT: lv_obj_set_y(ext->indic, indic_pos); break;
        }
    }
#if LV_USE_ANIMATION
    else {
        lv_anim_t a;
        a.var = ext->indic;

        switch(ext->btns_pos) {
            case LV_TABVIEW_BTNS_POS_TOP:
            case LV_TABVIEW_BTNS_POS_BOTTOM:
                a.start   = lv_obj_get_x(ext->indic);
                a.end     = indic_pos;
                a.exec_cb = (lv_anim_exec_xcb_t)lv_obj_set_x;
                break;
            case LV_TABVIEW_BTNS_POS_LEFT:
            case LV_TABVIEW_BTNS_POS_RIGHT:
                a.start   = lv_obj_get_y(ext->indic);
                a.end     = indic_pos;
                a.exec_cb = (lv_anim_exec_xcb_t)lv_obj_set_y;
                break;
        }

        a.path_cb        = lv_anim_path_linear;
        a.ready_cb       = NULL;
        a.act_time       = 0;
        a.time           = ext->anim_time;
        a.playback       = 0;
        a.playback_pause = 0;
        a.repeat         = 0;
        a.repeat_pause   = 0;
        lv_anim_create(&a);
    }
#endif

    lv_btnm_set_btn_ctrl(ext->btns, ext->tab_cur, LV_BTNM_CTRL_TGL_STATE);
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x48, %rsp
movl %edx, %r14d
movl %esi, %ebp
movq %rdi, %r15
callq 0x7994
testb %al, %al
je 0x10fac
movq %r15, %rdi
callq 0x6747
movq %rax, %rbx
movq 0x10(%rax), %rdi
callq 0x6316
movzwl 0x26(%rbx), %ecx
movl %ecx, %edx
decl %edx
cmpw %bp, %cx
cmovbel %edx, %ebp
movq %rax, %r12
movq (%rbx), %rdi
movzwl 0x24(%rbx), %esi
movl $0x80, %edx
callq 0x2058a
movw %bp, 0x24(%rbx)
movq %r15, %rdi
callq 0x47b9
cmpb $0x1, %al
jne 0x10f7d
notl %ebp
addw 0x26(%rbx), %bp
movzbl 0x2a(%rbx), %eax
shrl $0x5, %eax
andl $0x3, %eax
movq %r15, %rdi
cmpl $0x2, %eax
jae 0x10fbd
callq 0x5308
addw 0x1e(%r12), %ax
movl %ebp, %r13d
imull %eax, %r13d
addw 0x1a(%r12), %r13w
negl %r13d
jmp 0x11025
leaq 0x2a191(%rip), %rdi     # 0x3b144
movq %r15, %rsi
callq 0x7b01
jmp 0x10fbb
jne 0x10fff
callq 0x5308
movl %eax, %r13d
movq (%rbx), %rdi
callq 0x5308
addw 0x1e(%r12), %r13w
subl %r13d, %eax
movl %r14d, 0xc(%rsp)
movl %ebp, %r14d
imull %eax, %r14d
subw 0x1a(%r12), %r14w
movq (%rbx), %rdi
callq 0x5308
movl %eax, %r13d
addl %r14d, %r13d
movl 0xc(%rsp), %r14d
jmp 0x11025
callq 0x5308
movl %eax, %r13d
movq (%rbx), %rdi
callq 0x5308
addw 0x1e(%r12), %r13w
subl %r13d, %eax
movl %ebp, %r13d
imull %eax, %r13d
subw 0x1a(%r12), %r13w
testb %r14b, %r14b
je 0x1109d
movq %r15, %rdi
callq 0x111c4
testw %ax, %ax
je 0x1109d
movq 0x10(%rbx), %rdi
leaq 0x10(%rsp), %r12
movq %rdi, (%r12)
callq 0x48ca
cwtl
movl %eax, 0x20(%r12)
movswl %r13w, %eax
movl %eax, 0x24(%r12)
leaq -0xbecd(%rip), %rax     # 0x5192
movq %rax, 0x8(%r12)
leaq 0x165ee(%rip), %rax     # 0x27659
movq %rax, 0x10(%r12)
andq $0x0, 0x18(%r12)
andw $0x0, 0x2a(%r12)
movzwl 0x28(%rbx), %eax
movw %ax, 0x28(%r12)
movb $0x0, 0x30(%r12)
andl $0x0, 0x2c(%r12)
movq %r12, %rdi
callq 0x27685
jmp 0x110aa
movq 0x10(%rbx), %rdi
movswl %r13w, %esi
callq 0x5192
movq (%rbx), %rdi
callq 0x6316
testb $0x40, 0x2a(%rbx)
movq 0x8(%rbx), %rdi
jne 0x110d5
movq %rax, %r12
callq 0x5308
addw 0x1e(%r12), %ax
imull %eax, %ebp
addw 0x1a(%r12), %bp
jmp 0x11117
callq 0x5332
pushq $0x2
popq %rsi
movq %r15, %rdi
callq 0x111f0
movq %rax, %r15
movq (%rbx), %rdi
callq 0x5332
movzwl 0x26(%rbx), %ecx
testl %ecx, %ecx
je 0x11115
movzwl 0x18(%r15), %edx
addw 0x16(%r15), %dx
subl %edx, %eax
movswl %ax, %edx
movzwl 0x24(%rbx), %eax
imull %edx, %eax
cltd
idivl %ecx
movl %eax, %ebp
jmp 0x11117
xorl %ebp, %ebp
testb %r14b, %r14b
je 0x11140
cmpw $0x0, 0x28(%rbx)
je 0x11140
movq 0x8(%rbx), %rdi
movq %rdi, 0x10(%rsp)
testb $0x40, 0x2a(%rbx)
jne 0x1115b
callq 0x48ca
leaq -0xbfac(%rip), %rcx     # 0x5192
jmp 0x11167
testb $0x40, 0x2a(%rbx)
movq 0x8(%rbx), %rdi
movswl %bp, %esi
jne 0x11154
callq 0x5192
jmp 0x111a4
callq 0x51d0
jmp 0x111a4
callq 0x4902
leaq -0xbf97(%rip), %rcx     # 0x51d0
movswl %bp, %edx
cwtl
leaq 0x10(%rsp), %rdi
movl %eax, 0x20(%rdi)
movl %edx, 0x24(%rdi)
movq %rcx, 0x8(%rdi)
leaq 0x164d8(%rip), %rax     # 0x27659
movq %rax, 0x10(%rdi)
andq $0x0, 0x18(%rdi)
andw $0x0, 0x2a(%rdi)
movzwl 0x28(%rbx), %eax
movw %ax, 0x28(%rdi)
andl $0x0, 0x2c(%rdi)
movb $0x0, 0x30(%rdi)
callq 0x27685
movq (%rbx), %rdi
movzwl 0x24(%rbx), %esi
movl $0x80, %edx
callq 0x204cc
addq $0x48, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq