// File: /workspace/github_cpp_makefile_star2_O3/miklhh[P]mandelbrot/src/supersampling.cpp
// Function: get_px_4x_ss(int, int)
rgb_t get_px_4x_ss(int px_x, int px_y)
{
    using std::complex;
    double x = double((px_x - scr_width / 2) * scale.x + offset.x);
    double y = double((px_y - scr_height / 2) * scale.y + offset.y);
    complex<double> c(x, y);
    complex<double> z(0, 0);

    /* 'Pixel': 1. */
    complex<double> c1(x - scale.x / 4, y - scale.y / 4);
    complex<double> z1(0, 0);
    unsigned int iterations1;
    for (iterations1 = 0; iterations1 < max_iterations; iterations1++)
    {
        z1 = z1 * z1 + c1;
        if (test_escape(z1, 2.0)) { break; }
    }
    rgb_t color1 = get_color(iterations1, z1, c1);
    /* 'Pixel': 2. */
    complex<double> c2(c.real() - scale.x / 4, c.imag() + scale.y / 4);
    complex<double> z2(0, 0);
    unsigned int iterations2;
    for (iterations2 = 0; iterations2 < max_iterations; iterations2++)
    {
        z2 = z2 * z2 + c2;
        if (test_escape(z2, 2.0)) { break; }
    }
    rgb_t color2 = get_color(iterations2, z2, c2);
    /* 'Pixel': 3. */
    complex<double> c3(c.real() + scale.x / 4, c.imag() - scale.y / 4);
    complex<double> z3(0, 0);
    unsigned int iterations3;
    for (iterations3 = 0; iterations3 < max_iterations; iterations3++)
    {
        z3 = z3 * z3 + c3;
        if (test_escape(z3, 2.0)) { break; }
    }
    rgb_t color3 = get_color(iterations3, z3, c3);
    /* 'Pixel': 4. */
    complex<double> c4(c.real() + scale.x / 4, c.imag() + scale.y / 4);
    complex<double> z4(0, 0);
    unsigned int iterations4;
    for (iterations4 = 0; iterations4 < max_iterations; iterations4++)
    {
        z4 = z4 * z4 + c4;
        if (test_escape(z4, 2.0)) { break; }
    }
    rgb_t color4 = get_color(iterations4, z4, c4);
    /* Calculate the avrage and return the color. */
    rgb_t color;
    color.alpha = get_average(color1.alpha, color2.alpha, color3.alpha, color4.alpha);
    color.blue = get_average(color1.blue, color2.blue, color3.blue, color4.blue);
    color.green = get_average(color1.green, color2.green, color3.green, color4.green);
    color.red = get_average(color1.red, color2.red, color3.red, color4.red);
    return color;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0xc8, %rsp
leaq 0x18f5(%rip), %rax      # 0x5030
leaq 0x18f2(%rip), %rcx      # 0x5034
movd (%rcx), %xmm0
movd (%rax), %xmm1
punpckldq %xmm0, %xmm1    # xmm1 = xmm1[0],xmm0[0],xmm1[1],xmm0[1]
movdqa %xmm1, %xmm0
psrld $0x1f, %xmm0
paddd %xmm1, %xmm0
psrad $0x1, %xmm0
movd %esi, %xmm1
movd %edi, %xmm2
punpckldq %xmm1, %xmm2    # xmm2 = xmm2[0],xmm1[0],xmm2[1],xmm1[1]
psubd %xmm0, %xmm2
cvtdq2pd %xmm2, %xmm0
movapd 0x4b14(%rip), %xmm1     # 0x8290
mulpd %xmm1, %xmm0
addpd 0x4b18(%rip), %xmm0     # 0x82a0
mulpd 0x1b20(%rip), %xmm1     # 0x52b0
movapd %xmm0, 0x30(%rsp)
addpd %xmm0, %xmm1
movapd %xmm1, 0x10(%rsp)
movapd %xmm1, 0xb0(%rsp)
xorpd %xmm0, %xmm0
movapd %xmm0, 0x70(%rsp)
leaq 0x4a1e(%rip), %r12      # 0x81d8
xorl %ebx, %ebx
cmpl $0x0, (%r12)
movl $0x0, %ebp
je 0x3819
xorl %ebp, %ebp
movq %rsp, %r14
leaq 0x70(%rsp), %r15
movaps 0x70(%rsp), %xmm0
movaps %xmm0, (%rsp)
movq %r14, %rdi
movq %r15, %rsi
callq 0x35b2
movapd (%rsp), %xmm0
addpd 0x10(%rsp), %xmm0
movapd %xmm0, 0x70(%rsp)
mulpd %xmm0, %xmm0
movapd %xmm0, %xmm1
unpckhpd %xmm0, %xmm1            # xmm1 = xmm1[1],xmm0[1]
addsd %xmm0, %xmm1
ucomisd 0x1a69(%rip), %xmm1     # 0x5278
ja 0x3819
incl %ebp
cmpl (%r12), %ebp
jb 0x37d2
leaq 0x70(%rsp), %rsi
leaq 0xb0(%rsp), %rdx
movl %ebp, %edi
callq 0x335c
movl %eax, 0x2c(%rsp)
movapd 0x4a57(%rip), %xmm2     # 0x8290
mulpd 0x1a7f(%rip), %xmm2     # 0x52c0
movapd 0x30(%rsp), %xmm1
movapd %xmm1, %xmm0
subpd %xmm2, %xmm0
addpd %xmm1, %xmm2
movsd %xmm0, %xmm2            # xmm2 = xmm0[0],xmm2[1]
movapd %xmm2, 0x10(%rsp)
movapd %xmm2, 0xa0(%rsp)
xorpd %xmm0, %xmm0
movapd %xmm0, 0x60(%rsp)
cmpl $0x0, (%r12)
je 0x38c8
xorl %ebx, %ebx
movq %rsp, %r14
leaq 0x60(%rsp), %r15
movaps 0x60(%rsp), %xmm0
movaps %xmm0, (%rsp)
movq %r14, %rdi
movq %r15, %rsi
callq 0x35b2
movapd (%rsp), %xmm0
addpd 0x10(%rsp), %xmm0
movapd %xmm0, 0x60(%rsp)
mulpd %xmm0, %xmm0
movapd %xmm0, %xmm1
unpckhpd %xmm0, %xmm1            # xmm1 = xmm1[1],xmm0[1]
addsd %xmm0, %xmm1
ucomisd 0x19ba(%rip), %xmm1     # 0x5278
ja 0x38c8
incl %ebx
cmpl (%r12), %ebx
jb 0x3881
leaq 0x60(%rsp), %rsi
leaq 0xa0(%rsp), %rdx
movl %ebx, %edi
callq 0x335c
movl %eax, 0x28(%rsp)
movapd 0x49a8(%rip), %xmm0     # 0x8290
mulpd 0x19d0(%rip), %xmm0     # 0x52c0
movapd 0x30(%rsp), %xmm2
movapd %xmm2, %xmm1
addpd %xmm0, %xmm1
subpd %xmm0, %xmm2
movsd %xmm1, %xmm2            # xmm2 = xmm1[0],xmm2[1]
movapd %xmm2, 0x10(%rsp)
movapd %xmm2, 0x90(%rsp)
xorpd %xmm0, %xmm0
movapd %xmm0, 0x50(%rsp)
xorl %ebp, %ebp
cmpl $0x0, (%r12)
movl $0x0, %ebx
je 0x397e
xorl %ebx, %ebx
movq %rsp, %r14
leaq 0x50(%rsp), %r15
movaps 0x50(%rsp), %xmm0
movaps %xmm0, (%rsp)
movq %r14, %rdi
movq %r15, %rsi
callq 0x35b2
movapd (%rsp), %xmm0
addpd 0x10(%rsp), %xmm0
movapd %xmm0, 0x50(%rsp)
mulpd %xmm0, %xmm0
movapd %xmm0, %xmm1
unpckhpd %xmm0, %xmm1            # xmm1 = xmm1[1],xmm0[1]
addsd %xmm0, %xmm1
ucomisd 0x1904(%rip), %xmm1     # 0x5278
ja 0x397e
incl %ebx
cmpl (%r12), %ebx
jb 0x3937
leaq 0x50(%rsp), %rsi
leaq 0x90(%rsp), %rdx
movl %ebx, %edi
callq 0x335c
movl %eax, 0x10(%rsp)
movapd 0x48f2(%rip), %xmm0     # 0x8290
mulpd 0x191a(%rip), %xmm0     # 0x52c0
movapd 0x30(%rsp), %xmm1
addpd %xmm0, %xmm1
movapd %xmm1, 0x30(%rsp)
movapd %xmm1, 0x80(%rsp)
xorpd %xmm0, %xmm0
movapd %xmm0, 0x40(%rsp)
cmpl $0x0, (%r12)
je 0x3a21
xorl %ebp, %ebp
movq %rsp, %r14
leaq 0x40(%rsp), %r15
movaps 0x40(%rsp), %xmm0
movaps %xmm0, (%rsp)
movq %r14, %rdi
movq %r15, %rsi
callq 0x35b2
movapd (%rsp), %xmm0
addpd 0x30(%rsp), %xmm0
movapd %xmm0, 0x40(%rsp)
mulpd %xmm0, %xmm0
movapd %xmm0, %xmm1
unpckhpd %xmm0, %xmm1            # xmm1 = xmm1[1],xmm0[1]
addsd %xmm0, %xmm1
ucomisd 0x1861(%rip), %xmm1     # 0x5278
ja 0x3a21
incl %ebp
cmpl (%r12), %ebp
jb 0x39da
leaq 0x40(%rsp), %rsi
leaq 0x80(%rsp), %rdx
movl %ebp, %edi
callq 0x335c
movl 0x2c(%rsp), %ebx
movl %ebx, %edx
shrl $0x18, %edx
movl 0x28(%rsp), %ecx
movl %ecx, %r15d
shrl $0x18, %r15d
addl %edx, %r15d
movl %ebx, %r12d
movl %ecx, %esi
movl $0xff, %r14d
movzbl %bh, %edx
movl %edx, %r13d
movzbl %ch, %ebp
andl %r14d, %ebx
andl %r14d, %ecx
addl %ebx, %ecx
movl 0x10(%rsp), %edx
movl %edx, %r11d
movl %edx, %r10d
movzbl %dh, %edi
andl %r14d, %edx
addl %ecx, %edx
movl %eax, %r9d
movl %eax, %r8d
movzbl %ah, %ebx
andl %r14d, %eax
addl %edx, %eax
addl %r13d, %ebp
addl %edi, %ebp
addl %ebx, %ebp
shrl $0x18, %r11d
addl %r15d, %r11d
shrl $0x18, %r9d
addl %r11d, %r9d
andl $-0x4, %r9d
shll $0x16, %r9d
shrl $0x10, %r12d
shrl $0x10, %esi
shrl $0x10, %r10d
shrl $0x10, %r8d
andl %r14d, %r12d
andl %r14d, %esi
addl %r12d, %esi
andl %r14d, %r10d
addl %esi, %r10d
andl %r14d, %r8d
addl %r10d, %r8d
shll $0xe, %r8d
andl $0xff0000, %r8d         # imm = 0xFF0000
shll $0x6, %ebp
andl $0xff00, %ebp           # imm = 0xFF00
shrl $0x2, %eax
orl %r9d, %eax
orl %r8d, %eax
orl %ebp, %eax
addq $0xc8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
nop