// File: /workspace/github_c_makefile_star2_O0/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
movq %rsp, %rbp
subq $0x40, %rsp
movq %rdi, -0x8(%rbp)
movq -0x8(%rbp), %rdi
callq 0xa080
movq %rax, -0x18(%rbp)
movq -0x8(%rbp), %rdi
callq 0x8310
movw %ax, -0x1a(%rbp)
movq -0x8(%rbp), %rdi
xorl %eax, %eax
movl %eax, %esi
callq 0x7c20
movq %rax, %rdi
callq 0x8310
movw %ax, -0x1c(%rbp)
movq -0x8(%rbp), %rdi
callq 0xa1e0
movw %ax, -0x1e(%rbp)
movq -0x8(%rbp), %rdi
xorl %eax, %eax
movl %eax, %esi
callq 0x7c20
movq %rax, %rdi
callq 0x8350
movw %ax, -0x20(%rbp)
movswl -0x1e(%rbp), %eax
movswl -0x1c(%rbp), %ecx
movq -0x18(%rbp), %rdx
movswl 0x1e(%rdx), %edx
addl %edx, %ecx
cltd
idivl %ecx
movw %ax, -0x22(%rbp)
movzwl -0x22(%rbp), %eax
cmpl $0x1, %eax
jle 0x39b36
movswl -0x1c(%rbp), %eax
movl %eax, -0x30(%rbp)
movswl -0x1e(%rbp), %eax
movzwl -0x22(%rbp), %ecx
movswl -0x1c(%rbp), %edx
imull %edx, %ecx
subl %ecx, %eax
movzwl -0x22(%rbp), %ecx
subl $0x1, %ecx
cltd
idivl %ecx
movl %eax, %ecx
movl -0x30(%rbp), %eax
addl %ecx, %eax
movw %ax, -0x24(%rbp)
jmp 0x39b5c
movswl -0x1a(%rbp), %eax
movl $0x2, %ecx
cltd
idivl %ecx
movl %eax, -0x34(%rbp)
movswl -0x1c(%rbp), %eax
movl $0x2, %ecx
cltd
idivl %ecx
movl %eax, %ecx
movl -0x34(%rbp), %eax
subl %ecx, %eax
movw %ax, -0x24(%rbp)
movswl -0x20(%rbp), %eax
movq -0x18(%rbp), %rcx
movswl 0x1e(%rcx), %ecx
addl %ecx, %eax
movw %ax, -0x26(%rbp)
movq -0x8(%rbp), %rdi
movl $0x1, %esi
callq 0x9a50
movq -0x18(%rbp), %rax
movw 0x1a(%rax), %ax
movw %ax, -0x28(%rbp)
movq -0x18(%rbp), %rax
movw 0x16(%rax), %ax
movw %ax, -0x2a(%rbp)
movw $0x0, -0x2c(%rbp)
movq -0x8(%rbp), %rdi
addq $0x8, %rdi
callq 0x458e0
movq %rax, -0x10(%rbp)
cmpq $0x0, -0x10(%rbp)
je 0x39c78
movq -0x10(%rbp), %rdi
callq 0x7c90
andb $0x1, %al
movzbl %al, %eax
cmpl $0x0, %eax
jne 0x39be1
movq -0x10(%rbp), %rdi
movl $0x4, %esi
callq 0xa7d0
andb $0x1, %al
movzbl %al, %eax
cmpl $0x0, %eax
je 0x39be3
jmp 0x39c5e
movzwl -0x22(%rbp), %eax
cmpl $0x1, %eax
jle 0x39c10
movq -0x10(%rbp), %rdi
movw -0x28(%rbp), %ax
movswl %ax, %esi
movswl -0x2a(%rbp), %edx
callq 0x71f0
movswl -0x24(%rbp), %ecx
movswl -0x28(%rbp), %eax
addl %ecx, %eax
movw %ax, -0x28(%rbp)
jmp 0x39c24
movq -0x10(%rbp), %rdi
movw -0x24(%rbp), %ax
movswl %ax, %esi
movswl -0x2a(%rbp), %edx
callq 0x71f0
movw -0x2c(%rbp), %ax
addw $0x1, %ax
movw %ax, -0x2c(%rbp)
movzwl -0x2c(%rbp), %eax
movzwl -0x22(%rbp), %ecx
cmpl %ecx, %eax
jl 0x39c5c
movw $0x0, -0x2c(%rbp)
movq -0x18(%rbp), %rax
movw 0x1a(%rax), %ax
movw %ax, -0x28(%rbp)
movswl -0x26(%rbp), %ecx
movswl -0x2a(%rbp), %eax
addl %ecx, %eax
movw %ax, -0x2a(%rbp)
jmp 0x39c5e
movq -0x8(%rbp), %rdi
addq $0x8, %rdi
movq -0x10(%rbp), %rsi
callq 0x45690
movq %rax, -0x10(%rbp)
jmp 0x39bab
movq -0x8(%rbp), %rdi
movl $0x1, %esi
callq 0x9aa0
addq $0x40, %rsp
popq %rbp
retq
nopl (%rax)