// File: /workspace/github_c_makefile_star2_O0/OnionIoT[P]lv_example/lvgl/src/lv_objx/lv_list.c
// Function: lv_list_signal
static lv_res_t lv_list_signal(lv_obj_t * list, lv_signal_t sign, void * param)
{
    lv_res_t res;

    /* Include the ancient signal function */
    res = ancestor_page_signal(list, 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_RELEASED || sign == LV_SIGNAL_PRESSED || sign == LV_SIGNAL_PRESSING ||
       sign == LV_SIGNAL_LONG_PRESS || sign == LV_SIGNAL_LONG_PRESS_REP) {
#if LV_USE_GROUP
        /*If pressed/released etc by a KEYPAD or ENCODER delegate signal to the button*/
        lv_indev_t * indev         = lv_indev_get_act();
        lv_indev_type_t indev_type = lv_indev_get_type(indev);
        if(indev_type == LV_INDEV_TYPE_KEYPAD ||
           (indev_type == LV_INDEV_TYPE_ENCODER && lv_group_get_editing(lv_obj_get_group(list)))) {
            /*Get the 'pressed' button*/
            lv_obj_t * btn = NULL;
            btn            = lv_list_get_prev_btn(list, btn);
            while(btn != NULL) {
                if(lv_btn_get_state(btn) == LV_BTN_STATE_PR) break;
                btn = lv_list_get_prev_btn(list, btn);
            }
            lv_list_ext_t * ext = lv_obj_get_ext_attr(list);

            /*The page receives the key presses so the events should be propagated to the selected
             * button*/
            if(btn) {
                if(sign == LV_SIGNAL_PRESSED) {
                    res = lv_event_send(btn, LV_EVENT_PRESSED, NULL);
                } else if(sign == LV_SIGNAL_PRESSING) {
                    res = lv_event_send(btn, LV_EVENT_PRESSING, NULL);
                } else if(sign == LV_SIGNAL_LONG_PRESS) {
                    res = lv_event_send(btn, LV_EVENT_LONG_PRESSED, NULL);
                } else if(sign == LV_SIGNAL_LONG_PRESS_REP) {
                    res = lv_event_send(btn, LV_EVENT_LONG_PRESSED_REPEAT, NULL);
                } else if(sign == LV_SIGNAL_RELEASED) {
#if LV_USE_GROUP
                    ext->last_sel = btn;
#endif
                    if(indev->proc.long_pr_sent == 0) {
                        res = lv_event_send(btn, LV_EVENT_SHORT_CLICKED, NULL);
                    }
                    if(lv_indev_is_dragging(indev) == false && res == LV_RES_OK) {
                        res = lv_event_send(btn, LV_EVENT_CLICKED, NULL);
                    }
                    if(res == LV_RES_OK) {
                        res = lv_event_send(btn, LV_EVENT_RELEASED, NULL);
                    }
                }
            }
        }
#endif
    } else if(sign == LV_SIGNAL_FOCUS) {

#if LV_USE_GROUP
        lv_indev_type_t indev_type = lv_indev_get_type(lv_indev_get_act());
        /*With ENCODER select the first button only in edit mode*/
        if(indev_type == LV_INDEV_TYPE_ENCODER) {
            lv_group_t * g = lv_obj_get_group(list);
            if(lv_group_get_editing(g)) {
                lv_list_ext_t * ext = lv_obj_get_ext_attr(list);
                if(ext->last_sel) {
                    /* Select the    last used button */
                    lv_list_set_btn_selected(list, ext->last_sel);
                } else {
                    /*Get the first button and mark it as selected*/
                    lv_list_set_btn_selected(list, lv_list_get_next_btn(list, NULL));
                }
            } else {
                lv_list_set_btn_selected(list, NULL);
            }
        }
        /*Else select the clicked button*/
        else {
            /*Mark the last clicked button (if any) as selected because it triggered the focus*/
            lv_list_ext_t * ext = lv_obj_get_ext_attr(list);
            if(ext->last_clicked_btn) {
                lv_list_set_btn_selected(list, ext->last_clicked_btn);
                ext->last_clicked_btn = NULL;

            } else {
                if(ext->last_sel) {
                    /* Select the last used button */
                    lv_list_set_btn_selected(list, ext->last_sel);
                } else {
                    /*Get the first button and mark it as selected*/
                    lv_list_set_btn_selected(list, lv_list_get_next_btn(list, NULL));
                }
            }
        }
#endif
    } else if(sign == LV_SIGNAL_DEFOCUS) {

#if LV_USE_GROUP
        /*De-select the selected btn*/
        lv_list_set_btn_selected(list, NULL);
        lv_list_ext_t * ext = lv_obj_get_ext_attr(list);
        ext->last_clicked_btn    = NULL; /*button click will be set if click happens before focus*/
        ext->selected_btn   = NULL;
#endif
    } else if(sign == LV_SIGNAL_GET_EDITABLE) {
        bool * editable = (bool *)param;
        *editable       = true;
    } else if(sign == LV_SIGNAL_CONTROL) {

#if LV_USE_GROUP
        char c = *((char *)param);
        if(c == LV_KEY_RIGHT || c == LV_KEY_DOWN) {
            lv_list_ext_t * ext = lv_obj_get_ext_attr(list);
            /*If there is a valid selected button the make the previous selected*/
            if(ext->selected_btn) {
                lv_obj_t * btn_prev = lv_list_get_next_btn(list, ext->selected_btn);
                if(btn_prev) lv_list_set_btn_selected(list, btn_prev);
            }
            /*If there is no selected button the make the first selected*/
            else {
                lv_obj_t * btn = lv_list_get_next_btn(list, NULL);
                if(btn)
                    lv_list_set_btn_selected(list,
                                             btn); /*If there are no buttons on the list then there is no first button*/
            }
        } else if(c == LV_KEY_LEFT || c == LV_KEY_UP) {
            lv_list_ext_t * ext = lv_obj_get_ext_attr(list);
            /*If there is a valid selected button the make the next selected*/
            if(ext->selected_btn != NULL) {
                lv_obj_t * btn_next = lv_list_get_prev_btn(list, ext->selected_btn);
                if(btn_next) lv_list_set_btn_selected(list, btn_next);
            }
            /*If there is no selected button the make the first selected*/
            else {
                lv_obj_t * btn = lv_list_get_next_btn(list, NULL);
                if(btn) lv_list_set_btn_selected(list, btn);
            }
        }
#endif
    }
    return res;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0xc0, %rsp
movb %sil, %al
movq %rdi, -0x10(%rbp)
movb %al, -0x11(%rbp)
movq %rdx, -0x20(%rbp)
movq 0x5c4d8(%rip), %rax     # 0x89488
movq -0x10(%rbp), %rdi
movb -0x11(%rbp), %cl
movq -0x20(%rbp), %rdx
movzbl %cl, %esi
callq *%rax
movb %al, -0x21(%rbp)
movzbl -0x21(%rbp), %eax
cmpl $0x1, %eax
je 0x2cfd7
movb -0x21(%rbp), %al
movb %al, -0x1(%rbp)
jmp 0x2d513
movzbl -0x11(%rbp), %eax
cmpl $0x7, %eax
jne 0x2cff8
movq -0x20(%rbp), %rdi
leaq 0x3b64d(%rip), %rsi     # 0x68638
callq 0xaa80
movb %al, -0x1(%rbp)
jmp 0x2d513
movzbl -0x11(%rbp), %eax
cmpl $0xb, %eax
je 0x2d029
movzbl -0x11(%rbp), %eax
cmpl $0x8, %eax
je 0x2d029
movzbl -0x11(%rbp), %eax
cmpl $0x9, %eax
je 0x2d029
movzbl -0x11(%rbp), %eax
cmpl $0xc, %eax
je 0x2d029
movzbl -0x11(%rbp), %eax
cmpl $0xd, %eax
jne 0x2d1f9
callq 0x4b70
movq %rax, -0x30(%rbp)
movq -0x30(%rbp), %rdi
callq 0x4b80
movb %al, -0x31(%rbp)
movzbl -0x31(%rbp), %eax
cmpl $0x2, %eax
je 0x2d06e
movzbl -0x31(%rbp), %eax
cmpl $0x4, %eax
jne 0x2d1f4
movq -0x10(%rbp), %rdi
callq 0x77c0
movq %rax, %rdi
callq 0x32e0
testb $0x1, %al
jne 0x2d06e
jmp 0x2d1f4
movq $0x0, -0x40(%rbp)
movq -0x10(%rbp), %rdi
movq -0x40(%rbp), %rsi
callq 0x2e1b0
movq %rax, -0x40(%rbp)
cmpq $0x0, -0x40(%rbp)
je 0x2d0b4
movq -0x40(%rbp), %rdi
callq 0x20930
movzbl %al, %eax
cmpl $0x1, %eax
jne 0x2d0a1
jmp 0x2d0b4
movq -0x10(%rbp), %rdi
movq -0x40(%rbp), %rsi
callq 0x2e1b0
movq %rax, -0x40(%rbp)
jmp 0x2d087
movq -0x10(%rbp), %rdi
callq 0xa8f0
movq %rax, -0x48(%rbp)
cmpq $0x0, -0x40(%rbp)
je 0x2d1f2
movzbl -0x11(%rbp), %eax
cmpl $0x8, %eax
jne 0x2d0ec
movq -0x40(%rbp), %rdi
xorl %esi, %esi
xorl %eax, %eax
movl %eax, %edx
callq 0x7990
movb %al, -0x21(%rbp)
jmp 0x2d1f0
movzbl -0x11(%rbp), %eax
cmpl $0x9, %eax
jne 0x2d10f
movq -0x40(%rbp), %rdi
movl $0x1, %esi
xorl %eax, %eax
movl %eax, %edx
callq 0x7990
movb %al, -0x21(%rbp)
jmp 0x2d1ee
movzbl -0x11(%rbp), %eax
cmpl $0xc, %eax
jne 0x2d132
movq -0x40(%rbp), %rdi
movl $0x4, %esi
xorl %eax, %eax
movl %eax, %edx
callq 0x7990
movb %al, -0x21(%rbp)
jmp 0x2d1ec
movzbl -0x11(%rbp), %eax
cmpl $0xd, %eax
jne 0x2d155
movq -0x40(%rbp), %rdi
movl $0x5, %esi
xorl %eax, %eax
movl %eax, %edx
callq 0x7990
movb %al, -0x21(%rbp)
jmp 0x2d1ea
movzbl -0x11(%rbp), %eax
cmpl $0xb, %eax
jne 0x2d1e8
movq -0x40(%rbp), %rcx
movq -0x48(%rbp), %rax
movq %rcx, 0x88(%rax)
movq -0x30(%rbp), %rax
movb 0x78(%rax), %al
andb $0x1, %al
movzbl %al, %eax
cmpl $0x0, %eax
jne 0x2d197
movq -0x40(%rbp), %rdi
movl $0x3, %esi
xorl %eax, %eax
movl %eax, %edx
callq 0x7990
movb %al, -0x21(%rbp)
movq -0x30(%rbp), %rdi
callq 0x4dc0
andb $0x1, %al
movzbl %al, %eax
cmpl $0x0, %eax
jne 0x2d1c8
movzbl -0x21(%rbp), %eax
cmpl $0x1, %eax
jne 0x2d1c8
movq -0x40(%rbp), %rdi
movl $0x6, %esi
xorl %eax, %eax
movl %eax, %edx
callq 0x7990
movb %al, -0x21(%rbp)
movzbl -0x21(%rbp), %eax
cmpl $0x1, %eax
jne 0x2d1e6
movq -0x40(%rbp), %rdi
movl $0x7, %esi
xorl %eax, %eax
movl %eax, %edx
callq 0x7990
movb %al, -0x21(%rbp)
jmp 0x2d1e8
jmp 0x2d1ea
jmp 0x2d1ec
jmp 0x2d1ee
jmp 0x2d1f0
jmp 0x2d1f2
jmp 0x2d1f4
jmp 0x2d50d
movzbl -0x11(%rbp), %eax
cmpl $0x10, %eax
jne 0x2d33f
callq 0x4b70
movq %rax, %rdi
callq 0x4b80
movb %al, -0x49(%rbp)
movzbl -0x49(%rbp), %eax
cmpl $0x4, %eax
jne 0x2d2ab
movq -0x10(%rbp), %rdi
callq 0x77c0
movq %rax, -0x58(%rbp)
movq -0x58(%rbp), %rdi
callq 0x32e0
testb $0x1, %al
jne 0x2d23f
jmp 0x2d299
movq -0x10(%rbp), %rdi
callq 0xa8f0
movq %rax, -0x60(%rbp)
movq -0x60(%rbp), %rax
cmpq $0x0, 0x88(%rax)
je 0x2d270
movq -0x10(%rbp), %rdi
movq -0x60(%rbp), %rax
movq 0x88(%rax), %rsi
callq 0x2def0
jmp 0x2d297
movq -0x10(%rbp), %rax
movq %rax, -0xb8(%rbp)
movq -0x10(%rbp), %rdi
xorl %eax, %eax
movl %eax, %esi
callq 0x2d760
movq -0xb8(%rbp), %rdi
movq %rax, %rsi
callq 0x2def0
jmp 0x2d2a6
movq -0x10(%rbp), %rdi
xorl %eax, %eax
movl %eax, %esi
callq 0x2def0
jmp 0x2d33a
movq -0x10(%rbp), %rdi
callq 0xa8f0
movq %rax, -0x68(%rbp)
movq -0x68(%rbp), %rax
cmpq $0x0, 0x98(%rax)
je 0x2d2eb
movq -0x10(%rbp), %rdi
movq -0x68(%rbp), %rax
movq 0x98(%rax), %rsi
callq 0x2def0
movq -0x68(%rbp), %rax
movq $0x0, 0x98(%rax)
jmp 0x2d338
movq -0x68(%rbp), %rax
cmpq $0x0, 0x88(%rax)
je 0x2d30f
movq -0x10(%rbp), %rdi
movq -0x68(%rbp), %rax
movq 0x88(%rax), %rsi
callq 0x2def0
jmp 0x2d336
movq -0x10(%rbp), %rax
movq %rax, -0xc0(%rbp)
movq -0x10(%rbp), %rdi
xorl %eax, %eax
movl %eax, %esi
callq 0x2d760
movq -0xc0(%rbp), %rdi
movq %rax, %rsi
callq 0x2def0
jmp 0x2d338
jmp 0x2d33a
jmp 0x2d50b
movzbl -0x11(%rbp), %eax
cmpl $0x11, %eax
jne 0x2d385
movq -0x10(%rbp), %rdi
xorl %eax, %eax
movl %eax, %esi
callq 0x2def0
movq -0x10(%rbp), %rdi
callq 0xa8f0
movq %rax, -0x70(%rbp)
movq -0x70(%rbp), %rax
movq $0x0, 0x98(%rax)
movq -0x70(%rbp), %rax
movq $0x0, 0x90(%rax)
jmp 0x2d509
movzbl -0x11(%rbp), %eax
cmpl $0x13, %eax
jne 0x2d3a2
movq -0x20(%rbp), %rax
movq %rax, -0x78(%rbp)
movq -0x78(%rbp), %rax
movb $0x1, (%rax)
jmp 0x2d507
movzbl -0x11(%rbp), %eax
cmpl $0x12, %eax
jne 0x2d505
movq -0x20(%rbp), %rax
movb (%rax), %al
movb %al, -0x79(%rbp)
movsbl -0x79(%rbp), %eax
cmpl $0x13, %eax
je 0x2d3ce
movsbl -0x79(%rbp), %eax
cmpl $0x12, %eax
jne 0x2d45e
movq -0x10(%rbp), %rdi
callq 0xa8f0
movq %rax, -0x88(%rbp)
movq -0x88(%rbp), %rax
cmpq $0x0, 0x90(%rax)
je 0x2d429
movq -0x10(%rbp), %rdi
movq -0x88(%rbp), %rax
movq 0x90(%rax), %rsi
callq 0x2d760
movq %rax, -0x90(%rbp)
cmpq $0x0, -0x90(%rbp)
je 0x2d427
movq -0x10(%rbp), %rdi
movq -0x90(%rbp), %rsi
callq 0x2def0
jmp 0x2d459
movq -0x10(%rbp), %rdi
xorl %eax, %eax
movl %eax, %esi
callq 0x2d760
movq %rax, -0x98(%rbp)
cmpq $0x0, -0x98(%rbp)
je 0x2d457
movq -0x10(%rbp), %rdi
movq -0x98(%rbp), %rsi
callq 0x2def0
jmp 0x2d459
jmp 0x2d503
movsbl -0x79(%rbp), %eax
cmpl $0x14, %eax
je 0x2d474
movsbl -0x79(%rbp), %eax
cmpl $0x11, %eax
jne 0x2d501
movq -0x10(%rbp), %rdi
callq 0xa8f0
movq %rax, -0xa0(%rbp)
movq -0xa0(%rbp), %rax
cmpq $0x0, 0x90(%rax)
je 0x2d4cf
movq -0x10(%rbp), %rdi
movq -0xa0(%rbp), %rax
movq 0x90(%rax), %rsi
callq 0x2e1b0
movq %rax, -0xa8(%rbp)
cmpq $0x0, -0xa8(%rbp)
je 0x2d4cd
movq -0x10(%rbp), %rdi
movq -0xa8(%rbp), %rsi
callq 0x2def0
jmp 0x2d4ff
movq -0x10(%rbp), %rdi
xorl %eax, %eax
movl %eax, %esi
callq 0x2d760
movq %rax, -0xb0(%rbp)
cmpq $0x0, -0xb0(%rbp)
je 0x2d4fd
movq -0x10(%rbp), %rdi
movq -0xb0(%rbp), %rsi
callq 0x2def0
jmp 0x2d4ff
jmp 0x2d501
jmp 0x2d503
jmp 0x2d505
jmp 0x2d507
jmp 0x2d509
jmp 0x2d50b
jmp 0x2d50d
movb -0x21(%rbp), %al
movb %al, -0x1(%rbp)
movb -0x1(%rbp), %al
addq $0xc0, %rsp
popq %rbp
retq
nop