// File: /workspace/github_c_makefile_star2_O2/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 0x6747
movq %rax, %r12
movzwl (%rax), %eax
testw $0xff0, %ax             # imm = 0xFF0
je 0x2197f
movq %rbx, %rdi
callq 0x6316
movq %rax, %rbp
movq %rbx, %rdi
callq 0x47bc
movq %rax, %r14
movq %rax, %rdi
callq 0x6316
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 0x50e5
leaq 0x8(%rsp), %rsi
movq %rbx, %rdi
callq 0x50e5
leaq 0x8(%rbx), %r14
movq %r14, %rdi
callq 0x2805a
testb %al, %al
jne 0x217b2
movq %rbp, 0x28(%rsp)
movb %al, 0x13(%rsp)
movabsq $-0x7c177c1783e783e8, %rax # imm = 0x83E883E87C187C18
movq %rax, 0x8(%rsp)
movq %r14, %rdi
callq 0x27db9
movq %rax, %rbp
testq %rax, %rax
je 0x2177e
movq %rbp, %rdi
callq 0x4e98
testb %al, %al
jne 0x21771
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 0x27e93
jmp 0x21733
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 0x1a23b(%rip), %rsi     # 0x3ba1c
movslq (%rsi,%rdx,4), %rdx
addq %rsi, %rdx
jmpq *%rdx
movl %ecx, %r12d
jmp 0x21815
movl %edi, %ecx
shrl $0x6, %ecx
andl $0x3, %ecx
leaq 0x1a22e(%rip), %rdx     # 0x3ba2c
movslq (%rdx,%rcx,4), %rcx
addq %rdx, %rcx
movl 0x14(%rsp), %r12d
jmpq *%rcx
testb %al, %al
je 0x2184b
movl 0x14(%rsp), %r12d
movl %edi, %ecx
shrl $0x6, %ecx
andl $0x3, %ecx
leaq 0x1a208(%rip), %rdx     # 0x3ba2c
movslq (%rdx,%rcx,4), %rcx
addq %rdx, %rcx
jmpq *%rcx
movzwl 0x8(%rsp), %r12d
movl %edi, %ecx
shrl $0x6, %ecx
andl $0x3, %ecx
leaq 0x1a1ea(%rip), %rdx     # 0x3ba2c
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 0x1a1c4(%rip), %rsi     # 0x3ba2c
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 0x1a1b3(%rip), %rdx     # 0x3ba3c
movslq (%rdx,%rcx,4), %rcx
addq %rdx, %rcx
jmpq *%rcx
movl %edi, %ecx
shrl $0x8, %ecx
andl $0x3, %ecx
leaq 0x1a19b(%rip), %rdx     # 0x3ba3c
movslq (%rdx,%rcx,4), %rcx
addq %rdx, %rcx
jmpq *%rcx
testb %al, %al
je 0x218b3
movl %r13d, %r8d
jmp 0x218c0
movl 0xc(%rsp), %r8d
cmpw %r13w, %r8w
cmovlel %r13d, %r8d
movl %edi, %ecx
shrl $0x8, %ecx
andl $0x3, %ecx
leaq 0x1a16d(%rip), %rdx     # 0x3ba3c
movslq (%rdx,%rcx,4), %rcx
addq %rdx, %rcx
movq %r8, %r13
jmpq *%rcx
movzwl 0xa(%rsp), %ebp
shrl $0xa, %edi
andl $0x3, %edi
leaq 0x1a15f(%rip), %rcx     # 0x3ba4c
movslq (%rcx,%rdi,4), %rdx
addq %rcx, %rdx
jmpq *%rdx
shrl $0xa, %edi
andl $0x3, %edi
leaq 0x1a149(%rip), %rcx     # 0x3ba4c
movslq (%rcx,%rdi,4), %rdx
addq %rcx, %rdx
movl %r15d, %ebp
jmpq *%rdx
testb %al, %al
je 0x21918
movl %r15d, %ebp
jmp 0x21925
movzwl 0xa(%rsp), %ebp
cmpw %r15w, %bp
cmovgel %r15d, %ebp
shrl $0xa, %edi
andl $0x3, %edi
leaq 0x1a11a(%rip), %rcx     # 0x3ba4c
movslq (%rcx,%rdi,4), %rdx
addq %rcx, %rdx
jmpq *%rdx
movzwl 0xe(%rsp), %r9d
jmp 0x21964
testb %al, %al
je 0x21951
movq 0x18(%rsp), %rax
movl %eax, %r9d
jmp 0x21964
movzwl 0xe(%rsp), %r9d
movq 0x18(%rsp), %rax
cmpw %ax, %r9w
cmovlel %eax, %r9d
cmpw %r12w, 0x20(%rbx)
jne 0x2198e
cmpw %bp, 0x22(%rbx)
jne 0x2198e
cmpw %r13w, 0x24(%rbx)
jne 0x2198e
cmpw %r9w, 0x26(%rbx)
jne 0x2198e
addq $0x38, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq %rbx, %rdi
movq %r9, %r15
callq 0x493a
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 0x493a
pushq $0x2
popq %rsi
leaq 0x20(%rsp), %rdx
movq %rbx, %rdi
callq *0x30(%rbx)
pushq $0x1
popq %rsi
movq 0x30(%rsp), %rdi
movq %rbx, %rdx
callq *0x30(%rdi)
movq %rbx, %rdi
callq 0x6460
testb %al, %al
je 0x219f5
movq %rbx, %rdi
callq 0x535c
movq %r14, %rdi
callq 0x27db9
movq %rax, %rbx
pushq $0x3
popq %rbp
testq %rbx, %rbx
je 0x2197f
movq %rbx, %rdi
movl %ebp, %esi
xorl %edx, %edx
callq *0x30(%rbx)
movq %r14, %rdi
movq %rbx, %rsi
callq 0x27e93
movq %rax, %rbx
jmp 0x21a03
nop