// File: 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
movq %rsp, %rbp
subq $0x1a0, %rsp            # imm = 0x1A0
movl %edi, -0x8(%rbp)
movl %esi, -0xc(%rbp)
movl -0x8(%rbp), %eax
movl %eax, -0x184(%rbp)
leaq 0x703f(%rip), %rax      # 0xe020
movl (%rax), %eax
movl $0x2, %ecx
cltd
idivl %ecx
movl %eax, %ecx
movl -0x184(%rbp), %eax
subl %ecx, %eax
cvtsi2sd %eax, %xmm0
movsd 0xe2c7(%rip), %xmm2     # 0x152c8
movsd 0xe2cf(%rip), %xmm1     # 0x152d8
mulsd %xmm2, %xmm0
addsd %xmm1, %xmm0
movsd %xmm0, -0x18(%rbp)
movl -0xc(%rbp), %eax
movl %eax, -0x180(%rbp)
leaq 0x6ffe(%rip), %rax      # 0xe024
movl (%rax), %eax
movl $0x2, %ecx
cltd
idivl %ecx
movl %eax, %ecx
movl -0x180(%rbp), %eax
subl %ecx, %eax
cvtsi2sd %eax, %xmm0
movsd 0xe28a(%rip), %xmm2     # 0x152d0
movsd 0xe292(%rip), %xmm1     # 0x152e0
mulsd %xmm2, %xmm0
addsd %xmm1, %xmm0
movsd %xmm0, -0x20(%rbp)
movsd -0x18(%rbp), %xmm0
movsd -0x20(%rbp), %xmm1
leaq -0x30(%rbp), %rdi
callq 0x3980
leaq -0x40(%rbp), %rdi
xorps %xmm1, %xmm1
movaps %xmm1, %xmm0
callq 0x3980
movsd -0x18(%rbp), %xmm0
movsd 0xe23e(%rip), %xmm1     # 0x152c8
movsd 0x71ae(%rip), %xmm2     # 0xe240
divsd %xmm2, %xmm1
subsd %xmm1, %xmm0
movsd -0x20(%rbp), %xmm1
movsd 0xe229(%rip), %xmm2     # 0x152d0
movsd 0x7191(%rip), %xmm3     # 0xe240
divsd %xmm3, %xmm2
subsd %xmm2, %xmm1
leaq -0x50(%rbp), %rdi
callq 0x3980
leaq -0x60(%rbp), %rdi
xorps %xmm1, %xmm1
movaps %xmm1, %xmm0
callq 0x3980
movl $0x0, -0x64(%rbp)
movl -0x64(%rbp), %eax
leaq 0xe150(%rip), %rcx      # 0x15230
cmpl (%rcx), %eax
jae 0x714d
leaq -0x60(%rbp), %rsi
movq %rsi, %rdi
callq 0x6b40
movsd %xmm0, -0x88(%rbp)
movsd %xmm1, -0x80(%rbp)
leaq -0x88(%rbp), %rdi
leaq -0x50(%rbp), %rsi
callq 0x6b00
movsd %xmm0, -0x78(%rbp)
movsd %xmm1, -0x70(%rbp)
movq -0x78(%rbp), %rax
movq %rax, -0x60(%rbp)
movq -0x70(%rbp), %rax
movq %rax, -0x58(%rbp)
leaq -0x60(%rbp), %rdi
movsd 0x70ed(%rip), %xmm0     # 0xe220
callq 0x6f50
testb $0x1, %al
jne 0x713e
jmp 0x7140
jmp 0x714d
jmp 0x7142
movl -0x64(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x64(%rbp)
jmp 0x70d6
movl -0x64(%rbp), %edi
leaq -0x60(%rbp), %rsi
leaq -0x50(%rbp), %rdx
callq 0x6540
movl %eax, -0x8c(%rbp)
leaq -0x30(%rbp), %rdi
callq 0x4930
movsd 0xe154(%rip), %xmm1     # 0x152c8
movsd 0x70c4(%rip), %xmm2     # 0xe240
divsd %xmm2, %xmm1
subsd %xmm1, %xmm0
movsd %xmm0, -0x190(%rbp)
leaq -0x30(%rbp), %rdi
callq 0x4950
movaps %xmm0, %xmm1
movsd -0x190(%rbp), %xmm0
movsd 0xe128(%rip), %xmm2     # 0x152d0
movsd 0x7090(%rip), %xmm3     # 0xe240
divsd %xmm3, %xmm2
addsd %xmm2, %xmm1
leaq -0xa0(%rbp), %rdi
callq 0x3980
leaq -0xb0(%rbp), %rdi
xorps %xmm1, %xmm1
movaps %xmm1, %xmm0
callq 0x3980
movl $0x0, -0xb4(%rbp)
movl -0xb4(%rbp), %eax
leaq 0xe043(%rip), %rcx      # 0x15230
cmpl (%rcx), %eax
jae 0x7285
leaq -0xb0(%rbp), %rsi
movq %rsi, %rdi
callq 0x6b40
movsd %xmm0, -0xd8(%rbp)
movsd %xmm1, -0xd0(%rbp)
leaq -0xd8(%rbp), %rdi
leaq -0xa0(%rbp), %rsi
callq 0x6b00
movsd %xmm0, -0xc8(%rbp)
movsd %xmm1, -0xc0(%rbp)
movq -0xc8(%rbp), %rax
movq %rax, -0xb0(%rbp)
movq -0xc0(%rbp), %rax
movq %rax, -0xa8(%rbp)
leaq -0xb0(%rbp), %rdi
movsd 0x6fbe(%rip), %xmm0     # 0xe220
callq 0x6f50
testb $0x1, %al
jne 0x726d
jmp 0x726f
jmp 0x7285
jmp 0x7271
movl -0xb4(%rbp), %eax
addl $0x1, %eax
movl %eax, -0xb4(%rbp)
jmp 0x71e0
movl -0xb4(%rbp), %edi
leaq -0xb0(%rbp), %rsi
leaq -0xa0(%rbp), %rdx
callq 0x6540
movl %eax, -0xdc(%rbp)
leaq -0x30(%rbp), %rdi
callq 0x4930
movsd 0xe013(%rip), %xmm1     # 0x152c8
movsd 0x6f83(%rip), %xmm2     # 0xe240
divsd %xmm2, %xmm1
addsd %xmm1, %xmm0
movsd %xmm0, -0x198(%rbp)
leaq -0x30(%rbp), %rdi
callq 0x4950
movaps %xmm0, %xmm1
movsd -0x198(%rbp), %xmm0
movsd 0xdfe7(%rip), %xmm2     # 0x152d0
movsd 0x6f4f(%rip), %xmm3     # 0xe240
divsd %xmm3, %xmm2
subsd %xmm2, %xmm1
leaq -0xf0(%rbp), %rdi
callq 0x3980
leaq -0x100(%rbp), %rdi
xorps %xmm1, %xmm1
movaps %xmm1, %xmm0
callq 0x3980
movl $0x0, -0x104(%rbp)
movl -0x104(%rbp), %eax
leaq 0xdf02(%rip), %rcx      # 0x15230
cmpl (%rcx), %eax
jae 0x73c6
leaq -0x100(%rbp), %rsi
movq %rsi, %rdi
callq 0x6b40
movsd %xmm0, -0x128(%rbp)
movsd %xmm1, -0x120(%rbp)
leaq -0x128(%rbp), %rdi
leaq -0xf0(%rbp), %rsi
callq 0x6b00
movsd %xmm0, -0x118(%rbp)
movsd %xmm1, -0x110(%rbp)
movq -0x118(%rbp), %rax
movq %rax, -0x100(%rbp)
movq -0x110(%rbp), %rax
movq %rax, -0xf8(%rbp)
leaq -0x100(%rbp), %rdi
movsd 0x6e7d(%rip), %xmm0     # 0xe220
callq 0x6f50
testb $0x1, %al
jne 0x73ae
jmp 0x73b0
jmp 0x73c6
jmp 0x73b2
movl -0x104(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x104(%rbp)
jmp 0x7321
movl -0x104(%rbp), %edi
leaq -0x100(%rbp), %rsi
leaq -0xf0(%rbp), %rdx
callq 0x6540
movl %eax, -0x12c(%rbp)
leaq -0x30(%rbp), %rdi
callq 0x4930
movsd 0xded2(%rip), %xmm1     # 0x152c8
movsd 0x6e42(%rip), %xmm2     # 0xe240
divsd %xmm2, %xmm1
addsd %xmm1, %xmm0
movsd %xmm0, -0x1a0(%rbp)
leaq -0x30(%rbp), %rdi
callq 0x4950
movaps %xmm0, %xmm1
movsd -0x1a0(%rbp), %xmm0
movsd 0xdea6(%rip), %xmm2     # 0x152d0
movsd 0x6e0e(%rip), %xmm3     # 0xe240
divsd %xmm3, %xmm2
addsd %xmm2, %xmm1
leaq -0x140(%rbp), %rdi
callq 0x3980
leaq -0x150(%rbp), %rdi
xorps %xmm1, %xmm1
movaps %xmm1, %xmm0
callq 0x3980
movl $0x0, -0x154(%rbp)
movl -0x154(%rbp), %eax
leaq 0xddc1(%rip), %rcx      # 0x15230
cmpl (%rcx), %eax
jae 0x7507
leaq -0x150(%rbp), %rsi
movq %rsi, %rdi
callq 0x6b40
movsd %xmm0, -0x178(%rbp)
movsd %xmm1, -0x170(%rbp)
leaq -0x178(%rbp), %rdi
leaq -0x140(%rbp), %rsi
callq 0x6b00
movsd %xmm0, -0x168(%rbp)
movsd %xmm1, -0x160(%rbp)
movq -0x168(%rbp), %rax
movq %rax, -0x150(%rbp)
movq -0x160(%rbp), %rax
movq %rax, -0x148(%rbp)
leaq -0x150(%rbp), %rdi
movsd 0x6d3c(%rip), %xmm0     # 0xe220
callq 0x6f50
testb $0x1, %al
jne 0x74ef
jmp 0x74f1
jmp 0x7507
jmp 0x74f3
movl -0x154(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x154(%rbp)
jmp 0x7462
movl -0x154(%rbp), %edi
leaq -0x150(%rbp), %rsi
leaq -0x140(%rbp), %rdx
callq 0x6540
movl %eax, -0x17c(%rbp)
movl -0x8c(%rbp), %eax
shrl $0x18, %eax
movb %al, %sil
movl -0xdc(%rbp), %eax
shrl $0x18, %eax
movb %al, %dl
movl -0x12c(%rbp), %eax
shrl $0x18, %eax
movb %al, %cl
movl -0x17c(%rbp), %eax
shrl $0x18, %eax
movzbl %sil, %edi
movzbl %dl, %esi
movzbl %cl, %edx
movzbl %al, %ecx
callq 0x76c0
movzbl %al, %ecx
movl -0x4(%rbp), %eax
andl $0xff, %ecx
shll $0x18, %ecx
andl $0xffffff, %eax         # imm = 0xFFFFFF
orl %ecx, %eax
movl %eax, -0x4(%rbp)
movl -0x8c(%rbp), %eax
shrl $0x10, %eax
andl $0xff, %eax
movb %al, %sil
movl -0xdc(%rbp), %eax
shrl $0x10, %eax
andl $0xff, %eax
movb %al, %dl
movl -0x12c(%rbp), %eax
shrl $0x10, %eax
andl $0xff, %eax
movb %al, %cl
movl -0x17c(%rbp), %eax
shrl $0x10, %eax
andl $0xff, %eax
movzbl %sil, %edi
movzbl %dl, %esi
movzbl %cl, %edx
movzbl %al, %ecx
callq 0x76c0
movzbl %al, %ecx
movl -0x4(%rbp), %eax
andl $0xff, %ecx
shll $0x10, %ecx
andl $0xff00ffff, %eax       # imm = 0xFF00FFFF
orl %ecx, %eax
movl %eax, -0x4(%rbp)
movl -0x8c(%rbp), %eax
shrl $0x8, %eax
andl $0xff, %eax
movb %al, %sil
movl -0xdc(%rbp), %eax
shrl $0x8, %eax
andl $0xff, %eax
movb %al, %dl
movl -0x12c(%rbp), %eax
shrl $0x8, %eax
andl $0xff, %eax
movb %al, %cl
movl -0x17c(%rbp), %eax
shrl $0x8, %eax
andl $0xff, %eax
movzbl %sil, %edi
movzbl %dl, %esi
movzbl %cl, %edx
movzbl %al, %ecx
callq 0x76c0
movzbl %al, %ecx
movl -0x4(%rbp), %eax
andl $0xff, %ecx
shll $0x8, %ecx
andl $0xffff00ff, %eax       # imm = 0xFFFF00FF
orl %ecx, %eax
movl %eax, -0x4(%rbp)
movl -0x8c(%rbp), %eax
andl $0xff, %eax
movb %al, %sil
movl -0xdc(%rbp), %eax
andl $0xff, %eax
movb %al, %dl
movl -0x12c(%rbp), %eax
andl $0xff, %eax
movb %al, %cl
movl -0x17c(%rbp), %eax
andl $0xff, %eax
movzbl %sil, %edi
movzbl %dl, %esi
movzbl %cl, %edx
movzbl %al, %ecx
callq 0x76c0
movzbl %al, %ecx
movl -0x4(%rbp), %eax
andl $0xff, %ecx
andl $0xffffff00, %eax       # imm = 0xFFFFFF00
orl %ecx, %eax
movl %eax, -0x4(%rbp)
movl -0x4(%rbp), %eax
addq $0x1a0, %rsp            # imm = 0x1A0
popq %rbp
retq
nopw (%rax,%rax)