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

    /* Include the ancient signal function */
    res = ancestor_signal(btn, 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);

    lv_btn_ext_t * ext = lv_obj_get_ext_attr(btn);
    bool tgl           = lv_btn_get_toggle(btn);

    if(sign == LV_SIGNAL_PRESSED) {
        /*Refresh the state*/
        if(ext->state == LV_BTN_STATE_REL) {
            lv_btn_set_state(btn, LV_BTN_STATE_PR);
#if LV_USE_ANIMATION && LV_BTN_INK_EFFECT
            ink_bg_state  = LV_BTN_STATE_REL;
            ink_top_state = LV_BTN_STATE_PR;
#endif
        } else if(ext->state == LV_BTN_STATE_TGL_REL) {
            lv_btn_set_state(btn, LV_BTN_STATE_TGL_PR);
#if LV_USE_ANIMATION && LV_BTN_INK_EFFECT
            ink_bg_state  = LV_BTN_STATE_TGL_REL;
            ink_top_state = LV_BTN_STATE_TGL_PR;
#endif
        }

#if LV_USE_ANIMATION && LV_BTN_INK_EFFECT
        /*Forget the old inked button*/
        if(ink_obj != NULL && ink_obj != btn) {
            lv_anim_del(ink_obj, (lv_anim_exec_xcb_t)lv_btn_ink_effect_anim);
            lv_obj_invalidate(ink_obj);
            ink_obj = NULL;
        }
        /*Save the new data for inking and start it's animation if enabled*/
        if(ext->ink_in_time > 0) {
            ink_obj      = btn;
            ink_playback = false;
            ink_ready    = false;
            lv_indev_get_point(lv_indev_get_act(), &ink_point);

            lv_anim_t a;
            a.var            = btn;
            a.start          = 0;
            a.end            = LV_BTN_INK_VALUE_MAX;
            a.exec_cb        = (lv_anim_exec_xcb_t)lv_btn_ink_effect_anim;
            a.path_cb        = lv_anim_path_linear;
            a.ready_cb       = lv_btn_ink_effect_anim_ready;
            a.act_time       = 0;
            a.time           = ext->ink_in_time;
            a.playback       = 0;
            a.playback_pause = 0;
            a.repeat         = 0;
            a.repeat_pause   = 0;
            lv_anim_create(&a);
        }
#endif
    } else if(sign == LV_SIGNAL_PRESS_LOST) {
        /*Refresh the state*/
        if(ext->state == LV_BTN_STATE_PR)
            lv_btn_set_state(btn, LV_BTN_STATE_REL);
        else if(ext->state == LV_BTN_STATE_TGL_PR)
            lv_btn_set_state(btn, LV_BTN_STATE_TGL_REL);
    } else if(sign == LV_SIGNAL_PRESSING) {
        /*When the button begins to drag revert pressed states to released*/
        if(lv_indev_is_dragging(param) != false) {
            if(ext->state == LV_BTN_STATE_PR)
                lv_btn_set_state(btn, LV_BTN_STATE_REL);
            else if(ext->state == LV_BTN_STATE_TGL_PR)
                lv_btn_set_state(btn, LV_BTN_STATE_TGL_REL);
        }
    } else if(sign == LV_SIGNAL_RELEASED) {
        /*If not dragged and it was not long press action then
         *change state and run the action*/
        if(lv_indev_is_dragging(param) == false) {
            uint32_t toggled = 0;
            if(ext->state == LV_BTN_STATE_PR && tgl == false) {
                lv_btn_set_state(btn, LV_BTN_STATE_REL);
                toggled = 0;
            } else if(ext->state == LV_BTN_STATE_TGL_PR && tgl == false) {
                lv_btn_set_state(btn, LV_BTN_STATE_TGL_REL);
                toggled = 1;
            } else if(ext->state == LV_BTN_STATE_PR && tgl == true) {
                lv_btn_set_state(btn, LV_BTN_STATE_TGL_REL);
                toggled = 1;
            } else if(ext->state == LV_BTN_STATE_TGL_PR && tgl == true) {
                lv_btn_set_state(btn, LV_BTN_STATE_REL);
                toggled = 0;
            }

            if(tgl) {
                res = lv_event_send(btn, LV_EVENT_VALUE_CHANGED, &toggled);
                if(res != LV_RES_OK) return res;
            }

        } else { /*If dragged change back the state*/
            if(ext->state == LV_BTN_STATE_PR) {
                lv_btn_set_state(btn, LV_BTN_STATE_REL);
            } else if(ext->state == LV_BTN_STATE_TGL_PR) {
                lv_btn_set_state(btn, LV_BTN_STATE_TGL_REL);
            }
        }

#if LV_USE_ANIMATION && LV_BTN_INK_EFFECT
        /*Draw the toggled state in the inking instead*/
        if(ext->toggle) {
            ink_top_state = ext->state;
        }
        /*If not a toggle button and the "IN" inking is ready then start an "OUT" inking*/
        else if(ink_ready && ext->ink_out_time > 0) {
            ink_obj      = btn;
            ink_playback = true; /*It is the playback. If not set `lv_btn_ink_effect_anim_ready`
                                    will start its own playback*/
            lv_indev_get_point(lv_indev_get_act(), &ink_point);

            lv_anim_t a;
            a.var            = ink_obj;
            a.start          = LV_BTN_INK_VALUE_MAX;
            a.end            = 0;
            a.exec_cb        = (lv_anim_exec_xcb_t)lv_btn_ink_effect_anim;
            a.path_cb        = lv_anim_path_linear;
            a.ready_cb       = lv_btn_ink_effect_anim_ready;
            a.act_time       = 0;
            a.time           = ext->ink_out_time;
            a.playback       = 0;
            a.playback_pause = 0;
            a.repeat         = 0;
            a.repeat_pause   = 0;
            lv_anim_create(&a);
        }
#endif
    } else if(sign == LV_SIGNAL_CONTROL) {
        char c = *((char *)param);
        if(c == LV_KEY_RIGHT || c == LV_KEY_UP) {
            if(lv_btn_get_toggle(btn)) {
                lv_btn_set_state(btn, LV_BTN_STATE_TGL_REL);

                uint32_t state = 1;
                res            = lv_event_send(btn, LV_EVENT_VALUE_CHANGED, &state);
                if(res != LV_RES_OK) return res;
            }

        } else if(c == LV_KEY_LEFT || c == LV_KEY_DOWN) {
            if(lv_btn_get_toggle(btn)) {
                lv_btn_set_state(btn, LV_BTN_STATE_REL);

                uint32_t state = 0;
                res            = lv_event_send(btn, LV_EVENT_VALUE_CHANGED, &state);
                if(res != LV_RES_OK) return res;
            }
        }
    } else if(sign == LV_SIGNAL_CLEANUP) {
#if LV_USE_ANIMATION && LV_BTN_INK_EFFECT
        if(btn == ink_obj) {
            lv_anim_del(ink_obj, (lv_anim_exec_xcb_t)lv_btn_ink_effect_anim);
            ink_obj = NULL;
        }
#endif
    }

    return res;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x50, %rsp
movb %sil, %al
movq %rdi, -0x10(%rbp)
movb %al, -0x11(%rbp)
movq %rdx, -0x20(%rbp)
movq 0x692e3(%rip), %rax     # 0x89430
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 0x20174
movb -0x21(%rbp), %al
movb %al, -0x1(%rbp)
jmp 0x2051d
movzbl -0x11(%rbp), %eax
cmpl $0x7, %eax
jne 0x20195
movq -0x20(%rbp), %rdi
leaq 0x48374(%rip), %rsi     # 0x684fc
callq 0xaa80
movb %al, -0x1(%rbp)
jmp 0x2051d
movq -0x10(%rbp), %rdi
callq 0xa8f0
movq %rax, -0x30(%rbp)
movq -0x10(%rbp), %rdi
callq 0x20980
andb $0x1, %al
movb %al, -0x31(%rbp)
movzbl -0x11(%rbp), %eax
cmpl $0x8, %eax
jne 0x20200
movq -0x30(%rbp), %rax
movb 0x30(%rax), %al
andb $0x7, %al
movzbl %al, %eax
cmpl $0x0, %eax
jne 0x201da
movq -0x10(%rbp), %rdi
movl $0x1, %esi
callq 0x20730
jmp 0x201fb
movq -0x30(%rbp), %rax
movb 0x30(%rax), %al
andb $0x7, %al
movzbl %al, %eax
cmpl $0x2, %eax
jne 0x201f9
movq -0x10(%rbp), %rdi
movl $0x3, %esi
callq 0x20730
jmp 0x201fb
jmp 0x20517
movzbl -0x11(%rbp), %eax
cmpl $0xa, %eax
jne 0x2024d
movq -0x30(%rbp), %rax
movb 0x30(%rax), %al
andb $0x7, %al
movzbl %al, %eax
cmpl $0x1, %eax
jne 0x20227
movq -0x10(%rbp), %rdi
xorl %esi, %esi
callq 0x20730
jmp 0x20248
movq -0x30(%rbp), %rax
movb 0x30(%rax), %al
andb $0x7, %al
movzbl %al, %eax
cmpl $0x3, %eax
jne 0x20246
movq -0x10(%rbp), %rdi
movl $0x2, %esi
callq 0x20730
jmp 0x20248
jmp 0x20515
movzbl -0x11(%rbp), %eax
cmpl $0x9, %eax
jne 0x202af
movq -0x20(%rbp), %rdi
callq 0x4dc0
andb $0x1, %al
movzbl %al, %eax
cmpl $0x0, %eax
je 0x202aa
movq -0x30(%rbp), %rax
movb 0x30(%rax), %al
andb $0x7, %al
movzbl %al, %eax
cmpl $0x1, %eax
jne 0x20287
movq -0x10(%rbp), %rdi
xorl %esi, %esi
callq 0x20730
jmp 0x202a8
movq -0x30(%rbp), %rax
movb 0x30(%rax), %al
andb $0x7, %al
movzbl %al, %eax
cmpl $0x3, %eax
jne 0x202a6
movq -0x10(%rbp), %rdi
movl $0x2, %esi
callq 0x20730
jmp 0x202a8
jmp 0x202aa
jmp 0x20513
movzbl -0x11(%rbp), %eax
cmpl $0xb, %eax
jne 0x20428
movq -0x20(%rbp), %rdi
callq 0x4dc0
andb $0x1, %al
movzbl %al, %eax
cmpl $0x0, %eax
jne 0x203e2
movl $0x0, -0x38(%rbp)
movq -0x30(%rbp), %rax
movb 0x30(%rax), %al
andb $0x7, %al
movzbl %al, %eax
cmpl $0x1, %eax
jne 0x2030f
movb -0x31(%rbp), %al
andb $0x1, %al
movzbl %al, %eax
cmpl $0x0, %eax
jne 0x2030f
movq -0x10(%rbp), %rdi
xorl %esi, %esi
callq 0x20730
movl $0x0, -0x38(%rbp)
jmp 0x203af
movq -0x30(%rbp), %rax
movb 0x30(%rax), %al
andb $0x7, %al
movzbl %al, %eax
cmpl $0x3, %eax
jne 0x20344
movb -0x31(%rbp), %al
andb $0x1, %al
movzbl %al, %eax
cmpl $0x0, %eax
jne 0x20344
movq -0x10(%rbp), %rdi
movl $0x2, %esi
callq 0x20730
movl $0x1, -0x38(%rbp)
jmp 0x203ad
movq -0x30(%rbp), %rax
movb 0x30(%rax), %al
andb $0x7, %al
movzbl %al, %eax
cmpl $0x1, %eax
jne 0x20379
movb -0x31(%rbp), %al
andb $0x1, %al
movzbl %al, %eax
cmpl $0x1, %eax
jne 0x20379
movq -0x10(%rbp), %rdi
movl $0x2, %esi
callq 0x20730
movl $0x1, -0x38(%rbp)
jmp 0x203ab
movq -0x30(%rbp), %rax
movb 0x30(%rax), %al
andb $0x7, %al
movzbl %al, %eax
cmpl $0x3, %eax
jne 0x203a9
movb -0x31(%rbp), %al
andb $0x1, %al
movzbl %al, %eax
cmpl $0x1, %eax
jne 0x203a9
movq -0x10(%rbp), %rdi
xorl %esi, %esi
callq 0x20730
movl $0x0, -0x38(%rbp)
jmp 0x203ab
jmp 0x203ad
jmp 0x203af
testb $0x1, -0x31(%rbp)
je 0x203e0
movq -0x10(%rbp), %rdi
movl $0xe, %esi
leaq -0x38(%rbp), %rdx
callq 0x7990
movb %al, -0x21(%rbp)
movzbl -0x21(%rbp), %eax
cmpl $0x1, %eax
je 0x203de
movb -0x21(%rbp), %al
movb %al, -0x1(%rbp)
jmp 0x2051d
jmp 0x203e0
jmp 0x20423
movq -0x30(%rbp), %rax
movb 0x30(%rax), %al
andb $0x7, %al
movzbl %al, %eax
cmpl $0x1, %eax
jne 0x20400
movq -0x10(%rbp), %rdi
xorl %esi, %esi
callq 0x20730
jmp 0x20421
movq -0x30(%rbp), %rax
movb 0x30(%rax), %al
andb $0x7, %al
movzbl %al, %eax
cmpl $0x3, %eax
jne 0x2041f
movq -0x10(%rbp), %rdi
movl $0x2, %esi
callq 0x20730
jmp 0x20421
jmp 0x20423
jmp 0x20511
movzbl -0x11(%rbp), %eax
cmpl $0x12, %eax
jne 0x20502
movq -0x20(%rbp), %rax
movb (%rax), %al
movb %al, -0x39(%rbp)
movsbl -0x39(%rbp), %eax
cmpl $0x13, %eax
je 0x20450
movsbl -0x39(%rbp), %eax
cmpl $0x11, %eax
jne 0x204a1
movq -0x10(%rbp), %rdi
callq 0x20980
testb $0x1, %al
jne 0x2045f
jmp 0x2049f
movq -0x10(%rbp), %rdi
movl $0x2, %esi
callq 0x20730
movl $0x1, -0x40(%rbp)
movq -0x10(%rbp), %rdi
movl $0xe, %esi
leaq -0x40(%rbp), %rdx
callq 0x7990
movb %al, -0x21(%rbp)
movzbl -0x21(%rbp), %eax
cmpl $0x1, %eax
je 0x2049d
movb -0x21(%rbp), %al
movb %al, -0x1(%rbp)
jmp 0x2051d
jmp 0x2049f
jmp 0x20500
movsbl -0x39(%rbp), %eax
cmpl $0x14, %eax
je 0x204b3
movsbl -0x39(%rbp), %eax
cmpl $0x12, %eax
jne 0x204fe
movq -0x10(%rbp), %rdi
callq 0x20980
testb $0x1, %al
jne 0x204c2
jmp 0x204fc
movq -0x10(%rbp), %rdi
xorl %esi, %esi
callq 0x20730
movl $0x0, -0x44(%rbp)
movq -0x10(%rbp), %rdi
movl $0xe, %esi
leaq -0x44(%rbp), %rdx
callq 0x7990
movb %al, -0x21(%rbp)
movzbl -0x21(%rbp), %eax
cmpl $0x1, %eax
je 0x204fa
movb -0x21(%rbp), %al
movb %al, -0x1(%rbp)
jmp 0x2051d
jmp 0x204fc
jmp 0x204fe
jmp 0x20500
jmp 0x2050f
movzbl -0x11(%rbp), %eax
cmpl $0x0, %eax
jne 0x2050d
jmp 0x2050d
jmp 0x2050f
jmp 0x20511
jmp 0x20513
jmp 0x20515
jmp 0x20517
movb -0x21(%rbp), %al
movb %al, -0x1(%rbp)
movb -0x1(%rbp), %al
addq $0x50, %rsp
popq %rbp
retq
nopw %cs:(%rax,%rax)