// File: /workspace/github_c_makefile_star2_O1/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 0x6697
movq %rax, %r15
movq %r14, %rdi
callq 0x5651
movl %eax, %ebx
movq %r15, 0x18(%rsp)
movzwl 0x16(%r15), %eax
movl %eax, 0x4(%rsp)
leaq 0x8(%r14), %r15
movq %r15, %rdi
callq 0x29e0b
testq %rax, %rax
je 0x2334b
movq %rax, %r12
movq %r14, 0x10(%rsp)
movq %r14, %rdi
movl $0x1, %esi
callq 0x62e7
movswl %bx, %eax
movl %eax, 0xc(%rsp)
movq %r12, %r13
testq %r13, %r13
je 0x2332e
movq 0x18(%rsp), %rax
movzwl 0x1c(%rax), %ebx
addw 0x1a(%rax), %bx
movl $0x0, 0x8(%rsp)
xorl %r14d, %r14d
movq %r12, %rdi
callq 0x51ee
testb %al, %al
jne 0x230d1
movq %r12, %rdi
movl $0x4, %esi
callq 0x6a3c
testb %al, %al
jne 0x230d1
movswl %bx, %ebp
movq %r12, %rdi
callq 0x5651
cwtl
addl %ebp, %eax
cmpl 0xc(%rsp), %eax
jg 0x23304
movq %r12, %rdi
callq 0x5651
addl %eax, %ebx
movq 0x18(%rsp), %rax
addw 0x1e(%rax), %bx
movq %r12, %rdi
callq 0x567b
cmpw %ax, 0x8(%rsp)
jg 0x230bd
movq %r12, %rdi
callq 0x567b
movl %eax, 0x8(%rsp)
incl %r14d
movq %r12, %rdi
movl $0x8, %esi
callq 0x6a3c
testb %al, %al
jne 0x230f2
movq %r15, %rdi
movq %r12, %rsi
callq 0x29cdb
movq %rax, %r12
testl %r14d, %r14d
cmoveq %rax, %r13
testq %rax, %rax
jne 0x2305a
xorl %r12d, %r12d
cmpl $0x2, %r14d
je 0x23155
cmpl $0x1, %r14d
je 0x2313b
testl %r14d, %r14d
jne 0x23245
testq %r12, %r12
je 0x23206
movswl 0x4(%rsp), %r8d
movq %r12, %rdi
movq 0x10(%rsp), %rsi
movl $0x2, %edx
xorl %ecx, %ecx
callq 0x576d
movq %r12, %rdi
callq 0x567b
movl %eax, 0x8(%rsp)
jmp 0x23206
movswl 0x4(%rsp), %r8d
movq %r13, %rdi
movq 0x10(%rsp), %rsi
movl $0x2, %edx
xorl %ecx, %ecx
jmp 0x23201
movq %r15, %rdi
movq %r13, %rsi
callq 0x29cdb
movq %rax, %rbp
movq %r13, %rdi
callq 0x5651
movl %eax, %r14d
movq %rbp, %rdi
callq 0x5651
addl %r14d, %eax
cwtl
movl 0xc(%rsp), %ecx
subl %eax, %ecx
movslq %ecx, %rax
imulq $0x55555556, %rax, %r14 # imm = 0x55555556
movq %r14, %rax
shrq $0x3f, %rax
shrq $0x20, %r14
addl %eax, %r14d
movswl 0x8(%rsp), %ebx
movq %r13, %rdi
callq 0x567b
cwtl
movl %ebx, %ecx
subl %eax, %ecx
movl %ecx, %eax
shrl $0x1f, %eax
addl %ecx, %eax
shrl %eax
addl 0x4(%rsp), %eax
movswl %r14w, %ecx
movswl %ax, %r8d
movq %r13, %rdi
movq 0x10(%rsp), %rsi
movl $0x1, %edx
callq 0x576d
negl %r14d
movq %rbp, %rdi
callq 0x567b
cwtl
subl %eax, %ebx
movl %ebx, %eax
shrl $0x1f, %eax
addl %ebx, %eax
shrl %eax
addl 0x4(%rsp), %eax
movswl %r14w, %ecx
movswl %ax, %r8d
movq %rbp, %rdi
movq 0x10(%rsp), %rsi
movl $0x3, %edx
callq 0x576d
testq %r12, %r12
je 0x23232
movl 0x8(%rsp), %ebx
addl 0x4(%rsp), %ebx
movq 0x18(%rsp), %rax
addw 0x1e(%rax), %bx
movq %r15, %rdi
movq %r12, %rsi
callq 0x29cdb
movl %ebx, %ecx
movl %ecx, 0x4(%rsp)
movq %rax, %r13
jmp 0x23234
xorl %eax, %eax
testq %r12, %r12
movq %rax, %r12
jne 0x23039
jmp 0x2332e
testq %r13, %r13
je 0x23206
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, 0x24(%rsp)
movswl 0x8(%rsp), %eax
movl %eax, 0x20(%rsp)
movq %r13, %r14
movq %r14, %rdi
callq 0x51ee
testb %al, %al
jne 0x232e3
movq %r14, %rdi
movl $0x4, %esi
callq 0x6a3c
testb %al, %al
jne 0x232e3
movq %r14, %rdi
callq 0x567b
cwtl
movl 0x20(%rsp), %ecx
subl %eax, %ecx
movl %ecx, %eax
shrl $0x1f, %eax
addl %ecx, %eax
shrl %eax
addl 0x4(%rsp), %eax
movswl %ax, %r8d
movswl %bp, %ebx
movq %r14, %rdi
movq 0x10(%rsp), %rsi
movl $0x1, %edx
movl %ebx, %ecx
callq 0x576d
addl 0x24(%rsp), %ebx
movq %r14, %rdi
callq 0x5651
movl %eax, %ebp
addl %ebx, %ebp
cmpq %r12, %r14
je 0x23206
movq %r15, %rdi
movq %r14, %rsi
callq 0x29cdb
movq %rax, %r14
testq %rax, %rax
jne 0x2327f
jmp 0x23206
testq %r12, %r12
setne %al
testl %r14d, %r14d
setne %cl
andb %al, %cl
cmpb $0x1, %cl
jne 0x230f2
movq %r15, %rdi
movq %r12, %rsi
callq 0x29dfb
movq %rax, %r12
jmp 0x230f2
movq 0x10(%rsp), %rdi
movl $0x1, %esi
addq $0x28, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
jmp 0x6314
addq $0x28, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq