// File: /workspace/github_c_makefile_star2_O2/OnionIoT[P]lv_example/lvgl/src/lv_objx/lv_win.c
// Function: lv_win_create
lv_obj_t * lv_win_create(lv_obj_t * par, const lv_obj_t * copy)
{
    LV_LOG_TRACE("window create started");

    /*Create the ancestor object*/
    lv_obj_t * new_win = lv_obj_create(par, copy);
    LV_ASSERT_MEM(new_win);
    if(new_win == NULL) return NULL;

    if(ancestor_signal == NULL) ancestor_signal = lv_obj_get_signal_cb(new_win);

    /*Allocate the object type specific extended data*/
    lv_win_ext_t * ext = lv_obj_allocate_ext_attr(new_win, sizeof(lv_win_ext_t));
    LV_ASSERT_MEM(ext);
    if(ext == NULL) return NULL;

    ext->page          = NULL;
    ext->header        = NULL;
    ext->title         = NULL;
    ext->style_btn_rel = &lv_style_btn_rel;
    ext->style_btn_pr  = &lv_style_btn_pr;
    ext->btn_size      = (LV_DPI) / 2;

    /*Init the new window object*/
    if(copy == NULL) {
        /* Set a size which fits into the parent.
         * Don't use `par` directly because if the window is created on a page it is moved to the
         * scrollable so the parent has changed */
        lv_obj_set_size(new_win, lv_obj_get_width_fit(lv_obj_get_parent(new_win)),
                        lv_obj_get_height_fit(lv_obj_get_parent(new_win)));

        lv_obj_set_pos(new_win, 0, 0);
        lv_obj_set_style(new_win, &lv_style_pretty);

        ext->page = lv_page_create(new_win, NULL);
        lv_obj_set_protect(ext->page, LV_PROTECT_PARENT);
        lv_page_set_sb_mode(ext->page, LV_SB_MODE_AUTO);
        lv_page_set_style(ext->page, LV_PAGE_STYLE_BG, &lv_style_transp_fit);

        /*Create a holder for the header*/
        ext->header = lv_obj_create(new_win, NULL);
        /*Move back the header because it is automatically moved to the scrollable */
        lv_obj_set_protect(ext->header, LV_PROTECT_PARENT);
        lv_obj_set_parent(ext->header, new_win);

        /*Create a title on the header*/
        ext->title = lv_label_create(ext->header, NULL);
        lv_label_set_text(ext->title, "My title");

        lv_obj_set_signal_cb(new_win, lv_win_signal);

        /*Set the default styles*/
        lv_theme_t * th = lv_theme_get_current();
        if(th) {
            lv_win_set_style(new_win, LV_WIN_STYLE_BG, th->style.win.bg);
            lv_win_set_style(new_win, LV_WIN_STYLE_SB, th->style.win.sb);
            lv_win_set_style(new_win, LV_WIN_STYLE_HEADER, th->style.win.header);
            lv_win_set_style(new_win, LV_WIN_STYLE_CONTENT, th->style.win.content);
            lv_win_set_style(new_win, LV_WIN_STYLE_BTN_REL, th->style.win.btn.rel);
            lv_win_set_style(new_win, LV_WIN_STYLE_BTN_PR, th->style.win.btn.pr);
        } else {
            lv_win_set_style(new_win, LV_WIN_STYLE_BG, &lv_style_plain);
            lv_win_set_style(new_win, LV_WIN_STYLE_CONTENT, &lv_style_transp);
            lv_win_set_style(new_win, LV_WIN_STYLE_HEADER, &lv_style_plain_color);
        }
    }
    /*Copy an existing object*/
    else {
        lv_win_ext_t * copy_ext = lv_obj_get_ext_attr(copy);
        /*Create the objects*/
        ext->header   = lv_obj_create(new_win, copy_ext->header);
        ext->title    = lv_label_create(ext->header, copy_ext->title);
        ext->page     = lv_page_create(new_win, copy_ext->page);
        ext->btn_size = copy_ext->btn_size;

        /*Copy the control buttons*/
        lv_obj_t * child;
        lv_obj_t * cbtn;
        child = lv_obj_get_child_back(copy_ext->header, NULL);
        child = lv_obj_get_child_back(copy_ext->header, child); /*Sip the title*/
        while(child != NULL) {
            cbtn = lv_btn_create(ext->header, child);
            lv_img_create(cbtn, lv_obj_get_child(child, NULL));
            child = lv_obj_get_child_back(copy_ext->header, child);
        }

        lv_obj_set_signal_cb(new_win, lv_win_signal);
    }

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

    lv_win_realign(new_win);

    LV_LOG_INFO("window created");

    return new_win;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
pushq %rax
movq %rsi, %r15
callq 0x42c9
movq %rax, %rbx
movq %rax, %rdi
callq 0x7994
testb %al, %al
je 0x254e0
testq %rbx, %rbx
je 0x254f1
cmpq $0x0, 0x39099(%rip)     # 0x5e480
jne 0x253f8
movq %rbx, %rdi
callq 0x66db
movq %rax, 0x39088(%rip)     # 0x5e480
pushq $0x30
popq %rsi
movq %rbx, %rdi
callq 0x6146
movq %rax, %r14
movq %rax, %rdi
callq 0x7994
testb %al, %al
je 0x254f8
testq %r14, %r14
je 0x254f1
andq $0x0, 0x10(%r14)
xorps %xmm0, %xmm0
movups %xmm0, (%r14)
leaq 0x38cde(%rip), %rax     # 0x5e110
movq %rax, 0x18(%r14)
leaq 0x38d1b(%rip), %rax     # 0x5e158
movq %rax, 0x20(%r14)
movw $0x32, 0x28(%r14)
testq %r15, %r15
je 0x2551d
movq %r15, %rdi
callq 0x6747
movq %rax, %r15
movq 0x8(%rax), %rsi
movq %rbx, %rdi
callq 0x42c9
movq %rax, 0x8(%r14)
movq 0x10(%r15), %rsi
movq %rax, %rdi
callq 0x182f0
movq %rax, 0x10(%r14)
movq (%r15), %rsi
movq %rbx, %rdi
callq 0x230ac
movq %rax, (%r14)
movzwl 0x28(%r15), %eax
movw %ax, 0x28(%r14)
movq 0x8(%r15), %rdi
xorl %esi, %esi
callq 0x61b6
movq 0x8(%r15), %rdi
movq %rax, %rsi
callq 0x61b6
movq %rax, %r12
testq %rax, %rax
je 0x25509
movq 0x8(%r14), %rdi
movq %r12, %rsi
callq 0x122f0
movq %rax, %r13
movq %r12, %rdi
xorl %esi, %esi
callq 0x4e4d
movq %r13, %rdi
movq %rax, %rsi
callq 0x21a28
movq 0x8(%r15), %rdi
movq %r12, %rsi
jmp 0x254a6
leaq 0x15b59(%rip), %rdi     # 0x3b040
movq %rbx, %rsi
callq 0x7b01
jmp 0x254ef
xorl %ebx, %ebx
jmp 0x256a5
leaq 0x15b41(%rip), %rdi     # 0x3b040
movq %r14, %rsi
callq 0x7b01
jmp 0x25507
leaq 0x1a7(%rip), %rsi       # 0x256b7
movq %rbx, %rdi
callq 0x60e6
jmp 0x25695
movq %rbx, %rdi
callq 0x47bc
movq %rax, %rdi
callq 0x63d0
movl %eax, %ebp
movq %rbx, %rdi
callq 0x47bc
movq %rax, %rdi
callq 0x6418
movswl %bp, %esi
movswl %ax, %edx
movq %rbx, %rdi
callq 0x520e
movq %rbx, %rdi
xorl %esi, %esi
xorl %edx, %edx
callq 0x47df
leaq 0x38a48(%rip), %rsi     # 0x5dfa8
movq %rbx, %rdi
callq 0x5a3d
movq %rbx, %rdi
xorl %esi, %esi
callq 0x230ac
movq %rax, (%r14)
pushq $0x2
popq %rbp
movq %rax, %rdi
movl %ebp, %esi
callq 0x5f71
movq (%r14), %rdi
pushq $0x3
popq %rsi
callq 0x23fed
movq (%r14), %rdi
leaq 0x38ae9(%rip), %rdx     # 0x5e080
xorl %esi, %esi
callq 0x24089
movq %rbx, %rdi
xorl %esi, %esi
callq 0x42c9
movq %rax, 0x8(%r14)
movq %rax, %rdi
movl %ebp, %esi
callq 0x5f71
movq 0x8(%r14), %rdi
movq %rbx, %rsi
callq 0x4eff
movq 0x8(%r14), %rdi
xorl %esi, %esi
callq 0x182f0
movq %rax, 0x10(%r14)
leaq 0x1658c(%rip), %rsi     # 0x3bb64
movq %rax, %rdi
callq 0x18a9a
leaq 0xd0(%rip), %rsi        # 0x256b7
movq %rbx, %rdi
callq 0x60e6
callq 0x2be75
testq %rax, %rax
je 0x25660
movq %rax, %r14
movq 0x320(%rax), %rdx
movq %rbx, %rdi
xorl %esi, %esi
callq 0x257dd
movq 0x328(%r14), %rdx
pushq $0x2
popq %rsi
movq %rbx, %rdi
callq 0x257dd
movq 0x330(%r14), %rdx
pushq $0x3
popq %rsi
movq %rbx, %rdi
callq 0x257dd
movq 0x338(%r14), %rdx
pushq $0x1
popq %rsi
movq %rbx, %rdi
callq 0x257dd
movq 0x340(%r14), %rdx
pushq $0x4
popq %rsi
movq %rbx, %rdi
callq 0x257dd
movq 0x348(%r14), %rdx
pushq $0x5
jmp 0x2568c
leaq 0x388b1(%rip), %rdx     # 0x5df18
movq %rbx, %rdi
xorl %esi, %esi
callq 0x257dd
leaq 0x389c0(%rip), %rdx     # 0x5e038
pushq $0x1
popq %rsi
movq %rbx, %rdi
callq 0x257dd
leaq 0x388d6(%rip), %rdx     # 0x5df60
pushq $0x3
popq %rsi
movq %rbx, %rdi
callq 0x257dd
movq %rbx, %rdi
callq 0x5ae7
movq %rbx, %rdi
callq 0x258d5
movq %rbx, %rax
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq