// File: /workspace/github_c_makefile_star2_O2/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 0x42c9
movq %rax, %rbx
movq %rax, %rdi
callq 0x7994
testb %al, %al
je 0x12b97
testq %rbx, %rbx
je 0x12ba8
pushq $0x60
popq %rsi
movq %rbx, %rdi
callq 0x6146
movq %rax, %r14
movq %rax, %rdi
callq 0x7994
testb %al, %al
je 0x12bb3
testq %r14, %r14
je 0x12ba8
cmpq $0x0, 0x4b8fc(%rip)     # 0x5e370
jne 0x12a85
movq %rbx, %rdi
callq 0x66db
movq %rax, 0x4b8eb(%rip)     # 0x5e370
cmpq $0x0, 0x4b8eb(%rip)     # 0x5e378
jne 0x12a9e
movq %rbx, %rdi
callq 0x66ff
movq %rax, 0x4b8da(%rip)     # 0x5e378
movabsq $0x10107e2010107e2, %rax # imm = 0x10107E2010107E2
movq %rax, (%r14)
andq $0x0, 0x8(%r14)
xorps %xmm0, %xmm0
movups %xmm0, 0x12(%r14)
andq $0x0, 0x20(%r14)
leaq 0x4b49c(%rip), %rax     # 0x5df60
movq %rax, 0x28(%r14)
leaq 0x4b521(%rip), %rcx     # 0x5dff0
movq %rcx, 0x30(%r14)
movq %rax, 0x40(%r14)
leaq 0x4b752(%rip), %rdx     # 0x5e230
movq %rdx, 0x48(%r14)
movq %rax, 0x50(%r14)
movq %rcx, 0x58(%r14)
leaq 0x4b4b7(%rip), %rax     # 0x5dfa8
movq %rax, 0x38(%r14)
leaq 0x1ff(%rip), %rsi       # 0x12cfb
movq %rbx, %rdi
callq 0x60e6
leaq 0x634(%rip), %rsi       # 0x1313f
movq %rbx, %rdi
callq 0x6116
testq %r15, %r15
je 0x12bc4
movq %r15, %rdi
callq 0x6747
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)
movups 0x18(%rax), %xmm0
movups %xmm0, 0x18(%r14)
movups 0x28(%rax), %xmm0
movups %xmm0, 0x28(%r14)
movups 0x48(%rax), %xmm0
movups %xmm0, 0x48(%r14)
movq 0x58(%rax), %rcx
movq %rcx, 0x58(%r14)
movups 0x38(%rax), %xmm0
movups %xmm0, 0x38(%r14)
movq %rbx, %rdi
callq 0x5ae7
jmp 0x12baa
leaq 0x284a2(%rip), %rdi     # 0x3b040
movq %rbx, %rsi
callq 0x7b01
jmp 0x12ba6
xorl %ebx, %ebx
movq %rbx, %rax
popq %rbx
popq %r14
popq %r15
retq
leaq 0x28486(%rip), %rdi     # 0x3b040
movq %r14, %rsi
callq 0x7b01
jmp 0x12bc2
movq %rbx, %rdi
movl $0xc8, %esi
movl $0xc8, %edx
callq 0x520e
leaq 0x4b3cb(%rip), %rsi     # 0x5dfa8
movq %rbx, %rdi
callq 0x5a3d
callq 0x2be75
testq %rax, %rax
je 0x12c7c
movq %rax, %r15
movq 0x118(%rax), %rdx
movq %rbx, %rdi
xorl %esi, %esi
callq 0x139ea
movq 0x120(%r15), %rdx
pushq $0x1
popq %rsi
movq %rbx, %rdi
callq 0x139ea
movq 0x128(%r15), %rdx
pushq $0x2
popq %rsi
movq %rbx, %rdi
callq 0x139ea
movq 0x130(%r15), %rdx
pushq $0x3
popq %rsi
movq %rbx, %rdi
callq 0x139ea
movq 0x148(%r15), %rdx
pushq $0x6
popq %rsi
movq %rbx, %rdi
callq 0x139ea
movq 0x150(%r15), %rdx
pushq $0x7
popq %rsi
movq %rbx, %rdi
callq 0x139ea
movq 0x138(%r15), %rdx
pushq $0x4
popq %rsi
movq %rbx, %rdi
callq 0x139ea
movq 0x140(%r15), %rdx
jmp 0x12ceb
leaq 0x4b325(%rip), %rdx     # 0x5dfa8
movq %rbx, %rdi
xorl %esi, %esi
callq 0x139ea
movq 0x28(%r14), %rdx
pushq $0x1
popq %rsi
movq %rbx, %rdi
callq 0x139ea
movq 0x30(%r14), %rdx
pushq $0x2
popq %rsi
movq %rbx, %rdi
callq 0x139ea
movq 0x38(%r14), %rdx
pushq $0x3
popq %rsi
movq %rbx, %rdi
callq 0x139ea
movq 0x50(%r14), %rdx
pushq $0x6
popq %rsi
movq %rbx, %rdi
callq 0x139ea
movq 0x58(%r14), %rdx
pushq $0x7
popq %rsi
movq %rbx, %rdi
callq 0x139ea
movq 0x40(%r14), %rdx
pushq $0x4
popq %rsi
movq %rbx, %rdi
callq 0x139ea
movq 0x48(%r14), %rdx
pushq $0x5
popq %rsi
movq %rbx, %rdi
callq 0x139ea
jmp 0x12baa