// File: /workspace/github_c_makefile_star2_O1/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 0x6ad8
movq %rax, %r12
movzwl (%rax), %eax
testl $0xff0, %eax            # imm = 0xFF0
je 0x22fc5
movq %rbx, %rdi
callq 0x6697
movq %rax, %r13
movq %rbx, %rdi
callq 0x4abf
movq %rax, %r14
movq %rax, %rdi
callq 0x6697
movq %r14, 0x30(%rsp)
movq 0x20(%r14), %rcx
movq %rcx, %r15
movq %rcx, %rsi
movzwl 0x1a(%rax), %edx
addw %cx, %dx
movl %edx, 0x1c(%rsp)
shrl $0x10, %ecx
shrq $0x20, %r15
shrq $0x30, %rsi
subw 0x1c(%rax), %r15w
addw 0x16(%rax), %cx
movl %ecx, 0x18(%rsp)
subw 0x18(%rax), %si
movq %rsi, 0x20(%rsp)
leaq 0x28(%rsp), %rsi
movq %rbx, %rdi
callq 0x5427
leaq 0xe(%rsp), %rsi
movq %rbx, %rdi
callq 0x5427
leaq 0x8(%rbx), %r14
movq %r14, %rdi
callq 0x29fcc
testb %al, %al
jne 0x22d51
movb %al, 0x17(%rsp)
movabsq $-0x7c177c1783e783e8, %rax # imm = 0x83E883E87C187C18
movq %rax, 0xe(%rsp)
movq %r14, %rdi
callq 0x29cce
testq %rax, %rax
je 0x22d25
movq %rax, %rbp
movq %rbp, %rdi
callq 0x51ee
testb %al, %al
jne 0x22d12
movzwl 0xe(%rsp), %eax
movl 0x20(%rbp), %ecx
cmpw %cx, %ax
cmovll %eax, %ecx
movw %cx, 0xe(%rsp)
movzwl 0x10(%rsp), %eax
movzwl 0x22(%rbp), %ecx
cmpw %cx, %ax
cmovll %eax, %ecx
movw %cx, 0x10(%rsp)
movzwl 0x12(%rsp), %eax
movl 0x24(%rbp), %ecx
cmpw %cx, %ax
cmovgl %eax, %ecx
movw %cx, 0x12(%rsp)
movzwl 0x14(%rsp), %eax
movzwl 0x26(%rbp), %ecx
cmpw %cx, %ax
cmovgl %eax, %ecx
movw %cx, 0x14(%rsp)
movq %r14, %rdi
movq %rbp, %rsi
callq 0x29dfb
movq %rax, %rbp
testq %rax, %rax
jne 0x22cb8
movzwl 0x1a(%r13), %eax
subw %ax, 0xe(%rsp)
movzwl 0x1c(%r13), %eax
addw %ax, 0x12(%rsp)
movzwl 0x16(%r13), %eax
subw %ax, 0x10(%rsp)
movzwl 0x18(%r13), %eax
addw %ax, 0x14(%rsp)
movb 0x17(%rsp), %al
movq 0x28(%rsp), %rcx
movl %ecx, %r13d
shrl $0x10, %r13d
movq %rcx, %rdx
shrq $0x20, %rdx
movq %rdx, %r8
movq %rcx, %rbp
shrq $0x30, %rbp
movzwl (%r12), %edi
movl %edi, %edx
shrl $0x4, %edx
andl $0x3, %edx
leaq 0x1cc16(%rip), %rsi     # 0x3f998
movslq (%rsi,%rdx,4), %rdx
addq %rsi, %rdx
jmpq *%rdx
movl %ecx, %r12d
jmp 0x22db6
movl %edi, %ecx
shrl $0x6, %ecx
andl $0x3, %ecx
leaq 0x1cc09(%rip), %rdx     # 0x3f9a8
movslq (%rdx,%rcx,4), %rcx
addq %rdx, %rcx
movl 0x1c(%rsp), %r12d
jmpq *%rcx
testb %al, %al
je 0x22dec
movl 0x1c(%rsp), %r12d
movl %edi, %ecx
shrl $0x6, %ecx
andl $0x3, %ecx
leaq 0x1cbe3(%rip), %rdx     # 0x3f9a8
movslq (%rdx,%rcx,4), %rcx
addq %rdx, %rcx
jmpq *%rcx
movzwl 0xe(%rsp), %r12d
movl %edi, %ecx
shrl $0x6, %ecx
andl $0x3, %ecx
leaq 0x1cbc5(%rip), %rdx     # 0x3f9a8
movslq (%rdx,%rcx,4), %rcx
addq %rdx, %rcx
jmpq *%rcx
movzwl 0xe(%rsp), %ecx
movl 0x1c(%rsp), %edx
cmpw %dx, %cx
cmovgel %edx, %ecx
movl %edi, %edx
shrl $0x6, %edx
andl $0x3, %edx
leaq 0x1cb9e(%rip), %rsi     # 0x3f9a8
movslq (%rsi,%rdx,4), %rdx
addq %rsi, %rdx
movl %ecx, %r12d
jmpq *%rdx
movzwl 0x12(%rsp), %r15d
movl %edi, %ecx
shrl $0x8, %ecx
andl $0x3, %ecx
leaq 0x1cb8d(%rip), %rdx     # 0x3f9b8
movslq (%rdx,%rcx,4), %rcx
addq %rdx, %rcx
jmpq *%rcx
movl %edi, %ecx
shrl $0x8, %ecx
andl $0x3, %ecx
leaq 0x1cb75(%rip), %rdx     # 0x3f9b8
movslq (%rdx,%rcx,4), %rcx
addq %rdx, %rcx
jmpq *%rcx
testb %al, %al
je 0x22e55
movl %r15d, %r8d
jmp 0x22e63
movzwl 0x12(%rsp), %r8d
cmpw %r15w, %r8w
cmovlel %r15d, %r8d
movl %edi, %ecx
shrl $0x8, %ecx
andl $0x3, %ecx
leaq 0x1cb46(%rip), %rdx     # 0x3f9b8
movslq (%rdx,%rcx,4), %rcx
addq %rdx, %rcx
movq %r8, %r15
jmpq *%rcx
movzwl 0x10(%rsp), %r13d
shrl $0xa, %edi
andl $0x3, %edi
leaq 0x1cb37(%rip), %rcx     # 0x3f9c8
movslq (%rcx,%rdi,4), %rdx
addq %rcx, %rdx
jmpq *%rdx
shrl $0xa, %edi
andl $0x3, %edi
leaq 0x1cb21(%rip), %rcx     # 0x3f9c8
movslq (%rcx,%rdi,4), %rdx
addq %rcx, %rdx
movl 0x18(%rsp), %ecx
movl %ecx, %r13d
jmpq *%rdx
testb %al, %al
je 0x22ec4
movl 0x18(%rsp), %ecx
movl %ecx, %r13d
jmp 0x22ed6
movzwl 0x10(%rsp), %r13d
movl 0x18(%rsp), %ecx
cmpw %cx, %r13w
cmovgel %ecx, %r13d
shrl $0xa, %edi
andl $0x3, %edi
leaq 0x1cae5(%rip), %rcx     # 0x3f9c8
movslq (%rcx,%rdi,4), %rdx
addq %rcx, %rdx
jmpq *%rdx
movzwl 0x14(%rsp), %ebp
jmp 0x22f0e
testb %al, %al
je 0x22efe
movq 0x20(%rsp), %rbp
jmp 0x22f0e
movzwl 0x14(%rsp), %ebp
movq 0x20(%rsp), %rax
cmpw %ax, %bp
cmovlel %eax, %ebp
cmpw %r12w, 0x20(%rbx)
jne 0x22f2d
cmpw %r13w, 0x22(%rbx)
jne 0x22f2d
cmpw %r15w, 0x24(%rbx)
jne 0x22f2d
cmpw %bp, 0x26(%rbx)
je 0x22fc5
movq %rbx, %rdi
callq 0x4c36
movzwl %bp, %eax
shlq $0x30, %rax
movzwl %r15w, %ecx
shlq $0x20, %rcx
orq %rax, %rcx
shll $0x10, %r13d
orq %rcx, %r13
movzwl %r12w, %eax
orq %r13, %rax
movq %rax, 0x20(%rbx)
movq %rbx, %rdi
callq 0x4c36
leaq 0x28(%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 0x67e3
testb %al, %al
je 0x22f95
movq %rbx, %rdi
callq 0x56a5
movq %r14, %rdi
callq 0x29cce
testq %rax, %rax
je 0x22fc5
movq %rax, %rbx
movq %rbx, %rdi
movl $0x3, %esi
xorl %edx, %edx
callq *0x30(%rbx)
movq %r14, %rdi
movq %rbx, %rsi
callq 0x29dfb
movq %rax, %rbx
testq %rax, %rax
jne 0x22fa5
addq $0x38, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq