// File: /workspace/github_c_makefile_star2_O1/OnionIoT[P]lv_example/lvgl/src/lv_objx/lv_calendar.c
// Function: lv_calendar_create
lv_obj_t * lv_calendar_create(lv_obj_t * par, const lv_obj_t * copy)
{
    LV_LOG_TRACE("calendar create started");

    /*Create the ancestor of calendar*/
    lv_obj_t * new_calendar = lv_obj_create(par, copy);
    LV_ASSERT_MEM(new_calendar);
    if(new_calendar == NULL) return NULL;

    /*Allocate the calendar type specific extended data*/
    lv_calendar_ext_t * ext = lv_obj_allocate_ext_attr(new_calendar, sizeof(lv_calendar_ext_t));
    LV_ASSERT_MEM(ext);
    if(ext == NULL) return NULL;
    if(ancestor_signal == NULL) ancestor_signal = lv_obj_get_signal_cb(new_calendar);
    if(ancestor_design == NULL) ancestor_design = lv_obj_get_design_cb(new_calendar);

    /*Initialize the allocated 'ext' */
    ext->today.year  = 2018;
    ext->today.month = 1;
    ext->today.day   = 1;

    ext->showed_date.year  = 2018;
    ext->showed_date.month = 1;
    ext->showed_date.day   = 1;

    ext->pressed_date.year  = 0;
    ext->pressed_date.month = 0;
    ext->pressed_date.day   = 0;

    ext->highlighted_dates      = NULL;
    ext->highlighted_dates_num  = 0;
    ext->day_names              = NULL;
    ext->month_names            = NULL;
    ext->style_header           = &lv_style_plain_color;
    ext->style_header_pr        = &lv_style_pretty_color;
    ext->style_highlighted_days = &lv_style_plain_color;
    ext->style_inactive_days    = &lv_style_btn_ina;
    ext->style_week_box         = &lv_style_plain_color;
    ext->style_today_box        = &lv_style_pretty_color;
    ext->style_day_names        = &lv_style_pretty;

    /*The signal and design functions are not copied so set them here*/
    lv_obj_set_signal_cb(new_calendar, lv_calendar_signal);
    lv_obj_set_design_cb(new_calendar, lv_calendar_design);

    /*Init the new calendar calendar*/
    if(copy == NULL) {
        lv_obj_set_size(new_calendar, LV_DPI * 2, LV_DPI * 2);
        lv_obj_set_style(new_calendar, &lv_style_pretty);

        lv_theme_t * th = lv_theme_get_current();
        if(th) {
            lv_calendar_set_style(new_calendar, LV_CALENDAR_STYLE_BG, th->style.calendar.bg);
            lv_calendar_set_style(new_calendar, LV_CALENDAR_STYLE_HEADER, th->style.calendar.header);
            lv_calendar_set_style(new_calendar, LV_CALENDAR_STYLE_HEADER_PR, th->style.calendar.header_pr);
            lv_calendar_set_style(new_calendar, LV_CALENDAR_STYLE_DAY_NAMES, th->style.calendar.day_names);
            lv_calendar_set_style(new_calendar, LV_CALENDAR_STYLE_WEEK_BOX, th->style.calendar.week_box);
            lv_calendar_set_style(new_calendar, LV_CALENDAR_STYLE_TODAY_BOX, th->style.calendar.today_box);
            lv_calendar_set_style(new_calendar, LV_CALENDAR_STYLE_HIGHLIGHTED_DAYS,
                                  th->style.calendar.highlighted_days);
            lv_calendar_set_style(new_calendar, LV_CALENDAR_STYLE_INACTIVE_DAYS, th->style.calendar.inactive_days);
        } else {
            lv_calendar_set_style(new_calendar, LV_CALENDAR_STYLE_BG, &lv_style_pretty);
            lv_calendar_set_style(new_calendar, LV_CALENDAR_STYLE_HEADER, ext->style_header);
            lv_calendar_set_style(new_calendar, LV_CALENDAR_STYLE_HEADER_PR, ext->style_header_pr);
            lv_calendar_set_style(new_calendar, LV_CALENDAR_STYLE_DAY_NAMES, ext->style_day_names);
            lv_calendar_set_style(new_calendar, LV_CALENDAR_STYLE_WEEK_BOX, ext->style_week_box);
            lv_calendar_set_style(new_calendar, LV_CALENDAR_STYLE_TODAY_BOX, ext->style_today_box);
            lv_calendar_set_style(new_calendar, LV_CALENDAR_STYLE_HIGHLIGHTED_DAYS, ext->style_highlighted_days);
            lv_calendar_set_style(new_calendar, LV_CALENDAR_STYLE_INACTIVE_DAYS, ext->style_inactive_days);
        }
    }
    /*Copy an existing calendar*/
    else {
        lv_calendar_ext_t * copy_ext = lv_obj_get_ext_attr(copy);
        ext->today.year              = copy_ext->today.year;
        ext->today.month             = copy_ext->today.month;
        ext->today.day               = copy_ext->today.day;

        ext->showed_date.year  = copy_ext->showed_date.year;
        ext->showed_date.month = copy_ext->showed_date.month;
        ext->showed_date.day   = copy_ext->showed_date.day;

        ext->highlighted_dates     = copy_ext->highlighted_dates;
        ext->highlighted_dates_num = copy_ext->highlighted_dates_num;
        ext->day_names             = copy_ext->day_names;

        ext->month_names            = copy_ext->month_names;
        ext->style_header           = copy_ext->style_header;
        ext->style_header_pr        = copy_ext->style_header_pr;
        ext->style_highlighted_days = copy_ext->style_highlighted_days;
        ext->style_inactive_days    = copy_ext->style_inactive_days;
        ext->style_week_box         = copy_ext->style_week_box;
        ext->style_today_box        = copy_ext->style_today_box;
        ext->style_day_names        = copy_ext->style_day_names;
        /*Refresh the style with new signal function*/
        lv_obj_refresh_style(new_calendar);
    }

    LV_LOG_INFO("calendar created");

    return new_calendar;
}

// Assembly:
pushq %r15
pushq %r14
pushq %rbx
movq %rsi, %r15
callq 0x455f
movq %rax, %rbx
movq %rax, %rdi
callq 0x80d4
testb %al, %al
je 0x139f9
testq %rbx, %rbx
je 0x13a0a
movq %rbx, %rdi
movl $0x60, %esi
callq 0x64bc
movq %rax, %r14
movq %rax, %rdi
callq 0x80d4
testb %al, %al
je 0x13a15
testq %r14, %r14
je 0x13a0a
cmpq $0x0, 0x4cab6(%rip)     # 0x60370
jne 0x138cb
movq %rbx, %rdi
callq 0x6a6c
movq %rax, 0x4caa5(%rip)     # 0x60370
cmpq $0x0, 0x4caa5(%rip)     # 0x60378
jne 0x138e4
movq %rbx, %rdi
callq 0x6a90
movq %rax, 0x4ca94(%rip)     # 0x60378
movabsq $0x10107e2010107e2, %rax # imm = 0x10107E2010107E2
movq %rax, (%r14)
xorl %eax, %eax
movq %rax, 0x8(%r14)
xorps %xmm0, %xmm0
movups %xmm0, 0x12(%r14)
movq %rax, 0x20(%r14)
leaq 0x4c656(%rip), %rax     # 0x5ff60
movq %rax, 0x28(%r14)
leaq 0x4c6db(%rip), %rcx     # 0x5fff0
movq %rcx, 0x30(%r14)
movq %rax, 0x40(%r14)
leaq 0x4c90c(%rip), %rdx     # 0x60230
movq %rdx, 0x48(%r14)
movq %rax, 0x50(%r14)
movq %rcx, 0x58(%r14)
leaq 0x4c671(%rip), %rax     # 0x5ffa8
movq %rax, 0x38(%r14)
leaq 0x235(%rip), %rsi       # 0x13b77
movq %rbx, %rdi
callq 0x645c
leaq 0x761(%rip), %rsi       # 0x140b2
movq %rbx, %rdi
callq 0x648c
testq %r15, %r15
je 0x13a26
movq %r15, %rdi
callq 0x6ad8
movzwl (%rax), %ecx
movw %cx, (%r14)
movb 0x2(%rax), %cl
movb %cl, 0x2(%r14)
movb 0x3(%rax), %cl
movb %cl, 0x3(%r14)
movzwl 0x4(%rax), %ecx
movw %cx, 0x4(%r14)
movb 0x6(%rax), %cl
movb %cl, 0x6(%r14)
movb 0x7(%rax), %cl
movb %cl, 0x7(%r14)
movq 0x8(%rax), %rcx
movq %rcx, 0x8(%r14)
movzwl 0x12(%rax), %ecx
movw %cx, 0x12(%r14)
movq 0x18(%rax), %rcx
movq %rcx, 0x18(%r14)
movq 0x20(%rax), %rcx
movq %rcx, 0x20(%r14)
movq 0x28(%rax), %rcx
movq %rcx, 0x28(%r14)
movq 0x30(%rax), %rcx
movq %rcx, 0x30(%r14)
movq 0x40(%rax), %rcx
movq %rcx, 0x40(%r14)
movq 0x48(%rax), %rcx
movq %rcx, 0x48(%r14)
movq 0x50(%rax), %rcx
movq %rcx, 0x50(%r14)
movq 0x58(%rax), %rcx
movq %rcx, 0x58(%r14)
movq 0x38(%rax), %rax
movq %rax, 0x38(%r14)
movq %rbx, %rdi
callq 0x5e38
jmp 0x13a0c
leaq 0x2b640(%rip), %rdi     # 0x3f040
movq %rbx, %rsi
callq 0x829e
jmp 0x13a08
xorl %ebx, %ebx
movq %rbx, %rax
popq %rbx
popq %r14
popq %r15
retq
leaq 0x2b624(%rip), %rdi     # 0x3f040
movq %r14, %rsi
callq 0x829e
jmp 0x13a24
movq %rbx, %rdi
movl $0xc8, %esi
movl $0xc8, %edx
callq 0x553f
leaq 0x4c569(%rip), %rsi     # 0x5ffa8
movq %rbx, %rdi
callq 0x5d83
callq 0x2e244
testq %rax, %rax
je 0x13aea
movq %rax, %r15
movq 0x118(%rax), %rdx
movq %rbx, %rdi
xorl %esi, %esi
callq 0x14a79
movq 0x120(%r15), %rdx
movq %rbx, %rdi
movl $0x1, %esi
callq 0x14a79
movq 0x128(%r15), %rdx
movq %rbx, %rdi
movl $0x2, %esi
callq 0x14a79
movq 0x130(%r15), %rdx
movq %rbx, %rdi
movl $0x3, %esi
callq 0x14a79
movq 0x148(%r15), %rdx
movq %rbx, %rdi
movl $0x6, %esi
callq 0x14a79
movq 0x150(%r15), %rdx
movq %rbx, %rdi
movl $0x7, %esi
callq 0x14a79
movq 0x138(%r15), %rdx
movq %rbx, %rdi
movl $0x4, %esi
callq 0x14a79
movq 0x140(%r15), %rdx
jmp 0x13b65
leaq 0x4c4b7(%rip), %rdx     # 0x5ffa8
movq %rbx, %rdi
xorl %esi, %esi
callq 0x14a79
movq 0x28(%r14), %rdx
movq %rbx, %rdi
movl $0x1, %esi
callq 0x14a79
movq 0x30(%r14), %rdx
movq %rbx, %rdi
movl $0x2, %esi
callq 0x14a79
movq 0x38(%r14), %rdx
movq %rbx, %rdi
movl $0x3, %esi
callq 0x14a79
movq 0x50(%r14), %rdx
movq %rbx, %rdi
movl $0x6, %esi
callq 0x14a79
movq 0x58(%r14), %rdx
movq %rbx, %rdi
movl $0x7, %esi
callq 0x14a79
movq 0x40(%r14), %rdx
movq %rbx, %rdi
movl $0x4, %esi
callq 0x14a79
movq 0x48(%r14), %rdx
movq %rbx, %rdi
movl $0x5, %esi
callq 0x14a79
jmp 0x13a0c