// File: /workspace/github_c_makefile_star2_O2/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
movq %rsi, %rbx
movq %rdi, %r15
testl %edx, %edx
je 0x87a6
cmpl $0x1, %edx
je 0x8753
cmpl $0x2, %edx
jne 0x8a24
movq 0x55b62(%rip), %rax     # 0x5e2a0
pushq $0x2
popq %rdx
movq %r15, %rdi
movq %rbx, %rsi
addq $0x48, %rsp
popq %rbx
popq %r14
popq %r15
popq %rbp
jmpq *%rax
movq %r15, %rdi
callq 0x6812
testb %al, %al
je 0x8a24
movq %r15, %rdi
callq 0x6649
movl %eax, %ebp
movq %r15, %rdi
xorl %esi, %esi
callq 0x8dae
movq %rsp, %r14
movq %r14, %rdi
movq %rax, %rsi
callq 0x74d4
movb $0x0, 0x8(%r14)
andw $0x0, 0x12(%r14)
addq $0x20, %r15
movzbl %bpl, %ecx
movq %r15, %rdi
movq %rbx, %rsi
movq %r14, %rdx
jmp 0x8a1f
movq %r15, %rdi
callq 0x6649
movl %eax, %ebp
movq %r15, %rdi
callq 0x6812
movzbl %bpl, %ebp
movq %r15, %rdi
testb %al, %al
je 0x87f1
xorl %esi, %esi
callq 0x8dae
movq %rsp, %r14
movq %r14, %rdi
movq %rax, %rsi
callq 0x74d4
andw $0x0, 0xc(%r14)
leaq 0x20(%r15), %rdi
movq %rbx, %rsi
movq %r14, %rdx
movl %ebp, %ecx
callq 0x336d4
jmp 0x87fc
movq %rbx, %rsi
xorl %edx, %edx
callq *0x55aa4(%rip)          # 0x5e2a0
movq %r15, %rdi
callq 0x6747
movq %rax, %r14
movzwl (%rax), %eax
cmpw 0x2(%r14), %ax
jne 0x8824
testb $0x1, 0xe(%r14)
jne 0x8824
cmpw $-0x1, 0x6(%r14)
je 0x8a24
pushq $0x1
popq %rsi
movq %r15, %rdi
callq 0x8dae
movq %rax, %rcx
movq 0x20(%r15), %r8
movzwl 0x1a(%rax), %r9d
addw %r8w, %r9w
movw %r9w, (%rsp)
movq %r8, %rax
shrq $0x20, %rax
subw 0x1c(%rcx), %ax
movw %ax, 0x4(%rsp)
movl %r8d, %esi
shrl $0x10, %esi
addw 0x16(%rcx), %si
movw %si, 0x2(%rsp)
shrq $0x30, %r8
subw 0x18(%rcx), %r8w
subl %r9d, %eax
movl %r8d, %edx
subl %esi, %edx
movw %r8w, 0x6(%rsp)
incl %eax
incl %edx
movswl 0xa(%r14), %r10d
cmpw %dx, %ax
jge 0x88d7
movswl %dx, %esi
cmpw $-0x1, %r10w
je 0x8929
movswl 0x6(%r14), %eax
movswl 0x2(%r14), %r9d
subl %r9d, %eax
imull %esi, %eax
movswl 0x4(%r14), %r11d
movl %r11d, %r15d
subl %r9d, %r15d
cltd
idivl %r15d
movl %eax, %edi
movswl 0x8(%r14), %eax
subl %r9d, %eax
imull %esi, %eax
cltd
idivl %r15d
movswl %di, %edx
cwtl
subl %edx, %eax
imull %r10d, %eax
sarl $0x8, %eax
addl %edx, %eax
jmp 0x8946
movswl %ax, %esi
cmpw $-0x1, %r10w
je 0x8998
movswl 0x6(%r14), %eax
movswl 0x2(%r14), %r8d
subl %r8d, %eax
imull %esi, %eax
movswl 0x4(%r14), %r11d
movl %r11d, %r15d
subl %r8d, %r15d
cltd
idivl %r15d
movl %eax, %edi
movswl 0x8(%r14), %eax
subl %r8d, %eax
imull %esi, %eax
cltd
idivl %r15d
movswl %di, %edx
cwtl
subl %edx, %eax
imull %r10d, %eax
sarl $0x8, %eax
addl %edx, %eax
jmp 0x89b5
movswl (%r14), %eax
movswl 0x2(%r14), %r9d
subl %r9d, %eax
imull %esi, %eax
movswl 0x4(%r14), %r11d
movl %r11d, %edi
subl %r9d, %edi
cltd
idivl %edi
movl %r8d, %edi
subl %eax, %edi
incl %edi
movw %di, 0x2(%rsp)
testb $0x1, 0xe(%r14)
je 0x8a14
testw %r9w, %r9w
setns %al
testw %r11w, %r11w
setle %dl
orb %al, %dl
jne 0x8a14
movswl %r9w, %eax
movzwl %r11w, %r9d
imull %eax, %esi
subl %eax, %r9d
movl %esi, %eax
cltd
idivl %r9d
addl %eax, %r8d
cmpw %r8w, %di
jge 0x89fd
movw %r8w, 0x6(%rsp)
jmp 0x8a14
movswl (%r14), %eax
movswl 0x2(%r14), %r8d
subl %r8d, %eax
imull %esi, %eax
movswl 0x4(%r14), %r11d
movl %r11d, %edi
subl %r8d, %edi
cltd
idivl %edi
leal (%r9,%rax), %edi
decl %edi
movw %di, 0x4(%rsp)
testb $0x1, 0xe(%r14)
je 0x8a14
testw %r8w, %r8w
setns %al
testw %r11w, %r11w
setle %dl
orb %al, %dl
jne 0x8a14
movswl %r8w, %eax
movzwl %r11w, %r8d
imull %eax, %esi
subl %eax, %r8d
movl %esi, %eax
cltd
idivl %r8d
subl %eax, %r9d
cmpw %r9w, %di
jle 0x8a0a
movw %r9w, (%rsp)
jmp 0x8a14
movw %di, 0x6(%rsp)
movw %r8w, 0x2(%rsp)
jmp 0x8a14
movw %di, (%rsp)
movw %r9w, 0x4(%rsp)
movq %rsp, %rdi
movq %rbx, %rsi
movq %rcx, %rdx
movl %ebp, %ecx
callq 0x336d4
movb $0x1, %al
addq $0x48, %rsp
popq %rbx
popq %r14
popq %r15
popq %rbp
retq