// File: /workspace/github_c_makefile_star2_O3/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:
testl %edx, %edx
jne 0x25130
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x98, %rsp
movq %rsi, %r12
movq %rdi, %rbx
movl %edx, 0x18(%rsp)
callq 0x6af7
movq %rax, %r14
movq %rbx, %rdi
callq 0x66b6
movq %rax, %r15
movq %rbx, %rdi
callq 0x69eb
movb %al, 0xf(%rsp)
leaq 0x50(%rsp), %rdi
movq %r15, %rsi
callq 0x799d
movq %rbx, %rdi
callq 0x4ed1
movq %rax, %rdi
callq 0x2a19
cmpq %rbx, %rax
jne 0x24e1b
incw 0x8e(%rsp)
movq %rbx, %rdi
callq 0x566d
movl %eax, %r13d
movzwl 0x1a(%r15), %ebp
movq %rbx, %rdi
callq 0x566d
movzwl %ax, %ecx
shrl $0xf, %ecx
addl %eax, %ecx
movswl %cx, %eax
shrl %eax
addw 0x20(%rbx), %ax
movl %eax, 0x2c(%rsp)
movq %rbx, %rdi
callq 0x5697
movzwl %ax, %ecx
shrl $0xf, %ecx
addl %eax, %ecx
movswl %cx, %eax
shrl %eax
addw 0x22(%rbx), %ax
movl %eax, 0x28(%rsp)
movzwl 0x2(%r14), %edi
movzwl (%r14), %r8d
movswl 0x6(%r14), %eax
movswl 0x8(%r14), %edx
movzwl 0x4(%r14), %ecx
movswl 0xa(%r14), %esi
movq %r15, 0x40(%rsp)
movzwl 0x2(%r15), %r9d
movw %r9w, 0x8c(%rsp)
testl %ecx, %ecx
je 0x2511b
movq %r14, %rbx
movl $0x168, %r9d            # imm = 0x168
subl %r8d, %r9d
movl %r9d, %r8d
shrl $0x1f, %r8d
addl %r9d, %r8d
sarl %r8d
addl %r8d, %edi
addl $0x5a, %edi
movq %rdi, 0x48(%rsp)
movzwl %r13w, %edi
shrl $0xf, %edi
addl %r13d, %edi
movswl %di, %edi
sarl %edi
movl %edi, %r8d
subl %ebp, %r8d
cmpw $0x2, %r8w
movl $0x1, %r9d
cmovgel %r8d, %r9d
shll $0x5, %r9d
shll $0x5, %edi
subl %edx, %eax
imull %ecx, %eax
subl %edx, %esi
cltd
idivl %esi
movswl %di, %edx
movswl %r9w, %esi
addl %edx, %edx
movl %edx, 0x24(%rsp)
addl %esi, %esi
movl %esi, 0x20(%rsp)
cwtl
movl %eax, 0x1c(%rsp)
movb $0x1, %r14b
xorl %r15d, %r15d
movq %r12, 0x38(%rsp)
movq %rbx, 0x30(%rsp)
movzwl (%rbx), %eax
imull %r15d, %eax
decl %ecx
xorl %edx, %edx
divl %ecx
movl %eax, %ebx
movq 0x48(%rsp), %r12
leal (%r12,%rbx), %eax
movswl %ax, %r13d
movl %r13d, %edi
callq 0x2b4d8
movswl %ax, %ebp
leal (%r12,%rbx), %eax
addl $0x5a, %eax
movswl %ax, %ebx
movl %ebx, %edi
callq 0x2b4d8
movswl %ax, %r12d
movl %r13d, %edi
callq 0x2b4d8
movswl %ax, %r13d
movl %ebx, %edi
callq 0x2b4d8
movswl %ax, %edx
movl 0x24(%rsp), %edi
imull %edi, %r12d
sarl $0x10, %r12d
movl %r12d, %eax
negl %eax
cmovsl %r12d, %eax
movl %eax, %ecx
shrl $0x5, %ecx
btl $0x4, %eax
adcl $0x0, %ecx
movl %ecx, %eax
negl %eax
testl %r12d, %r12d
cmovnsl %ecx, %eax
movl 0x20(%rsp), %r8d
imull %r8d, %edx
sarl $0x10, %edx
movl %edx, %ecx
negl %ecx
cmovsl %edx, %ecx
movl %ecx, %esi
shrl $0x5, %esi
btl $0x4, %ecx
adcl $0x0, %esi
movl %esi, %ecx
negl %ecx
testl %edx, %edx
cmovnsl %esi, %ecx
imull %edi, %ebp
sarl $0x10, %ebp
movl %ebp, %edx
negl %edx
cmovsl %ebp, %edx
movl %edx, %esi
shrl $0x5, %esi
btl $0x4, %edx
adcl $0x0, %esi
movl %esi, %edx
negl %edx
testl %ebp, %ebp
cmovnsl %esi, %edx
imull %r8d, %r13d
sarl $0x10, %r13d
movl %r13d, %esi
negl %esi
cmovsl %r13d, %esi
movl %esi, %edi
shrl $0x5, %edi
btl $0x4, %esi
adcl $0x0, %edi
movl %edi, %esi
negl %esi
testl %r13d, %r13d
cmovnsl %edi, %esi
movl 0x2c(%rsp), %edi
addl %edi, %ecx
movw %cx, 0x10(%rsp)
movl 0x28(%rsp), %ecx
addl %ecx, %esi
movw %si, 0x12(%rsp)
addl %edi, %eax
movw %ax, 0x14(%rsp)
addl %ecx, %edx
movw %dx, 0x16(%rsp)
cmpl %r15d, 0x1c(%rsp)
jle 0x250cf
leal -0x1(%r14), %eax
movzbl %al, %ecx
movl %ecx, %eax
shll $0x8, %eax
subl %ecx, %eax
xorl %edx, %edx
movq 0x30(%rsp), %r10
divw 0x4(%r10)
movq 0x40(%rsp), %rcx
movzwl 0x4(%rcx), %edx
movzwl 0x2(%rcx), %ecx
movl %edx, %edi
shrl $0xb, %edi
movl $0xff, %r9d
andl %r9d, %eax
imull %eax, %edi
movl %ecx, %esi
shrl $0xb, %esi
movl %edx, %r8d
shrl $0x5, %r8d
andl $0x3f, %r8d
imull %eax, %r8d
andl $0x1f, %edx
imull %eax, %edx
xorl %r9d, %eax
imull %eax, %esi
addl %edi, %esi
andl $0xffff3f00, %esi       # imm = 0xFFFF3F00
movl %ecx, %edi
shrl $0x5, %edi
andl $0x3f, %edi
imull %eax, %edi
addl %r8d, %edi
shrl $0x3, %edi
andl $0x7e0, %edi            # imm = 0x7E0
andl $0x1f, %ecx
imull %eax, %ecx
addl %edx, %ecx
shrl $0x8, %ecx
andl $0x1f, %ecx
leal (%rcx,%rsi,8), %eax
orl %edi, %eax
movq 0x38(%rsp), %r12
movq %r10, %rbx
jmp 0x250e2
movq 0x40(%rsp), %rax
movzwl 0x3c(%rax), %eax
movq 0x38(%rsp), %r12
movq 0x30(%rsp), %rbx
movw %ax, 0x8c(%rsp)
movzbl 0xf(%rsp), %r8d
leaq 0x14(%rsp), %rdi
leaq 0x10(%rsp), %rsi
movq %r12, %rdx
leaq 0x50(%rsp), %rcx
callq 0x3ad34
movzbl %r14b, %r15d
movzwl 0x4(%rbx), %ecx
incb %r14b
cmpl %ecx, %r15d
jb 0x24f1e
movl 0x18(%rsp), %edx
addq $0x98, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
cmpb $0x2, %dl
setne %al
retq