// File: /workspace/github_c_makefile_star2_O3/OnionIoT[P]lv_example/lvgl/src/lv_objx/lv_cont.c
// Function: lv_cont_refr_autofit
static void lv_cont_refr_autofit(lv_obj_t * cont)
{
    lv_cont_ext_t * ext = lv_obj_get_ext_attr(cont);

    if(ext->fit_left == LV_FIT_NONE && ext->fit_right == LV_FIT_NONE && ext->fit_top == LV_FIT_NONE &&
       ext->fit_bottom == LV_FIT_NONE) {
        return;
    }

    lv_area_t tight_area;
    lv_area_t ori;
    const lv_style_t * style = lv_obj_get_style(cont);
    lv_obj_t * child_i;

    lv_obj_t * par               = lv_obj_get_parent(cont);
    const lv_style_t * par_style = lv_obj_get_style(par);
    lv_area_t flood_area;
    lv_area_copy(&flood_area, &par->coords);
    flood_area.x1 += par_style->body.padding.left;
    flood_area.x2 -= par_style->body.padding.right;
    flood_area.y1 += par_style->body.padding.top;
    flood_area.y2 -= par_style->body.padding.bottom;

    /*Search the side coordinates of the children*/
    lv_obj_get_coords(cont, &ori);
    lv_obj_get_coords(cont, &tight_area);

    bool has_children = lv_ll_is_empty(&cont->child_ll) ? false : true;

    if(has_children) {
        tight_area.x1 = LV_COORD_MAX;
        tight_area.y1 = LV_COORD_MAX;
        tight_area.x2 = LV_COORD_MIN;
        tight_area.y2 = LV_COORD_MIN;

        LV_LL_READ(cont->child_ll, child_i)
        {
            if(lv_obj_get_hidden(child_i) != false) continue;
            tight_area.x1 = LV_MATH_MIN(tight_area.x1, child_i->coords.x1);
            tight_area.y1 = LV_MATH_MIN(tight_area.y1, child_i->coords.y1);
            tight_area.x2 = LV_MATH_MAX(tight_area.x2, child_i->coords.x2);
            tight_area.y2 = LV_MATH_MAX(tight_area.y2, child_i->coords.y2);
        }

        tight_area.x1 -= style->body.padding.left;
        tight_area.x2 += style->body.padding.right;
        tight_area.y1 -= style->body.padding.top;
        tight_area.y2 += style->body.padding.bottom;
    }

    lv_area_t new_area;
    lv_area_copy(&new_area, &ori);

    switch(ext->fit_left) {
        case LV_FIT_TIGHT: new_area.x1 = tight_area.x1; break;
        case LV_FIT_FLOOD: new_area.x1 = flood_area.x1; break;
        case LV_FIT_FILL: new_area.x1 = has_children ? LV_MATH_MIN(tight_area.x1, flood_area.x1) : flood_area.x1; break;
        default: break;
    }

    switch(ext->fit_right) {
        case LV_FIT_TIGHT: new_area.x2 = tight_area.x2; break;
        case LV_FIT_FLOOD: new_area.x2 = flood_area.x2; break;
        case LV_FIT_FILL: new_area.x2 = has_children ? LV_MATH_MAX(tight_area.x2, flood_area.x2) : flood_area.x2; break;
        default: break;
    }

    switch(ext->fit_top) {
        case LV_FIT_TIGHT: new_area.y1 = tight_area.y1; break;
        case LV_FIT_FLOOD: new_area.y1 = flood_area.y1; break;
        case LV_FIT_FILL: new_area.y1 = has_children ? LV_MATH_MIN(tight_area.y1, flood_area.y1) : flood_area.y1; break;
        default: break;
    }

    switch(ext->fit_bottom) {
        case LV_FIT_TIGHT: new_area.y2 = tight_area.y2; break;
        case LV_FIT_FLOOD: new_area.y2 = flood_area.y2; break;
        case LV_FIT_FILL: new_area.y2 = has_children ? LV_MATH_MAX(tight_area.y2, flood_area.y2) : flood_area.y2; break;
        default: break;
    }

    /*Do nothing if the coordinates are not changed*/
    if(cont->coords.x1 != new_area.x1 || cont->coords.y1 != new_area.y1 || cont->coords.x2 != new_area.x2 ||
       cont->coords.y2 != new_area.y2) {

        lv_obj_invalidate(cont);
        lv_area_copy(&cont->coords, &new_area);
        lv_obj_invalidate(cont);

        /*Notify the object about its new coordinates*/
        cont->signal_cb(cont, LV_SIGNAL_CORD_CHG, &ori);

        /*Inform the parent about the new coordinates*/
        par->signal_cb(par, LV_SIGNAL_CHILD_CHG, cont);

        if(lv_obj_get_auto_realign(cont)) {
            lv_obj_realign(cont);
        }

        /*Tell the children the parent's size has changed*/
        LV_LL_READ(cont->child_ll, child_i)
        {
            child_i->signal_cb(child_i, LV_SIGNAL_PARENT_SIZE_CHG, NULL);
        }
    }
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x38, %rsp
movq %rdi, %rbx
callq 0x6af7
movq %rax, %r12
movzwl (%rax), %eax
testl $0xff0, %eax            # imm = 0xFF0
je 0x2371b
movq %rbx, %rdi
callq 0x66b6
movq %rax, %rbp
movq %rbx, %rdi
callq 0x4ab5
movq %rax, %r14
movq %rax, %rdi
callq 0x66b6
movq %r14, 0x30(%rsp)
movq 0x20(%r14), %rcx
movq %rcx, %r13
movq %rcx, %rsi
movzwl 0x1a(%rax), %edx
addw %cx, %dx
movl %edx, 0x14(%rsp)
movl %ecx, %r15d
shrl $0x10, %r15d
shrq $0x20, %r13
shrq $0x30, %rsi
subw 0x1c(%rax), %r13w
addw 0x16(%rax), %r15w
subw 0x18(%rax), %si
movq %rsi, 0x18(%rsp)
leaq 0x20(%rsp), %rsi
movq %rbx, %rdi
callq 0x542b
leaq 0x8(%rsp), %rsi
movq %rbx, %rdi
callq 0x542b
leaq 0x8(%rbx), %r14
movq %r14, %rdi
callq 0x2a60b
testb %al, %al
jne 0x234af
movq %rbp, 0x28(%rsp)
movb %al, 0x13(%rsp)
movabsq $-0x7c177c1783e783e8, %rax # imm = 0x83E883E87C187C18
movq %rax, 0x8(%rsp)
movq %r14, %rdi
callq 0x2a35c
testq %rax, %rax
je 0x2347b
movq %rax, %rbp
movq %rbp, %rdi
callq 0x51f2
testb %al, %al
jne 0x23468
movq 0x8(%rsp), %xmm0
movq 0x20(%rbp), %xmm1
pminsw %xmm0, %xmm1
movd %xmm1, 0x8(%rsp)
movd 0xc(%rsp), %xmm0
movd 0x24(%rbp), %xmm1
pmaxsw %xmm0, %xmm1
movd %xmm1, 0xc(%rsp)
movq %r14, %rdi
movq %rbp, %rsi
callq 0x2a448
movq %rax, %rbp
testq %rax, %rax
jne 0x23432
movq 0x28(%rsp), %rax
movq 0x16(%rax), %xmm0
pshuflw $0x72, %xmm0, %xmm0     # xmm0 = xmm0[2,0,3,1,4,5,6,7]
movq 0x8(%rsp), %xmm1
movdqa %xmm1, %xmm2
psubw %xmm0, %xmm2
paddw %xmm0, %xmm1
pshufd $0x55, %xmm1, %xmm0     # xmm0 = xmm1[1,1,1,1]
punpckldq %xmm0, %xmm2    # xmm2 = xmm2[0],xmm0[0],xmm2[1],xmm0[1]
movq %xmm2, 0x8(%rsp)
movb 0x13(%rsp), %al
movq 0x20(%rsp), %rcx
movl %ecx, %ebp
shrl $0x10, %ebp
movq %rcx, %rdx
shrq $0x20, %rdx
movq %rdx, %r8
movq %rcx, %r9
shrq $0x30, %r9
movzwl (%r12), %edi
movl %edi, %edx
shrl $0x4, %edx
andl $0x3, %edx
leaq 0x1c63e(%rip), %rsi     # 0x3fb1c
movslq (%rsi,%rdx,4), %rdx
addq %rsi, %rdx
jmpq *%rdx
movl %ecx, %r12d
jmp 0x23512
movl %edi, %ecx
shrl $0x6, %ecx
andl $0x3, %ecx
leaq 0x1c631(%rip), %rdx     # 0x3fb2c
movslq (%rdx,%rcx,4), %rcx
addq %rdx, %rcx
movl 0x14(%rsp), %r12d
jmpq *%rcx
testb %al, %al
je 0x23548
movl 0x14(%rsp), %r12d
movl %edi, %ecx
shrl $0x6, %ecx
andl $0x3, %ecx
leaq 0x1c60b(%rip), %rdx     # 0x3fb2c
movslq (%rdx,%rcx,4), %rcx
addq %rdx, %rcx
jmpq *%rcx
movzwl 0x8(%rsp), %r12d
movl %edi, %ecx
shrl $0x6, %ecx
andl $0x3, %ecx
leaq 0x1c5ed(%rip), %rdx     # 0x3fb2c
movslq (%rdx,%rcx,4), %rcx
addq %rdx, %rcx
jmpq *%rcx
movl 0x8(%rsp), %ecx
movl 0x14(%rsp), %edx
cmpw %dx, %cx
cmovgel %edx, %ecx
movl %edi, %edx
shrl $0x6, %edx
andl $0x3, %edx
leaq 0x1c5c7(%rip), %rsi     # 0x3fb2c
movslq (%rsi,%rdx,4), %rdx
addq %rsi, %rdx
movl %ecx, %r12d
jmpq *%rdx
movzwl 0xc(%rsp), %r13d
movl %edi, %ecx
shrl $0x8, %ecx
andl $0x3, %ecx
leaq 0x1c5b6(%rip), %rdx     # 0x3fb3c
movslq (%rdx,%rcx,4), %rcx
addq %rdx, %rcx
jmpq *%rcx
movl %edi, %ecx
shrl $0x8, %ecx
andl $0x3, %ecx
leaq 0x1c59e(%rip), %rdx     # 0x3fb3c
movslq (%rdx,%rcx,4), %rcx
addq %rdx, %rcx
jmpq *%rcx
testb %al, %al
je 0x235b0
movl %r13d, %r8d
jmp 0x235bd
movl 0xc(%rsp), %r8d
cmpw %r13w, %r8w
cmovlel %r13d, %r8d
movl %edi, %ecx
shrl $0x8, %ecx
andl $0x3, %ecx
leaq 0x1c570(%rip), %rdx     # 0x3fb3c
movslq (%rdx,%rcx,4), %rcx
addq %rdx, %rcx
movq %r8, %r13
jmpq *%rcx
movzwl 0xa(%rsp), %ebp
shrl $0xa, %edi
andl $0x3, %edi
leaq 0x1c562(%rip), %rcx     # 0x3fb4c
movslq (%rcx,%rdi,4), %rdx
addq %rcx, %rdx
jmpq *%rdx
shrl $0xa, %edi
andl $0x3, %edi
leaq 0x1c54c(%rip), %rcx     # 0x3fb4c
movslq (%rcx,%rdi,4), %rdx
addq %rcx, %rdx
movl %r15d, %ebp
jmpq *%rdx
testb %al, %al
je 0x23615
movl %r15d, %ebp
jmp 0x23622
movzwl 0xa(%rsp), %ebp
cmpw %r15w, %bp
cmovgel %r15d, %ebp
shrl $0xa, %edi
andl $0x3, %edi
leaq 0x1c51d(%rip), %rcx     # 0x3fb4c
movslq (%rcx,%rdi,4), %rdx
addq %rcx, %rdx
jmpq *%rdx
movzwl 0xe(%rsp), %r9d
jmp 0x23661
testb %al, %al
je 0x2364e
movq 0x18(%rsp), %rax
movl %eax, %r9d
jmp 0x23661
movzwl 0xe(%rsp), %r9d
movq 0x18(%rsp), %rax
cmpw %ax, %r9w
cmovlel %eax, %r9d
cmpw %r12w, 0x20(%rbx)
jne 0x23680
cmpw %bp, 0x22(%rbx)
jne 0x23680
cmpw %r13w, 0x24(%rbx)
jne 0x23680
cmpw %r9w, 0x26(%rbx)
je 0x2371b
movq %rbx, %rdi
movq %r9, %r15
callq 0x4c4d
movzwl %r15w, %eax
shlq $0x30, %rax
movzwl %r13w, %ecx
shlq $0x20, %rcx
orq %rax, %rcx
shll $0x10, %ebp
orq %rcx, %rbp
movzwl %r12w, %eax
orq %rbp, %rax
movq %rax, 0x20(%rbx)
movq %rbx, %rdi
callq 0x4c4d
leaq 0x20(%rsp), %rdx
movq %rbx, %rdi
movl $0x2, %esi
callq *0x30(%rbx)
movq 0x30(%rsp), %rdi
movl $0x1, %esi
movq %rbx, %rdx
callq *0x30(%rdi)
movq %rbx, %rdi
callq 0x6802
testb %al, %al
je 0x236eb
movq %rbx, %rdi
callq 0x56c1
movq %r14, %rdi
callq 0x2a35c
testq %rax, %rax
je 0x2371b
movq %rax, %rbx
movq %rbx, %rdi
movl $0x3, %esi
xorl %edx, %edx
callq *0x30(%rbx)
movq %r14, %rdi
movq %rbx, %rsi
callq 0x2a448
movq %rax, %rbx
testq %rax, %rax
jne 0x236fb
addq $0x38, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq