// File: /workspace/github_cpp_makefile_star2_O3/kylegranger[P]ImageScaling/filter16.cpp
// Function: UpfilterLeft(color_t*, color_t*, color_t*, color_t*, color_t*)
void UpfilterLeft(color_t *src1, color_t *src2, color_t *src3, color_t *dst1, color_t *dst2)
{
	// we mix 9 source pixels to four destination pixels
	dst1[0].r = (3 * src1[1].r + src2[1].r * 9 + 6) / 12;
	dst1[1].r = ((src1[2].r + 3 * (src1[1].r + src2[2].r) + src2[1].r * 9 + 8) >> 4);
	dst2[0].r = (3 * src3[1].r + src2[1].r * 9 + 6) / 12;
	dst2[1].r = ((src3[2].r + 3 * (src3[1].r + src2[2].r) + src2[1].r * 9 + 8) >> 4);

	dst1[0].g = (3 * src1[1].g + src2[1].g * 9 + 6) / 12;
	dst1[1].g = ((src1[2].g + 3 * (src1[1].g + src2[2].g) + src2[1].g * 9 + 8) >> 4);
	dst2[0].g = (3 * src3[1].g + src2[1].g * 9 + 6) / 12;
	dst2[1].g = ((src3[2].g + 3 * (src3[1].g + src2[2].g) + src2[1].g * 9 + 8) >> 4);

	dst1[0].b = (3 * src1[1].b + src2[1].b * 9 + 6) / 12;
	dst1[1].b = ((src1[2].b + 3 * (src1[1].b + src2[2].b) + src2[1].b * 9 + 8) >> 4);
	dst2[0].b = (3 * src3[1].b + src2[1].b * 9 + 6) / 12;
	dst2[1].b = ((src3[2].b + 3 * (src3[1].b + src2[2].b) + src2[1].b * 9 + 8) >> 4);

	dst1[0].a = (3 * src1[1].a + src2[1].a * 9 + 6) / 12;
	dst1[1].a = ((src1[2].a + 3 * (src1[1].a + src2[2].a) + src2[1].a * 9 + 8) >> 4);
	dst2[0].a = (3 * src3[1].a + src2[1].a * 9 + 6) / 12;
	dst2[1].a = ((src3[2].a + 3 * (src3[1].a + src2[2].a) + src2[1].a * 9 + 8) >> 4);
}

// Assembly:
movzwl 0xc(%rdi), %eax
leal (%rax,%rax,2), %eax
movzwl 0xc(%rsi), %r9d
leal (%r9,%r9,8), %r9d
addl %r9d, %eax
addl $0x6, %eax
imulq $0x15555556, %rax, %rax # imm = 0x15555556
shrq $0x20, %rax
movw %ax, 0x4(%rcx)
movzwl 0xa(%rdi), %eax
leal (%rax,%rax,2), %eax
movzwl 0xa(%rsi), %r9d
leal (%r9,%r9,8), %r9d
addl %r9d, %eax
addl $0x6, %eax
imulq $0x15555556, %rax, %rax # imm = 0x15555556
shrq $0x20, %rax
movw %ax, 0x2(%rcx)
movzwl 0x8(%rdi), %eax
leal (%rax,%rax,2), %eax
movzwl 0x8(%rsi), %r9d
leal (%r9,%r9,8), %r9d
addl %r9d, %eax
addl $0x6, %eax
imulq $0x15555556, %rax, %rax # imm = 0x15555556
shrq $0x20, %rax
movw %ax, (%rcx)
movzwl 0xe(%rdi), %eax
leal (%rax,%rax,2), %eax
movzwl 0xe(%rsi), %r9d
leal (%r9,%r9,8), %r9d
addl %r9d, %eax
addl $0x6, %eax
imulq $0x15555556, %rax, %rax # imm = 0x15555556
shrq $0x20, %rax
movw %ax, 0x6(%rcx)
movq 0x10(%rdi), %xmm1
pxor %xmm0, %xmm0
punpcklwd %xmm0, %xmm1    # xmm1 = xmm1[0],xmm0[0],xmm1[1],xmm0[1],xmm1[2],xmm0[2],xmm1[3],xmm0[3]
movq 0x8(%rdi), %xmm2
punpcklwd %xmm0, %xmm2    # xmm2 = xmm2[0],xmm0[0],xmm2[1],xmm0[1],xmm2[2],xmm0[2],xmm2[3],xmm0[3]
movq 0x10(%rsi), %xmm3
punpcklwd %xmm0, %xmm3    # xmm3 = xmm3[0],xmm0[0],xmm3[1],xmm0[1],xmm3[2],xmm0[2],xmm3[3],xmm0[3]
paddd %xmm2, %xmm3
movq 0x8(%rsi), %xmm2
punpcklwd %xmm0, %xmm2    # xmm2 = xmm2[0],xmm0[0],xmm2[1],xmm0[1],xmm2[2],xmm0[2],xmm2[3],xmm0[3]
movdqa %xmm2, %xmm4
pslld $0x3, %xmm4
paddd %xmm2, %xmm4
paddd %xmm3, %xmm1
paddd %xmm3, %xmm3
paddd %xmm1, %xmm3
movdqa 0x17fa2(%rip), %xmm1    # 0x1e230
paddd %xmm1, %xmm4
paddd %xmm3, %xmm4
psrld $0x4, %xmm4
pshuflw $0xe8, %xmm4, %xmm2     # xmm2 = xmm4[0,2,2,3,4,5,6,7]
pshufhw $0xe8, %xmm2, %xmm2     # xmm2 = xmm2[0,1,2,3,4,6,6,7]
pshufd $0xe8, %xmm2, %xmm2     # xmm2 = xmm2[0,2,2,3]
movq %xmm2, 0x8(%rcx)
movq 0x8(%rdx), %xmm2
punpcklwd %xmm0, %xmm2    # xmm2 = xmm2[0],xmm0[0],xmm2[1],xmm0[1],xmm2[2],xmm0[2],xmm2[3],xmm0[3]
movdqa %xmm2, %xmm3
paddd %xmm2, %xmm3
paddd %xmm2, %xmm3
movq 0x8(%rsi), %xmm2
punpcklwd %xmm0, %xmm2    # xmm2 = xmm2[0],xmm0[0],xmm2[1],xmm0[1],xmm2[2],xmm0[2],xmm2[3],xmm0[3]
movdqa %xmm2, %xmm4
pslld $0x3, %xmm4
paddd %xmm2, %xmm4
paddd %xmm3, %xmm4
paddd 0x17f5a(%rip), %xmm4    # 0x1e240
movdqa 0x17f62(%rip), %xmm2    # 0x1e250
pshufd $0xf5, %xmm4, %xmm3     # xmm3 = xmm4[1,1,3,3]
pmuludq %xmm2, %xmm4
pshufd $0xed, %xmm4, %xmm4     # xmm4 = xmm4[1,3,2,3]
pmuludq %xmm2, %xmm3
pshufd $0xed, %xmm3, %xmm2     # xmm2 = xmm3[1,3,2,3]
punpcklwd %xmm2, %xmm4    # xmm4 = xmm4[0],xmm2[0],xmm4[1],xmm2[1],xmm4[2],xmm2[2],xmm4[3],xmm2[3]
pshufd $0xe8, %xmm4, %xmm2     # xmm2 = xmm4[0,2,2,3]
movq %xmm2, (%r8)
movq 0x10(%rdx), %xmm2
punpcklwd %xmm0, %xmm2    # xmm2 = xmm2[0],xmm0[0],xmm2[1],xmm0[1],xmm2[2],xmm0[2],xmm2[3],xmm0[3]
movq 0x8(%rdx), %xmm3
punpcklwd %xmm0, %xmm3    # xmm3 = xmm3[0],xmm0[0],xmm3[1],xmm0[1],xmm3[2],xmm0[2],xmm3[3],xmm0[3]
movq 0x10(%rsi), %xmm4
punpcklwd %xmm0, %xmm4    # xmm4 = xmm4[0],xmm0[0],xmm4[1],xmm0[1],xmm4[2],xmm0[2],xmm4[3],xmm0[3]
paddd %xmm3, %xmm4
movq 0x8(%rsi), %xmm3
punpcklwd %xmm0, %xmm3    # xmm3 = xmm3[0],xmm0[0],xmm3[1],xmm0[1],xmm3[2],xmm0[2],xmm3[3],xmm0[3]
movdqa %xmm3, %xmm0
pslld $0x3, %xmm0
paddd %xmm3, %xmm0
paddd %xmm4, %xmm2
paddd %xmm4, %xmm4
paddd %xmm2, %xmm4
paddd %xmm1, %xmm0
paddd %xmm4, %xmm0
psrld $0x4, %xmm0
pshuflw $0xe8, %xmm0, %xmm0     # xmm0 = xmm0[0,2,2,3,4,5,6,7]
pshufhw $0xe8, %xmm0, %xmm0     # xmm0 = xmm0[0,1,2,3,4,6,6,7]
pshufd $0xe8, %xmm0, %xmm0     # xmm0 = xmm0[0,2,2,3]
movq %xmm0, 0x8(%r8)
retq