// File: /workspace/github_c_makefile_star2_O3/OnionIoT[P]lv_example/lvgl/src/lv_objx/lv_tabview.c
// Function: lv_tabview_create
lv_obj_t * lv_tabview_create(lv_obj_t * par, const lv_obj_t * copy)
{
    LV_LOG_TRACE("tab view create started");

    /*Create the ancestor of tab*/
    lv_obj_t * new_tabview = lv_obj_create(par, copy);
    LV_ASSERT_MEM(new_tabview);
    if(new_tabview == NULL) return NULL;
    if(ancestor_signal == NULL) ancestor_signal = lv_obj_get_signal_cb(new_tabview);

    /*Allocate the tab type specific extended data*/
    lv_tabview_ext_t * ext = lv_obj_allocate_ext_attr(new_tabview, sizeof(lv_tabview_ext_t));
    LV_ASSERT_MEM(ext);
    if(ext == NULL) return NULL;

    /*Initialize the allocated 'ext' */
    ext->drag_hor     = 0;
    ext->draging      = 0;
    ext->scroll_ver   = 0;
    ext->slide_enable = 1;
    ext->tab_cur      = 0;
    ext->point_last.x = 0;
    ext->point_last.y = 0;
    ext->content      = NULL;
    ext->indic        = NULL;
    ext->btns         = NULL;
    ext->btns_pos     = LV_TABVIEW_BTNS_POS_TOP;
#if LV_USE_ANIMATION
    ext->anim_time = LV_TABVIEW_DEF_ANIM_TIME;
#endif
    ext->btns_hide = 0;

    /*The signal and design functions are not copied so set them here*/
    lv_obj_set_signal_cb(new_tabview, lv_tabview_signal);

    /*Init the new tab tab*/
    if(copy == NULL) {
        ext->tab_name_ptr = lv_mem_alloc(sizeof(char *));
        LV_ASSERT_MEM(ext->tab_name_ptr);
        if(ext->tab_name_ptr == NULL) return NULL;
        ext->tab_name_ptr[0] = "";
        ext->tab_cnt         = 0;

        /* Set a size which fits into the parent.
         * Don't use `par` directly because if the tabview is created on a page it is moved to the
         * scrollable so the parent has changed */
        lv_obj_set_size(new_tabview, lv_obj_get_width_fit(lv_obj_get_parent(new_tabview)),
                        lv_obj_get_height_fit(lv_obj_get_parent(new_tabview)));

        ext->content = lv_cont_create(new_tabview, NULL);
        ext->btns    = lv_btnm_create(new_tabview, NULL);
        ext->indic   = lv_obj_create(ext->btns, NULL);

        lv_obj_set_height(ext->btns, 3 * LV_DPI / 4);
        lv_btnm_set_map(ext->btns, tab_def);
        lv_obj_set_event_cb(ext->btns, tab_btnm_event_cb);

        lv_obj_set_width(ext->indic, LV_DPI);
        lv_obj_align(ext->indic, ext->btns, LV_ALIGN_IN_BOTTOM_LEFT, 0, 0);
        lv_obj_set_click(ext->indic, false);

        lv_cont_set_fit2(ext->content, LV_FIT_TIGHT, LV_FIT_NONE);
        lv_cont_set_layout(ext->content, LV_LAYOUT_ROW_T);
        lv_cont_set_style(ext->content, LV_CONT_STYLE_MAIN, &lv_style_transp_tight);
        lv_obj_set_height(ext->content, lv_obj_get_height(new_tabview) - lv_obj_get_height(ext->btns));
        lv_obj_align(ext->content, ext->btns, LV_ALIGN_OUT_BOTTOM_LEFT, 0, 0);

        /*Set the default styles*/
        lv_theme_t * th = lv_theme_get_current();
        if(th) {
            lv_tabview_set_style(new_tabview, LV_TABVIEW_STYLE_BG, th->style.tabview.bg);
            lv_tabview_set_style(new_tabview, LV_TABVIEW_STYLE_INDIC, th->style.tabview.indic);
            lv_tabview_set_style(new_tabview, LV_TABVIEW_STYLE_BTN_BG, th->style.tabview.btn.bg);
            lv_tabview_set_style(new_tabview, LV_TABVIEW_STYLE_BTN_REL, th->style.tabview.btn.rel);
            lv_tabview_set_style(new_tabview, LV_TABVIEW_STYLE_BTN_PR, th->style.tabview.btn.pr);
            lv_tabview_set_style(new_tabview, LV_TABVIEW_STYLE_BTN_TGL_REL, th->style.tabview.btn.tgl_rel);
            lv_tabview_set_style(new_tabview, LV_TABVIEW_STYLE_BTN_TGL_PR, th->style.tabview.btn.tgl_pr);
        } else {
            lv_tabview_set_style(new_tabview, LV_TABVIEW_STYLE_BG, &lv_style_plain);
            lv_tabview_set_style(new_tabview, LV_TABVIEW_STYLE_BTN_BG, &lv_style_pretty);//transp);
            lv_tabview_set_style(new_tabview, LV_TABVIEW_STYLE_INDIC, &lv_style_plain_color);
        }
    }
    /*Copy an existing tab view*/
    else {
        lv_tabview_ext_t * copy_ext = lv_obj_get_ext_attr(copy);
        ext->point_last.x           = 0;
        ext->point_last.y           = 0;
        ext->btns                   = lv_btnm_create(new_tabview, copy_ext->btns);
        ext->indic                  = lv_obj_create(ext->btns, copy_ext->indic);
        ext->content                = lv_cont_create(new_tabview, copy_ext->content);
#if LV_USE_ANIMATION
        ext->anim_time = copy_ext->anim_time;
#endif

        ext->tab_name_ptr = lv_mem_alloc(sizeof(char *));
        LV_ASSERT_MEM(ext->tab_name_ptr);
        if(ext->tab_name_ptr == NULL) return NULL;
        ext->tab_name_ptr[0] = "";
        lv_btnm_set_map(ext->btns, ext->tab_name_ptr);

        uint16_t i;
        lv_obj_t * new_tab;
        lv_obj_t * copy_tab;
        for(i = 0; i < copy_ext->tab_cnt; i++) {
            new_tab  = lv_tabview_add_tab(new_tabview, copy_ext->tab_name_ptr[i]);
            copy_tab = lv_tabview_get_tab(copy, i);
            lv_page_set_style(new_tab, LV_PAGE_STYLE_BG, lv_page_get_style(copy_tab, LV_PAGE_STYLE_BG));
            lv_page_set_style(new_tab, LV_PAGE_STYLE_SCRL, lv_page_get_style(copy_tab, LV_PAGE_STYLE_SCRL));
            lv_page_set_style(new_tab, LV_PAGE_STYLE_SB, lv_page_get_style(copy_tab, LV_PAGE_STYLE_SB));
        }

        /*Refresh the style with new signal function*/
        lv_obj_refresh_style(new_tabview);
    }

    LV_LOG_INFO("tab view created");

    return new_tabview;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
pushq %rax
movq %rsi, %r15
callq 0x454f
movq %rax, %rbx
movq %rax, %rdi
callq 0x80e4
testb %al, %al
je 0x10ca6
testq %rbx, %rbx
je 0x10ebd
cmpq $0x0, 0x4f83d(%rip)     # 0x60330
jne 0x10b04
movq %rbx, %rdi
callq 0x6a8b
movq %rax, 0x4f82c(%rip)     # 0x60330
movq %rbx, %rdi
movl $0x30, %esi
callq 0x64db
movq %rax, %r14
movq %rax, %rdi
callq 0x80e4
testb %al, %al
je 0x10cb7
testq %r14, %r14
je 0x10ebd
movb 0x2a(%r14), %al
movw $0x0, 0x24(%r14)
movl $0x0, 0x20(%r14)
xorps %xmm0, %xmm0
movups %xmm0, (%r14)
movq $0x0, 0x10(%r14)
movw $0x12c, 0x28(%r14)      # imm = 0x12C
andb $-0x80, %al
incb %al
movb %al, 0x2a(%r14)
leaq 0x3c3(%rip), %rsi       # 0x10f28
movq %rbx, %rdi
callq 0x647b
testq %r15, %r15
je 0x10cc8
movq %r15, %rdi
callq 0x6af7
movq %rax, %r12
movl $0x0, 0x20(%r14)
movq (%rax), %rsi
movq %rbx, %rdi
callq 0x2148c
movq %rax, (%r14)
movq 0x8(%r12), %rsi
movq %rax, %rdi
callq 0x454f
movq %rax, 0x8(%r14)
movq 0x10(%r12), %rsi
movq %rbx, %rdi
callq 0x22b18
movq %rax, 0x10(%r14)
movzwl 0x28(%r12), %eax
movw %ax, 0x28(%r14)
movl $0x8, %edi
callq 0x29f85
movq %rax, 0x18(%r14)
movq %rax, %rdi
callq 0x80e4
movq 0x18(%r14), %rsi
testb %al, %al
je 0x10ed1
testq %rsi, %rsi
je 0x10ebd
leaq 0x329c7(%rip), %rax     # 0x435bd
movq %rax, (%rsi)
movq (%r14), %rdi
movq 0x18(%r14), %rsi
callq 0x21f33
cmpw $0x0, 0x26(%r12)
je 0x10c99
xorl %ebp, %ebp
movq 0x18(%r12), %rax
movq (%rax,%rbp,8), %rsi
movq %rbx, %rdi
callq 0x11273
movq %rax, %r14
movzwl %bp, %esi
movq %r15, %rdi
callq 0x115c7
movq %rax, %r13
movq %rax, %rdi
xorl %esi, %esi
callq 0x264cb
movq %r14, %rdi
xorl %esi, %esi
movq %rax, %rdx
callq 0x2640b
movq %r13, %rdi
movl $0x1, %esi
callq 0x264cb
movq %r14, %rdi
movl $0x1, %esi
movq %rax, %rdx
callq 0x2640b
movq %r13, %rdi
movl $0x2, %esi
callq 0x264cb
movq %r14, %rdi
movl $0x2, %esi
movq %rax, %rdx
callq 0x2640b
incq %rbp
movzwl 0x26(%r12), %eax
cmpq %rax, %rbp
jb 0x10c14
movq %rbx, %rdi
callq 0x5e54
jmp 0x10ebf
leaq 0x2e423(%rip), %rdi     # 0x3f0d0
movq %rbx, %rsi
callq 0x8294
jmp 0x10cb5
leaq 0x2e412(%rip), %rdi     # 0x3f0d0
movq %r14, %rsi
callq 0x8294
jmp 0x10cc6
movl $0x8, %edi
callq 0x29f85
movq %rax, 0x18(%r14)
movq %rax, %rdi
callq 0x80e4
movq 0x18(%r14), %rsi
testb %al, %al
je 0x10edf
testq %rsi, %rsi
je 0x10ebd
leaq 0x328c3(%rip), %rax     # 0x435bd
movq %rax, (%rsi)
movw $0x0, 0x26(%r14)
movq %rbx, %rdi
callq 0x4ab5
movq %rax, %rdi
callq 0x6772
movl %eax, %ebp
movq %rbx, %rdi
callq 0x4ab5
movq %rax, %rdi
callq 0x67ba
movswl %bp, %esi
movswl %ax, %edx
movq %rbx, %rdi
callq 0x5557
movq %rbx, %rdi
xorl %esi, %esi
callq 0x22b18
movq %rax, 0x10(%r14)
movq %rbx, %rdi
xorl %esi, %esi
callq 0x2148c
movq %rax, (%r14)
movq %rax, %rdi
xorl %esi, %esi
callq 0x454f
movq %rax, 0x8(%r14)
movq (%r14), %rdi
movl $0x4b, %esi
callq 0x574b
movq (%r14), %rdi
leaq 0x4280c(%rip), %rsi     # 0x53580
callq 0x21f33
movq (%r14), %rdi
leaq 0x369(%rip), %rsi       # 0x110ec
callq 0x6363
movq 0x8(%r14), %rdi
movl $0x64, %esi
callq 0x570d
movq (%r14), %rsi
movq 0x8(%r14), %rdi
movl $0x4, %edx
xorl %ecx, %ecx
xorl %r8d, %r8d
callq 0x5789
movq 0x8(%r14), %rdi
xorl %esi, %esi
callq 0x5ff7
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), %rdi
leaq 0x4f2e0(%rip), %rsi     # 0x600c8
callq 0x5d9f
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 (%r14), %rsi
movq 0x10(%r14), %rdi
movl $0xc, %edx
xorl %ecx, %ecx
xorl %r8d, %r8d
callq 0x5789
callq 0x2e91c
testq %rax, %rax
je 0x10eed
movq %rax, %r14
movq 0x2c0(%rax), %rdx
movq %rbx, %rdi
xorl %esi, %esi
callq 0x11181
movq 0x2c8(%r14), %rdx
movq %rbx, %rdi
movl $0x1, %esi
callq 0x11181
movq 0x2d0(%r14), %rdx
movq %rbx, %rdi
movl $0x2, %esi
callq 0x11181
movq 0x2d8(%r14), %rdx
movq %rbx, %rdi
movl $0x3, %esi
callq 0x11181
movq 0x2e0(%r14), %rdx
movq %rbx, %rdi
movl $0x4, %esi
callq 0x11181
movq 0x2e8(%r14), %rdx
movq %rbx, %rdi
movl $0x5, %esi
callq 0x11181
movq 0x2f0(%r14), %rdx
movq %rbx, %rdi
movl $0x6, %esi
jmp 0x10f21
xorl %ebx, %ebx
movq %rbx, %rax
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
leaq 0x2e1f8(%rip), %rdi     # 0x3f0d0
callq 0x8294
jmp 0x10edd
leaq 0x2e1ea(%rip), %rdi     # 0x3f0d0
callq 0x8294
jmp 0x10eeb
leaq 0x4f024(%rip), %rdx     # 0x5ff18
movq %rbx, %rdi
xorl %esi, %esi
callq 0x11181
leaq 0x4f0a3(%rip), %rdx     # 0x5ffa8
movq %rbx, %rdi
movl $0x2, %esi
callq 0x11181
leaq 0x4f047(%rip), %rdx     # 0x5ff60
movq %rbx, %rdi
movl $0x1, %esi
callq 0x11181
jmp 0x10ebf