// File: /workspace/github_c_makefile_star2_O3/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 0x454f
movq %rax, %rbx
movq %rax, %rdi
callq 0x80e4
testb %al, %al
je 0x27908
testq %rbx, %rbx
je 0x27919
cmpq $0x0, 0x38c95(%rip)     # 0x60480
jne 0x277fc
movq %rbx, %rdi
callq 0x6a8b
movq %rax, 0x38c84(%rip)     # 0x60480
movq %rbx, %rdi
movl $0x30, %esi
callq 0x64db
movq %rax, %r14
movq %rax, %rdi
callq 0x80e4
testb %al, %al
je 0x27920
testq %r14, %r14
je 0x27919
xorps %xmm0, %xmm0
movups %xmm0, (%r14)
movq $0x0, 0x10(%r14)
leaq 0x388d5(%rip), %rax     # 0x60110
movq %rax, 0x18(%r14)
leaq 0x38912(%rip), %rax     # 0x60158
movq %rax, 0x20(%r14)
movw $0x32, 0x28(%r14)
testq %r15, %r15
je 0x27931
movq %r15, %rdi
callq 0x6af7
movq %rax, %r15
movq 0x8(%rax), %rsi
movq %rbx, %rdi
callq 0x454f
movq %rax, 0x8(%r14)
movq 0x10(%r15), %rsi
movq %rax, %rdi
callq 0x19ed4
movq %rax, 0x10(%r14)
movq (%r15), %rsi
movq %rbx, %rdi
callq 0x25398
movq %rax, (%r14)
movzwl 0x28(%r15), %eax
movw %ax, 0x28(%r14)
movq 0x8(%r15), %rdi
xorl %esi, %esi
callq 0x654e
movq 0x8(%r15), %rdi
movq %rax, %rsi
callq 0x654e
testq %rax, %rax
je 0x278f4
movq %rax, %r12
movq 0x8(%r14), %rdi
movq %r12, %rsi
callq 0x13104
movq %rax, %r13
movq %r12, %rdi
xorl %esi, %esi
callq 0x51a7
movq %r13, %rdi
movq %rax, %rsi
callq 0x23c3c
movq 0x8(%r15), %rdi
movq %r12, %rsi
callq 0x654e
movq %rax, %r12
testq %rax, %rax
jne 0x278bc
leaq 0x1e7(%rip), %rsi       # 0x27ae2
movq %rbx, %rdi
callq 0x647b
jmp 0x27ac0
leaq 0x177c1(%rip), %rdi     # 0x3f0d0
movq %rbx, %rsi
callq 0x8294
jmp 0x27917
xorl %ebx, %ebx
jmp 0x27ad0
leaq 0x177a9(%rip), %rdi     # 0x3f0d0
movq %r14, %rsi
callq 0x8294
jmp 0x2792f
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
xorl %edx, %edx
callq 0x4ad8
leaq 0x38634(%rip), %rsi     # 0x5ffa8
movq %rbx, %rdi
callq 0x5d9f
movq %rbx, %rdi
xorl %esi, %esi
callq 0x25398
movq %rax, (%r14)
movq %rax, %rdi
movl $0x2, %esi
callq 0x6306
movq (%r14), %rdi
movl $0x3, %esi
callq 0x2636f
movq (%r14), %rdi
leaq 0x386d3(%rip), %rdx     # 0x60080
xorl %esi, %esi
callq 0x2640b
movq %rbx, %rdi
xorl %esi, %esi
callq 0x454f
movq %rax, 0x8(%r14)
movq %rax, %rdi
movl $0x2, %esi
callq 0x6306
movq 0x8(%r14), %rdi
movq %rbx, %rsi
callq 0x5259
movq 0x8(%r14), %rdi
xorl %esi, %esi
callq 0x19ed4
movq %rax, 0x10(%r14)
leaq 0x18287(%rip), %rsi     # 0x3fc78
movq %rax, %rdi
callq 0x1a6da
leaq 0xe2(%rip), %rsi        # 0x27ae2
movq %rbx, %rdi
callq 0x647b
callq 0x2e91c
testq %rax, %rax
je 0x27a87
movq %rax, %r14
movq 0x320(%rax), %rdx
movq %rbx, %rdi
xorl %esi, %esi
callq 0x27c0c
movq 0x328(%r14), %rdx
movq %rbx, %rdi
movl $0x2, %esi
callq 0x27c0c
movq 0x330(%r14), %rdx
movq %rbx, %rdi
movl $0x3, %esi
callq 0x27c0c
movq 0x338(%r14), %rdx
movq %rbx, %rdi
movl $0x1, %esi
callq 0x27c0c
movq 0x340(%r14), %rdx
movq %rbx, %rdi
movl $0x4, %esi
callq 0x27c0c
movq 0x348(%r14), %rdx
movq %rbx, %rdi
movl $0x5, %esi
jmp 0x27abb
leaq 0x3848a(%rip), %rdx     # 0x5ff18
movq %rbx, %rdi
xorl %esi, %esi
callq 0x27c0c
leaq 0x38599(%rip), %rdx     # 0x60038
movq %rbx, %rdi
movl $0x1, %esi
callq 0x27c0c
leaq 0x384ad(%rip), %rdx     # 0x5ff60
movq %rbx, %rdi
movl $0x3, %esi
callq 0x27c0c
movq %rbx, %rdi
callq 0x5e54
movq %rbx, %rdi
callq 0x27d16
movq %rbx, %rax
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq