// File: /workspace/github_c_makefile_star2_O0/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
movq %rsp, %rbp
subq $0x60, %rsp
movq %rdi, -0x10(%rbp)
movq %rsi, -0x18(%rbp)
movq -0x10(%rbp), %rdi
movq -0x18(%rbp), %rsi
callq 0x66b0
movq %rax, -0x20(%rbp)
movq -0x20(%rbp), %rdi
callq 0xd120
testb $0x1, %al
jne 0x40270
movq -0x20(%rbp), %rsi
leaq 0x27ddb(%rip), %rdi     # 0x68044
callq 0xd410
jmp 0x4026e
cmpq $0x0, -0x20(%rbp)
jne 0x40284
movq $0x0, -0x8(%rbp)
jmp 0x40665
cmpq $0x0, 0x492c4(%rip)     # 0x89550
jne 0x4029e
movq -0x20(%rbp), %rdi
callq 0xa830
movq %rax, 0x492b2(%rip)     # 0x89550
movq -0x20(%rbp), %rdi
movl $0x30, %esi
callq 0x9d60
movq %rax, -0x28(%rbp)
movq -0x28(%rbp), %rdi
callq 0xd120
testb $0x1, %al
jne 0x402cf
movq -0x28(%rbp), %rsi
leaq 0x27d7c(%rip), %rdi     # 0x68044
callq 0xd410
jmp 0x402cd
cmpq $0x0, -0x28(%rbp)
jne 0x402e3
movq $0x0, -0x8(%rbp)
jmp 0x40665
movq -0x28(%rbp), %rax
movq $0x0, (%rax)
movq -0x28(%rbp), %rax
movq $0x0, 0x8(%rax)
movq -0x28(%rbp), %rax
movq $0x0, 0x10(%rax)
movq -0x28(%rbp), %rax
leaq 0x48ecf(%rip), %rcx     # 0x891e0
movq %rcx, 0x18(%rax)
movq -0x28(%rbp), %rax
leaq 0x48f08(%rip), %rcx     # 0x89228
movq %rcx, 0x20(%rax)
movq -0x28(%rbp), %rax
movw $0x32, 0x28(%rax)
cmpq $0x0, -0x18(%rbp)
jne 0x4054a
movq -0x20(%rbp), %rax
movq %rax, -0x58(%rbp)
movq -0x20(%rbp), %rdi
callq 0x71b0
movq %rax, %rdi
callq 0xa1e0
movw %ax, -0x4a(%rbp)
movq -0x20(%rbp), %rdi
callq 0x71b0
movq %rax, %rdi
callq 0xa240
movq -0x58(%rbp), %rdi
movw -0x4a(%rbp), %cx
movswl %cx, %esi
movswl %ax, %edx
callq 0x8180
movq -0x20(%rbp), %rdi
xorl %edx, %edx
movl %edx, %esi
callq 0x71f0
movq -0x20(%rbp), %rdi
leaq 0x48ce6(%rip), %rsi     # 0x89078
callq 0x9150
movq -0x20(%rbp), %rdi
xorl %eax, %eax
movl %eax, %esi
callq 0x3c400
movq %rax, %rcx
movq -0x28(%rbp), %rax
movq %rcx, (%rax)
movq -0x28(%rbp), %rax
movq (%rax), %rdi
movl $0x2, %esi
callq 0x9a50
movq -0x28(%rbp), %rax
movq (%rax), %rdi
movl $0x3, %esi
callq 0x3dec0
movq -0x28(%rbp), %rax
movq (%rax), %rdi
xorl %esi, %esi
leaq 0x48d70(%rip), %rdx     # 0x89150
callq 0x3dff0
movq -0x20(%rbp), %rdi
xorl %eax, %eax
movl %eax, %esi
callq 0x66b0
movq %rax, %rcx
movq -0x28(%rbp), %rax
movq %rcx, 0x8(%rax)
movq -0x28(%rbp), %rax
movq 0x8(%rax), %rdi
movl $0x2, %esi
callq 0x9a50
movq -0x28(%rbp), %rax
movq 0x8(%rax), %rdi
movq -0x20(%rbp), %rsi
callq 0x7d50
movq -0x28(%rbp), %rax
movq 0x8(%rax), %rdi
xorl %eax, %eax
movl %eax, %esi
callq 0x29820
movq %rax, %rcx
movq -0x28(%rbp), %rax
movq %rcx, 0x10(%rax)
movq -0x28(%rbp), %rax
movq 0x10(%rax), %rdi
leaq 0x28345(%rip), %rsi     # 0x68790
callq 0x2a630
movq -0x20(%rbp), %rdi
leaq 0x215(%rip), %rsi       # 0x40670
callq 0x9cc0
callq 0x4cfc0
movq %rax, -0x30(%rbp)
cmpq $0x0, -0x30(%rbp)
je 0x40509
movq -0x20(%rbp), %rdi
movq -0x30(%rbp), %rax
movq 0x320(%rax), %rdx
xorl %esi, %esi
callq 0x40850
movq -0x20(%rbp), %rdi
movq -0x30(%rbp), %rax
movq 0x328(%rax), %rdx
movl $0x2, %esi
callq 0x40850
movq -0x20(%rbp), %rdi
movq -0x30(%rbp), %rax
movq 0x330(%rax), %rdx
movl $0x3, %esi
callq 0x40850
movq -0x20(%rbp), %rdi
movq -0x30(%rbp), %rax
movq 0x338(%rax), %rdx
movl $0x1, %esi
callq 0x40850
movq -0x20(%rbp), %rdi
movq -0x30(%rbp), %rax
movq 0x340(%rax), %rdx
movl $0x4, %esi
callq 0x40850
movq -0x20(%rbp), %rdi
movq -0x30(%rbp), %rax
movq 0x348(%rax), %rdx
movl $0x5, %esi
callq 0x40850
jmp 0x40545
movq -0x20(%rbp), %rdi
xorl %esi, %esi
leaq 0x48ad2(%rip), %rdx     # 0x88fe8
callq 0x40850
movq -0x20(%rbp), %rdi
movl $0x1, %esi
leaq 0x48bdd(%rip), %rdx     # 0x89108
callq 0x40850
movq -0x20(%rbp), %rdi
movl $0x3, %esi
leaq 0x48af0(%rip), %rdx     # 0x89030
callq 0x40850
jmp 0x4064b
movq -0x18(%rbp), %rdi
callq 0xa8f0
movq %rax, -0x38(%rbp)
movq -0x20(%rbp), %rdi
movq -0x38(%rbp), %rax
movq 0x8(%rax), %rsi
callq 0x66b0
movq %rax, %rcx
movq -0x28(%rbp), %rax
movq %rcx, 0x8(%rax)
movq -0x28(%rbp), %rax
movq 0x8(%rax), %rdi
movq -0x38(%rbp), %rax
movq 0x10(%rax), %rsi
callq 0x29820
movq %rax, %rcx
movq -0x28(%rbp), %rax
movq %rcx, 0x10(%rax)
movq -0x20(%rbp), %rdi
movq -0x38(%rbp), %rax
movq (%rax), %rsi
callq 0x3c400
movq %rax, %rcx
movq -0x28(%rbp), %rax
movq %rcx, (%rax)
movq -0x38(%rbp), %rax
movw 0x28(%rax), %cx
movq -0x28(%rbp), %rax
movw %cx, 0x28(%rax)
movq -0x38(%rbp), %rax
movq 0x8(%rax), %rdi
xorl %eax, %eax
movl %eax, %esi
callq 0x9e20
movq %rax, -0x40(%rbp)
movq -0x38(%rbp), %rax
movq 0x8(%rax), %rdi
movq -0x40(%rbp), %rsi
callq 0x9e20
movq %rax, -0x40(%rbp)
cmpq $0x0, -0x40(%rbp)
je 0x4063b
movq -0x28(%rbp), %rax
movq 0x8(%rax), %rdi
movq -0x40(%rbp), %rsi
callq 0x1fe90
movq %rax, -0x48(%rbp)
movq -0x48(%rbp), %rax
movq %rax, -0x60(%rbp)
movq -0x40(%rbp), %rdi
xorl %eax, %eax
movl %eax, %esi
callq 0x7c20
movq -0x60(%rbp), %rdi
movq %rax, %rsi
callq 0x39cb0
movq -0x38(%rbp), %rax
movq 0x8(%rax), %rdi
movq -0x40(%rbp), %rsi
callq 0x9e20
movq %rax, -0x40(%rbp)
jmp 0x405e7
movq -0x20(%rbp), %rdi
leaq 0x2a(%rip), %rsi        # 0x40670
callq 0x9cc0
movq -0x20(%rbp), %rdi
callq 0x9250
movq -0x20(%rbp), %rdi
callq 0x409d0
movq -0x20(%rbp), %rax
movq %rax, -0x8(%rbp)
movq -0x8(%rbp), %rax
addq $0x60, %rsp
popq %rbp
retq
nop