// File: /workspace/github_c_makefile_star2_O3/OnionIoT[P]lv_example/lvgl/src/lv_objx/lv_calendar.c
// Function: lv_calendar_signal
static lv_res_t lv_calendar_signal(lv_obj_t * calendar, lv_signal_t sign, void * param)
{
    lv_res_t res;

    /* Include the ancient signal function */
    res = ancestor_signal(calendar, sign, param);
    if(res != LV_RES_OK) return res;
    if(sign == LV_SIGNAL_GET_TYPE) return lv_obj_handle_get_type_signal(param, LV_OBJX_NAME);

    if(sign == LV_SIGNAL_CLEANUP) {
        /*Nothing to cleanup. (No dynamically allocated memory in 'ext')*/
    } else if(sign == LV_SIGNAL_PRESSING) {
        lv_calendar_ext_t * ext = lv_obj_get_ext_attr(calendar);
        lv_area_t header_area;
        lv_area_copy(&header_area, &calendar->coords);
        header_area.y2 = header_area.y1 + get_header_height(calendar);

        lv_indev_t * indev = lv_indev_get_act();
        lv_point_t p;
        lv_indev_get_point(indev, &p);

        /*If the header is pressed mark an arrow as pressed*/
        if(lv_area_is_point_on(&header_area, &p)) {
            if(p.x < header_area.x1 + lv_area_get_width(&header_area) / 2) {
                if(ext->btn_pressing != -1) lv_obj_invalidate(calendar);
                ext->btn_pressing = -1;
            } else {
                if(ext->btn_pressing != 1) lv_obj_invalidate(calendar);
                ext->btn_pressing = 1;
            }

            ext->pressed_date.year  = 0;
            ext->pressed_date.month = 0;
            ext->pressed_date.day   = 0;
        }
        /*If a day is pressed save it*/
        else if(calculate_touched_day(calendar, &p)) {
            if(ext->btn_pressing != 0) lv_obj_invalidate(calendar);
            ext->btn_pressing = 0;
        }
        /*ELse set a deafault state*/
        else {
            if(ext->btn_pressing != 0) lv_obj_invalidate(calendar);
            ext->btn_pressing       = 0;
            ext->pressed_date.year  = 0;
            ext->pressed_date.month = 0;
            ext->pressed_date.day   = 0;
        }
    } else if(sign == LV_SIGNAL_PRESS_LOST) {
        lv_calendar_ext_t * ext = lv_obj_get_ext_attr(calendar);
        ext->btn_pressing       = 0;
        lv_obj_invalidate(calendar);

    } else if(sign == LV_SIGNAL_RELEASED) {
        lv_calendar_ext_t * ext = lv_obj_get_ext_attr(calendar);
        if(ext->btn_pressing < 0) {
            if(ext->showed_date.month <= 1) {
                ext->showed_date.month = 12;
                ext->showed_date.year--;
            } else {
                ext->showed_date.month--;
            }
        } else if(ext->btn_pressing > 0) {
            if(ext->showed_date.month >= 12) {
                ext->showed_date.month = 1;
                ext->showed_date.year++;
            } else {
                ext->showed_date.month++;
            }
        } else if(ext->pressed_date.year != 0) {
            res = lv_event_send(calendar, LV_EVENT_VALUE_CHANGED, NULL);
            if(res != LV_RES_OK) return res;
        }

        ext->btn_pressing = 0;
        lv_obj_invalidate(calendar);
    } else if(sign == LV_SIGNAL_CONTROL) {
        uint8_t c               = *((uint8_t *)param);
        lv_calendar_ext_t * ext = lv_obj_get_ext_attr(calendar);
        if(c == LV_KEY_RIGHT || c == LV_KEY_UP) {
            if(ext->showed_date.month >= 12) {
                ext->showed_date.month = 1;
                ext->showed_date.year++;
            } else {
                ext->showed_date.month++;
            }
            lv_obj_invalidate(calendar);
        } else if(c == LV_KEY_LEFT || c == LV_KEY_DOWN) {
            if(ext->showed_date.month <= 1) {
                ext->showed_date.month = 12;
                ext->showed_date.year--;
            } else {
                ext->showed_date.month--;
            }
            lv_obj_invalidate(calendar);
        }
    }

    return res;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x38, %rsp
movq %rdx, %r15
movl %esi, %ebp
movq %rdi, %r14
callq *0x4c801(%rip)          # 0x60370
cmpb $0x1, %al
jne 0x13fac
movzbl %bpl, %eax
movb $0x1, %bl
addl $-0x7, %eax
cmpl $0xb, %eax
ja 0x13fce
leaq 0x2bb8c(%rip), %rcx     # 0x3f71c
movslq (%rcx,%rax,4), %rax
addq %rcx, %rax
jmpq *%rax
leaq 0x2bc57(%rip), %rsi     # 0x3f7f7
movq %r15, %rdi
addq $0x38, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
jmp 0x6c02
movq %r14, %rdi
callq 0x6af7
movb $0x0, 0x10(%rax)
jmp 0x13fc6
movq %r14, %rdi
callq 0x6af7
movq %rax, %rbp
movq 0x20(%r14), %r15
leaq 0x30(%rsp), %r12
movq %r15, (%r12)
shrl $0x10, %r15d
movq %r14, %rdi
callq 0x6af7
movq 0x28(%rax), %rax
movq 0x28(%rax), %rcx
movzbl 0x10(%rcx), %ecx
addl %r15d, %ecx
addw 0x16(%rax), %cx
addw 0x18(%rax), %cx
movw %cx, 0x6(%r12)
callq 0x378a
leaq 0x4(%rsp), %r13
movq %rax, %rdi
movq %r13, %rsi
callq 0x3838
movq %r12, %rdi
movq %r13, %rsi
callq 0x28d87
testb %al, %al
je 0x13ce1
movswl 0x4(%rsp), %ecx
movswl 0x30(%rsp), %eax
movl 0x34(%rsp), %edx
subl %eax, %edx
leal 0x1(%rdx), %esi
movzwl %si, %esi
shrl $0xf, %esi
addl %esi, %edx
incl %edx
movswl %dx, %edx
sarl %edx
addl %eax, %edx
movb 0x10(%rbp), %al
cmpl %ecx, %edx
movq %rbp, %r15
jle 0x13f5a
movb $-0x1, %bpl
cmpb $-0x1, %al
je 0x13c71
movq %r14, %rdi
callq 0x4c4d
movb %bpl, 0x10(%r15)
jmp 0x13f83
movq %r14, %rdi
callq 0x6af7
movq %rax, %r15
cmpb $0x0, 0x10(%rax)
js 0x13f46
je 0x13f91
movb 0x6(%r15), %al
cmpb $0xc, %al
jl 0x13fb0
movb $0x1, 0x6(%r15)
incw 0x4(%r15)
jmp 0x13fba
movzbl (%r15), %ebp
movq %r14, %rdi
callq 0x6af7
movl %ebp, %ecx
andb $-0x3, %cl
cmpb $0x11, %cl
jne 0x13f24
movb 0x6(%rax), %cl
cmpb $0xc, %cl
jl 0x13f8d
incw 0x4(%rax)
movb $0x1, %cl
jmp 0x13fc3
movq %rbp, 0x10(%rsp)
movq 0x20(%r14), %r15
leaq 0x18(%rsp), %r12
movq %r15, (%r12)
movq %r14, %rdi
xorl %esi, %esi
callq 0x14de2
movq %rax, %r13
movzwl 0x1a(%rax), %eax
addw %r15w, %ax
movw %ax, (%r12)
shrq $0x20, %r15
subw 0x1c(%r13), %r15w
movw %r15w, 0x4(%r12)
movzwl 0x22(%r14), %ebp
movq %r14, %rdi
callq 0x6af7
movq 0x28(%rax), %rax
movq 0x28(%rax), %rcx
movzbl 0x10(%rcx), %r15d
addw %bp, %r15w
addw 0x16(%rax), %r15w
addw 0x18(%rax), %r15w
movq %r14, %rdi
callq 0x6af7
movq 0x38(%rax), %rax
movq 0x28(%rax), %rcx
movzbl 0x10(%rcx), %ecx
addl %ecx, %r15d
addw 0x16(%rax), %r15w
addw 0x18(%rax), %r15w
subw 0x16(%r13), %r15w
movw %r15w, 0x2(%r12)
leaq 0x4(%rsp), %rsi
movq %r12, %rdi
callq 0x28d87
testb %al, %al
je 0x13f6a
movswl 0x1c(%rsp), %r15d
movswl 0x18(%rsp), %eax
movl %eax, 0x24(%rsp)
movswl 0x1e(%rsp), %r13d
movswl 0x1a(%rsp), %eax
movl %eax, (%rsp)
movswl 0x4(%rsp), %r12d
movswl 0x6(%rsp), %ebp
movq %r14, %rdi
callq 0x6af7
movzwl 0x4(%rax), %r11d
movzwl %r11w, %edi
movq %rax, 0x28(%rsp)
movsbl 0x6(%rax), %eax
cmpl $0x3, %eax
movl %edi, %esi
sbbl $0x0, %esi
leal 0xc(%rax), %r8d
cmpl $0x3, %eax
movq %rax, 0x8(%rsp)
cmovael %eax, %r8d
movl 0x24(%rsp), %edx
subl %edx, %r15d
movl %r15d, %eax
incl %eax
cltq
imulq $-0x6db6db6d, %rax, %rax # imm = 0x92492493
shrq $0x20, %rax
leal (%rax,%r15), %ecx
incl %ecx
movl %ecx, %eax
shrl $0x1f, %eax
sarl $0x2, %ecx
addl %eax, %ecx
movl (%rsp), %r15d
subl %r15d, %r13d
incl %r13d
movslq %r13d, %rax
imulq $0x2aaaaaab, %rax, %r9  # imm = 0x2AAAAAAB
movq %r9, %rax
shrq $0x3f, %rax
shrq $0x20, %r9
addl %eax, %r9d
subl %edx, %r12d
movl %r12d, %eax
cltd
idivl %ecx
movl %eax, %ecx
movl $0xff, %r12d
movl %eax, %r10d
andl %r12d, %r10d
subl %r15d, %ebp
movl %ebp, %eax
cltd
idivl %r9d
leal (,%rax,8), %edx
subl %eax, %edx
andl $0xfe, %eax
cmpl $0x6, %eax
movl $0x23, %eax
cmovbl %edx, %eax
cmpl $0x7, %r10d
movl $0x6, %ebp
cmovbl %ecx, %ebp
addl %eax, %ebp
andl %ebp, %r12d
movl %r8d, %eax
shll $0x5, %eax
subl %r8d, %eax
addl $-0x3e, %eax
movl $0xaaaaaaab, %ecx       # imm = 0xAAAAAAAB
imulq %rax, %rcx
shrq $0x23, %rcx
movl %esi, %eax
shrl $0x2, %eax
imulq $0x51eb851f, %rsi, %rdx # imm = 0x51EB851F
movq %rdx, %r8
shrq $0x25, %r8
shrq $0x27, %rdx
addl %esi, %eax
subl %r8d, %eax
addl %edx, %eax
addl %ecx, %eax
incl %eax
imulq $0x24924925, %rax, %rcx # imm = 0x24924925
shrq $0x20, %rcx
movl %eax, %r15d
subl %ecx, %r15d
shrl %r15d
addl %ecx, %r15d
shrl $0x2, %r15d
leal (,%r15,8), %ecx
subl %ecx, %r15d
addl %eax, %r15d
cmpl %r15d, %r12d
jae 0x13fdf
movq 0x8(%rsp), %rdx
leal -0x1(%rdx), %eax
xorl %ecx, %ecx
cmpb $0x1, %dl
sete %cl
movzbl %al, %eax
movl $0xc, %edx
cmovnel %eax, %edx
subl %ecx, %r11d
movq 0x28(%rsp), %r13
movw %r11w, 0x14(%r13)
movb %dl, 0x16(%r13)
movzwl %r11w, %edi
movsbl %dl, %esi
callq 0x14e67
subl %r15d, %ebp
addb %al, %bpl
jmp 0x14011
cmpl $0x14, %ebp
je 0x13f32
cmpl $0x12, %ebp
jne 0x13fce
movb 0x6(%rax), %cl
cmpb $0x1, %cl
jg 0x13fc1
decw 0x4(%rax)
movb $0xc, %cl
jmp 0x13fc3
movb 0x6(%r15), %al
cmpb $0x1, %al
jg 0x13fb4
movb $0xc, 0x6(%r15)
decw 0x4(%r15)
jmp 0x13fba
movb $0x1, %bpl
cmpb $0x1, %al
jne 0x13c69
jmp 0x13c71
movq 0x10(%rsp), %r15
cmpb $0x0, 0x10(%r15)
je 0x13f7e
movq %r14, %rdi
callq 0x4c4d
movb $0x0, 0x10(%r15)
movl $0x0, 0x14(%r15)
jmp 0x13fce
incb %cl
jmp 0x13fc3
cmpw $0x0, 0x14(%r15)
je 0x13fba
movq %r14, %rdi
movl $0xe, %esi
xorl %edx, %edx
callq 0x5018
cmpb $0x1, %al
je 0x13fba
movl %eax, %ebx
jmp 0x13fce
incb %al
jmp 0x13fb6
decb %al
movb %al, 0x6(%r15)
movb $0x0, 0x10(%r15)
jmp 0x13fc6
decb %cl
movb %cl, 0x6(%rax)
movq %r14, %rdi
callq 0x4c4d
movl %ebx, %eax
addq $0x38, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movl %r11d, (%rsp)
movq 0x28(%rsp), %r13
movq 0x8(%rsp), %rsi
callq 0x14e67
movzbl %al, %eax
addl %r15d, %eax
cmpl %eax, %r12d
jae 0x14033
movl (%rsp), %eax
movw %ax, 0x14(%r13)
movq 0x8(%rsp), %rax
movb %al, 0x16(%r13)
subb %r15b, %bpl
incb %bpl
movq 0x10(%rsp), %r15
movb %bpl, 0x17(%r13)
cmpb $0x0, 0x10(%r15)
je 0x1402c
movq %r14, %rdi
callq 0x4c4d
movb $0x0, 0x10(%r15)
jmp 0x13fce
movq 0x8(%rsp), %rcx
cmpl $0x29, %r12d
movq 0x10(%rsp), %r15
movl (%rsp), %edi
ja 0x1401d
movq %rcx, %rsi
incl %ecx
xorl %edx, %edx
cmpb $0xc, %sil
sete %dl
movzbl %cl, %ecx
movl $0x1, %esi
cmovnel %ecx, %esi
addl %edx, %edi
movw %di, 0x14(%r13)
movb %sil, 0x16(%r13)
subl %eax, %ebp
incb %bpl
jmp 0x14019