// File: /workspace/github_c_makefile_star2_O1/OnionIoT[P]lv_example/lvgl/src/lv_objx/lv_bar.c
// Function: lv_bar_design
static bool lv_bar_design(lv_obj_t * bar, const lv_area_t * mask, lv_design_mode_t mode)
{
    if(mode == LV_DESIGN_COVER_CHK) {
        /*Return false if the object is not covers the mask area*/
        return ancestor_design_f(bar, mask, mode);
    } else if(mode == LV_DESIGN_DRAW_MAIN) {
        lv_opa_t opa_scale = lv_obj_get_opa_scale(bar);

#if LV_USE_GROUP == 0
        ancestor_design_f(bar, mask, mode);
#else
        /* Draw the borders later if the bar is focused.
         * At value = 100% the indicator can cover to whole background and the focused style won't
         * be visible*/
        if(lv_obj_is_focused(bar)) {
            const lv_style_t * style_bg = lv_bar_get_style(bar, LV_BAR_STYLE_BG);
            lv_style_t style_tmp;
            lv_style_copy(&style_tmp, style_bg);
            style_tmp.body.border.width = 0;
            lv_draw_rect(&bar->coords, mask, &style_tmp, opa_scale);
        } else {
            ancestor_design_f(bar, mask, mode);
        }
#endif
        lv_bar_ext_t * ext = lv_obj_get_ext_attr(bar);

        if(ext->cur_value != ext->min_value || ext->sym
#if LV_USE_ANIMATION
           || ext->anim_start != LV_BAR_ANIM_STATE_INV
#endif
        ) {
            const lv_style_t * style_indic = lv_bar_get_style(bar, LV_BAR_STYLE_INDIC);
            lv_area_t indic_area;
            lv_area_copy(&indic_area, &bar->coords);
            indic_area.x1 += style_indic->body.padding.left;
            indic_area.x2 -= style_indic->body.padding.right;
            indic_area.y1 += style_indic->body.padding.top;
            indic_area.y2 -= style_indic->body.padding.bottom;

            lv_coord_t w = lv_area_get_width(&indic_area);
            lv_coord_t h = lv_area_get_height(&indic_area);

            if(w >= h) {
                /*Horizontal*/
#if LV_USE_ANIMATION
                if(ext->anim_state != LV_BAR_ANIM_STATE_INV) {
                    /*Calculate the coordinates of anim. start and end*/
                    lv_coord_t anim_start_x =
                        (int32_t)((int32_t)w * (ext->anim_start - ext->min_value)) / (ext->max_value - ext->min_value);
                    lv_coord_t anim_end_x =
                        (int32_t)((int32_t)w * (ext->anim_end - ext->min_value)) / (ext->max_value - ext->min_value);

                    /*Calculate the real position based on `anim_state` (between `anim_start` and
                     * `anim_end`)*/
                    indic_area.x2 =
                        anim_start_x + (((anim_end_x - anim_start_x) * ext->anim_state) >> LV_BAR_ANIM_STATE_NORM);
                } else
#endif
                {
                    indic_area.x2 =
                        (int32_t)((int32_t)w * (ext->cur_value - ext->min_value)) / (ext->max_value - ext->min_value);
                }

                indic_area.x2 = indic_area.x1 + indic_area.x2 - 1;
                if(ext->sym && ext->min_value < 0 && ext->max_value > 0) {
                    /*Calculate the coordinate of the zero point*/
                    lv_coord_t zero;
                    zero = indic_area.x1 + (-ext->min_value * w) / (ext->max_value - ext->min_value);
                    if(indic_area.x2 > zero)
                        indic_area.x1 = zero;
                    else {
                        indic_area.x1 = indic_area.x2;
                        indic_area.x2 = zero;
                    }
                }
            } else {
#if LV_USE_ANIMATION
                if(ext->anim_state != LV_BAR_ANIM_STATE_INV) {
                    /*Calculate the coordinates of anim. start and end*/
                    lv_coord_t anim_start_y =
                        (int32_t)((int32_t)h * (ext->anim_start - ext->min_value)) / (ext->max_value - ext->min_value);
                    lv_coord_t anim_end_y =
                        (int32_t)((int32_t)h * (ext->anim_end - ext->min_value)) / (ext->max_value - ext->min_value);

                    /*Calculate the real position based on `anim_state` (between `anim_start` and
                     * `anim_end`)*/
                    indic_area.y1 =
                        anim_start_y + (((anim_end_y - anim_start_y) * ext->anim_state) >> LV_BAR_ANIM_STATE_NORM);
                } else
#endif
                {
                    indic_area.y1 =
                        (int32_t)((int32_t)h * (ext->cur_value - ext->min_value)) / (ext->max_value - ext->min_value);
                }

                indic_area.y1 = indic_area.y2 - indic_area.y1 + 1;

                if(ext->sym && ext->min_value < 0 && ext->max_value > 0) {
                    /*Calculate the coordinate of the zero point*/
                    lv_coord_t zero;
                    zero = indic_area.y2 - (-ext->min_value * h) / (ext->max_value - ext->min_value);
                    if(indic_area.y1 < zero)
                        indic_area.y2 = zero;
                    else {
                        indic_area.y2 = indic_area.y1;
                        indic_area.y1 = zero;
                    }
                }
            }

            /*Draw the indicator*/
            lv_draw_rect(&indic_area, mask, style_indic, opa_scale);
        }
    } else if(mode == LV_DESIGN_DRAW_POST) {
#if LV_USE_GROUP
        /*Draw the border*/
        if(lv_obj_is_focused(bar)) {
            lv_opa_t opa_scale          = lv_obj_get_opa_scale(bar);
            const lv_style_t * style_bg = lv_bar_get_style(bar, LV_BAR_STYLE_BG);
            lv_style_t style_tmp;
            lv_style_copy(&style_tmp, style_bg);
            style_tmp.body.opa          = LV_OPA_TRANSP;
            style_tmp.body.shadow.width = 0;
            lv_draw_rect(&bar->coords, mask, &style_tmp, opa_scale);
        }
#endif
    }
    return true;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %rbx
subq $0x48, %rsp
movl %edx, %r14d
movq %rsi, %rbx
movq %rdi, %r15
testl %edx, %edx
je 0x9022
cmpl $0x1, %r14d
je 0x8fce
cmpl $0x2, %r14d
jne 0x9241
movq 0x572e8(%rip), %rax     # 0x602a0
movzbl %r14b, %edx
movq %r15, %rdi
movq %rbx, %rsi
addq $0x48, %rsp
popq %rbx
popq %r14
popq %r15
popq %rbp
jmpq *%rax
movq %r15, %rdi
callq 0x6bbc
testb %al, %al
je 0x9241
movq %r15, %rdi
callq 0x69cc
movl %eax, %ebp
movq %r15, %rdi
xorl %esi, %esi
callq 0x960c
movq %rsp, %r14
movq %r14, %rdi
movq %rax, %rsi
callq 0x798d
movb $0x0, 0x8(%r14)
movw $0x0, 0x12(%r14)
addq $0x20, %r15
movzbl %bpl, %ecx
movq %r15, %rdi
movq %rbx, %rsi
movq %r14, %rdx
jmp 0x923c
movq %r15, %rdi
callq 0x69cc
movl %eax, %ebp
movq %r15, %rdi
callq 0x6bbc
movzbl %bpl, %ebp
testb %al, %al
je 0x906e
movq %r15, %rdi
xorl %esi, %esi
callq 0x960c
movq %rsp, %r14
movq %r14, %rdi
movq %rax, %rsi
callq 0x798d
movw $0x0, 0xc(%r14)
leaq 0x20(%r15), %rdi
movq %rbx, %rsi
movq %r14, %rdx
movl %ebp, %ecx
callq 0x365ac
jmp 0x907e
movzbl %r14b, %edx
movq %r15, %rdi
movq %rbx, %rsi
callq *0x57222(%rip)          # 0x602a0
movq %r15, %rdi
callq 0x6ad8
movq %rax, %r14
movzwl (%rax), %eax
cmpw 0x2(%r14), %ax
jne 0x90a6
testb $0x1, 0xe(%r14)
jne 0x90a6
cmpw $-0x1, 0x6(%r14)
je 0x9241
movq %r15, %rdi
movl $0x1, %esi
callq 0x960c
movq %rax, %rcx
movq 0x20(%r15), %r8
movq %r8, (%rsp)
addw 0x1a(%rax), %r8w
movw %r8w, (%rsp)
movzwl 0x2(%rsp), %esi
movzwl 0x4(%rsp), %eax
subw 0x1c(%rcx), %ax
movw %ax, 0x4(%rsp)
addw 0x16(%rcx), %si
movw %si, 0x2(%rsp)
movzwl 0x6(%rsp), %r9d
subw 0x18(%rcx), %r9w
subl %r8d, %eax
movl %r9d, %edx
subl %esi, %edx
movw %r9w, 0x6(%rsp)
incl %eax
incl %edx
movswl 0xa(%r14), %r10d
cmpw %dx, %ax
jge 0x9157
movswl %dx, %esi
cmpw $-0x1, %r10w
je 0x91a3
movswl 0x6(%r14), %eax
movswl 0x2(%r14), %r8d
subl %r8d, %eax
imull %esi, %eax
movswl 0x4(%r14), %r11d
subl %r8d, %r11d
cltd
idivl %r11d
movl %eax, %edi
movswl 0x8(%r14), %eax
subl %r8d, %eax
imull %esi, %eax
cltd
idivl %r11d
movswl %di, %edx
cwtl
subl %edx, %eax
imull %r10d, %eax
sarl $0x8, %eax
addl %edx, %eax
jmp 0x91bb
movswl %ax, %esi
cmpw $-0x1, %r10w
je 0x91fe
movswl 0x6(%r14), %eax
movswl 0x2(%r14), %r9d
subl %r9d, %eax
imull %esi, %eax
movswl 0x4(%r14), %r11d
subl %r9d, %r11d
cltd
idivl %r11d
movl %eax, %edi
movswl 0x8(%r14), %eax
subl %r9d, %eax
imull %esi, %eax
cltd
idivl %r11d
movswl %di, %edx
cwtl
subl %edx, %eax
imull %r10d, %eax
sarl $0x8, %eax
addl %edx, %eax
jmp 0x9216
movswl (%r14), %eax
movswl 0x2(%r14), %edx
subl %edx, %eax
imull %esi, %eax
movswl 0x4(%r14), %edi
subl %edx, %edi
cltd
idivl %edi
movl %r9d, %edi
subl %eax, %edi
incl %edi
movw %di, 0x2(%rsp)
testb $0x1, 0xe(%r14)
je 0x9231
movswl 0x2(%r14), %eax
testl %eax, %eax
jns 0x9231
movswl 0x4(%r14), %r8d
testl %r8d, %r8d
jle 0x9231
imull %eax, %esi
subl %eax, %r8d
movl %esi, %eax
cltd
idivl %r8d
addl %eax, %r9d
cmpw %r9w, %di
jge 0x9274
movw %r9w, 0x6(%rsp)
jmp 0x9231
movswl (%r14), %eax
movswl 0x2(%r14), %edx
subl %edx, %eax
imull %esi, %eax
movswl 0x4(%r14), %edi
subl %edx, %edi
cltd
idivl %edi
leal (%r8,%rax), %edi
decl %edi
movw %di, 0x4(%rsp)
testb $0x1, 0xe(%r14)
je 0x9231
movswl 0x2(%r14), %eax
testl %eax, %eax
js 0x924e
movq %rsp, %rdi
movq %rbx, %rsi
movq %rcx, %rdx
movl %ebp, %ecx
callq 0x365ac
movb $0x1, %al
addq $0x48, %rsp
popq %rbx
popq %r14
popq %r15
popq %rbp
retq
movswl 0x4(%r14), %r9d
testl %r9d, %r9d
jle 0x9231
imull %eax, %esi
subl %eax, %r9d
movl %esi, %eax
cltd
idivl %r9d
subl %eax, %r8d
cmpw %r8w, %di
jle 0x9281
movw %r8w, (%rsp)
jmp 0x9231
movw %di, 0x6(%rsp)
movw %r9w, 0x2(%rsp)
jmp 0x9231
movw %di, (%rsp)
movw %r8w, 0x4(%rsp)
jmp 0x9231