// File: /workspace/github_c_makefile_star2_O3/OnionIoT[P]lv_example/lvgl/src/lv_objx/lv_cont.c
// Function: lv_cont_layout_pretty
static void lv_cont_layout_pretty(lv_obj_t * cont)
{
    lv_obj_t * child_rs;  /* Row starter child */
    lv_obj_t * child_rc;  /* Row closer child */
    lv_obj_t * child_tmp; /* Temporary child */
    const lv_style_t * style = lv_obj_get_style(cont);
    lv_coord_t w_obj         = lv_obj_get_width(cont);
    lv_coord_t act_y         = style->body.padding.top;
    /* Disable child change action because the children will be moved a lot
     * an unnecessary child change signals could be sent*/

    child_rs = lv_ll_get_tail(&cont->child_ll); /*Set the row starter child*/
    if(child_rs == NULL) return;                /*Return if no child*/

    lv_obj_set_protect(cont, LV_PROTECT_CHILD_CHG);

    child_rc = child_rs; /*Initially the the row starter and closer is the same*/
    while(child_rs != NULL) {
        lv_coord_t h_row = 0;
        lv_coord_t w_row =
            style->body.padding.left + style->body.padding.right; /*The width is at least the left+right hpad*/
        uint32_t obj_num = 0;

        /*Find the row closer object and collect some data*/
        do {
            if(lv_obj_get_hidden(child_rc) == false && lv_obj_is_protected(child_rc, LV_PROTECT_POS) == false) {
                /*If this object is already not fit then break*/
                if(w_row + lv_obj_get_width(child_rc) > w_obj) {
                    /*Step back one child because the last already not fit, so the previous is the
                     * closer*/
                    if(child_rc != NULL && obj_num != 0) {
                        child_rc = lv_ll_get_next(&cont->child_ll, child_rc);
                    }
                    break;
                }
                w_row += lv_obj_get_width(child_rc) + style->body.padding.inner; /*Add the object width + opad*/
                h_row = LV_MATH_MAX(h_row, lv_obj_get_height(child_rc));         /*Search the highest object*/
                obj_num++;
                if(lv_obj_is_protected(child_rc, LV_PROTECT_FOLLOW))
                    break; /*If can not be followed by an other object then break here*/
            }
            child_rc = lv_ll_get_prev(&cont->child_ll, child_rc); /*Load the next object*/
            if(obj_num == 0)
                child_rs = child_rc; /*If the first object was hidden (or too long) then set the
                                        next as first */
        } while(child_rc != NULL);

        /*If the object is too long  then align it to the middle*/
        if(obj_num == 0) {
            if(child_rc != NULL) {
                lv_obj_align(child_rc, cont, LV_ALIGN_IN_TOP_MID, 0, act_y);
                h_row = lv_obj_get_height(child_rc); /*Not set previously because of the early break*/
            }
        }
        /*If there is only one object in the row then align it to the middle*/
        else if(obj_num == 1) {
            lv_obj_align(child_rs, cont, LV_ALIGN_IN_TOP_MID, 0, act_y);
        }
        /*If there are two object in the row then align them proportionally*/
        else if(obj_num == 2) {
            lv_obj_t * obj1 = child_rs;
            lv_obj_t * obj2 = lv_ll_get_prev(&cont->child_ll, child_rs);
            w_row           = lv_obj_get_width(obj1) + lv_obj_get_width(obj2);
            lv_coord_t pad  = (w_obj - w_row) / 3;
            lv_obj_align(obj1, cont, LV_ALIGN_IN_TOP_LEFT, pad, act_y + (h_row - lv_obj_get_height(obj1)) / 2);
            lv_obj_align(obj2, cont, LV_ALIGN_IN_TOP_RIGHT, -pad, act_y + (h_row - lv_obj_get_height(obj2)) / 2);
        }
        /* Align the children (from child_rs to child_rc)*/
        else {
            w_row -= style->body.padding.inner * obj_num;
            lv_coord_t new_opad = (w_obj - w_row) / (obj_num - 1);
            lv_coord_t act_x    = style->body.padding.left; /*x init*/
            child_tmp           = child_rs;
            while(child_tmp != NULL) {
                if(lv_obj_get_hidden(child_tmp) == false && lv_obj_is_protected(child_tmp, LV_PROTECT_POS) == false) {
                    lv_obj_align(child_tmp, cont, LV_ALIGN_IN_TOP_LEFT, act_x,
                                 act_y + (h_row - lv_obj_get_height(child_tmp)) / 2);
                    act_x += lv_obj_get_width(child_tmp) + new_opad;
                }
                if(child_tmp == child_rc) break;
                child_tmp = lv_ll_get_prev(&cont->child_ll, child_tmp);
            }
        }

        if(child_rc == NULL) break;
        act_y += style->body.padding.inner + h_row;           /*y increment*/
        child_rs = lv_ll_get_prev(&cont->child_ll, child_rc); /*Go to the next object*/
        child_rc = child_rs;
    }
    lv_obj_clear_protect(cont, LV_PROTECT_CHILD_CHG);
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x28, %rsp
movq %rdi, %r14
callq 0x66b6
movq %rax, %r15
movq %r14, %rdi
callq 0x566d
movl %eax, %ebx
movq %r15, 0x18(%rsp)
movzwl 0x16(%r15), %eax
movl %eax, 0x4(%rsp)
leaq 0x8(%r14), %r15
movq %r15, %rdi
callq 0x2a458
testq %rax, %rax
je 0x23a8b
movq %rax, %r12
movq %r14, 0x10(%rsp)
movq %r14, %rdi
movl $0x1, %esi
callq 0x6306
movswl %bx, %eax
movl %eax, 0xc(%rsp)
movq 0x18(%rsp), %rax
movzwl 0x1c(%rax), %ebx
addw 0x1a(%rax), %bx
movl $0x0, 0x8(%rsp)
xorl %r14d, %r14d
movq %r12, %r13
movq %r12, %rdi
callq 0x51f2
testb %al, %al
jne 0x2381e
movq %r12, %rdi
movl $0x4, %esi
callq 0x6a5b
testb %al, %al
jne 0x2381e
movswl %bx, %ebp
movq %r12, %rdi
callq 0x566d
cwtl
addl %ebp, %eax
cmpl 0xc(%rsp), %eax
jg 0x23a02
movq %r12, %rdi
callq 0x566d
addl %eax, %ebx
movq 0x18(%rsp), %rax
addw 0x1e(%rax), %bx
movq %r12, %rdi
callq 0x5697
cmpw %ax, 0x8(%rsp)
jg 0x2380a
movq %r12, %rdi
callq 0x5697
movl %eax, 0x8(%rsp)
incl %r14d
movq %r12, %rdi
movl $0x8, %esi
callq 0x6a5b
testb %al, %al
jne 0x2383f
movq %r15, %rdi
movq %r12, %rsi
callq 0x2a369
movq %rax, %r12
testl %r14d, %r14d
cmoveq %rax, %r13
testq %rax, %rax
jne 0x237a7
xorl %r12d, %r12d
cmpl $0x2, %r14d
je 0x2387c
cmpl $0x1, %r14d
je 0x23862
testl %r14d, %r14d
jne 0x23944
testq %r12, %r12
jne 0x23a1a
jmp 0x23a6e
movswl 0x4(%rsp), %r8d
movq %r13, %rdi
movq 0x10(%rsp), %rsi
movl $0x2, %edx
xorl %ecx, %ecx
jmp 0x23931
movq %r15, %rdi
movq %r13, %rsi
callq 0x2a369
movq %rax, %r14
movq %rax, 0x20(%rsp)
movq %r13, %rdi
callq 0x566d
movl %eax, %ebx
movq %r14, %rdi
callq 0x566d
addl %ebx, %eax
cwtl
movl 0xc(%rsp), %ecx
subl %eax, %ecx
movslq %ecx, %rax
imulq $0x55555556, %rax, %rbx # imm = 0x55555556
movq %rbx, %rax
shrq $0x3f, %rax
shrq $0x20, %rbx
addl %eax, %ebx
movswl 0x8(%rsp), %r14d
movq %r13, %rdi
callq 0x5697
cwtl
movl %r14d, %ecx
subl %eax, %ecx
movl %ecx, %eax
shrl $0x1f, %eax
addl %ecx, %eax
shrl %eax
movl 0x4(%rsp), %ebp
addl %ebp, %eax
movswl %bx, %ecx
movswl %ax, %r8d
movq %r13, %rdi
movq 0x10(%rsp), %rsi
movl $0x1, %edx
callq 0x5789
negl %ebx
movq 0x20(%rsp), %r13
movq %r13, %rdi
callq 0x5697
cwtl
subl %eax, %r14d
movl %r14d, %eax
shrl $0x1f, %eax
addl %r14d, %eax
shrl %eax
addl %ebp, %eax
movswl %bx, %ecx
movswl %ax, %r8d
movq %r13, %rdi
movq 0x10(%rsp), %rsi
movl $0x3, %edx
callq 0x5789
testq %r12, %r12
jne 0x23a40
jmp 0x23a6e
testq %r13, %r13
je 0x23936
movq 0x18(%rsp), %rax
movzwl 0x1a(%rax), %ebp
movzwl 0x1e(%rax), %eax
imulw %r14w, %ax
subl %eax, %ebx
movswl %bx, %ecx
movl 0xc(%rsp), %eax
subl %ecx, %eax
decl %r14d
xorl %edx, %edx
divl %r14d
movl %eax, 0x20(%rsp)
movswl 0x8(%rsp), %ebx
movq %r13, %rdi
callq 0x51f2
testb %al, %al
jne 0x239dd
movq %r13, %rdi
movl $0x4, %esi
callq 0x6a5b
testb %al, %al
jne 0x239dd
movq %r13, %rdi
callq 0x5697
cwtl
movl %ebx, %ecx
subl %eax, %ecx
movl %ecx, %eax
shrl $0x1f, %eax
addl %ecx, %eax
shrl %eax
addl 0x4(%rsp), %eax
movswl %ax, %r8d
movswl %bp, %r14d
movq %r13, %rdi
movq 0x10(%rsp), %rsi
movl $0x1, %edx
movl %r14d, %ecx
callq 0x5789
addl 0x20(%rsp), %r14d
movq %r13, %rdi
callq 0x566d
movl %eax, %ebp
addl %r14d, %ebp
cmpq %r12, %r13
je 0x23936
movq %r15, %rdi
movq %r13, %rsi
callq 0x2a369
movq %rax, %r13
testq %rax, %rax
jne 0x23977
jmp 0x23936
testl %r14d, %r14d
je 0x23a1a
movq %r15, %rdi
movq %r12, %rsi
callq 0x2a448
movq %rax, %r12
jmp 0x2383f
movswl 0x4(%rsp), %r8d
movq %r12, %rdi
movq 0x10(%rsp), %rsi
movl $0x2, %edx
xorl %ecx, %ecx
callq 0x5789
movq %r12, %rdi
callq 0x5697
movl %eax, 0x8(%rsp)
movl 0x8(%rsp), %ebx
addl 0x4(%rsp), %ebx
movq 0x18(%rsp), %rax
addw 0x1e(%rax), %bx
movq %r15, %rdi
movq %r12, %rsi
callq 0x2a369
movq %rax, %r12
movl %ebx, %eax
movl %eax, 0x4(%rsp)
testq %r12, %r12
jne 0x2378c
movq 0x10(%rsp), %rdi
movl $0x1, %esi
addq $0x28, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
jmp 0x6333
addq $0x28, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq