// File: /workspace/github_c_makefile_star2_O3/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, 0x30(%rsp)
movl %edx, %ebx
movl %esi, %r13d
movq %rdi, 0x28(%rsp)
movq 0xe0(%rsp), %rax
movswl 0x3e(%rax), %ecx
cmpl %edx, %ecx
cmovgl %edx, %ecx
movb 0xe8(%rsp), %dl
leal -0x1(%rcx), %r12d
leal -0x1(%rbx), %esi
movl %esi, 0x44(%rsp)
cmpb $-0x1, %dl
je 0x3ca93
movzbl %dl, %edx
movzbl 0x8(%rax), %ebp
imull %edx, %ebp
shrl $0x8, %ebp
jmp 0x3ca97
movb 0x8(%rax), %bpl
movl %ebx, %r15d
subl %ecx, %r15d
movzwl 0x3c(%rax), %eax
movl %eax, 0xc(%rsp)
cmpw %r9w, %r8w
leaq 0x71e(%rip), %rax       # 0x3d1ce
leaq 0x708(%rip), %rcx       # 0x3d1bf
cmovaq %rax, %rcx
movzwl %r8w, %esi
movzwl %r9w, %edx
movl $0x10e, %edi            # imm = 0x10E
movl %esi, 0x14(%rsp)
movl %edx, 0x10(%rsp)
movq %rcx, 0x38(%rsp)
callq *%rcx
movzbl %bpl, %ecx
movl %ecx, 0x1c(%rsp)
testb %al, %al
je 0x3cb1f
movq 0x28(%rsp), %rax
subl 0x44(%rsp), %eax
leal (%r12,%rax), %ecx
movswl %ax, %esi
movswl %cx, %ecx
movswl %r13w, %edx
leaq 0x70(%rsp), %r14
movq %r14, %rdi
movl %edx, %r8d
callq 0x28cbc
movq %r14, %rdi
movq 0x30(%rsp), %rsi
movl 0xc(%rsp), %edx
movl 0x1c(%rsp), %ecx
callq 0x35793
movl $0x5a, %edi
movl 0x14(%rsp), %esi
movl 0x10(%rsp), %edx
callq *0x38(%rsp)
testb %al, %al
je 0x3cb6f
movq 0x28(%rsp), %rax
addl %r15d, %eax
leal (%r12,%rax), %ecx
movswl %ax, %esi
movswl %cx, %ecx
movswl %r13w, %edx
leaq 0x70(%rsp), %r14
movq %r14, %rdi
movl %edx, %r8d
callq 0x28cbc
movq %r14, %rdi
movq 0x30(%rsp), %rsi
movl 0xc(%rsp), %edx
movl 0x1c(%rsp), %ecx
callq 0x35793
movl $0xb4, %edi
movl 0x14(%rsp), %esi
movl 0x10(%rsp), %edx
callq *0x38(%rsp)
testb %al, %al
je 0x3cbbf
movl %r13d, %eax
subl 0x44(%rsp), %eax
leal (%r12,%rax), %ecx
movswl %ax, %edx
movswl %cx, %r8d
movswl 0x28(%rsp), %ecx
leaq 0x70(%rsp), %r14
movq %r14, %rdi
movl %ecx, %esi
callq 0x28cbc
movq %r14, %rdi
movq 0x30(%rsp), %rsi
movl 0xc(%rsp), %edx
movl 0x1c(%rsp), %ecx
callq 0x35793
xorl %edi, %edi
movl 0x14(%rsp), %esi
movl 0x10(%rsp), %edx
callq *0x38(%rsp)
testb %al, %al
je 0x3cc08
leal (%r15,%r13), %eax
addl %eax, %r12d
movswl %ax, %edx
movswl %r12w, %r8d
movswl 0x28(%rsp), %ecx
leaq 0x70(%rsp), %r14
movq %r14, %rdi
movl %ecx, %esi
callq 0x28cbc
movq %r14, %rdi
movq 0x30(%rsp), %rsi
movl 0xc(%rsp), %edx
movl 0x1c(%rsp), %ecx
callq 0x35793
movw $0x1, %ax
subw %bx, %ax
jns 0x3d1ad
movswl 0x44(%rsp), %ecx
movl %ecx, %edx
imull %ecx, %edx
movl %edx, 0x9c(%rsp)
movswl %r15w, %edx
movl %edx, %esi
imull %edx, %esi
movl %esi, 0x90(%rsp)
incl %ecx
movl %ecx, %esi
shll $0x8, %esi
subl %ecx, %esi
movl %esi, 0x8c(%rsp)
movl %ecx, %r12d
imull %ecx, %r12d
decl %edx
movl %edx, %ecx
imull %edx, %ecx
movl %ecx, 0x84(%rsp)
movl %edx, %ecx
shll $0x8, %ecx
subl %ecx, %edx
movl %edx, 0x88(%rsp)
cwtl
movl %eax, 0x80(%rsp)
movl %eax, %r15d
movq %r13, 0xa0(%rsp)
movl %r12d, 0x68(%rsp)
movl %r15d, %ecx
imull %r15d, %ecx
leal (%r15,%r13), %eax
movl %eax, 0x98(%rsp)
movl %r13d, %eax
subl %r15d, %eax
movl %eax, 0x94(%rsp)
movw $0x83e8, %bp            # imm = 0x83E8
movq $0x0, 0x60(%rsp)
movl 0x44(%rsp), %eax
movl %eax, %r13d
movl 0x80(%rsp), %eax
movl %eax, %ebx
movw $0x83e8, 0x26(%rsp)     # imm = 0x83E8
movw $0x83e8, %si            # imm = 0x83E8
movw $0x83e8, %ax            # imm = 0x83E8
movl %eax, 0x5c(%rsp)
movw $0x83e8, %ax            # imm = 0x83E8
movl %eax, 0x58(%rsp)
movw $0x83e8, %ax            # imm = 0x83E8
movl %eax, 0x4c(%rsp)
movw $0x83e8, %ax            # imm = 0x83E8
movl %eax, 0x50(%rsp)
movw $0x83e8, %ax            # imm = 0x83E8
movl %eax, 0x54(%rsp)
movq %r15, 0x78(%rsp)
movl %ecx, 0x48(%rsp)
movl %ebx, %r14d
imull %ebx, %r14d
addl %ecx, %r14d
cmpl %r12d, %r14d
ja 0x3cef6
movl %esi, 0x20(%rsp)
movw %bp, 0x1a(%rsp)
movl %ebx, %edi
movl %r15d, %esi
callq 0x2b5af
movl %eax, %ebp
leal -0xb4(%rbp), %eax
movl %eax, 0x6c(%rsp)
cmpl 0x9c(%rsp), %r14d
jbe 0x3cd6b
imull $0xfe01, %r14d, %edi    # imm = 0xFE01
callq 0x2b67f
movl 0x8c(%rsp), %r15d
subl %eax, %r15d
js 0x3cdf0
movl $0xff, %eax
cmpl %eax, %r15d
jb 0x3cdf3
movl $0xff, %r15d
jmp 0x3cdf3
cmpl 0x90(%rsp), %r14d
jae 0x3cdc2
movq 0x60(%rsp), %rax
testl %eax, %eax
cmovel %ebx, %eax
movq %rax, 0x60(%rsp)
imull $0xfe01, %r14d, %edi    # imm = 0xFE01
callq 0x2b67f
movl %eax, %r15d
addl 0x88(%rsp), %r15d
movl $0xff, %eax
cmpl %eax, %r15d
jl 0x3cdab
movl $0xff, %r15d
testl %r15d, %r15d
jg 0x3cdb3
xorl %r15d, %r15d
cmpl 0x84(%rsp), %r14d
jae 0x3cdf3
jmp 0x3d004
movzwl %bp, %edi
movl 0x14(%rsp), %esi
movl 0x10(%rsp), %edx
callq *0x38(%rsp)
movzwl 0x5c(%rsp), %ecx
testb %al, %al
je 0x3cf09
cmpl $0x83e8, %ecx           # imm = 0x83E8
cmovel %ebx, %ecx
movl %ecx, 0x5c(%rsp)
jmp 0x3cf24
xorl %r15d, %r15d
movzwl %bp, %edi
movl 0x14(%rsp), %esi
movl 0x10(%rsp), %edx
callq *0x38(%rsp)
movswl 0x98(%rsp), %r14d
testb %al, %al
je 0x3ce2e
movq 0x28(%rsp), %rax
addl %ebx, %eax
movswl %ax, %edi
movzbl %r15b, %r8d
movl %r14d, %esi
movq 0x30(%rsp), %rdx
movl 0xc(%rsp), %ecx
callq 0x35638
movl $0x21c, %eax            # imm = 0x21C
subl %ebp, %eax
movzwl %ax, %edi
movl 0x14(%rsp), %esi
movl 0x10(%rsp), %edx
callq *0x38(%rsp)
movswl 0x94(%rsp), %r12d
testb %al, %al
je 0x3ce70
movq 0x28(%rsp), %rax
addl %ebx, %eax
movswl %ax, %edi
movzbl %r15b, %r8d
movl %r12d, %esi
movq 0x30(%rsp), %rdx
movl 0xc(%rsp), %ecx
callq 0x35638
movl $0x168, %eax            # imm = 0x168
subl %ebp, %eax
movzwl %ax, %edi
movl 0x14(%rsp), %esi
movl 0x10(%rsp), %edx
callq *0x38(%rsp)
testb %al, %al
je 0x3ceaa
movq 0x28(%rsp), %rax
addl %r13d, %eax
movswl %ax, %edi
movzbl %r15b, %r8d
movl %r14d, %esi
movq 0x30(%rsp), %rdx
movl 0xc(%rsp), %ecx
callq 0x35638
movzwl 0x6c(%rsp), %edi
movl 0x14(%rsp), %esi
movl 0x10(%rsp), %edx
callq *0x38(%rsp)
testb %al, %al
movzwl 0x1a(%rsp), %ebp
je 0x3cee4
movq 0x28(%rsp), %rax
addl %r13d, %eax
movswl %ax, %edi
movzbl %r15b, %r8d
movl %r12d, %esi
movq 0x30(%rsp), %rdx
movl 0xc(%rsp), %ecx
callq 0x35638
movl 0x68(%rsp), %r12d
movq 0x78(%rsp), %r15
movl 0x20(%rsp), %esi
movl 0x48(%rsp), %ecx
incl %ebx
decl %r13d
testw %bx, %bx
jne 0x3ccf9
jmp 0x3d012
movzwl 0x4c(%rsp), %eax
leal -0x1(%rbx), %esi
movl $0x83e8, %edx           # imm = 0x83E8
cmpl %edx, %eax
cmovnel %eax, %esi
cmpl %edx, %ecx
cmovel %eax, %esi
movl %esi, 0x4c(%rsp)
movl $0x21c, %eax            # imm = 0x21C
subl %ebp, %eax
movzwl %ax, %edi
movl 0x14(%rsp), %esi
movl 0x10(%rsp), %edx
callq *0x38(%rsp)
movzwl 0x20(%rsp), %ecx
testb %al, %al
je 0x3cf52
cmpl $0x83e8, %ecx           # imm = 0x83E8
cmovel %ebx, %ecx
movl %ecx, 0x20(%rsp)
jmp 0x3cf6d
movzwl 0x50(%rsp), %eax
leal -0x1(%rbx), %esi
movl $0x83e8, %edx           # imm = 0x83E8
cmpl %edx, %eax
cmovnel %eax, %esi
cmpl %edx, %ecx
cmovel %eax, %esi
movl %esi, 0x50(%rsp)
movl $0x168, %eax            # imm = 0x168
subl %ebp, %eax
movzwl %ax, %edi
movl 0x14(%rsp), %esi
movl 0x10(%rsp), %edx
callq *0x38(%rsp)
movzwl 0x26(%rsp), %ecx
testb %al, %al
je 0x3cf9c
cmpl $0x83e8, %ecx           # imm = 0x83E8
cmovel %ebx, %ecx
movw %cx, 0x26(%rsp)
jmp 0x3cfb7
movzwl 0x54(%rsp), %eax
leal -0x1(%rbx), %esi
movl $0x83e8, %edx           # imm = 0x83E8
cmpl %edx, %eax
cmovnel %eax, %esi
cmpl %edx, %ecx
cmovel %eax, %esi
movl %esi, 0x54(%rsp)
movzwl 0x1a(%rsp), %ebp
movzwl 0x6c(%rsp), %edi
movl 0x14(%rsp), %esi
movl 0x10(%rsp), %edx
callq *0x38(%rsp)
movzwl %bp, %ecx
testb %al, %al
je 0x3cfe4
cmpl $0x83e8, %ecx           # imm = 0x83E8
cmovel %ebx, %ecx
movl %ecx, %ebp
jmp 0x3ceee
movzwl 0x58(%rsp), %eax
leal -0x1(%rbx), %esi
movl $0x83e8, %edx           # imm = 0x83E8
cmpl %edx, %eax
cmovnel %eax, %esi
cmpl %edx, %ecx
cmovel %eax, %esi
movl %esi, 0x58(%rsp)
jmp 0x3ceee
movq 0x78(%rsp), %r15
movzwl 0x1a(%rsp), %ebp
movl 0x20(%rsp), %esi
movl 0x5c(%rsp), %edi
movzwl %di, %eax
cmpl $0x83e8, %eax           # imm = 0x83E8
movq 0xa0(%rsp), %r13
leaq 0x70(%rsp), %rbx
je 0x3d07d
movzwl 0x4c(%rsp), %eax
movq 0x60(%rsp), %rcx
decl %ecx
cmpl $0x83e8, %eax           # imm = 0x83E8
cmovel %ecx, %eax
movq 0x28(%rsp), %rcx
addl %ecx, %edi
leal (%r15,%r13), %edx
addl %ecx, %eax
movl %esi, %r14d
movswl %di, %esi
movswl %ax, %ecx
movswl %dx, %edx
movq %rbx, %rdi
movl %edx, %r8d
callq 0x28cbc
movq %rbx, %rdi
movq 0x30(%rsp), %rsi
movl 0xc(%rsp), %edx
movl 0x1c(%rsp), %ecx
callq 0x35793
movl %r14d, %esi
movzwl %si, %eax
cmpl $0x83e8, %eax           # imm = 0x83E8
je 0x3d0d3
movzwl 0x50(%rsp), %eax
movq 0x60(%rsp), %rcx
decl %ecx
cmpl $0x83e8, %eax           # imm = 0x83E8
cmovel %ecx, %eax
movq 0x28(%rsp), %rcx
addl %ecx, %esi
movl %r13d, %edx
subl %r15d, %edx
addl %ecx, %eax
movswl %si, %esi
movswl %ax, %ecx
movswl %dx, %edx
movq %rbx, %rdi
movl %edx, %r8d
callq 0x28cbc
movq %rbx, %rdi
movq 0x30(%rsp), %rsi
movl 0xc(%rsp), %edx
movl 0x1c(%rsp), %ecx
callq 0x35793
movzwl 0x26(%rsp), %esi
movzwl %si, %eax
cmpl $0x83e8, %eax           # imm = 0x83E8
je 0x3d13b
movzwl 0x54(%rsp), %eax
movq 0x60(%rsp), %rcx
decl %ecx
cmpl $0x83e8, %eax           # imm = 0x83E8
cmovel %ecx, %eax
movq 0x28(%rsp), %rcx
movl %ecx, %edx
subl %eax, %edx
leal (%r15,%r13), %edi
cwtl
movswl %si, %ecx
subl %ecx, %eax
movl %eax, %ecx
negl %ecx
cmovsl %eax, %ecx
addl %edx, %ecx
movswl %cx, %ecx
movswl %dx, %esi
movswl %di, %edx
movq %rbx, %rdi
movl %edx, %r8d
callq 0x28cbc
movq %rbx, %rdi
movq 0x30(%rsp), %rsi
movl 0xc(%rsp), %edx
movl 0x1c(%rsp), %ecx
callq 0x35793
movzwl %bp, %eax
cmpl $0x83e8, %eax           # imm = 0x83E8
je 0x3d1a0
movzwl 0x58(%rsp), %eax
movq 0x60(%rsp), %rcx
decl %ecx
cmpl $0x83e8, %eax           # imm = 0x83E8
cmovel %ecx, %eax
movq 0x28(%rsp), %rcx
movl %ecx, %edx
subl %eax, %edx
movl %r13d, %edi
subl %r15d, %edi
cwtl
movswl %bp, %ecx
subl %ecx, %eax
movl %eax, %ecx
negl %ecx
cmovsl %eax, %ecx
addl %edx, %ecx
movswl %cx, %ecx
movswl %dx, %esi
movswl %di, %edx
movq %rbx, %rdi
movl %edx, %r8d
callq 0x28cbc
movq %rbx, %rdi
movq 0x30(%rsp), %rsi
movl 0xc(%rsp), %edx
movl 0x1c(%rsp), %ecx
callq 0x35793
incl %r15d
testw %r15w, %r15w
jne 0x3cc81
addq $0xa8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq