// File: /workspace/github_c_makefile_star2_O3/OnionIoT[P]lv_example/lvgl/src/lv_objx/lv_cont.c
// Function: lv_cont_layout_grid
static void lv_cont_layout_grid(lv_obj_t * cont)
{
    lv_obj_t * child;
    const lv_style_t * style = lv_obj_get_style(cont);
    lv_coord_t w_tot         = lv_obj_get_width(cont);
    lv_coord_t w_obj         = lv_obj_get_width(lv_obj_get_child(cont, NULL));
    lv_coord_t w_fit         =  lv_obj_get_width_fit(cont);
    lv_coord_t h_obj         = lv_obj_get_height(lv_obj_get_child(cont, NULL));
    uint16_t obj_row         = (w_fit) / (w_obj + style->body.padding.inner); /*Obj. num. in a row*/
    lv_coord_t x_ofs;
    if(obj_row > 1) {
        x_ofs = w_obj + (w_fit - (obj_row * w_obj)) / (obj_row - 1);
    } else {
        x_ofs = w_tot / 2 - w_obj / 2;
    }
    lv_coord_t y_ofs = h_obj + style->body.padding.inner;

    /* Disable child change action because the children will be moved a lot
     * an unnecessary child change signals could be sent*/
    lv_obj_set_protect(cont, LV_PROTECT_CHILD_CHG);

    /* Align the children */
    lv_coord_t act_x = style->body.padding.left;
    lv_coord_t act_y = style->body.padding.top;
    uint16_t obj_cnt = 0;
    LV_LL_READ_BACK(cont->child_ll, child)
    {
        if(lv_obj_get_hidden(child) != false || lv_obj_is_protected(child, LV_PROTECT_POS) != false) continue;

        if(obj_row > 1) {
            lv_obj_set_pos(child, act_x, act_y);
            act_x += x_ofs;
        } else {
            lv_obj_set_pos(child, x_ofs, act_y);
        }
        obj_cnt++;

        if(obj_cnt >= obj_row) {
            obj_cnt = 0;
            act_x   = style->body.padding.left;
            act_y += y_ofs;
        }
    }

    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, %r13
callq 0x66b6
movq %rax, %rbx
movq %r13, %rdi
callq 0x566d
movl %eax, %ebp
movq %r13, %rdi
xorl %esi, %esi
callq 0x51a7
movq %rax, %rdi
callq 0x566d
movl %eax, %r15d
movq %r13, %rdi
callq 0x6772
movl %eax, %r12d
movq %r13, %rdi
xorl %esi, %esi
callq 0x51a7
movq %rax, %rdi
callq 0x5697
movl %eax, %r8d
movswl %r12w, %ecx
movswl %r15w, %esi
movq %rbx, 0x18(%rsp)
movswl 0x1e(%rbx), %eax
movq %rax, 0x10(%rsp)
leal (%rax,%rsi), %edi
movl %ecx, %eax
cltd
idivl %edi
movzwl %ax, %r14d
cmpl $0x2, %r14d
movl %r8d, 0x8(%rsp)
jb 0x23b38
movl %r14d, %eax
imull %esi, %eax
subl %eax, %ecx
leal -0x1(%r14), %edi
movl %ecx, %eax
cltd
idivl %edi
addl %esi, %eax
movl %eax, 0xc(%rsp)
jmp 0x23b56
movzwl %si, %eax
movzwl %bp, %ecx
shrl $0xf, %ecx
addl %ebp, %ecx
movswl %cx, %ecx
sarl %ecx
shrl $0xf, %eax
addl %esi, %eax
cwtl
sarl %eax
subl %eax, %ecx
movl %ecx, 0xc(%rsp)
movq %r13, %rdi
movl $0x1, %esi
callq 0x6306
movq 0x18(%rsp), %rax
movzwl 0x16(%rax), %ebx
movzwl 0x1a(%rax), %r12d
movq %r13, 0x20(%rsp)
leaq 0x8(%r13), %r15
movq %r15, %rdi
callq 0x2a458
testq %rax, %rax
je 0x23c1c
movq %rax, %r13
movq 0x10(%rsp), %rax
addl 0x8(%rsp), %eax
movq %rax, 0x10(%rsp)
xorl %ebp, %ebp
movswl 0xc(%rsp), %eax
movl %eax, 0x8(%rsp)
movq %r13, %rdi
callq 0x51f2
testb %al, %al
jne 0x23c09
movq %r13, %rdi
movl $0x4, %esi
callq 0x6a5b
testb %al, %al
jne 0x23c09
movswl %bx, %edx
cmpl $0x2, %r14d
jb 0x23be3
movswl %r12w, %r12d
movq %r13, %rdi
movl %r12d, %esi
callq 0x4ad8
addl 0xc(%rsp), %r12d
jmp 0x23bef
movq %r13, %rdi
movl 0x8(%rsp), %esi
callq 0x4ad8
incl %ebp
movzwl %bp, %eax
cmpl %eax, %r14d
ja 0x23c09
movq 0x18(%rsp), %rax
movzwl 0x1a(%rax), %r12d
addl 0x10(%rsp), %ebx
xorl %ebp, %ebp
movq %r15, %rdi
movq %r13, %rsi
callq 0x2a369
movq %rax, %r13
testq %rax, %rax
jne 0x23ba7
movq 0x20(%rsp), %rdi
movl $0x1, %esi
addq $0x28, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
jmp 0x6333
nopl (%rax)