// File: /workspace/github_c_makefile_star2_O0/OnionIoT[P]lv_example/lvgl/src/lv_core/lv_indev.c
// Function: indev_encoder_proc
static void indev_encoder_proc(lv_indev_t * i, lv_indev_data_t * data)
{
#if LV_USE_GROUP

    if(data->state == LV_INDEV_STATE_PR && i->proc.wait_until_release) return;

    if(i->proc.wait_until_release) {
        i->proc.wait_until_release      = 0;
        i->proc.pr_timestamp            = 0;
        i->proc.long_pr_sent            = 0;
        i->proc.types.keypad.last_state = LV_INDEV_STATE_REL; /*To skip the processing of release*/
    }

    /* Save the last keys before anything else.
     * They need to be already saved if the the function returns for any reason*/
    lv_indev_state_t last_state     = i->proc.types.keypad.last_state;
    i->proc.types.keypad.last_state = data->state;
    i->proc.types.keypad.last_key   = data->key;

    lv_group_t * g = i->group;
    if(g == NULL) return;

    indev_obj_act = lv_group_get_focused(g);
    if(indev_obj_act == NULL) return;

    /*Process the steps first. They are valid only with released button*/
    if(data->state == LV_INDEV_STATE_REL) {
        /*In edit mode send LEFT/RIGHT keys*/
        if(lv_group_get_editing(g)) {
            int32_t s;
            if(data->enc_diff < 0) {
                for(s = 0; s < -data->enc_diff; s++) lv_group_send_data(g, LV_KEY_LEFT);
            } else if(data->enc_diff > 0) {
                for(s = 0; s < data->enc_diff; s++) lv_group_send_data(g, LV_KEY_RIGHT);
            }
        }
        /*In navigate mode focus on the next/prev objects*/
        else {
            int32_t s;
            if(data->enc_diff < 0) {
                for(s = 0; s < -data->enc_diff; s++) lv_group_focus_prev(g);
            } else if(data->enc_diff > 0) {
                for(s = 0; s < data->enc_diff; s++) lv_group_focus_next(g);
            }
        }
    }

    /*Refresh the focused object. It might change due to lv_group_focus_prev/next*/
    indev_obj_act = lv_group_get_focused(g);
    if(indev_obj_act == NULL) return;

    /*Button press happened*/
    if(data->state == LV_INDEV_STATE_PR && last_state == LV_INDEV_STATE_REL) {
        bool editable = false;
        indev_obj_act->signal_cb(indev_obj_act, LV_SIGNAL_GET_EDITABLE, &editable);

        i->proc.pr_timestamp = lv_tick_get();
        if(lv_group_get_editing(g) == true || editable == false) {
            indev_obj_act->signal_cb(indev_obj_act, LV_SIGNAL_PRESSED, NULL);
            if(indev_reset_check(&i->proc)) return;

            lv_event_send(indev_obj_act, LV_EVENT_PRESSED, NULL);
            if(indev_reset_check(&i->proc)) return;
        }
    }
    /*Pressing*/
    else if(data->state == LV_INDEV_STATE_PR && last_state == LV_INDEV_STATE_PR) {
        if(i->proc.long_pr_sent == 0 && lv_tick_elaps(i->proc.pr_timestamp) > i->driver.long_press_time) {
            bool editable = false;
            indev_obj_act->signal_cb(indev_obj_act, LV_SIGNAL_GET_EDITABLE, &editable);

            /*On enter long press toggle edit mode.*/
            if(editable) {
                /*Don't leave edit mode if there is only one object (nowhere to navigate)*/
                if(lv_ll_is_empty(&g->obj_ll) == false) {
                    lv_group_set_editing(g, lv_group_get_editing(g) ? false : true); /*Toggle edit mode on long press*/
                }
            }
            /*If not editable then just send a long press signal*/
            else {
                indev_obj_act->signal_cb(indev_obj_act, LV_SIGNAL_LONG_PRESS, NULL);
                if(indev_reset_check(&i->proc)) return;
                lv_event_send(indev_obj_act, LV_EVENT_LONG_PRESSED, NULL);
                if(indev_reset_check(&i->proc)) return;
            }
            i->proc.long_pr_sent = 1;
        }
    }
    /*Release happened*/
    else if(data->state == LV_INDEV_STATE_REL && last_state == LV_INDEV_STATE_PR) {

        bool editable = false;
        indev_obj_act->signal_cb(indev_obj_act, LV_SIGNAL_GET_EDITABLE, &editable);

        /*The button was released on a non-editable object. Just send enter*/
        if(editable == false) {
            indev_obj_act->signal_cb(indev_obj_act, LV_SIGNAL_RELEASED, NULL);
            if(indev_reset_check(&i->proc)) return;

            if(i->proc.long_pr_sent == 0) lv_event_send(indev_obj_act, LV_EVENT_SHORT_CLICKED, NULL);
            if(indev_reset_check(&i->proc)) return;

            lv_event_send(indev_obj_act, LV_EVENT_CLICKED, NULL);
            if(indev_reset_check(&i->proc)) return;

            lv_event_send(indev_obj_act, LV_EVENT_RELEASED, NULL);
            if(indev_reset_check(&i->proc)) return;
        }
        /*An object is being edited and the button is released. */
        else if(g->editing) {
            /*Ignore long pressed enter release because it comes from mode switch*/
            if(!i->proc.long_pr_sent || lv_ll_is_empty(&g->obj_ll)) {
                indev_obj_act->signal_cb(indev_obj_act, LV_SIGNAL_RELEASED, NULL);
                if(indev_reset_check(&i->proc)) return;

                lv_event_send(indev_obj_act, LV_EVENT_SHORT_CLICKED, NULL);
                if(indev_reset_check(&i->proc)) return;

                lv_event_send(indev_obj_act, LV_EVENT_CLICKED, NULL);
                if(indev_reset_check(&i->proc)) return;

                lv_event_send(indev_obj_act, LV_EVENT_RELEASED, NULL);
                if(indev_reset_check(&i->proc)) return;

                lv_group_send_data(g, LV_KEY_ENTER);
            }
        }
        /*If the focused object is editable and now in navigate mode then on enter switch edit
           mode*/
        else if(editable && !g->editing && !i->proc.long_pr_sent) {
            lv_group_set_editing(g, true); /*Set edit mode*/
        }

        i->proc.pr_timestamp = 0;
        i->proc.long_pr_sent = 0;
    }
    indev_obj_act = NULL;
#else
    (void)data; /*Unused*/
    (void)i;    /*Unused*/
#endif
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x40, %rsp
movq %rdi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
movq -0x10(%rbp), %rax
movzbl 0xe(%rax), %eax
cmpl $0x1, %eax
jne 0x4426
movq -0x8(%rbp), %rax
movb 0x78(%rax), %al
shrb $0x3, %al
andb $0x1, %al
movzbl %al, %eax
cmpl $0x0, %eax
je 0x4426
jmp 0x4a98
movq -0x8(%rbp), %rax
movb 0x78(%rax), %al
shrb $0x3, %al
andb $0x1, %al
cmpb $0x0, %al
je 0x4469
movq -0x8(%rbp), %rax
movb 0x78(%rax), %cl
andb $-0x9, %cl
orb $0x0, %cl
movb %cl, 0x78(%rax)
movq -0x8(%rbp), %rax
movl $0x0, 0x70(%rax)
movq -0x8(%rbp), %rax
movb 0x78(%rax), %cl
andb $-0x2, %cl
orb $0x0, %cl
movb %cl, 0x78(%rax)
movq -0x8(%rbp), %rax
movb $0x0, 0x38(%rax)
movq -0x8(%rbp), %rax
movb 0x38(%rax), %al
movb %al, -0x11(%rbp)
movq -0x10(%rbp), %rax
movb 0xe(%rax), %cl
movq -0x8(%rbp), %rax
movb %cl, 0x38(%rax)
movq -0x10(%rbp), %rax
movl 0x4(%rax), %ecx
movq -0x8(%rbp), %rax
movl %ecx, 0x3c(%rax)
movq -0x8(%rbp), %rax
movq 0x88(%rax), %rax
movq %rax, -0x20(%rbp)
cmpq $0x0, -0x20(%rbp)
jne 0x44aa
jmp 0x4a98
movq -0x20(%rbp), %rdi
callq 0x3010
movq %rax, 0x84ab6(%rip)     # 0x88f70
cmpq $0x0, 0x84aae(%rip)     # 0x88f70
jne 0x44c9
jmp 0x4a98
movq -0x10(%rbp), %rax
movzbl 0xe(%rax), %eax
cmpl $0x0, %eax
jne 0x45ec
movq -0x20(%rbp), %rdi
callq 0x32e0
testb $0x1, %al
jne 0x44ec
jmp 0x4570
movq -0x10(%rbp), %rax
movswl 0xc(%rax), %eax
cmpl $0x0, %eax
jge 0x452e
movl $0x0, -0x24(%rbp)
movl -0x24(%rbp), %eax
movq -0x10(%rbp), %rcx
movswl 0xc(%rcx), %edx
xorl %ecx, %ecx
subl %edx, %ecx
cmpl %ecx, %eax
jge 0x452c
movq -0x20(%rbp), %rdi
movl $0x14, %esi
callq 0x2f80
movl -0x24(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x24(%rbp)
jmp 0x4500
jmp 0x456e
movq -0x10(%rbp), %rax
movswl 0xc(%rax), %eax
cmpl $0x0, %eax
jle 0x456c
movl $0x0, -0x24(%rbp)
movl -0x24(%rbp), %eax
movq -0x10(%rbp), %rcx
movswl 0xc(%rcx), %ecx
cmpl %ecx, %eax
jge 0x456a
movq -0x20(%rbp), %rdi
movl $0x13, %esi
callq 0x2f80
movl -0x24(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x24(%rbp)
jmp 0x4542
jmp 0x456c
jmp 0x456e
jmp 0x45ea
movq -0x10(%rbp), %rax
movswl 0xc(%rax), %eax
cmpl $0x0, %eax
jge 0x45ad
movl $0x0, -0x28(%rbp)
movl -0x28(%rbp), %eax
movq -0x10(%rbp), %rcx
movswl 0xc(%rcx), %edx
xorl %ecx, %ecx
subl %edx, %ecx
cmpl %ecx, %eax
jge 0x45ab
movq -0x20(%rbp), %rdi
callq 0x2f00
movl -0x28(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x28(%rbp)
jmp 0x4584
jmp 0x45e8
movq -0x10(%rbp), %rax
movswl 0xc(%rax), %eax
cmpl $0x0, %eax
jle 0x45e6
movl $0x0, -0x28(%rbp)
movl -0x28(%rbp), %eax
movq -0x10(%rbp), %rcx
movswl 0xc(%rcx), %ecx
cmpl %ecx, %eax
jge 0x45e4
movq -0x20(%rbp), %rdi
callq 0x2cb0
movl -0x28(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x28(%rbp)
jmp 0x45c1
jmp 0x45e6
jmp 0x45e8
jmp 0x45ea
jmp 0x45ec
movq -0x20(%rbp), %rdi
callq 0x3010
movq %rax, 0x84974(%rip)     # 0x88f70
cmpq $0x0, 0x8496c(%rip)     # 0x88f70
jne 0x460b
jmp 0x4a98
movq -0x10(%rbp), %rax
movzbl 0xe(%rax), %eax
cmpl $0x1, %eax
jne 0x46de
movzbl -0x11(%rbp), %eax
cmpl $0x0, %eax
jne 0x46de
movb $0x0, -0x29(%rbp)
movq 0x8493c(%rip), %rax     # 0x88f70
movq 0x30(%rax), %rax
movq 0x84931(%rip), %rdi     # 0x88f70
movl $0x13, %esi
leaq -0x29(%rbp), %rdx
callq *%rax
callq 0xdfe0
movl %eax, %ecx
movq -0x8(%rbp), %rax
movl %ecx, 0x70(%rax)
movq -0x20(%rbp), %rdi
callq 0x32e0
andb $0x1, %al
movzbl %al, %eax
cmpl $0x1, %eax
je 0x4678
movb -0x29(%rbp), %al
andb $0x1, %al
movzbl %al, %eax
cmpl $0x0, %eax
jne 0x46d9
movq 0x848f1(%rip), %rax     # 0x88f70
movq 0x30(%rax), %rax
movq 0x848e6(%rip), %rdi     # 0x88f70
movl $0x8, %esi
xorl %ecx, %ecx
movl %ecx, %edx
callq *%rax
movq -0x8(%rbp), %rdi
addq $0x30, %rdi
callq 0x5ee0
testb $0x1, %al
jne 0x46a8
jmp 0x46ad
jmp 0x4a98
movq 0x848bc(%rip), %rdi     # 0x88f70
xorl %esi, %esi
xorl %eax, %eax
movl %eax, %edx
callq 0x7990
movq -0x8(%rbp), %rdi
addq $0x30, %rdi
callq 0x5ee0
testb $0x1, %al
jne 0x46d2
jmp 0x46d7
jmp 0x4a98
jmp 0x46d9
jmp 0x4a8d
movq -0x10(%rbp), %rax
movzbl 0xe(%rax), %eax
cmpl $0x1, %eax
jne 0x4817
movzbl -0x11(%rbp), %eax
cmpl $0x1, %eax
jne 0x4817
movq -0x8(%rbp), %rax
movb 0x78(%rax), %al
andb $0x1, %al
movzbl %al, %eax
cmpl $0x0, %eax
jne 0x4812
movq -0x8(%rbp), %rax
movl 0x70(%rax), %edi
callq 0xe010
movq -0x8(%rbp), %rcx
movzwl 0x2a(%rcx), %ecx
cmpl %ecx, %eax
jbe 0x4812
movb $0x0, -0x2a(%rbp)
movq 0x84838(%rip), %rax     # 0x88f70
movq 0x30(%rax), %rax
movq 0x8482d(%rip), %rdi     # 0x88f70
movl $0x13, %esi
leaq -0x2a(%rbp), %rdx
callq *%rax
testb $0x1, -0x2a(%rbp)
je 0x479e
movq -0x20(%rbp), %rdi
callq 0x45bb0
andb $0x1, %al
movzbl %al, %eax
cmpl $0x0, %eax
jne 0x479c
movq -0x20(%rbp), %rax
movq %rax, -0x38(%rbp)
movq -0x20(%rbp), %rdi
callq 0x32e0
movq -0x38(%rbp), %rdi
movb %al, %dl
movl $0x1, %eax
xorl %ecx, %ecx
testb $0x1, %dl
cmovnel %ecx, %eax
cmpl $0x0, %eax
setne %al
movzbl %al, %esi
andl $0x1, %esi
callq 0x2b70
jmp 0x4802
movq 0x847cb(%rip), %rax     # 0x88f70
movq 0x30(%rax), %rax
movq 0x847c0(%rip), %rdi     # 0x88f70
movl $0xc, %esi
xorl %ecx, %ecx
movl %ecx, %edx
callq *%rax
movq -0x8(%rbp), %rdi
addq $0x30, %rdi
callq 0x5ee0
testb $0x1, %al
jne 0x47ce
jmp 0x47d3
jmp 0x4a98
movq 0x84796(%rip), %rdi     # 0x88f70
movl $0x4, %esi
xorl %eax, %eax
movl %eax, %edx
callq 0x7990
movq -0x8(%rbp), %rdi
addq $0x30, %rdi
callq 0x5ee0
testb $0x1, %al
jne 0x47fb
jmp 0x4800
jmp 0x4a98
jmp 0x4802
movq -0x8(%rbp), %rax
movb 0x78(%rax), %cl
andb $-0x2, %cl
orb $0x1, %cl
movb %cl, 0x78(%rax)
jmp 0x4a8b
movq -0x10(%rbp), %rax
movzbl 0xe(%rax), %eax
cmpl $0x0, %eax
jne 0x4a89
movzbl -0x11(%rbp), %eax
cmpl $0x1, %eax
jne 0x4a89
movb $0x0, -0x2b(%rbp)
movq 0x84730(%rip), %rax     # 0x88f70
movq 0x30(%rax), %rax
movq 0x84725(%rip), %rdi     # 0x88f70
movl $0x13, %esi
leaq -0x2b(%rbp), %rdx
callq *%rax
movb -0x2b(%rbp), %al
andb $0x1, %al
movzbl %al, %eax
cmpl $0x0, %eax
jne 0x4939
movq 0x84702(%rip), %rax     # 0x88f70
movq 0x30(%rax), %rax
movq 0x846f7(%rip), %rdi     # 0x88f70
movl $0xb, %esi
xorl %ecx, %ecx
movl %ecx, %edx
callq *%rax
movq -0x8(%rbp), %rdi
addq $0x30, %rdi
callq 0x5ee0
testb $0x1, %al
jne 0x4897
jmp 0x489c
jmp 0x4a98
movq -0x8(%rbp), %rax
movb 0x78(%rax), %al
andb $0x1, %al
movzbl %al, %eax
cmpl $0x0, %eax
jne 0x48c2
movq 0x846bc(%rip), %rdi     # 0x88f70
movl $0x3, %esi
xorl %eax, %eax
movl %eax, %edx
callq 0x7990
movq -0x8(%rbp), %rdi
addq $0x30, %rdi
callq 0x5ee0
testb $0x1, %al
jne 0x48d5
jmp 0x48da
jmp 0x4a98
movq 0x8468f(%rip), %rdi     # 0x88f70
movl $0x6, %esi
xorl %eax, %eax
movl %eax, %edx
callq 0x7990
movq -0x8(%rbp), %rdi
addq $0x30, %rdi
callq 0x5ee0
testb $0x1, %al
jne 0x4902
jmp 0x4907
jmp 0x4a98
movq 0x84662(%rip), %rdi     # 0x88f70
movl $0x7, %esi
xorl %eax, %eax
movl %eax, %edx
callq 0x7990
movq -0x8(%rbp), %rdi
addq $0x30, %rdi
callq 0x5ee0
testb $0x1, %al
jne 0x492f
jmp 0x4934
jmp 0x4a98
jmp 0x4a6e
movq -0x20(%rbp), %rax
movb 0x80(%rax), %al
shrb %al
andb $0x1, %al
cmpb $0x0, %al
je 0x4a37
movq -0x8(%rbp), %rax
movb 0x78(%rax), %al
andb $0x1, %al
cmpb $0x0, %al
je 0x496e
movq -0x20(%rbp), %rdi
callq 0x45bb0
testb $0x1, %al
jne 0x496e
jmp 0x4a35
movq 0x845fb(%rip), %rax     # 0x88f70
movq 0x30(%rax), %rax
movq 0x845f0(%rip), %rdi     # 0x88f70
movl $0xb, %esi
xorl %ecx, %ecx
movl %ecx, %edx
callq *%rax
movq -0x8(%rbp), %rdi
addq $0x30, %rdi
callq 0x5ee0
testb $0x1, %al
jne 0x499e
jmp 0x49a3
jmp 0x4a98
movq 0x845c6(%rip), %rdi     # 0x88f70
movl $0x3, %esi
xorl %eax, %eax
movl %eax, %edx
callq 0x7990
movq -0x8(%rbp), %rdi
addq $0x30, %rdi
callq 0x5ee0
testb $0x1, %al
jne 0x49cb
jmp 0x49d0
jmp 0x4a98
movq 0x84599(%rip), %rdi     # 0x88f70
movl $0x6, %esi
xorl %eax, %eax
movl %eax, %edx
callq 0x7990
movq -0x8(%rbp), %rdi
addq $0x30, %rdi
callq 0x5ee0
testb $0x1, %al
jne 0x49f8
jmp 0x49fd
jmp 0x4a98
movq 0x8456c(%rip), %rdi     # 0x88f70
movl $0x7, %esi
xorl %eax, %eax
movl %eax, %edx
callq 0x7990
movq -0x8(%rbp), %rdi
addq $0x30, %rdi
callq 0x5ee0
testb $0x1, %al
jne 0x4a25
jmp 0x4a27
jmp 0x4a98
movq -0x20(%rbp), %rdi
movl $0xa, %esi
callq 0x2f80
jmp 0x4a6c
testb $0x1, -0x2b(%rbp)
je 0x4a6a
movq -0x20(%rbp), %rax
movb 0x80(%rax), %al
shrb %al
andb $0x1, %al
cmpb $0x0, %al
jne 0x4a6a
movq -0x8(%rbp), %rax
movb 0x78(%rax), %al
andb $0x1, %al
cmpb $0x0, %al
jne 0x4a6a
movq -0x20(%rbp), %rdi
movl $0x1, %esi
callq 0x2b70
jmp 0x4a6c
jmp 0x4a6e
movq -0x8(%rbp), %rax
movl $0x0, 0x70(%rax)
movq -0x8(%rbp), %rax
movb 0x78(%rax), %cl
andb $-0x2, %cl
orb $0x0, %cl
movb %cl, 0x78(%rax)
jmp 0x4a8b
jmp 0x4a8d
movq $0x0, 0x844d8(%rip) # 0x88f70
addq $0x40, %rsp
popq %rbp
retq
nop