// File: /workspace/github_c_makefile_star2_O1/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 $0x48, %rsp
movq %rdx, %r15
movl %esi, %ebp
movq %rdi, %r14
callq *0x4c7dd(%rip)          # 0x60370
movl %eax, %ebx
cmpb $0x1, %al
jne 0x14058
movzbl %bpl, %eax
addl $-0x7, %eax
cmpl $0xb, %eax
ja 0x14058
leaq 0x2ba4c(%rip), %rcx     # 0x3f600
movslq (%rcx,%rax,4), %rax
addq %rcx, %rax
jmpq *%rax
leaq 0x2bb17(%rip), %rsi     # 0x3f6db
movq %r15, %rdi
addq $0x48, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
jmp 0x6bf5
movq %r14, %rdi
callq 0x6ad8
movb $0x0, 0x10(%rax)
jmp 0x13fd2
movq %r14, %rdi
callq 0x6ad8
movq %rax, %r15
movq 0x20(%r14), %rax
leaq 0x40(%rsp), %r12
movq %rax, (%r12)
movzwl 0x2(%r12), %ebp
movq %r14, %rdi
callq 0x6ad8
movq 0x28(%rax), %rax
movq 0x28(%rax), %rcx
movzbl 0x10(%rcx), %ecx
addw %bp, %cx
addw 0x16(%rax), %cx
addw 0x18(%rax), %cx
movw %cx, 0x6(%r12)
callq 0x3784
leaq 0x14(%rsp), %r13
movq %rax, %rdi
movq %r13, %rsi
callq 0x3832
movq %r12, %rdi
movq %r13, %rsi
callq 0x28702
testb %al, %al
je 0x13d07
movswl 0x14(%rsp), %ecx
movswl 0x40(%rsp), %eax
movl 0x44(%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(%r15), %al
cmpl %ecx, %edx
jle 0x13f7c
movb $-0x1, %bpl
cmpb $-0x1, %al
je 0x13c95
movq %r14, %rdi
callq 0x4c36
movb %bpl, 0x10(%r15)
jmp 0x14050
movq %r14, %rdi
callq 0x6ad8
movq %rax, %r15
cmpb $0x0, 0x10(%rax)
js 0x13f68
je 0x13f9a
movb 0x6(%r15), %al
cmpb $0xc, %al
jl 0x13fbc
movb $0x1, 0x6(%r15)
incw 0x4(%r15)
jmp 0x13fc6
movzbl (%r15), %ebp
movq %r14, %rdi
callq 0x6ad8
movl %ebp, %ecx
andb $-0x3, %cl
cmpb $0x11, %cl
jne 0x13f48
movb 0x6(%rax), %cl
cmpb $0xc, %cl
jl 0x13f96
movb $0x1, 0x6(%rax)
incw 0x4(%rax)
jmp 0x13fd2
movq %r15, 0x20(%rsp)
movq 0x20(%r14), %rax
leaq 0x28(%rsp), %r12
movq %rax, (%r12)
movq %r14, %rdi
xorl %esi, %esi
callq 0x14e31
movq %rax, %r13
movzwl 0x1a(%rax), %eax
addw %ax, (%r12)
movzwl 0x1c(%r13), %eax
subw %ax, 0x4(%r12)
movzwl 0x22(%r14), %ebp
movq %r14, %rdi
callq 0x6ad8
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 0x6ad8
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 0x14(%rsp), %rsi
movq %r12, %rdi
callq 0x28702
testb %al, %al
je 0x13f8c
movb %al, 0xf(%rsp)
movswl 0x2c(%rsp), %r15d
movswl 0x28(%rsp), %eax
movl %eax, 0x34(%rsp)
movswl 0x2e(%rsp), %r13d
movswl 0x2a(%rsp), %eax
movl %eax, 0x10(%rsp)
movswl 0x14(%rsp), %r12d
movswl 0x16(%rsp), %ebp
movq %r14, %rdi
callq 0x6ad8
movzwl 0x4(%rax), %r11d
movzwl %r11w, %edi
movq %rax, 0x38(%rsp)
movsbl 0x6(%rax), %eax
cmpl $0x3, %eax
movl %edi, %esi
sbbl $0x0, %esi
leal 0xc(%rax), %r8d
cmpl $0x3, %eax
movq %rax, 0x18(%rsp)
cmovael %eax, %r8d
movl 0x34(%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 0x10(%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 0x13fdc
movq 0x18(%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 0x38(%rsp), %r13
movw %r11w, 0x14(%r13)
movb %dl, 0x16(%r13)
movzwl %r11w, %edi
movsbl %dl, %esi
callq 0x14eb6
subl %r15d, %ebp
addb %al, %bpl
jmp 0x14010
cmpl $0x14, %ebp
je 0x13f56
cmpl $0x12, %ebp
jne 0x14058
movb 0x6(%rax), %cl
cmpb $0x1, %cl
jg 0x13fcd
movb $0xc, 0x6(%rax)
decw 0x4(%rax)
jmp 0x13fd2
movb 0x6(%r15), %al
cmpb $0x1, %al
jg 0x13fc0
movb $0xc, 0x6(%r15)
decw 0x4(%r15)
jmp 0x13fc6
movb $0x1, %bpl
cmpb $0x1, %al
jne 0x13c8d
jmp 0x13c95
movq 0x20(%rsp), %r15
jmp 0x1403c
incb %cl
jmp 0x13fcf
cmpw $0x0, 0x14(%r15)
je 0x13fc6
movq %r14, %rdi
movl $0xe, %esi
xorl %edx, %edx
callq 0x4fea
movl %eax, %ebx
cmpb $0x1, %al
je 0x13fc6
jmp 0x14058
incb %al
jmp 0x13fc2
decb %al
movb %al, 0x6(%r15)
movb $0x0, 0x10(%r15)
jmp 0x13fd2
decb %cl
movb %cl, 0x6(%rax)
movq %r14, %rdi
callq 0x4c36
jmp 0x14058
movl %r11d, 0x10(%rsp)
movq 0x38(%rsp), %r13
movq 0x18(%rsp), %rsi
callq 0x14eb6
movzbl %al, %eax
addl %r15d, %eax
cmpl %eax, %r12d
jae 0x14069
movl 0x10(%rsp), %eax
movw %ax, 0x14(%r13)
movq 0x18(%rsp), %rax
movb %al, 0x16(%r13)
subb %r15b, %bpl
incb %bpl
movq 0x20(%rsp), %r15
movb 0xf(%rsp), %dil
movb %bpl, 0x17(%r13)
testb %dil, %dil
je 0x1403c
cmpb $0x0, 0x10(%r15)
je 0x14035
movq %r14, %rdi
callq 0x4c36
movb $0x0, 0x10(%r15)
jmp 0x14058
cmpb $0x0, 0x10(%r15)
je 0x1404b
movq %r14, %rdi
callq 0x4c36
movb $0x0, 0x10(%r15)
movl $0x0, 0x14(%r15)
movl %ebx, %eax
addq $0x48, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq 0x18(%rsp), %rcx
cmpl $0x29, %r12d
movq 0x20(%rsp), %r15
movb 0xf(%rsp), %dil
movl 0x10(%rsp), %r8d
ja 0x14021
movq %rcx, %rsi
incl %ecx
xorl %edx, %edx
cmpb $0xc, %sil
sete %dl
movzbl %cl, %ecx
movl $0x1, %esi
cmovnel %ecx, %esi
addl %edx, %r8d
movw %r8w, 0x14(%r13)
movb %sil, 0x16(%r13)
subl %eax, %ebp
incb %bpl
jmp 0x1401d