// File: /workspace/github_c_makefile_star2_O1/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 0x455f
movq %rax, %rbx
movq %rax, %rdi
callq 0x80d4
testb %al, %al
je 0x2722c
testq %rbx, %rbx
je 0x2723d
cmpq $0x0, 0x39371(%rip)     # 0x60480
jne 0x27120
movq %rbx, %rdi
callq 0x6a6c
movq %rax, 0x39360(%rip)     # 0x60480
movq %rbx, %rdi
movl $0x30, %esi
callq 0x64bc
movq %rax, %r14
movq %rax, %rdi
callq 0x80d4
testb %al, %al
je 0x27244
testq %r14, %r14
je 0x2723d
xorps %xmm0, %xmm0
movups %xmm0, (%r14)
movq $0x0, 0x10(%r14)
leaq 0x38fb1(%rip), %rax     # 0x60110
movq %rax, 0x18(%r14)
leaq 0x38fee(%rip), %rax     # 0x60158
movq %rax, 0x20(%r14)
movw $0x32, 0x28(%r14)
testq %r15, %r15
je 0x27255
movq %r15, %rdi
callq 0x6ad8
movq %rax, %r15
movq 0x8(%rax), %rsi
movq %rbx, %rdi
callq 0x455f
movq %rax, 0x8(%r14)
movq 0x10(%r15), %rsi
movq %rax, %rdi
callq 0x196f4
movq %rax, 0x10(%r14)
movq (%r15), %rsi
movq %rbx, %rdi
callq 0x24c9c
movq %rax, (%r14)
movzwl 0x28(%r15), %eax
movw %ax, 0x28(%r14)
movq 0x8(%r15), %rdi
xorl %esi, %esi
callq 0x652f
movq 0x8(%r15), %rdi
movq %rax, %rsi
callq 0x652f
testq %rax, %rax
je 0x27218
movq %rax, %r12
movq 0x8(%r14), %rdi
movq %r12, %rsi
callq 0x130d4
movq %rax, %r13
movq %r12, %rdi
xorl %esi, %esi
callq 0x51a3
movq %r13, %rdi
movq %rax, %rsi
callq 0x2350c
movq 0x8(%r15), %rdi
movq %r12, %rsi
callq 0x652f
movq %rax, %r12
testq %rax, %rax
jne 0x271e0
leaq 0x1e7(%rip), %rsi       # 0x27406
movq %rbx, %rdi
callq 0x645c
jmp 0x273e4
leaq 0x17e0d(%rip), %rdi     # 0x3f040
movq %rbx, %rsi
callq 0x829e
jmp 0x2723b
xorl %ebx, %ebx
jmp 0x273f4
leaq 0x17df5(%rip), %rdi     # 0x3f040
movq %r14, %rsi
callq 0x829e
jmp 0x27253
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
xorl %edx, %edx
callq 0x4ae2
leaq 0x38d10(%rip), %rsi     # 0x5ffa8
movq %rbx, %rdi
callq 0x5d83
movq %rbx, %rdi
xorl %esi, %esi
callq 0x24c9c
movq %rax, (%r14)
movq %rax, %rdi
movl $0x2, %esi
callq 0x62e7
movq (%r14), %rdi
movl $0x3, %esi
callq 0x25c83
movq (%r14), %rdi
leaq 0x38daf(%rip), %rdx     # 0x60080
xorl %esi, %esi
callq 0x25d1f
movq %rbx, %rdi
xorl %esi, %esi
callq 0x455f
movq %rax, 0x8(%r14)
movq %rax, %rdi
movl $0x2, %esi
callq 0x62e7
movq 0x8(%r14), %rdi
movq %rbx, %rsi
callq 0x5255
movq 0x8(%r14), %rdi
xorl %esi, %esi
callq 0x196f4
movq %rax, 0x10(%r14)
leaq 0x187cb(%rip), %rsi     # 0x3fae0
movq %rax, %rdi
callq 0x19f13
leaq 0xe2(%rip), %rsi        # 0x27406
movq %rbx, %rdi
callq 0x645c
callq 0x2e244
testq %rax, %rax
je 0x273ab
movq %rax, %r14
movq 0x320(%rax), %rdx
movq %rbx, %rdi
xorl %esi, %esi
callq 0x27529
movq 0x328(%r14), %rdx
movq %rbx, %rdi
movl $0x2, %esi
callq 0x27529
movq 0x330(%r14), %rdx
movq %rbx, %rdi
movl $0x3, %esi
callq 0x27529
movq 0x338(%r14), %rdx
movq %rbx, %rdi
movl $0x1, %esi
callq 0x27529
movq 0x340(%r14), %rdx
movq %rbx, %rdi
movl $0x4, %esi
callq 0x27529
movq 0x348(%r14), %rdx
movq %rbx, %rdi
movl $0x5, %esi
jmp 0x273df
leaq 0x38b66(%rip), %rdx     # 0x5ff18
movq %rbx, %rdi
xorl %esi, %esi
callq 0x27529
leaq 0x38c75(%rip), %rdx     # 0x60038
movq %rbx, %rdi
movl $0x1, %esi
callq 0x27529
leaq 0x38b89(%rip), %rdx     # 0x5ff60
movq %rbx, %rdi
movl $0x3, %esi
callq 0x27529
movq %rbx, %rdi
callq 0x5e38
movq %rbx, %rdi
callq 0x27616
movq %rbx, %rax
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq