// File: /workspace/github_c_makefile_star2_O0/OnionIoT[P]lv_example/lvgl/src/lv_objx/lv_lmeter.c
// Function: lv_lmeter_design
static bool lv_lmeter_design(lv_obj_t * lmeter, const lv_area_t * mask, lv_design_mode_t mode)
{
    /*Return false if the object is not covers the mask_p area*/
    if(mode == LV_DESIGN_COVER_CHK) {
        return false;
    }
    /*Draw the object*/
    else if(mode == LV_DESIGN_DRAW_MAIN) {
        lv_lmeter_ext_t * ext    = lv_obj_get_ext_attr(lmeter);
        const lv_style_t * style = lv_obj_get_style(lmeter);
        lv_opa_t opa_scale       = lv_obj_get_opa_scale(lmeter);
        lv_style_t style_tmp;
        lv_style_copy(&style_tmp, style);

#if LV_USE_GROUP
        lv_group_t * g = lv_obj_get_group(lmeter);
        if(lv_group_get_focused(g) == lmeter) {
            style_tmp.line.width += 1;
        }
#endif

        lv_coord_t r_out = lv_obj_get_width(lmeter) / 2;
        lv_coord_t r_in  = r_out - style->body.padding.left;
        if(r_in < 1) r_in = 1;

        lv_coord_t x_ofs  = lv_obj_get_width(lmeter) / 2 + lmeter->coords.x1;
        lv_coord_t y_ofs  = lv_obj_get_height(lmeter) / 2 + lmeter->coords.y1;
        int16_t angle_ofs = ext->angle_ofs + 90 + (360 - ext->scale_angle) / 2;
        int16_t level =
            (int32_t)((int32_t)(ext->cur_value - ext->min_value) * ext->line_cnt) / (ext->max_value - ext->min_value);
        uint8_t i;

        style_tmp.line.color = style->body.main_color;

        /*Calculate every coordinate in a bigger size to make rounding later*/
        r_out = r_out << LV_LMETER_LINE_UPSCALE;
        r_in  = r_in << LV_LMETER_LINE_UPSCALE;

        for(i = 0; i < ext->line_cnt; i++) {
            /*Calculate the position a scale label*/
            int16_t angle = (i * ext->scale_angle) / (ext->line_cnt - 1) + angle_ofs;

            lv_coord_t y_out = (int32_t)((int32_t)lv_trigo_sin(angle) * r_out) >> LV_TRIGO_SHIFT;
            lv_coord_t x_out = (int32_t)((int32_t)lv_trigo_sin(angle + 90) * r_out) >> LV_TRIGO_SHIFT;
            lv_coord_t y_in  = (int32_t)((int32_t)lv_trigo_sin(angle) * r_in) >> LV_TRIGO_SHIFT;
            lv_coord_t x_in  = (int32_t)((int32_t)lv_trigo_sin(angle + 90) * r_in) >> LV_TRIGO_SHIFT;

            /*Rounding*/
            x_out = lv_lmeter_coord_round(x_out);
            x_in  = lv_lmeter_coord_round(x_in);
            y_out = lv_lmeter_coord_round(y_out);
            y_in  = lv_lmeter_coord_round(y_in);

            lv_point_t p1;
            lv_point_t p2;

            p2.x = x_in + x_ofs;
            p2.y = y_in + y_ofs;

            p1.x = x_out + x_ofs;
            p1.y = y_out + y_ofs;

            if(i >= level)
                style_tmp.line.color = style->line.color;
            else {
                style_tmp.line.color =
                    lv_color_mix(style->body.grad_color, style->body.main_color, (255 * i) / ext->line_cnt);
            }

            lv_draw_line(&p1, &p2, mask, &style_tmp, opa_scale);
        }

    }
    /*Post draw when the children are drawn*/
    else if(mode == LV_DESIGN_DRAW_POST) {
    }

    return true;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0xc0, %rsp
movb %dl, %al
movq %rdi, -0x10(%rbp)
movq %rsi, -0x18(%rbp)
movb %al, -0x19(%rbp)
movzbl -0x19(%rbp), %eax
cmpl $0x2, %eax
jne 0x3b9ea
movb $0x0, -0x1(%rbp)
jmp 0x3bdc2
movzbl -0x19(%rbp), %eax
cmpl $0x0, %eax
jne 0x3bdaf
movq -0x10(%rbp), %rdi
callq 0xa8f0
movq %rax, -0x28(%rbp)
movq -0x10(%rbp), %rdi
callq 0xa080
movq %rax, -0x30(%rbp)
movq -0x10(%rbp), %rdi
callq 0xa710
movb %al, -0x31(%rbp)
movq -0x30(%rbp), %rsi
leaq -0x80(%rbp), %rdi
callq 0xc550
movq -0x10(%rbp), %rdi
callq 0x77c0
movq %rax, -0x88(%rbp)
movq -0x88(%rbp), %rdi
callq 0x3010
cmpq -0x10(%rbp), %rax
jne 0x3ba57
movswl -0x42(%rbp), %eax
addl $0x1, %eax
movw %ax, -0x42(%rbp)
movq -0x10(%rbp), %rdi
callq 0x8310
cwtl
movl $0x2, %ecx
cltd
idivl %ecx
movw %ax, -0x8a(%rbp)
movswl -0x8a(%rbp), %eax
movq -0x30(%rbp), %rcx
movswl 0x1a(%rcx), %ecx
subl %ecx, %eax
movw %ax, -0x8c(%rbp)
movswl -0x8c(%rbp), %eax
cmpl $0x1, %eax
jge 0x3ba9d
movw $0x1, -0x8c(%rbp)
movq -0x10(%rbp), %rdi
callq 0x8310
cwtl
movl $0x2, %ecx
cltd
idivl %ecx
movq -0x10(%rbp), %rcx
movswl 0x20(%rcx), %ecx
addl %ecx, %eax
movw %ax, -0x8e(%rbp)
movq -0x10(%rbp), %rdi
callq 0x8350
cwtl
movl $0x2, %ecx
cltd
idivl %ecx
movq -0x10(%rbp), %rcx
movswl 0x22(%rcx), %ecx
addl %ecx, %eax
movw %ax, -0x90(%rbp)
movq -0x28(%rbp), %rax
movzwl 0x2(%rax), %eax
addl $0x5a, %eax
movl %eax, -0xb0(%rbp)
movq -0x28(%rbp), %rax
movzwl (%rax), %ecx
movl $0x168, %eax            # imm = 0x168
subl %ecx, %eax
movl $0x2, %ecx
cltd
idivl %ecx
movl %eax, %ecx
movl -0xb0(%rbp), %eax
addl %ecx, %eax
movw %ax, -0x92(%rbp)
movq -0x28(%rbp), %rax
movswl 0x6(%rax), %eax
movq -0x28(%rbp), %rcx
movswl 0x8(%rcx), %ecx
subl %ecx, %eax
movq -0x28(%rbp), %rcx
movzwl 0x4(%rcx), %ecx
imull %ecx, %eax
movq -0x28(%rbp), %rcx
movswl 0xa(%rcx), %ecx
movq -0x28(%rbp), %rdx
movswl 0x8(%rdx), %edx
subl %edx, %ecx
cltd
idivl %ecx
movw %ax, -0x94(%rbp)
movq -0x30(%rbp), %rax
movw 0x2(%rax), %ax
movw %ax, -0x44(%rbp)
movswl -0x8a(%rbp), %eax
shll $0x5, %eax
movw %ax, -0x8a(%rbp)
movswl -0x8c(%rbp), %eax
shll $0x5, %eax
movw %ax, -0x8c(%rbp)
movb $0x0, -0x95(%rbp)
movzbl -0x95(%rbp), %eax
movq -0x28(%rbp), %rcx
movzwl 0x4(%rcx), %ecx
cmpl %ecx, %eax
jge 0x3bdad
movzbl -0x95(%rbp), %eax
movq -0x28(%rbp), %rcx
movzwl (%rcx), %ecx
imull %ecx, %eax
movq -0x28(%rbp), %rcx
movzwl 0x4(%rcx), %ecx
subl $0x1, %ecx
cltd
idivl %ecx
movswl -0x92(%rbp), %ecx
addl %ecx, %eax
movw %ax, -0x98(%rbp)
movswl -0x98(%rbp), %edi
callq 0x47220
cwtl
movswl -0x8a(%rbp), %ecx
imull %ecx, %eax
sarl $0xf, %eax
movw %ax, -0x9a(%rbp)
movswl -0x98(%rbp), %eax
addl $0x5a, %eax
movswl %ax, %edi
callq 0x47220
cwtl
movswl -0x8a(%rbp), %ecx
imull %ecx, %eax
sarl $0xf, %eax
movw %ax, -0x9c(%rbp)
movswl -0x98(%rbp), %edi
callq 0x47220
cwtl
movswl -0x8c(%rbp), %ecx
imull %ecx, %eax
sarl $0xf, %eax
movw %ax, -0x9e(%rbp)
movswl -0x98(%rbp), %eax
addl $0x5a, %eax
movswl %ax, %edi
callq 0x47220
cwtl
movswl -0x8c(%rbp), %ecx
imull %ecx, %eax
sarl $0xf, %eax
movw %ax, -0xa0(%rbp)
movswl -0x9c(%rbp), %edi
callq 0x3c260
movw %ax, -0x9c(%rbp)
movswl -0xa0(%rbp), %edi
callq 0x3c260
movw %ax, -0xa0(%rbp)
movswl -0x9a(%rbp), %edi
callq 0x3c260
movw %ax, -0x9a(%rbp)
movswl -0x9e(%rbp), %edi
callq 0x3c260
movw %ax, -0x9e(%rbp)
movswl -0xa0(%rbp), %eax
movswl -0x8e(%rbp), %ecx
addl %ecx, %eax
movw %ax, -0xa8(%rbp)
movswl -0x9e(%rbp), %eax
movswl -0x90(%rbp), %ecx
addl %ecx, %eax
movw %ax, -0xa6(%rbp)
movswl -0x9c(%rbp), %eax
movswl -0x8e(%rbp), %ecx
addl %ecx, %eax
movw %ax, -0xa4(%rbp)
movswl -0x9a(%rbp), %eax
movswl -0x90(%rbp), %ecx
addl %ecx, %eax
movw %ax, -0xa2(%rbp)
movzbl -0x95(%rbp), %eax
movswl -0x94(%rbp), %ecx
cmpl %ecx, %eax
jl 0x3bd27
movq -0x30(%rbp), %rax
movw 0x3c(%rax), %ax
movw %ax, -0x44(%rbp)
jmp 0x3bd7a
movq -0x30(%rbp), %rax
movq %rax, -0xb8(%rbp)
movq -0x30(%rbp), %rcx
movzbl -0x95(%rbp), %eax
imull $0xff, %eax, %eax
movq -0x28(%rbp), %rdx
movzwl 0x4(%rdx), %esi
cltd
idivl %esi
movq -0xb8(%rbp), %rdx
movw 0x4(%rdx), %dx
movzwl %dx, %edi
movzwl 0x2(%rcx), %esi
movzbl %al, %edx
callq 0x3c2b0
movw %ax, -0xaa(%rbp)
movw -0xaa(%rbp), %ax
movw %ax, -0x44(%rbp)
movq -0x18(%rbp), %rdx
leaq -0xa4(%rbp), %rdi
leaq -0xa8(%rbp), %rsi
leaq -0x80(%rbp), %rcx
movzbl -0x31(%rbp), %r8d
callq 0x5fcd0
movb -0x95(%rbp), %al
addb $0x1, %al
movb %al, -0x95(%rbp)
jmp 0x3bb89
jmp 0x3bdbc
movzbl -0x19(%rbp), %eax
cmpl $0x1, %eax
jne 0x3bdba
jmp 0x3bdba
jmp 0x3bdbc
jmp 0x3bdbe
movb $0x1, -0x1(%rbp)
movb -0x1(%rbp), %al
andb $0x1, %al
addq $0xc0, %rsp
popq %rbp
retq