// File: /workspace/github_c_makefile_star2_O1/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, %rbx
callq 0x6697
movq %rax, %r14
movq %rbx, %rdi
callq 0x5651
movl %eax, %ebp
movq %rbx, %rdi
xorl %esi, %esi
callq 0x51a3
movq %rax, %rdi
callq 0x5651
movl %eax, %r15d
movq %rbx, %rdi
callq 0x6753
movl %eax, %r12d
movq %rbx, 0x18(%rsp)
movq %rbx, %rdi
xorl %esi, %esi
callq 0x51a3
movq %rax, %rdi
callq 0x567b
movl %eax, %r8d
movswl %r12w, %ecx
movswl %r15w, %edi
movq %r14, 0x20(%rsp)
movswl 0x1e(%r14), %eax
movq %rax, 0x10(%rsp)
leal (%rax,%rdi), %esi
movl %ecx, %eax
cltd
idivl %esi
movzwl %ax, %ebx
cmpl $0x2, %ebx
movl %r8d, 0x4(%rsp)
jb 0x233fc
movq %rdi, 0x8(%rsp)
movl %edi, %eax
imull %ebx, %eax
subl %eax, %ecx
leal -0x1(%rbx), %esi
movl %ecx, %eax
cltd
idivl %esi
movl %eax, %r13d
jmp 0x2341c
movzwl %bp, %eax
shrl $0xf, %eax
addl %ebp, %eax
movl %edi, %r13d
shrl $0x1f, %r13d
addl %edi, %r13d
cwtl
shrl %eax
sarl %r13d
negl %r13d
movq %rax, 0x8(%rsp)
movq 0x18(%rsp), %r15
movq %r15, %rdi
movl $0x1, %esi
callq 0x62e7
movq 0x20(%rsp), %rax
movzwl 0x16(%rax), %r14d
movzwl 0x1a(%rax), %ebp
addq $0x8, %r15
movq %r15, %rdi
callq 0x29e0b
testq %rax, %rax
je 0x234ed
movq %rax, %r12
movq 0x8(%rsp), %rcx
addl %r13d, %ecx
movq 0x10(%rsp), %rax
addl 0x4(%rsp), %eax
movq %rax, 0x10(%rsp)
xorl %r13d, %r13d
movq %rcx, 0x8(%rsp)
movswl %cx, %eax
movl %eax, 0x4(%rsp)
movq %r12, %rdi
callq 0x51ee
testb %al, %al
jne 0x234da
movq %r12, %rdi
movl $0x4, %esi
callq 0x6a3c
testb %al, %al
jne 0x234da
movswl %r14w, %edx
cmpl $0x2, %ebx
jb 0x234b2
movswl %bp, %ebp
movq %r12, %rdi
movl %ebp, %esi
callq 0x4ae2
addl 0x8(%rsp), %ebp
jmp 0x234be
movq %r12, %rdi
movl 0x4(%rsp), %esi
callq 0x4ae2
incl %r13d
movzwl %r13w, %eax
cmpl %eax, %ebx
ja 0x234da
movq 0x20(%rsp), %rax
movzwl 0x1a(%rax), %ebp
addl 0x10(%rsp), %r14d
xorl %r13d, %r13d
movq %r15, %rdi
movq %r12, %rsi
callq 0x29cdb
movq %rax, %r12
testq %rax, %rax
jne 0x23479
movq 0x18(%rsp), %rdi
movl $0x1, %esi
addq $0x28, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
jmp 0x6314
nop