// File: /workspace/github_cpp_makefile_star2_O3/misohena[P]drawstars/drawstars.cpp
// Function: void fillCircle<PixelPlotter>(Image<ColorRGB<double>>&, float, float, float, PixelPlotter)
void fillCircle(ImageType &canvas, float cx, float cy, float radius, F funcPlot)
{
    const float canvasW = canvas.width();
    const float canvasH = canvas.height();
    const int xmin = static_cast<int>(clamp(std::floor(cx - radius), 0.0f, canvasW));
    const int xmax = static_cast<int>(clamp(std::ceil(cx + radius), 0.0f, canvasW));
    const int ymin = static_cast<int>(clamp(std::floor(cy - radius), 0.0f, canvasH));
    const int ymax = static_cast<int>(clamp(std::ceil(cy + radius), 0.0f, canvasH));
    for(int py = ymin; py < ymax; ++py){
        for(int px = xmin; px < xmax; ++px){
            const float pxf = px + 0.5f;
            const float pyf = py + 0.5f;
            const float dx = pxf - cx;
            const float dy = pyf - cy;
            const float dist = std::sqrt(dx*dx + dy*dy);
            funcPlot(canvas.at(px, py), pxf, pyf, cx, cy, dist);
        }
    }
}

// Assembly:
pushq %r14
pushq %rbx
subq $0x58, %rsp
movss %xmm2, 0x4(%rsp)
movss %xmm1, 0x8(%rsp)
movq %rdi, %rbx
movl 0x4(%rdi), %eax
xorps %xmm1, %xmm1
cvtsi2ss %rax, %xmm1
movaps %xmm1, 0x40(%rsp)
movss %xmm0, 0xc(%rsp)
movl (%rdi), %r14d
subss %xmm2, %xmm0
callq 0x4110
movaps %xmm0, 0x10(%rsp)
movss 0xc(%rsp), %xmm0
addss 0x4(%rsp), %xmm0
callq 0x4190
movaps %xmm0, 0x20(%rsp)
movss 0x8(%rsp), %xmm0
subss 0x4(%rsp), %xmm0
callq 0x4110
movaps %xmm0, 0x30(%rsp)
movss 0x4(%rsp), %xmm0
addss 0x8(%rsp), %xmm0
callq 0x4190
movss 0xc(%rsp), %xmm10
movaps 0x30(%rsp), %xmm2
unpcklps %xmm0, %xmm2            # xmm2 = xmm2[0],xmm0[0],xmm2[1],xmm0[1]
xorps %xmm0, %xmm0
movaps 0x40(%rsp), %xmm1
shufps $0x0, %xmm1, %xmm1      # xmm1 = xmm1[0,0,0,0]
minps %xmm2, %xmm1
cmpnltps %xmm0, %xmm2
andps %xmm1, %xmm2
cvttps2dq %xmm2, %xmm0
movd %xmm0, %eax
pshufd $0x55, %xmm0, %xmm0     # xmm0 = xmm0[1,1,1,1]
movd %xmm0, %ecx
cmpl %ecx, %eax
jge 0xbf15
xorps %xmm1, %xmm1
cvtsi2ss %r14, %xmm1
movaps %xmm1, %xmm2
movaps 0x10(%rsp), %xmm3
minss %xmm3, %xmm2
pxor %xmm0, %xmm0
cmpltss %xmm0, %xmm3
andnps %xmm2, %xmm3
cvttss2si %xmm3, %edx
leaq 0x70(%rsp), %r8
movaps 0x20(%rsp), %xmm2
minss %xmm2, %xmm1
cmpltss %xmm0, %xmm2
andnps %xmm1, %xmm2
cvttss2si %xmm2, %esi
movq 0x8(%rbx), %rdi
movss 0x18(%r8), %xmm1
addss 0x11e2(%rip), %xmm1     # 0xd02c
movupd (%r8), %xmm2
movsd 0x10(%r8), %xmm3
movl %eax, %r8d
imull %r14d, %r8d
movss 0x11b0(%rip), %xmm4     # 0xd014
movss 0x11a4(%rip), %xmm5     # 0xd010
cmpl %esi, %edx
jge 0xbf08
xorps %xmm6, %xmm6
cvtsi2ss %eax, %xmm6
addss %xmm4, %xmm6
subss 0x8(%rsp), %xmm6
mulss %xmm6, %xmm6
movl %edx, %r9d
xorps %xmm7, %xmm7
cvtsi2ss %r9d, %xmm7
addss %xmm4, %xmm7
subss %xmm10, %xmm7
mulss %xmm7, %xmm7
addss %xmm6, %xmm7
sqrtss %xmm7, %xmm7
divss %xmm1, %xmm7
movaps %xmm5, %xmm8
subss %xmm7, %xmm8
leal (%r8,%r9), %r10d
leaq (%r10,%r10,2), %r10
maxss %xmm0, %xmm8
xorps %xmm7, %xmm7
sqrtss %xmm8, %xmm7
movapd %xmm3, %xmm8
cvtss2sd %xmm7, %xmm7
mulsd %xmm7, %xmm8
unpcklpd %xmm7, %xmm7            # xmm7 = xmm7[0,0]
movupd (%rdi,%r10,8), %xmm9
mulpd %xmm2, %xmm7
addpd %xmm7, %xmm9
movupd %xmm9, (%rdi,%r10,8)
addsd 0x10(%rdi,%r10,8), %xmm8
movsd %xmm8, 0x10(%rdi,%r10,8)
incl %r9d
cmpl %r9d, %esi
jne 0xbe8c
incl %eax
addl %r14d, %r8d
cmpl %ecx, %eax
jne 0xbe6c
addq $0x58, %rsp
popq %rbx
popq %r14
retq