// File: /workspace/github_c_makefile_star2_O3/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 0x80e4
testb %al, %al
je 0x11d1d
movq %r15, %rdi
callq 0x6af7
movq %rax, %rbx
movq 0x10(%rax), %rdi
callq 0x66b6
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 0x226b0
movw %bp, 0x24(%rbx)
movq %r15, %rdi
callq 0x4ab2
cmpb $0x1, %al
jne 0x11cee
notl %ebp
addw 0x26(%rbx), %bp
movzbl 0x2a(%rbx), %eax
shrl $0x5, %eax
andl $0x3, %eax
movq %r15, %rdi
cmpl $0x2, %eax
jae 0x11d2e
callq 0x566d
addw 0x1e(%r12), %ax
movl %ebp, %r13d
imull %eax, %r13d
addw 0x1a(%r12), %r13w
negl %r13d
jmp 0x11d96
leaq 0x2d4c0(%rip), %rdi     # 0x3f1e4
movq %r15, %rsi
callq 0x8294
jmp 0x11d2c
jne 0x11d70
callq 0x566d
movl %eax, %r13d
movq (%rbx), %rdi
callq 0x566d
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 0x566d
movl %eax, %r13d
addl %r14d, %r13d
movl 0xc(%rsp), %r14d
jmp 0x11d96
callq 0x566d
movl %eax, %r13d
movq (%rbx), %rdi
callq 0x566d
addw 0x1e(%r12), %r13w
subl %r13d, %eax
movl %ebp, %r13d
imull %eax, %r13d
subw 0x1a(%r12), %r13w
testb %r14b, %r14b
je 0x11e15
movq %r15, %rdi
callq 0x11f45
testw %ax, %ax
je 0x11e15
movq 0x10(%rbx), %rdi
leaq 0x10(%rsp), %r12
movq %rdi, (%r12)
callq 0x4bdd
cwtl
movl %eax, 0x20(%r12)
movswl %r13w, %eax
movl %eax, 0x24(%r12)
leaq -0xc8f5(%rip), %rax     # 0x54db
movq %rax, 0x8(%r12)
leaq 0x17dac(%rip), %rax     # 0x29b88
movq %rax, 0x10(%r12)
movq $0x0, 0x18(%r12)
movw $0x0, 0x2a(%r12)
movzwl 0x28(%rbx), %eax
movw %ax, 0x28(%r12)
movb $0x0, 0x30(%r12)
movl $0x0, 0x2c(%r12)
movq %r12, %rdi
callq 0x29bb4
jmp 0x11e22
movq 0x10(%rbx), %rdi
movswl %r13w, %esi
callq 0x54db
movq (%rbx), %rdi
callq 0x66b6
testb $0x40, 0x2a(%rbx)
movq 0x8(%rbx), %rdi
jne 0x11e4d
movq %rax, %r12
callq 0x566d
addw 0x1e(%r12), %ax
imull %eax, %ebp
addw 0x1a(%r12), %bp
jmp 0x11e91
callq 0x5697
movq %r15, %rdi
movl $0x2, %esi
callq 0x11f71
movq %rax, %r15
movq (%rbx), %rdi
callq 0x5697
movzwl 0x26(%rbx), %ecx
testl %ecx, %ecx
je 0x11e8f
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 0x11e91
xorl %ebp, %ebp
testb %r14b, %r14b
je 0x11eba
cmpw $0x0, 0x28(%rbx)
je 0x11eba
movq 0x8(%rbx), %rdi
movq %rdi, 0x10(%rsp)
testb $0x40, 0x2a(%rbx)
jne 0x11ed5
callq 0x4bdd
leaq -0xc9dd(%rip), %rcx     # 0x54db
jmp 0x11ee1
testb $0x40, 0x2a(%rbx)
movq 0x8(%rbx), %rdi
movswl %bp, %esi
jne 0x11ece
callq 0x54db
jmp 0x11f25
callq 0x5519
jmp 0x11f25
callq 0x4c15
leaq -0xc9c8(%rip), %rcx     # 0x5519
movswl %bp, %edx
cwtl
leaq 0x10(%rsp), %rdi
movl %eax, 0x20(%rdi)
movl %edx, 0x24(%rdi)
movq %rcx, 0x8(%rdi)
leaq 0x17c8d(%rip), %rax     # 0x29b88
movq %rax, 0x10(%rdi)
movq $0x0, 0x18(%rdi)
movw $0x0, 0x2a(%rdi)
movzwl 0x28(%rbx), %eax
movw %ax, 0x28(%rdi)
movl $0x0, 0x2c(%rdi)
movb $0x0, 0x30(%rdi)
callq 0x29bb4
movq (%rbx), %rdi
movzwl 0x24(%rbx), %esi
movl $0x80, %edx
callq 0x225f2
addq $0x48, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq