// File: /workspace/github_cpp_makefile_star2_O1/kylegranger[P]ImageScaling/filter16.cpp
// Function: Downfilter(color_t*, color_t*, color_t*, color_t*)
void Downfilter(color_t *src1, color_t *src2, color_t *src3, color_t *dst)
{
	// we mix 16 source pixels into one destination pixel
	int r = (src1[0].r + src1[3].r)     + 3 * (src1[1].r + src1[2].r);
	r    += (src2[0].r + src2[3].r) * 3 + 9 * (src2[1].r + src2[2].r);
	r    += (src3[0].r + src3[3].r) * 3 + 9 * (src3[1].r + src3[2].r);
	dst->r = ((r+28)/56);
	int g = (src1[0].g + src1[3].g)     + 3 * (src1[1].g + src1[2].g);
	g    += (src2[0].g + src2[3].g) * 3 + 9 * (src2[1].g + src2[2].g);
	g    += (src3[0].g + src3[3].g) * 3 + 9 * (src3[1].g + src3[2].g);
	dst->g = ((g+28)/56);
	int b = (src1[0].b + src1[3].b)     + 3 * (src1[1].b + src1[2].b);
	b    += (src2[0].b + src2[3].b) * 3 + 9 * (src2[1].b + src2[2].b);
	b    += (src3[0].b + src3[3].b) * 3 + 9 * (src3[1].b + src3[2].b);
	dst->b = ((b+28)/56);
	int a = (src1[0].a + src1[3].a)     + 3 * (src1[1].a + src1[2].a);
	a    += (src2[0].a + src2[3].a) * 3 + 9 * (src2[1].a + src2[2].a);
	a    += (src3[0].a + src3[3].a) * 3 + 9 * (src3[1].a + src3[2].a);
	dst->a = ((a+28)/56);
}

// Assembly:
movzwl 0x4(%rdi), %r8d
movzwl 0x1c(%rdi), %eax
addl %r8d, %eax
movzwl 0xc(%rdi), %r8d
movzwl 0x14(%rdi), %r9d
addl %r8d, %r9d
movzwl 0x4(%rsi), %r8d
movzwl 0x1c(%rsi), %r10d
addl %r8d, %r10d
addl %r9d, %r10d
movzwl 0xc(%rsi), %r8d
movzwl 0x14(%rsi), %r9d
addl %r8d, %r9d
movzwl 0x4(%rdx), %r8d
movzwl 0x1c(%rdx), %r11d
addl %r8d, %r11d
addl %r10d, %r11d
movzwl 0xc(%rdx), %r8d
movzwl 0x14(%rdx), %r10d
addl %r8d, %r10d
addl %r9d, %r10d
leal (%r11,%r11,2), %r8d
addl %eax, %r8d
leal (%r10,%r10,8), %eax
addl %r8d, %eax
addl $0x1c, %eax
shrl $0x3, %eax
imulq $0x24924925, %rax, %rax # imm = 0x24924925
shrq $0x20, %rax
movw %ax, 0x4(%rcx)
movzwl 0x2(%rdi), %r8d
movzwl 0x1a(%rdi), %eax
addl %r8d, %eax
movzwl 0xa(%rdi), %r8d
movzwl 0x12(%rdi), %r9d
addl %r8d, %r9d
movzwl 0x2(%rsi), %r8d
movzwl 0x1a(%rsi), %r10d
addl %r8d, %r10d
addl %r9d, %r10d
movzwl 0xa(%rsi), %r8d
movzwl 0x12(%rsi), %r9d
addl %r8d, %r9d
movzwl 0x2(%rdx), %r8d
movzwl 0x1a(%rdx), %r11d
addl %r8d, %r11d
addl %r10d, %r11d
movzwl 0xa(%rdx), %r8d
movzwl 0x12(%rdx), %r10d
addl %r8d, %r10d
addl %r9d, %r10d
leal (%r11,%r11,2), %r8d
addl %eax, %r8d
leal (%r10,%r10,8), %eax
addl %r8d, %eax
addl $0x1c, %eax
shrl $0x3, %eax
imulq $0x24924925, %rax, %rax # imm = 0x24924925
shrq $0x20, %rax
movw %ax, 0x2(%rcx)
movzwl (%rdi), %r8d
movzwl 0x18(%rdi), %eax
addl %r8d, %eax
movzwl 0x8(%rdi), %r8d
movzwl 0x10(%rdi), %r9d
addl %r8d, %r9d
movzwl (%rsi), %r8d
movzwl 0x18(%rsi), %r10d
addl %r8d, %r10d
addl %r9d, %r10d
movzwl 0x8(%rsi), %r8d
movzwl 0x10(%rsi), %r9d
addl %r8d, %r9d
movzwl (%rdx), %r8d
movzwl 0x18(%rdx), %r11d
addl %r8d, %r11d
addl %r10d, %r11d
movzwl 0x8(%rdx), %r8d
movzwl 0x10(%rdx), %r10d
addl %r8d, %r10d
addl %r9d, %r10d
leal (%r11,%r11,2), %r8d
addl %eax, %r8d
leal (%r10,%r10,8), %eax
addl %r8d, %eax
addl $0x1c, %eax
shrl $0x3, %eax
imulq $0x24924925, %rax, %rax # imm = 0x24924925
shrq $0x20, %rax
movw %ax, (%rcx)
movzwl 0x6(%rdi), %r8d
movzwl 0x1e(%rdi), %eax
addl %r8d, %eax
movzwl 0xe(%rdi), %r8d
movzwl 0x16(%rdi), %edi
addl %r8d, %edi
movzwl 0x6(%rsi), %r8d
movzwl 0x1e(%rsi), %r9d
addl %r8d, %r9d
addl %edi, %r9d
movzwl 0xe(%rsi), %edi
movzwl 0x16(%rsi), %esi
addl %edi, %esi
movzwl 0x6(%rdx), %edi
movzwl 0x1e(%rdx), %r8d
addl %edi, %r8d
addl %r9d, %r8d
movzwl 0xe(%rdx), %edi
movzwl 0x16(%rdx), %edx
addl %edi, %edx
addl %esi, %edx
leal (%r8,%r8,2), %esi
addl %eax, %esi
leal (%rdx,%rdx,8), %eax
addl %esi, %eax
addl $0x1c, %eax
shrl $0x3, %eax
imulq $0x24924925, %rax, %rax # imm = 0x24924925
shrq $0x20, %rax
movw %ax, 0x6(%rcx)
retq