// File: /workspace/github_c_makefile_star2_O0/OnionIoT[P]lv_example/lvgl/src/lv_objx/lv_calendar.c
// Function: calculate_touched_day
static bool calculate_touched_day(lv_obj_t * calendar, const lv_point_t * touched_point)
{
    lv_area_t days_area;
    lv_area_copy(&days_area, &calendar->coords);
    const lv_style_t * style_bg = lv_calendar_get_style(calendar, LV_CALENDAR_STYLE_BG);
    days_area.x1 += style_bg->body.padding.left;
    days_area.x2 -= style_bg->body.padding.right;
    days_area.y1 =
        calendar->coords.y1 + get_header_height(calendar) + get_day_names_height(calendar) - style_bg->body.padding.top;

    if(lv_area_is_point_on(&days_area, touched_point)) {
        lv_coord_t w  = (days_area.x2 - days_area.x1 + 1) / 7;
        lv_coord_t h  = (days_area.y2 - days_area.y1 + 1) / 6;
        uint8_t x_pos = 0;
        x_pos         = (touched_point->x - days_area.x1) / w;
        if(x_pos > 6) x_pos = 6;
        uint8_t y_pos = 0;
        y_pos         = (touched_point->y - days_area.y1) / h;
        if(y_pos > 5) y_pos = 5;

        uint8_t i_pos           = 0;
        i_pos                   = (y_pos * 7) + x_pos;
        lv_calendar_ext_t * ext = lv_obj_get_ext_attr(calendar);
        if(i_pos < get_day_of_week(ext->showed_date.year, ext->showed_date.month, 1)) {
            ext->pressed_date.year  = ext->showed_date.year - (ext->showed_date.month == 1 ? 1 : 0);
            ext->pressed_date.month = ext->showed_date.month == 1 ? 12 : (ext->showed_date.month - 1);
            ext->pressed_date.day   = get_month_length(ext->pressed_date.year, ext->pressed_date.month) -
                                    get_day_of_week(ext->showed_date.year, ext->showed_date.month, 1) + 1 + i_pos;
        } else if(i_pos < (get_day_of_week(ext->showed_date.year, ext->showed_date.month, 1) +
                           get_month_length(ext->showed_date.year, ext->showed_date.month))) {
            ext->pressed_date.year  = ext->showed_date.year;
            ext->pressed_date.month = ext->showed_date.month;
            ext->pressed_date.day   = i_pos + 1 - get_day_of_week(ext->showed_date.year, ext->showed_date.month, 1);
        } else if(i_pos < 42) {
            ext->pressed_date.year  = ext->showed_date.year + (ext->showed_date.month == 12 ? 1 : 0);
            ext->pressed_date.month = ext->showed_date.month == 12 ? 1 : (ext->showed_date.month + 1);
            ext->pressed_date.day   = i_pos + 1 - get_day_of_week(ext->showed_date.year, ext->showed_date.month, 1) -
                                    get_month_length(ext->showed_date.year, ext->showed_date.month);
        }
        return true;
    } else {
        return false;
    }
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x70, %rsp
movq %rdi, -0x10(%rbp)
movq %rsi, -0x18(%rbp)
movq -0x10(%rbp), %rsi
addq $0x20, %rsi
leaq -0x20(%rbp), %rdi
callq 0x22a50
movq -0x10(%rbp), %rdi
xorl %esi, %esi
callq 0x21b80
movq %rax, -0x28(%rbp)
movq -0x28(%rbp), %rax
movswl 0x1a(%rax), %ecx
movswl -0x20(%rbp), %eax
addl %ecx, %eax
movw %ax, -0x20(%rbp)
movq -0x28(%rbp), %rax
movswl 0x1c(%rax), %ecx
movswl -0x1c(%rbp), %eax
subl %ecx, %eax
movw %ax, -0x1c(%rbp)
movq -0x10(%rbp), %rax
movswl 0x22(%rax), %eax
movl %eax, -0x40(%rbp)
movq -0x10(%rbp), %rdi
callq 0x227d0
movw %ax, %cx
movl -0x40(%rbp), %eax
movswl %cx, %ecx
addl %ecx, %eax
movl %eax, -0x3c(%rbp)
movq -0x10(%rbp), %rdi
callq 0x22f70
movw %ax, %cx
movl -0x3c(%rbp), %eax
movswl %cx, %ecx
addl %ecx, %eax
movq -0x28(%rbp), %rcx
movswl 0x16(%rcx), %ecx
subl %ecx, %eax
movw %ax, -0x1e(%rbp)
movq -0x18(%rbp), %rsi
leaq -0x20(%rbp), %rdi
callq 0x42a00
testb $0x1, %al
jne 0x22c5e
jmp 0x22f56
movswl -0x1c(%rbp), %eax
movswl -0x20(%rbp), %ecx
subl %ecx, %eax
addl $0x1, %eax
movl $0x7, %ecx
cltd
idivl %ecx
movw %ax, -0x2a(%rbp)
movswl -0x1a(%rbp), %eax
movswl -0x1e(%rbp), %ecx
subl %ecx, %eax
addl $0x1, %eax
movl $0x6, %ecx
cltd
idivl %ecx
movw %ax, -0x2c(%rbp)
movb $0x0, -0x2d(%rbp)
movq -0x18(%rbp), %rax
movswl (%rax), %eax
movswl -0x20(%rbp), %ecx
subl %ecx, %eax
movswl -0x2a(%rbp), %ecx
cltd
idivl %ecx
movb %al, -0x2d(%rbp)
movzbl -0x2d(%rbp), %eax
cmpl $0x6, %eax
jle 0x22cb8
movb $0x6, -0x2d(%rbp)
movb $0x0, -0x2e(%rbp)
movq -0x18(%rbp), %rax
movswl 0x2(%rax), %eax
movswl -0x1e(%rbp), %ecx
subl %ecx, %eax
movswl -0x2c(%rbp), %ecx
cltd
idivl %ecx
movb %al, -0x2e(%rbp)
movzbl -0x2e(%rbp), %eax
cmpl $0x5, %eax
jle 0x22ce1
movb $0x5, -0x2e(%rbp)
movb $0x0, -0x2f(%rbp)
movzbl -0x2e(%rbp), %eax
imull $0x7, %eax, %eax
movzbl -0x2d(%rbp), %ecx
addl %ecx, %eax
movb %al, -0x2f(%rbp)
movq -0x10(%rbp), %rdi
callq 0xa8f0
movq %rax, -0x38(%rbp)
movzbl -0x2f(%rbp), %eax
movl %eax, -0x44(%rbp)
movq -0x38(%rbp), %rax
movzwl 0x4(%rax), %edi
movq -0x38(%rbp), %rax
movsbl 0x6(%rax), %esi
movl $0x1, %edx
callq 0x22920
movb %al, %cl
movl -0x44(%rbp), %eax
movzbl %cl, %ecx
cmpl %ecx, %eax
jge 0x22de4
movq -0x38(%rbp), %rax
movzwl 0x4(%rax), %eax
movq -0x38(%rbp), %rcx
movsbl 0x6(%rcx), %esi
xorl %ecx, %ecx
movl $0x1, %edx
cmpl $0x1, %esi
cmovel %edx, %ecx
subl %ecx, %eax
movw %ax, %cx
movq -0x38(%rbp), %rax
movw %cx, 0x14(%rax)
movq -0x38(%rbp), %rax
movsbl 0x6(%rax), %eax
cmpl $0x1, %eax
jne 0x22d74
movl $0xc, %eax
movl %eax, -0x48(%rbp)
jmp 0x22d82
movq -0x38(%rbp), %rax
movsbl 0x6(%rax), %eax
subl $0x1, %eax
movl %eax, -0x48(%rbp)
movl -0x48(%rbp), %eax
movb %al, %cl
movq -0x38(%rbp), %rax
movb %cl, 0x16(%rax)
movq -0x38(%rbp), %rax
movzwl 0x14(%rax), %edi
movq -0x38(%rbp), %rax
movsbl 0x16(%rax), %esi
callq 0x229c0
movzbl %al, %eax
movl %eax, -0x4c(%rbp)
movq -0x38(%rbp), %rax
movzwl 0x4(%rax), %edi
movq -0x38(%rbp), %rax
movsbl 0x6(%rax), %esi
movl $0x1, %edx
callq 0x22920
movb %al, %cl
movl -0x4c(%rbp), %eax
movzbl %cl, %ecx
subl %ecx, %eax
addl $0x1, %eax
movzbl -0x2f(%rbp), %ecx
addl %ecx, %eax
movb %al, %cl
movq -0x38(%rbp), %rax
movb %cl, 0x17(%rax)
jmp 0x22f50
movzbl -0x2f(%rbp), %eax
movl %eax, -0x50(%rbp)
movq -0x38(%rbp), %rax
movzwl 0x4(%rax), %edi
movq -0x38(%rbp), %rax
movsbl 0x6(%rax), %esi
movl $0x1, %edx
callq 0x22920
movzbl %al, %eax
movl %eax, -0x54(%rbp)
movq -0x38(%rbp), %rax
movzwl 0x4(%rax), %edi
movq -0x38(%rbp), %rax
movsbl 0x6(%rax), %esi
callq 0x229c0
movl -0x54(%rbp), %ecx
movb %al, %dl
movl -0x50(%rbp), %eax
movzbl %dl, %edx
addl %edx, %ecx
cmpl %ecx, %eax
jge 0x22e8b
movq -0x38(%rbp), %rax
movw 0x4(%rax), %cx
movq -0x38(%rbp), %rax
movw %cx, 0x14(%rax)
movq -0x38(%rbp), %rax
movb 0x6(%rax), %cl
movq -0x38(%rbp), %rax
movb %cl, 0x16(%rax)
movzbl -0x2f(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x58(%rbp)
movq -0x38(%rbp), %rax
movzwl 0x4(%rax), %edi
movq -0x38(%rbp), %rax
movsbl 0x6(%rax), %esi
movl $0x1, %edx
callq 0x22920
movb %al, %cl
movl -0x58(%rbp), %eax
movzbl %cl, %ecx
subl %ecx, %eax
movb %al, %cl
movq -0x38(%rbp), %rax
movb %cl, 0x17(%rax)
jmp 0x22f4e
movzbl -0x2f(%rbp), %eax
cmpl $0x2a, %eax
jge 0x22f4c
movq -0x38(%rbp), %rax
movzwl 0x4(%rax), %eax
movq -0x38(%rbp), %rcx
movsbl 0x6(%rcx), %esi
xorl %ecx, %ecx
movl $0x1, %edx
cmpl $0xc, %esi
cmovel %edx, %ecx
addl %ecx, %eax
movw %ax, %cx
movq -0x38(%rbp), %rax
movw %cx, 0x14(%rax)
movq -0x38(%rbp), %rax
movsbl 0x6(%rax), %eax
cmpl $0xc, %eax
jne 0x22ed9
movl $0x1, %eax
movl %eax, -0x5c(%rbp)
jmp 0x22ee7
movq -0x38(%rbp), %rax
movsbl 0x6(%rax), %eax
addl $0x1, %eax
movl %eax, -0x5c(%rbp)
movl -0x5c(%rbp), %eax
movb %al, %cl
movq -0x38(%rbp), %rax
movb %cl, 0x16(%rax)
movzbl -0x2f(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x64(%rbp)
movq -0x38(%rbp), %rax
movzwl 0x4(%rax), %edi
movq -0x38(%rbp), %rax
movsbl 0x6(%rax), %esi
movl $0x1, %edx
callq 0x22920
movb %al, %cl
movl -0x64(%rbp), %eax
movzbl %cl, %ecx
subl %ecx, %eax
movl %eax, -0x60(%rbp)
movq -0x38(%rbp), %rax
movzwl 0x4(%rax), %edi
movq -0x38(%rbp), %rax
movsbl 0x6(%rax), %esi
callq 0x229c0
movb %al, %cl
movl -0x60(%rbp), %eax
movzbl %cl, %ecx
subl %ecx, %eax
movb %al, %cl
movq -0x38(%rbp), %rax
movb %cl, 0x17(%rax)
jmp 0x22f4e
jmp 0x22f50
movb $0x1, -0x1(%rbp)
jmp 0x22f5a
movb $0x0, -0x1(%rbp)
movb -0x1(%rbp), %al
andb $0x1, %al
addq $0x70, %rsp
popq %rbp
retq
nopw %cs:(%rax,%rax)