// File: /workspace/github_c_makefile_star2_O0/OnionIoT[P]lv_example/lvgl/src/lv_core/lv_group.c
// Function: focus_next_core
static void focus_next_core(lv_group_t * group, void * (*begin)(const lv_ll_t *),
                            void * (*move)(const lv_ll_t *, const void *))
{
    if(group->frozen) return;

    lv_obj_t ** obj_next     = group->obj_focus;
    lv_obj_t ** obj_sentinel = NULL;
    bool can_move            = true;
    bool can_begin           = true;

    for(;;) {
        if(obj_next == NULL) {
            if(group->wrap || obj_sentinel == NULL) {
                if(!can_begin) return;
                obj_next  = begin(&group->obj_ll);
                can_move  = false;
                can_begin = false;
            } else {
                /*Currently focused object is the last/first in the group, keep it that way*/
                return;
            }
        }

        if(obj_sentinel == NULL) {
            obj_sentinel = obj_next;
            if(obj_sentinel == NULL) return; /*Group is empty*/
        }

        if(can_move) {
            obj_next = move(&group->obj_ll, obj_next);

            /*Give up if we walked the entire list and haven't found another visible object*/
            if(obj_next == obj_sentinel) return;
        }

        can_move = true;

        if(obj_next == NULL) continue;

        /*Hidden objects don't receive focus*/
        if(!lv_obj_get_hidden(*obj_next)) break;
    }

    if(obj_next == group->obj_focus) return; /*There's only one visible object and it's already focused*/

    if(group->obj_focus) {
        (*group->obj_focus)->signal_cb(*group->obj_focus, LV_SIGNAL_DEFOCUS, NULL);
        lv_res_t res = lv_event_send(*group->obj_focus, LV_EVENT_DEFOCUSED, NULL);
        if(res != LV_RES_OK) return;
        lv_obj_invalidate(*group->obj_focus);
    }

    group->obj_focus = obj_next;

    (*group->obj_focus)->signal_cb(*group->obj_focus, LV_SIGNAL_FOCUS, NULL);
    lv_res_t res = lv_event_send(*group->obj_focus, LV_EVENT_FOCUSED, NULL);
    if(res != LV_RES_OK) return;

    /*If the object or its parent has `top == true` bring it to the foregorund*/
    obj_to_foreground(*group->obj_focus);

    lv_obj_invalidate(*group->obj_focus);

    if(group->focus_cb) group->focus_cb(group);
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x30, %rsp
movq %rdi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
movq %rdx, -0x18(%rbp)
movq -0x8(%rbp), %rax
movb 0x80(%rax), %al
andb $0x1, %al
cmpb $0x0, %al
je 0x2d09
jmp 0x2eef
movq -0x8(%rbp), %rax
movq 0x18(%rax), %rax
movq %rax, -0x20(%rbp)
movq $0x0, -0x28(%rbp)
movb $0x1, -0x29(%rbp)
movb $0x1, -0x2a(%rbp)
cmpq $0x0, -0x20(%rbp)
jne 0x2d74
movq -0x8(%rbp), %rax
movb 0x80(%rax), %al
shrb $0x4, %al
andb $0x1, %al
movzbl %al, %eax
cmpl $0x0, %eax
jne 0x2d4a
cmpq $0x0, -0x28(%rbp)
jne 0x2d6d
testb $0x1, -0x2a(%rbp)
jne 0x2d55
jmp 0x2eef
movq -0x10(%rbp), %rax
movq -0x8(%rbp), %rdi
callq *%rax
movq %rax, -0x20(%rbp)
movb $0x0, -0x29(%rbp)
movb $0x0, -0x2a(%rbp)
jmp 0x2d72
jmp 0x2eef
jmp 0x2d74
cmpq $0x0, -0x28(%rbp)
jne 0x2d91
movq -0x20(%rbp), %rax
movq %rax, -0x28(%rbp)
cmpq $0x0, -0x28(%rbp)
jne 0x2d8f
jmp 0x2eef
jmp 0x2d91
testb $0x1, -0x29(%rbp)
je 0x2dba
movq -0x18(%rbp), %rax
movq -0x8(%rbp), %rdi
movq -0x20(%rbp), %rsi
callq *%rax
movq %rax, -0x20(%rbp)
movq -0x20(%rbp), %rax
cmpq -0x28(%rbp), %rax
jne 0x2db8
jmp 0x2eef
jmp 0x2dba
movb $0x1, -0x29(%rbp)
cmpq $0x0, -0x20(%rbp)
jne 0x2dca
jmp 0x2d25
movq -0x20(%rbp), %rax
movq (%rax), %rdi
callq 0x7c90
testb $0x1, %al
jne 0x2ddc
jmp 0x2de1
jmp 0x2d25
movq -0x20(%rbp), %rax
movq -0x8(%rbp), %rcx
cmpq 0x18(%rcx), %rax
jne 0x2df4
jmp 0x2eef
movq -0x8(%rbp), %rax
cmpq $0x0, 0x18(%rax)
je 0x2e5e
movq -0x8(%rbp), %rax
movq 0x18(%rax), %rax
movq (%rax), %rax
movq 0x30(%rax), %rax
movq -0x8(%rbp), %rcx
movq 0x18(%rcx), %rcx
movq (%rcx), %rdi
movl $0x11, %esi
xorl %ecx, %ecx
movl %ecx, %edx
callq *%rax
movq -0x8(%rbp), %rax
movq 0x18(%rax), %rax
movq (%rax), %rdi
movl $0xd, %esi
xorl %eax, %eax
movl %eax, %edx
callq 0x7990
movb %al, -0x2b(%rbp)
movzbl -0x2b(%rbp), %eax
cmpl $0x1, %eax
je 0x2e4e
jmp 0x2eef
movq -0x8(%rbp), %rax
movq 0x18(%rax), %rax
movq (%rax), %rdi
callq 0x7430
movq -0x20(%rbp), %rcx
movq -0x8(%rbp), %rax
movq %rcx, 0x18(%rax)
movq -0x8(%rbp), %rax
movq 0x18(%rax), %rax
movq (%rax), %rax
movq 0x30(%rax), %rax
movq -0x8(%rbp), %rcx
movq 0x18(%rcx), %rcx
movq (%rcx), %rdi
movl $0x10, %esi
xorl %ecx, %ecx
movl %ecx, %edx
callq *%rax
movq -0x8(%rbp), %rax
movq 0x18(%rax), %rax
movq (%rax), %rdi
movl $0xc, %esi
xorl %eax, %eax
movl %eax, %edx
callq 0x7990
movb %al, -0x2c(%rbp)
movzbl -0x2c(%rbp), %eax
cmpl $0x1, %eax
je 0x2eb6
jmp 0x2eef
movq -0x8(%rbp), %rax
movq 0x18(%rax), %rax
movq (%rax), %rdi
callq 0x2c40
movq -0x8(%rbp), %rax
movq 0x18(%rax), %rax
movq (%rax), %rdi
callq 0x7430
movq -0x8(%rbp), %rax
cmpq $0x0, 0x30(%rax)
je 0x2eef
movq -0x8(%rbp), %rax
movq 0x30(%rax), %rax
movq -0x8(%rbp), %rdi
callq *%rax
addq $0x30, %rsp
popq %rbp
retq
nopw %cs:(%rax,%rax)