// File: /workspace/github_c_makefile_star2_O1/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, %ebp
movl %esi, %r14d
movq %rdi, %r15
callq 0x80d4
testb %al, %al
je 0x11ced
movq %r15, %rdi
callq 0x6ad8
movq %rax, %rbx
movq 0x10(%rax), %rdi
callq 0x6697
movzwl 0x26(%rbx), %ecx
movl %ecx, %edx
decl %edx
cmpw %r14w, %cx
cmovbel %edx, %r14d
movq %rax, %r12
movq (%rbx), %rdi
movzwl 0x24(%rbx), %esi
movl $0x80, %edx
callq 0x21efb
movw %r14w, 0x24(%rbx)
movq %r15, %rdi
callq 0x4abc
cmpb $0x1, %al
jne 0x11cbe
notl %r14d
addw 0x26(%rbx), %r14w
movzbl 0x2a(%rbx), %eax
shrl $0x5, %eax
andl $0x3, %eax
movq %r15, %rdi
cmpl $0x2, %eax
jae 0x11cfe
callq 0x5651
addw 0x1e(%r12), %ax
movl %r14d, %r13d
imull %eax, %r13d
addw 0x1a(%r12), %r13w
negl %r13d
jmp 0x11d63
leaq 0x2d440(%rip), %rdi     # 0x3f134
movq %r15, %rsi
callq 0x829e
jmp 0x11cfc
jne 0x11d3d
callq 0x5651
movl %eax, %r13d
movq (%rbx), %rdi
callq 0x5651
addw 0x1e(%r12), %r13w
subl %r13d, %eax
movl %ebp, 0xc(%rsp)
movl %r14d, %ebp
imull %eax, %ebp
subw 0x1a(%r12), %bp
movq (%rbx), %rdi
callq 0x5651
movl %eax, %r13d
addl %ebp, %r13d
movl 0xc(%rsp), %ebp
jmp 0x11d63
callq 0x5651
movl %eax, %r13d
movq (%rbx), %rdi
callq 0x5651
addw 0x1e(%r12), %r13w
subl %r13d, %eax
movl %r14d, %r13d
imull %eax, %r13d
subw 0x1a(%r12), %r13w
testb %bpl, %bpl
je 0x11de2
movq %r15, %rdi
callq 0x11f17
testw %ax, %ax
je 0x11de2
movq 0x10(%rbx), %rdi
leaq 0x10(%rsp), %r12
movq %rdi, (%r12)
callq 0x4bc6
cwtl
movl %eax, 0x20(%r12)
movswl %r13w, %eax
movl %eax, 0x24(%r12)
leaq -0xc8da(%rip), %rax     # 0x54c3
movq %rax, 0x8(%r12)
leaq 0x1774c(%rip), %rax     # 0x294f5
movq %rax, 0x10(%r12)
movq $0x0, 0x18(%r12)
movw $0x0, 0x2a(%r12)
movzwl 0x28(%rbx), %eax
movw %ax, 0x28(%r12)
movl $0x0, 0x2c(%r12)
andb $-0x4, 0x30(%r12)
movq %r12, %rdi
callq 0x29521
jmp 0x11def
movq 0x10(%rbx), %rdi
movswl %r13w, %esi
callq 0x54c3
movq (%rbx), %rdi
callq 0x6697
testb $0x40, 0x2a(%rbx)
movq 0x8(%rbx), %rdi
jne 0x11e1b
movq %rax, %r12
callq 0x5651
addw 0x1e(%r12), %ax
imull %eax, %r14d
addw 0x1a(%r12), %r14w
jmp 0x11e61
callq 0x567b
movq %r15, %rdi
movl $0x2, %esi
callq 0x11f43
movq %rax, %r14
movq (%rbx), %rdi
callq 0x567b
movzwl 0x26(%rbx), %ecx
testl %ecx, %ecx
je 0x11e5e
movzwl 0x18(%r14), %edx
addw 0x16(%r14), %dx
subl %edx, %eax
movswl %ax, %edx
movzwl 0x24(%rbx), %eax
imull %edx, %eax
cltd
idivl %ecx
movl %eax, %r14d
jmp 0x11e61
xorl %r14d, %r14d
testb %bpl, %bpl
je 0x11e8e
cmpw $0x0, 0x28(%rbx)
je 0x11e8e
movq 0x8(%rbx), %rdi
movq %rdi, 0x10(%rsp)
testb $0x40, 0x2a(%rbx)
movswl %r14w, %ebp
jne 0x11eaa
callq 0x4bc6
leaq -0xc9c9(%rip), %rcx     # 0x54c3
jmp 0x11eb6
testb $0x40, 0x2a(%rbx)
movq 0x8(%rbx), %rdi
movswl %r14w, %esi
jne 0x11ea3
callq 0x54c3
jmp 0x11ef7
callq 0x5501
jmp 0x11ef7
callq 0x4bfe
leaq -0xc9b5(%rip), %rcx     # 0x5501
cwtl
leaq 0x10(%rsp), %rdi
movl %eax, 0x20(%rdi)
movl %ebp, 0x24(%rdi)
movq %rcx, 0x8(%rdi)
leaq 0x17628(%rip), %rax     # 0x294f5
movq %rax, 0x10(%rdi)
movq $0x0, 0x18(%rdi)
movw $0x0, 0x2a(%rdi)
movzwl 0x28(%rbx), %eax
movw %ax, 0x28(%rdi)
movl $0x0, 0x2c(%rdi)
andb $-0x4, 0x30(%rdi)
callq 0x29521
movq (%rbx), %rdi
movzwl 0x24(%rbx), %esi
movl $0x80, %edx
callq 0x21e33
addq $0x48, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq