// File: /workspace/github_c_makefile_star2_O1/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 0x455f
movq %rax, %rbx
movq %rax, %rdi
callq 0x80d4
testb %al, %al
je 0x10c76
testq %rbx, %rbx
je 0x10e8d
cmpq $0x0, 0x4f86d(%rip)     # 0x60330
jne 0x10ad4
movq %rbx, %rdi
callq 0x6a6c
movq %rax, 0x4f85c(%rip)     # 0x60330
movq %rbx, %rdi
movl $0x30, %esi
callq 0x64bc
movq %rax, %r14
movq %rax, %rdi
callq 0x80d4
testb %al, %al
je 0x10c87
testq %r14, %r14
je 0x10e8d
movb 0x2a(%r14), %al
orb $0x1, %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 $-0x7f, %al
movb %al, 0x2a(%r14)
leaq 0x3c3(%rip), %rsi       # 0x10ef8
movq %rbx, %rdi
callq 0x645c
testq %r15, %r15
je 0x10c98
movq %r15, %rdi
callq 0x6ad8
movq %rax, %r12
movl $0x0, 0x20(%r14)
movq (%rax), %rsi
movq %rbx, %rdi
callq 0x20cb8
movq %rax, (%r14)
movq 0x8(%r12), %rsi
movq %rax, %rdi
callq 0x455f
movq %rax, 0x8(%r14)
movq 0x10(%r12), %rsi
movq %rbx, %rdi
callq 0x22398
movq %rax, 0x10(%r14)
movzwl 0x28(%r12), %eax
movw %ax, 0x28(%r14)
movl $0x8, %edi
callq 0x298d9
movq %rax, 0x18(%r14)
movq %rax, %rdi
callq 0x80d4
movq 0x18(%r14), %rsi
testb %al, %al
je 0x10ea1
testq %rsi, %rsi
je 0x10e8d
leaq 0x32807(%rip), %rax     # 0x433cd
movq %rax, (%rsi)
movq (%r14), %rdi
movq 0x18(%r14), %rsi
callq 0x21710
cmpw $0x0, 0x26(%r12)
je 0x10c69
xorl %ebp, %ebp
movq 0x18(%r12), %rax
movq (%rax,%rbp,8), %rsi
movq %rbx, %rdi
callq 0x1123e
movq %rax, %r14
movzwl %bp, %esi
movq %r15, %rdi
callq 0x11592
movq %rax, %r13
movq %rax, %rdi
xorl %esi, %esi
callq 0x25ddf
movq %r14, %rdi
xorl %esi, %esi
movq %rax, %rdx
callq 0x25d1f
movq %r13, %rdi
movl $0x1, %esi
callq 0x25ddf
movq %r14, %rdi
movl $0x1, %esi
movq %rax, %rdx
callq 0x25d1f
movq %r13, %rdi
movl $0x2, %esi
callq 0x25ddf
movq %r14, %rdi
movl $0x2, %esi
movq %rax, %rdx
callq 0x25d1f
incq %rbp
movzwl 0x26(%r12), %eax
cmpq %rax, %rbp
jb 0x10be4
movq %rbx, %rdi
callq 0x5e38
jmp 0x10e8f
leaq 0x2e3c3(%rip), %rdi     # 0x3f040
movq %rbx, %rsi
callq 0x829e
jmp 0x10c85
leaq 0x2e3b2(%rip), %rdi     # 0x3f040
movq %r14, %rsi
callq 0x829e
jmp 0x10c96
movl $0x8, %edi
callq 0x298d9
movq %rax, 0x18(%r14)
movq %rax, %rdi
callq 0x80d4
movq 0x18(%r14), %rsi
testb %al, %al
je 0x10eaf
testq %rsi, %rsi
je 0x10e8d
leaq 0x32703(%rip), %rax     # 0x433cd
movq %rax, (%rsi)
movw $0x0, 0x26(%r14)
movq %rbx, %rdi
callq 0x4abf
movq %rax, %rdi
callq 0x6753
movl %eax, %ebp
movq %rbx, %rdi
callq 0x4abf
movq %rax, %rdi
callq 0x679b
movswl %bp, %esi
movswl %ax, %edx
movq %rbx, %rdi
callq 0x553f
movq %rbx, %rdi
xorl %esi, %esi
callq 0x22398
movq %rax, 0x10(%r14)
movq %rbx, %rdi
xorl %esi, %esi
callq 0x20cb8
movq %rax, (%r14)
movq %rax, %rdi
xorl %esi, %esi
callq 0x455f
movq %rax, 0x8(%r14)
movq (%r14), %rdi
movl $0x4b, %esi
callq 0x572f
movq (%r14), %rdi
leaq 0x4283c(%rip), %rsi     # 0x53580
callq 0x21710
movq (%r14), %rdi
leaq 0x364(%rip), %rsi       # 0x110b7
callq 0x6344
movq 0x8(%r14), %rdi
movl $0x64, %esi
callq 0x56f1
movq (%r14), %rsi
movq 0x8(%r14), %rdi
movl $0x4, %edx
xorl %ecx, %ecx
xorl %r8d, %r8d
callq 0x576d
movq 0x8(%r14), %rdi
xorl %esi, %esi
callq 0x5fd8
movq 0x10(%r14), %rdi
movl $0x1, %esi
movl $0x1, %edx
xorl %ecx, %ecx
xorl %r8d, %r8d
callq 0x22602
movq 0x10(%r14), %rdi
movl $0x5, %esi
callq 0x2259a
movq 0x10(%r14), %rdi
leaq 0x4f310(%rip), %rsi     # 0x600c8
callq 0x5d83
movq 0x10(%r14), %r15
movq %rbx, %rdi
callq 0x567b
movl %eax, %ebp
movq (%r14), %rdi
callq 0x567b
subl %eax, %ebp
movswl %bp, %esi
movq %r15, %rdi
callq 0x572f
movq (%r14), %rsi
movq 0x10(%r14), %rdi
movl $0xc, %edx
xorl %ecx, %ecx
xorl %r8d, %r8d
callq 0x576d
callq 0x2e244
testq %rax, %rax
je 0x10ebd
movq %rax, %r14
movq 0x2c0(%rax), %rdx
movq %rbx, %rdi
xorl %esi, %esi
callq 0x1114c
movq 0x2c8(%r14), %rdx
movq %rbx, %rdi
movl $0x1, %esi
callq 0x1114c
movq 0x2d0(%r14), %rdx
movq %rbx, %rdi
movl $0x2, %esi
callq 0x1114c
movq 0x2d8(%r14), %rdx
movq %rbx, %rdi
movl $0x3, %esi
callq 0x1114c
movq 0x2e0(%r14), %rdx
movq %rbx, %rdi
movl $0x4, %esi
callq 0x1114c
movq 0x2e8(%r14), %rdx
movq %rbx, %rdi
movl $0x5, %esi
callq 0x1114c
movq 0x2f0(%r14), %rdx
movq %rbx, %rdi
movl $0x6, %esi
jmp 0x10ef1
xorl %ebx, %ebx
movq %rbx, %rax
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
leaq 0x2e198(%rip), %rdi     # 0x3f040
callq 0x829e
jmp 0x10ead
leaq 0x2e18a(%rip), %rdi     # 0x3f040
callq 0x829e
jmp 0x10ebb
leaq 0x4f054(%rip), %rdx     # 0x5ff18
movq %rbx, %rdi
xorl %esi, %esi
callq 0x1114c
leaq 0x4f0d3(%rip), %rdx     # 0x5ffa8
movq %rbx, %rdi
movl $0x2, %esi
callq 0x1114c
leaq 0x4f077(%rip), %rdx     # 0x5ff60
movq %rbx, %rdi
movl $0x1, %esi
callq 0x1114c
jmp 0x10e8f