// File: /workspace/github_c_makefile_star2_O2/OnionIoT[P]lv_example/lvgl/src/lv_draw/lv_draw_arc.c
// Function: lv_draw_arc
void lv_draw_arc(lv_coord_t center_x, lv_coord_t center_y, uint16_t radius, const lv_area_t * mask,
                 uint16_t start_angle, uint16_t end_angle, const lv_style_t * style, lv_opa_t opa_scale)
{
    lv_coord_t thickness = style->line.width;
    if(thickness > radius) thickness = radius;

#if LV_ANTIALIAS
    thickness--;
    radius--;
#endif

    lv_coord_t r_out = radius;
    lv_coord_t r_in  = r_out - thickness;
    int16_t deg_base;
    int16_t deg;
    lv_coord_t x_start[4];
    lv_coord_t x_end[4];

    lv_color_t color = style->line.color;
    lv_opa_t opa = opa_scale == LV_OPA_COVER ? style->body.opa : (uint16_t)((uint16_t)style->body.opa * opa_scale) >> 8;

    bool (*deg_test)(uint16_t, uint16_t, uint16_t);
    if(start_angle <= end_angle)
        deg_test = deg_test_norm;
    else
        deg_test = deg_test_inv;

    int middle_r_out = r_out;
#if !LV_ANTIALIAS
    thickness--;
    middle_r_out = r_out - 1;
#endif
    if(deg_test(270, start_angle, end_angle))
        hor_line(center_x - middle_r_out, center_y, mask, thickness, color, opa); /*Left Middle*/
    if(deg_test(90, start_angle, end_angle))
        hor_line(center_x + r_in, center_y, mask, thickness, color, opa); /*Right Middle*/
    if(deg_test(180, start_angle, end_angle))
        ver_line(center_x, center_y - middle_r_out, mask, thickness, color, opa); /*Top Middle*/
    if(deg_test(0, start_angle, end_angle))
        ver_line(center_x, center_y + r_in, mask, thickness, color, opa); /*Bottom middle*/

    uint32_t r_out_sqr = r_out * r_out;
    uint32_t r_in_sqr  = r_in * r_in;
#if LV_ANTIALIAS
    uint32_t r_out_aa_sqr = (r_out + 1) * (r_out + 1);
    uint32_t r_in_aa_sqr  = (r_in - 1) * (r_in - 1);
#endif
    int16_t xi;
    int16_t yi;
    for(yi = -r_out; yi < 0; yi++) {
        x_start[0] = LV_COORD_MIN;
        x_start[1] = LV_COORD_MIN;
        x_start[2] = LV_COORD_MIN;
        x_start[3] = LV_COORD_MIN;
        x_end[0]   = LV_COORD_MIN;
        x_end[1]   = LV_COORD_MIN;
        x_end[2]   = LV_COORD_MIN;
        x_end[3]   = LV_COORD_MIN;
        int xe     = 0;
        for(xi = -r_out; xi < 0; xi++) {

            uint32_t r_act_sqr = xi * xi + yi * yi;
#if LV_ANTIALIAS
            if(r_act_sqr > r_out_aa_sqr) {
                continue;
            }
#else
            if(r_act_sqr > r_out_sqr) continue;
#endif

            deg_base = lv_atan2(xi, yi) - 180;

#if LV_ANTIALIAS
            int opa2 = -1;
            if(r_act_sqr > r_out_sqr) {
                opa2 = LV_OPA_100 * (r_out + 1) - lv_sqrt(LV_OPA_100 * LV_OPA_100 * r_act_sqr);
                if(opa2 < LV_OPA_0)
                    opa2 = LV_OPA_0;
                else if(opa2 > LV_OPA_100)
                    opa2 = LV_OPA_100;
            } else if(r_act_sqr < r_in_sqr) {
                if(xe == 0) xe = xi;
                opa2 = lv_sqrt(LV_OPA_100 * LV_OPA_100 * r_act_sqr) - LV_OPA_100 * (r_in - 1);
                if(opa2 < LV_OPA_0)
                    opa2 = LV_OPA_0;
                else if(opa2 > LV_OPA_100)
                    opa2 = LV_OPA_100;
                if(r_act_sqr < r_in_aa_sqr)
                    break; /*No need to continue the iteration in x once we found the inner edge of the
                              arc*/
            }
            if(opa2 != -1) {
                if(deg_test(180 + deg_base, start_angle, end_angle)) {
                    lv_draw_px(center_x + xi, center_y + yi, mask, color, opa2);
                }
                if(deg_test(360 - deg_base, start_angle, end_angle)) {
                    lv_draw_px(center_x + xi, center_y - yi, mask, color, opa2);
                }
                if(deg_test(180 - deg_base, start_angle, end_angle)) {
                    lv_draw_px(center_x - xi, center_y + yi, mask, color, opa2);
                }
                if(deg_test(deg_base, start_angle, end_angle)) {
                    lv_draw_px(center_x - xi, center_y - yi, mask, color, opa2);
                }
                continue;
            }
#endif

            deg = 180 + deg_base;
            if(deg_test(deg, start_angle, end_angle)) {
                if(x_start[0] == LV_COORD_MIN) x_start[0] = xi;
            } else if(x_start[0] != LV_COORD_MIN && x_end[0] == LV_COORD_MIN) {
                x_end[0] = xi - 1;
            }

            deg = 360 - deg_base;
            if(deg_test(deg, start_angle, end_angle)) {
                if(x_start[1] == LV_COORD_MIN) x_start[1] = xi;
            } else if(x_start[1] != LV_COORD_MIN && x_end[1] == LV_COORD_MIN) {
                x_end[1] = xi - 1;
            }

            deg = 180 - deg_base;
            if(deg_test(deg, start_angle, end_angle)) {
                if(x_start[2] == LV_COORD_MIN) x_start[2] = xi;
            } else if(x_start[2] != LV_COORD_MIN && x_end[2] == LV_COORD_MIN) {
                x_end[2] = xi - 1;
            }

            deg = deg_base;
            if(deg_test(deg, start_angle, end_angle)) {
                if(x_start[3] == LV_COORD_MIN) x_start[3] = xi;
            } else if(x_start[3] != LV_COORD_MIN && x_end[3] == LV_COORD_MIN) {
                x_end[3] = xi - 1;
            }

            if(r_act_sqr < r_in_sqr) {
                xe = xi;
                break; /*No need to continue the iteration in x once we found the inner edge of the
                          arc*/
            }
        }

        if(x_start[0] != LV_COORD_MIN) {
            if(x_end[0] == LV_COORD_MIN) x_end[0] = xe - 1;
            hor_line(center_x + x_start[0], center_y + yi, mask, x_end[0] - x_start[0], color, opa);
        }

        if(x_start[1] != LV_COORD_MIN) {
            if(x_end[1] == LV_COORD_MIN) x_end[1] = xe - 1;
            hor_line(center_x + x_start[1], center_y - yi, mask, x_end[1] - x_start[1], color, opa);
        }

        if(x_start[2] != LV_COORD_MIN) {
            if(x_end[2] == LV_COORD_MIN) x_end[2] = xe - 1;
            hor_line(center_x - x_end[2], center_y + yi, mask, LV_MATH_ABS(x_end[2] - x_start[2]), color, opa);
        }

        if(x_start[3] != LV_COORD_MIN) {
            if(x_end[3] == LV_COORD_MIN) x_end[3] = xe - 1;
            hor_line(center_x - x_end[3], center_y - yi, mask, LV_MATH_ABS(x_end[3] - x_start[3]), color, opa);
        }
    }
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0xa8, %rsp
movq %rcx, 0x18(%rsp)
movl %edx, %ebx
movq %rsi, 0x78(%rsp)
movq %rdi, 0x20(%rsp)
movq 0xe0(%rsp), %rax
movswl 0x3e(%rax), %ecx
cmpl %edx, %ecx
cmovgl %edx, %ecx
movb 0xe8(%rsp), %sil
leal -0x1(%rcx), %ebp
leal -0x1(%rbx), %edx
cmpb $-0x1, %sil
je 0x38bbe
movzbl %sil, %esi
movzbl 0x8(%rax), %r12d
imull %esi, %r12d
shrl $0x8, %r12d
jmp 0x38bc2
movb 0x8(%rax), %r12b
movl %ebx, %r15d
subl %ecx, %r15d
movswl %dx, %r13d
movzwl 0x3c(%rax), %eax
movl %eax, 0xc(%rsp)
cmpw %r9w, %r8w
leaq 0x675(%rip), %rax       # 0x39254
leaq 0x65f(%rip), %rcx       # 0x39245
cmovaq %rax, %rcx
movzwl %r8w, %esi
movzwl %r9w, %edx
movl $0x10e, %edi            # imm = 0x10E
movl %esi, 0x14(%rsp)
movl %edx, 0x10(%rsp)
movq %rcx, 0x48(%rsp)
callq *%rcx
movswl 0x78(%rsp), %r14d
movswl %bp, %ebp
movzbl %r12b, %r12d
testb %al, %al
je 0x38c39
movq 0x20(%rsp), %rax
subl %r13d, %eax
movswl %ax, %edi
movl %r14d, %esi
movq 0x18(%rsp), %rdx
movl %ebp, %ecx
movl 0xc(%rsp), %r8d
movl %r12d, %r9d
callq 0x39263
pushq $0x5a
popq %rdi
movl 0x14(%rsp), %esi
movl 0x10(%rsp), %edx
callq *0x48(%rsp)
testb %al, %al
je 0x38c6e
movq 0x20(%rsp), %rax
addl %r15d, %eax
movswl %ax, %edi
movl %r14d, %esi
movq 0x18(%rsp), %rdx
movl %ebp, %ecx
movl 0xc(%rsp), %r8d
movl %r12d, %r9d
callq 0x39263
movl $0xb4, %edi
movl 0x14(%rsp), %esi
movl 0x10(%rsp), %edx
callq *0x48(%rsp)
movswl 0x20(%rsp), %r14d
testb %al, %al
je 0x38cab
movq 0x78(%rsp), %rax
subl %r13d, %eax
movswl %ax, %esi
movl %r14d, %edi
movq 0x18(%rsp), %rdx
movl %ebp, %ecx
movl 0xc(%rsp), %r8d
movl %r12d, %r9d
callq 0x392a4
xorl %edi, %edi
movl 0x14(%rsp), %esi
movl 0x10(%rsp), %edx
callq *0x48(%rsp)
testb %al, %al
je 0x38cdf
movq 0x78(%rsp), %rax
addl %r15d, %eax
movswl %ax, %esi
movl %r14d, %edi
movq 0x18(%rsp), %rdx
movl %ebp, %ecx
movl 0xc(%rsp), %r8d
movl %r12d, %r9d
callq 0x392a4
movl %r13d, %eax
imull %r13d, %eax
movl %eax, 0xa4(%rsp)
movswl %r15w, %ecx
movl %ecx, %eax
imull %ecx, %eax
movl %eax, 0xa0(%rsp)
incl %r13d
decl %ecx
pushq $0x1
popq %rax
subl %ebx, %eax
imull $0xffffff01, %ecx, %edx # imm = 0xFFFFFF01
movl %edx, 0x94(%rsp)
imull %ecx, %ecx
movl %ecx, 0x98(%rsp)
imull $0xff, %r13d, %ecx
movl %ecx, 0x9c(%rsp)
imull %r13d, %r13d
movswl %ax, %ecx
movq 0x20(%rsp), %rax
addl %ebx, %eax
decl %eax
movl %eax, 0x88(%rsp)
movl %ecx, 0x8c(%rsp)
movl %ecx, %esi
movl %r13d, 0x60(%rsp)
movl %r12d, 0x90(%rsp)
testl %esi, %esi
jns 0x39233
movl %esi, %ecx
imull %esi, %ecx
movq 0x78(%rsp), %rax
leal (%rsi,%rax), %edx
movl %eax, %edi
subl %esi, %edi
movq $0x0, 0x80(%rsp)
movw $0x83e8, %ax            # imm = 0x83E8
movl %eax, 0x58(%rsp)
movl 0x88(%rsp), %eax
movl %eax, %r12d
movl 0x8c(%rsp), %eax
movl %eax, %r15d
movw $0x83e8, %ax            # imm = 0x83E8
movl %eax, 0x54(%rsp)
movw $0x83e8, %ax            # imm = 0x83E8
movl %eax, 0x50(%rsp)
movw $0x83e8, %ax            # imm = 0x83E8
movl %eax, 0x5c(%rsp)
movw $0x83e8, %ax            # imm = 0x83E8
movl %eax, 0x28(%rsp)
movw $0x83e8, %ax            # imm = 0x83E8
movl %eax, 0x2c(%rsp)
movw $0x83e8, %ax            # imm = 0x83E8
movl %eax, 0x30(%rsp)
movw $0x83e8, %ax            # imm = 0x83E8
movl %eax, 0x34(%rsp)
movq %rsi, 0x68(%rsp)
movl %ecx, 0x44(%rsp)
movl %edx, 0x40(%rsp)
movl %edi, 0x3c(%rsp)
movswl %dx, %r14d
movswl %di, %ebx
testl %r15d, %r15d
je 0x39104
movl %r15d, %ebp
imull %r15d, %ebp
addl %ecx, %ebp
cmpl %r13d, %ebp
ja 0x38ffa
movl %r12d, 0x64(%rsp)
movl %r15d, %edi
callq 0x28e4f
movl %eax, %r12d
leal -0xb4(%r12), %eax
movzwl %r12w, %edi
movzwl %ax, %eax
movl %eax, 0x74(%rsp)
cmpl 0xa4(%rsp), %ebp
jbe 0x38e75
movl %ebx, 0x38(%rsp)
movq %r12, %rbx
movl %edi, %r12d
imull $0xfe01, %ebp, %edi     # imm = 0xFE01
callq 0x28f13
movl 0x9c(%rsp), %r13d
subl %eax, %r13d
js 0x38f09
movl $0xff, %eax
cmpl %eax, %r13d
movq 0x48(%rsp), %rbp
jb 0x38f11
movl $0xff, %r13d
jmp 0x38f11
cmpl 0xa0(%rsp), %ebp
jae 0x38edd
movl %edi, 0x38(%rsp)
movq 0x80(%rsp), %rax
testl %eax, %eax
cmovel %r15d, %eax
movq %rax, 0x80(%rsp)
imull $0xfe01, %ebp, %edi     # imm = 0xFE01
callq 0x28f13
movl %eax, %r13d
addl 0x94(%rsp), %r13d
movl $0xff, %eax
cmpl %eax, %r13d
jl 0x38ebe
movl $0xff, %r13d
testl %r13d, %r13d
jg 0x38ec6
xorl %r13d, %r13d
cmpl 0x98(%rsp), %ebp
movq 0x48(%rsp), %rbp
movl 0x38(%rsp), %edi
jae 0x38f1b
jmp 0x39104
movl 0x14(%rsp), %esi
movl 0x10(%rsp), %edx
movq 0x48(%rsp), %rbx
callq *%rbx
testb %al, %al
je 0x39005
movl 0x28(%rsp), %eax
cmpw $0x83e8, %ax            # imm = 0x83E8
cmovel %r15d, %eax
movl %eax, 0x28(%rsp)
jmp 0x39023
xorl %r13d, %r13d
movq 0x48(%rsp), %rbp
movl %r12d, %edi
movq %rbx, %r12
movl 0x38(%rsp), %ebx
movl 0x14(%rsp), %esi
movl 0x10(%rsp), %edx
callq *%rbp
testb %al, %al
je 0x38f49
movq 0x20(%rsp), %rax
addl %r15d, %eax
movswl %ax, %edi
movzbl %r13b, %r8d
movl %r14d, %esi
movq 0x18(%rsp), %rdx
movl 0xc(%rsp), %ecx
callq 0x325fc
movl $0x21c, %eax            # imm = 0x21C
subl %r12d, %eax
movzwl %ax, %edi
movl 0x14(%rsp), %esi
movl 0x10(%rsp), %edx
callq *%rbp
testb %al, %al
je 0x38f81
movq 0x20(%rsp), %rax
addl %r15d, %eax
movswl %ax, %edi
movzbl %r13b, %r8d
movl %ebx, %esi
movq 0x18(%rsp), %rdx
movl 0xc(%rsp), %ecx
callq 0x325fc
movl $0x168, %eax            # imm = 0x168
subl %r12d, %eax
movzwl %ax, %edi
movl 0x14(%rsp), %esi
movl 0x10(%rsp), %edx
callq *%rbp
movl 0x64(%rsp), %r12d
movswl %r12w, %ebp
testb %al, %al
je 0x38fba
movzbl %r13b, %r8d
movl %ebp, %edi
movl %r14d, %esi
movq 0x18(%rsp), %rdx
movl 0xc(%rsp), %ecx
callq 0x325fc
movl 0x74(%rsp), %edi
movl 0x14(%rsp), %esi
movl 0x10(%rsp), %edx
callq *0x48(%rsp)
testb %al, %al
je 0x38fe4
movzbl %r13b, %r8d
movl %ebp, %edi
movl %ebx, %esi
movq 0x18(%rsp), %rdx
movl 0xc(%rsp), %ecx
callq 0x325fc
movl 0x60(%rsp), %r13d
movq 0x68(%rsp), %rsi
movl 0x44(%rsp), %ecx
movl 0x40(%rsp), %edx
movl 0x3c(%rsp), %edi
incl %r15d
decl %r12d
jmp 0x38de3
leal -0x1(%r15), %eax
movw $0x83e8, %cx            # imm = 0x83E8
movl 0x50(%rsp), %edx
cmpw %cx, %dx
cmovnel %edx, %eax
cmpw %cx, 0x28(%rsp)
cmovel %edx, %eax
movl %eax, 0x50(%rsp)
movl $0x21c, %eax            # imm = 0x21C
subl %r12d, %eax
movzwl %ax, %edi
movl 0x14(%rsp), %esi
movl 0x10(%rsp), %edx
callq *%rbx
testb %al, %al
je 0x3904e
movl 0x2c(%rsp), %eax
cmpw $0x83e8, %ax            # imm = 0x83E8
cmovel %r15d, %eax
movl %eax, 0x2c(%rsp)
jmp 0x3906c
leal -0x1(%r15), %eax
movw $0x83e8, %cx            # imm = 0x83E8
movl 0x54(%rsp), %edx
cmpw %cx, %dx
cmovnel %edx, %eax
cmpw %cx, 0x2c(%rsp)
cmovel %edx, %eax
movl %eax, 0x54(%rsp)
movl $0x168, %eax            # imm = 0x168
subl %r12d, %eax
movzwl %ax, %edi
movl 0x14(%rsp), %esi
movl 0x10(%rsp), %edx
callq *%rbx
testb %al, %al
je 0x39097
movl 0x30(%rsp), %eax
cmpw $0x83e8, %ax            # imm = 0x83E8
cmovel %r15d, %eax
movl %eax, 0x30(%rsp)
jmp 0x390b5
leal -0x1(%r15), %eax
movw $0x83e8, %cx            # imm = 0x83E8
movl 0x58(%rsp), %edx
cmpw %cx, %dx
cmovnel %edx, %eax
cmpw %cx, 0x30(%rsp)
cmovel %edx, %eax
movl %eax, 0x58(%rsp)
movl 0x64(%rsp), %r12d
movl 0x74(%rsp), %edi
movl 0x14(%rsp), %esi
movl 0x10(%rsp), %edx
callq *%rbx
testb %al, %al
je 0x390e1
movl 0x34(%rsp), %eax
cmpw $0x83e8, %ax            # imm = 0x83E8
cmovel %r15d, %eax
movl %eax, 0x34(%rsp)
jmp 0x38fe9
leal -0x1(%r15), %eax
movw $0x83e8, %cx            # imm = 0x83E8
movl 0x5c(%rsp), %edx
cmpw %cx, %dx
cmovnel %edx, %eax
cmpw %cx, 0x34(%rsp)
cmovel %edx, %eax
movl %eax, 0x5c(%rsp)
jmp 0x38fe9
movl 0x28(%rsp), %edx
cmpw $0x83e8, %dx            # imm = 0x83E8
movl 0x90(%rsp), %r12d
movq 0x80(%rsp), %r15
je 0x39150
leal -0x1(%r15), %eax
movl 0x50(%rsp), %ecx
cmpw $0x83e8, %cx            # imm = 0x83E8
cmovel %eax, %ecx
subl %edx, %ecx
addl 0x20(%rsp), %edx
movswl %dx, %edi
movswl %cx, %ecx
movl %r14d, %esi
movq 0x18(%rsp), %rdx
movl 0xc(%rsp), %r8d
movl %r12d, %r9d
callq 0x39263
movl 0x2c(%rsp), %edx
cmpw $0x83e8, %dx            # imm = 0x83E8
je 0x3918b
leal -0x1(%r15), %eax
movl 0x54(%rsp), %ecx
cmpw $0x83e8, %cx            # imm = 0x83E8
cmovel %eax, %ecx
subl %edx, %ecx
addl 0x20(%rsp), %edx
movswl %dx, %edi
movswl %cx, %ecx
movl %ebx, %esi
movq 0x18(%rsp), %rdx
movl 0xc(%rsp), %r8d
movl %r12d, %r9d
callq 0x39263
movl 0x30(%rsp), %edx
cmpw $0x83e8, %dx            # imm = 0x83E8
movl 0x60(%rsp), %r13d
je 0x391dc
leal -0x1(%r15), %eax
movl 0x58(%rsp), %ecx
cmpw $0x83e8, %cx            # imm = 0x83E8
cmovel %eax, %ecx
movq 0x20(%rsp), %rax
subl %ecx, %eax
movswl %cx, %ecx
movswl %dx, %edx
subl %edx, %ecx
movl %ecx, %edx
negl %edx
cmovsl %ecx, %edx
movswl %dx, %ecx
movswl %ax, %edi
movl %r14d, %esi
movq 0x18(%rsp), %rdx
movl 0xc(%rsp), %r8d
movl %r12d, %r9d
callq 0x39263
movl 0x34(%rsp), %edx
cmpw $0x83e8, %dx            # imm = 0x83E8
je 0x39227
decl %r15d
movl 0x5c(%rsp), %ecx
cmpw $0x83e8, %cx            # imm = 0x83E8
cmovel %r15d, %ecx
movq 0x20(%rsp), %rax
subl %ecx, %eax
movswl %cx, %ecx
movswl %dx, %edx
subl %edx, %ecx
movl %ecx, %edx
negl %edx
cmovsl %ecx, %edx
movswl %dx, %ecx
movswl %ax, %edi
movl %ebx, %esi
movq 0x18(%rsp), %rdx
movl 0xc(%rsp), %r8d
movl %r12d, %r9d
callq 0x39263
movq 0x68(%rsp), %rsi
incl %esi
jmp 0x38d59
addq $0xa8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq