// File: /workspace/github_cpp_makefile_star2_O2/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 $0xb8, %rsp
leaq 0x1a08(%rip), %rax      # 0x5030
leaq 0x1a05(%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 0x5c17(%rip), %xmm1     # 0x9280
mulpd %xmm1, %xmm0
addpd 0x5c1b(%rip), %xmm0     # 0x9290
mulpd 0x1c33(%rip), %xmm1     # 0x52b0
movapd %xmm0, 0x20(%rsp)
addpd %xmm0, %xmm1
movapd %xmm1, (%rsp)
movapd %xmm1, 0xa0(%rsp)
xorpd %xmm0, %xmm0
leaq 0x60(%rsp), %r14
movapd %xmm0, (%r14)
xorl %ebx, %ebx
leaq 0x5b1c(%rip), %r15      # 0x91c8
cmpl (%r15), %ebx
jae 0x36e9
movq %r14, %rdi
movq %r14, %rsi
callq 0x3481
unpcklpd %xmm1, %xmm0            # xmm0 = xmm0[0],xmm1[0]
addpd (%rsp), %xmm0
movapd %xmm0, 0x60(%rsp)
mulpd %xmm0, %xmm0
movapd %xmm0, %xmm1
unpckhpd %xmm0, %xmm1            # xmm1 = xmm1[1],xmm0[1]
addsd %xmm0, %xmm1
ucomisd 0x1b95(%rip), %xmm1     # 0x5278
ja 0x36e9
incl %ebx
jmp 0x36ac
leaq 0x60(%rsp), %rsi
leaq 0xa0(%rsp), %rdx
movl %ebx, %edi
callq 0x3240
movl %eax, 0x1c(%rsp)
movapd 0x5b77(%rip), %xmm2     # 0x9280
mulpd 0x1baf(%rip), %xmm2     # 0x52c0
movapd 0x20(%rsp), %xmm1
movapd %xmm1, %xmm0
subpd %xmm2, %xmm0
addpd %xmm1, %xmm2
movsd %xmm0, %xmm2            # xmm2 = xmm0[0],xmm2[1]
movapd %xmm2, (%rsp)
movapd %xmm2, 0x90(%rsp)
xorpd %xmm0, %xmm0
leaq 0x50(%rsp), %r14
movapd %xmm0, (%r14)
xorl %ebx, %ebx
cmpl (%r15), %ebx
jae 0x3782
movq %r14, %rdi
movq %r14, %rsi
callq 0x3481
unpcklpd %xmm1, %xmm0            # xmm0 = xmm0[0],xmm1[0]
addpd (%rsp), %xmm0
movapd %xmm0, 0x50(%rsp)
mulpd %xmm0, %xmm0
movapd %xmm0, %xmm1
unpckhpd %xmm0, %xmm1            # xmm1 = xmm1[1],xmm0[1]
addsd %xmm0, %xmm1
ucomisd 0x1afc(%rip), %xmm1     # 0x5278
ja 0x3782
incl %ebx
jmp 0x3745
leaq 0x50(%rsp), %rsi
leaq 0x90(%rsp), %rdx
movl %ebx, %edi
callq 0x3240
movl %eax, %r13d
movapd 0x5adf(%rip), %xmm0     # 0x9280
mulpd 0x1b17(%rip), %xmm0     # 0x52c0
movapd 0x20(%rsp), %xmm2
movapd %xmm2, %xmm1
addpd %xmm0, %xmm1
subpd %xmm0, %xmm2
movsd %xmm1, %xmm2            # xmm2 = xmm1[0],xmm2[1]
movapd %xmm2, (%rsp)
movapd %xmm2, 0x80(%rsp)
xorpd %xmm0, %xmm0
leaq 0x40(%rsp), %r14
movapd %xmm0, (%r14)
xorl %ebx, %ebx
cmpl (%r15), %ebx
jae 0x381a
movq %r14, %rdi
movq %r14, %rsi
callq 0x3481
unpcklpd %xmm1, %xmm0            # xmm0 = xmm0[0],xmm1[0]
addpd (%rsp), %xmm0
movapd %xmm0, 0x40(%rsp)
mulpd %xmm0, %xmm0
movapd %xmm0, %xmm1
unpckhpd %xmm0, %xmm1            # xmm1 = xmm1[1],xmm0[1]
addsd %xmm0, %xmm1
ucomisd 0x1a64(%rip), %xmm1     # 0x5278
ja 0x381a
incl %ebx
jmp 0x37dd
leaq 0x40(%rsp), %rsi
leaq 0x80(%rsp), %rdx
movl %ebx, %edi
callq 0x3240
movl %eax, (%rsp)
movapd 0x5a47(%rip), %xmm0     # 0x9280
mulpd 0x1a7f(%rip), %xmm0     # 0x52c0
movapd 0x20(%rsp), %xmm1
addpd %xmm0, %xmm1
movapd %xmm1, 0x20(%rsp)
movapd %xmm1, 0x70(%rsp)
xorpd %xmm0, %xmm0
leaq 0x30(%rsp), %r14
movapd %xmm0, (%r14)
xorl %ebp, %ebp
cmpl (%r15), %ebp
jae 0x38a5
movq %r14, %rdi
movq %r14, %rsi
callq 0x3481
unpcklpd %xmm1, %xmm0            # xmm0 = xmm0[0],xmm1[0]
addpd 0x20(%rsp), %xmm0
movapd %xmm0, 0x30(%rsp)
mulpd %xmm0, %xmm0
movapd %xmm0, %xmm1
unpckhpd %xmm0, %xmm1            # xmm1 = xmm1[1],xmm0[1]
addsd %xmm0, %xmm1
ucomisd 0x19d9(%rip), %xmm1     # 0x5278
ja 0x38a5
incl %ebp
jmp 0x3867
leaq 0x30(%rsp), %rsi
leaq 0x70(%rsp), %rdx
movl %ebp, %edi
callq 0x3240
movl 0x1c(%rsp), %ecx
movl %ecx, %edx
shrl $0x18, %edx
movl %r13d, %ebx
movl %r13d, %r15d
shrl $0x18, %r15d
addl %edx, %r15d
movl %ecx, %r13d
movl %ebx, %esi
movl $0xff, %r14d
movzbl %ch, %edx
movl %edx, %r12d
movzbl %bh, %ebp
andl %r14d, %ecx
andl %r14d, %ebx
addl %ecx, %ebx
movl (%rsp), %edx
movl %edx, %r11d
movl %edx, %r10d
movzbl %dh, %edi
andl %r14d, %edx
addl %ebx, %edx
movl %eax, %r9d
movl %eax, %r8d
movzbl %ah, %ecx
andl %r14d, %eax
addl %edx, %eax
addl %r12d, %ebp
addl %edi, %ebp
addl %ecx, %ebp
shrl $0x18, %r11d
addl %r15d, %r11d
shrl $0x18, %r9d
addl %r11d, %r9d
andl $-0x4, %r9d
shll $0x16, %r9d
shrl $0x10, %r13d
shrl $0x10, %esi
shrl $0x10, %r10d
shrl $0x10, %r8d
andl %r14d, %r13d
andl %r14d, %esi
addl %r13d, %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 $0xb8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
nopl (%rax)