// File: /workspace/github_c_makefile_star2_O0/OnionIoT[P]lv_example/lvgl/src/lv_objx/lv_ddlist.c
// Function: release_handler
static lv_res_t release_handler(lv_obj_t * ddlist)
{
    lv_ddlist_ext_t * ext = lv_obj_get_ext_attr(ddlist);

    if(ext->opened == 0) { /*Open the list*/
        ext->opened = 1;
        lv_obj_set_drag(lv_page_get_scrl(ddlist), true);
        lv_ddlist_refr_size(ddlist, true);
    } else {

        lv_indev_t * indev = lv_indev_get_act();
#if LV_USE_GROUP
        /*Leave edit mode once a new item is selected*/
        if(lv_indev_get_type(indev) == LV_INDEV_TYPE_ENCODER) {
            ext->sel_opt_id_ori = ext->sel_opt_id;
            lv_group_t * g      = lv_obj_get_group(ddlist);
            if(lv_group_get_editing(g)) {
                lv_group_set_editing(g, false);
            }
        }
#endif

        /*Search the clicked option (For KEYPAD and ENCODER the new value should be already set)*/
        if(lv_indev_get_type(indev) == LV_INDEV_TYPE_POINTER || lv_indev_get_type(indev) == LV_INDEV_TYPE_BUTTON) {
            lv_point_t p;
            lv_indev_get_point(indev, &p);
            p.y -= ext->label->coords.y1;
            p.x -= ext->label->coords.x1;
            uint16_t letter_i;
            letter_i = lv_label_get_letter_on(ext->label, &p);

            uint16_t new_opt  = 0;
            const char * txt  = lv_label_get_text(ext->label);
            uint32_t i        = 0;
            uint32_t i_prev   = 0;

            uint32_t letter_cnt = 0;
            uint32_t letter;
            for(letter_cnt = 0; letter_cnt < letter_i; letter_cnt++) {
                letter = lv_txt_encoded_next(txt, &i);
                /*Count he lines to reach the clicked letter. But ignore the last '\n' because it
                 * still belongs to the clicked line*/
                if(letter == '\n' && i_prev != letter_i) new_opt++;
                i_prev = i;
            }

            ext->sel_opt_id     = new_opt;
            ext->sel_opt_id_ori = ext->sel_opt_id;
        }

        uint32_t id  = ext->sel_opt_id; /*Just to use uint32_t in event data*/
        lv_res_t res = lv_event_send(ddlist, LV_EVENT_VALUE_CHANGED, &id);
        if(res != LV_RES_OK) return res;

        if(ext->stay_open == 0) {
            ext->opened = 0;
            lv_obj_set_drag(lv_page_get_scrl(ddlist), false);
            lv_ddlist_refr_size(ddlist, true);
        } else {
            lv_obj_invalidate(ddlist);
        }
    }

    return LV_RES_OK;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x50, %rsp
movq %rdi, -0x10(%rbp)
movq -0x10(%rbp), %rdi
callq 0xa8f0
movq %rax, -0x18(%rbp)
movq -0x18(%rbp), %rax
movb 0x66(%rax), %al
andb $0x1, %al
movzbl %al, %eax
cmpl $0x0, %eax
jne 0x14cc3
movq -0x18(%rbp), %rax
movb 0x66(%rax), %cl
andb $-0x2, %cl
orb $0x1, %cl
movb %cl, 0x66(%rax)
movq -0x10(%rbp), %rdi
callq 0x3e970
movq %rax, %rdi
movl $0x1, %esi
callq 0x95a0
movq -0x10(%rbp), %rdi
movl $0x1, %esi
callq 0x140b0
jmp 0x14eac
callq 0x4b70
movq %rax, -0x20(%rbp)
movq -0x20(%rbp), %rdi
callq 0x4b80
movzbl %al, %eax
cmpl $0x4, %eax
jne 0x14d16
movq -0x18(%rbp), %rax
movw 0x62(%rax), %cx
movq -0x18(%rbp), %rax
movw %cx, 0x64(%rax)
movq -0x10(%rbp), %rdi
callq 0x77c0
movq %rax, -0x28(%rbp)
movq -0x28(%rbp), %rdi
callq 0x32e0
testb $0x1, %al
jne 0x14d09
jmp 0x14d14
movq -0x28(%rbp), %rdi
xorl %esi, %esi
callq 0x2b70
jmp 0x14d16
movq -0x20(%rbp), %rdi
callq 0x4b80
movzbl %al, %eax
cmpl $0x1, %eax
je 0x14d3c
movq -0x20(%rbp), %rdi
callq 0x4b80
movzbl %al, %eax
cmpl $0x3, %eax
jne 0x14e29
movq -0x20(%rbp), %rdi
leaq -0x2c(%rbp), %rsi
callq 0x4d30
movq -0x18(%rbp), %rax
movq 0x50(%rax), %rax
movswl 0x22(%rax), %ecx
movswl -0x2a(%rbp), %eax
subl %ecx, %eax
movw %ax, -0x2a(%rbp)
movq -0x18(%rbp), %rax
movq 0x50(%rax), %rax
movswl 0x20(%rax), %ecx
movswl -0x2c(%rbp), %eax
subl %ecx, %eax
movw %ax, -0x2c(%rbp)
movq -0x18(%rbp), %rax
movq 0x50(%rax), %rdi
leaq -0x2c(%rbp), %rsi
callq 0x2c040
movw %ax, -0x2e(%rbp)
movw $0x0, -0x30(%rbp)
movq -0x18(%rbp), %rax
movq 0x50(%rax), %rdi
callq 0x2abc0
movq %rax, -0x38(%rbp)
movl $0x0, -0x3c(%rbp)
movl $0x0, -0x40(%rbp)
movl $0x0, -0x44(%rbp)
movl $0x0, -0x44(%rbp)
movl -0x44(%rbp), %eax
movzwl -0x2e(%rbp), %ecx
cmpl %ecx, %eax
jae 0x14e0d
leaq 0x678f1(%rip), %rax     # 0x7c6c0
movq (%rax), %rax
movq -0x38(%rbp), %rdi
leaq -0x3c(%rbp), %rsi
callq *%rax
movl %eax, -0x48(%rbp)
cmpl $0xa, -0x48(%rbp)
jne 0x14dfc
movl -0x40(%rbp), %eax
movzwl -0x2e(%rbp), %ecx
cmpl %ecx, %eax
je 0x14dfc
movw -0x30(%rbp), %ax
addw $0x1, %ax
movw %ax, -0x30(%rbp)
movl -0x3c(%rbp), %eax
movl %eax, -0x40(%rbp)
movl -0x44(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x44(%rbp)
jmp 0x14dbd
movw -0x30(%rbp), %cx
movq -0x18(%rbp), %rax
movw %cx, 0x62(%rax)
movq -0x18(%rbp), %rax
movw 0x62(%rax), %cx
movq -0x18(%rbp), %rax
movw %cx, 0x64(%rax)
movq -0x18(%rbp), %rax
movzwl 0x62(%rax), %eax
movl %eax, -0x4c(%rbp)
movq -0x10(%rbp), %rdi
movl $0xe, %esi
leaq -0x4c(%rbp), %rdx
callq 0x7990
movb %al, -0x4d(%rbp)
movzbl -0x4d(%rbp), %eax
cmpl $0x1, %eax
je 0x14e5a
movb -0x4d(%rbp), %al
movb %al, -0x1(%rbp)
jmp 0x14eb0
movq -0x18(%rbp), %rax
movb 0x66(%rax), %al
shrb $0x3, %al
andb $0x1, %al
movzbl %al, %eax
cmpl $0x0, %eax
jne 0x14ea1
movq -0x18(%rbp), %rax
movb 0x66(%rax), %cl
andb $-0x2, %cl
orb $0x0, %cl
movb %cl, 0x66(%rax)
movq -0x10(%rbp), %rdi
callq 0x3e970
movq %rax, %rdi
xorl %esi, %esi
callq 0x95a0
movq -0x10(%rbp), %rdi
movl $0x1, %esi
callq 0x140b0
jmp 0x14eaa
movq -0x10(%rbp), %rdi
callq 0x7430
jmp 0x14eac
movb $0x1, -0x1(%rbp)
movb -0x1(%rbp), %al
addq $0x50, %rsp
popq %rbp
retq
nopl (%rax)