#define NULL ((void *)0)
typedef unsigned long size_t; // Customize by platform.
typedef long intptr_t;
typedef unsigned long uintptr_t;
typedef long scalar_t__; // Either arithmetic or pointer type.
/* By default, we understand bool (as a convenience). */
typedef int bool;
#define false 0
#define true 1

/* Forward declarations */

/* Type definitions */
typedef int /*<<< orphan*/ __m256i;

/* Variables and functions */
int /*<<< orphan*/ _mm256_packus_epi32(int /*<<< orphan*/, int /*<<< orphan*/);
int /*<<< orphan*/ _mm256_permute2x128_si256(int /*<<< orphan*/ const,
                                             int /*<<< orphan*/ const, int);
int /*<<< orphan*/ filter_8x1_pixels(int /*<<< orphan*/ const *,
                                     int /*<<< orphan*/ const *,
                                     int /*<<< orphan*/ *);
void filter_16x9_pixels(const __m256i *sig, const __m256i *f, __m256i *y0,
                        __m256i *y1) {
  __m256i res[4];
  int i;
  for (i = 0; i < 4; ++i) {
    filter_8x1_pixels(&sig[i << 2], f, &res[i]);
  }
  {
    const __m256i l0l1 = _mm256_packus_epi32(res[0], res[1]);
    const __m256i h0h1 = _mm256_packus_epi32(res[2], res[3]);
    *y0 = _mm256_permute2x128_si256(l0l1, h0h1, 0x20);
    *y1 = _mm256_permute2x128_si256(l0l1, h0h1, 0x31);
  }
}


x86 assembly (clang, -O0):
<filter_16x9_pixels>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
mov    %rcx,-0x20(%rbp)
movl   $0x0,-0x34(%rbp)
cmpl   $0x4,-0x34(%rbp)
jge    1192 <filter_16x9_pixels+0x62>
mov    -0x8(%rbp),%rdi
mov    -0x34(%rbp),%eax
shl    $0x2,%eax
cltq
shl    $0x2,%rax
add    %rax,%rdi
mov    -0x10(%rbp),%rsi
movslq -0x34(%rbp),%rax
lea    -0x30(%rbp),%rdx
shl    $0x2,%rax
add    %rax,%rdx
call   1050 <filter_8x1_pixels@plt>
mov    -0x34(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x34(%rbp)
jmp    114f <filter_16x9_pixels+0x1f>
mov    -0x30(%rbp),%edi
mov    -0x2c(%rbp),%esi
call   1030 <_mm256_packus_epi32@plt>
mov    %eax,-0x38(%rbp)
mov    -0x28(%rbp),%edi
mov    -0x24(%rbp),%esi
call   1030 <_mm256_packus_epi32@plt>
mov    %eax,-0x3c(%rbp)
mov    -0x38(%rbp),%edi
mov    -0x3c(%rbp),%esi
mov    $0x20,%edx
call   1040 <_mm256_permute2x128_si256@plt>
mov    %eax,%ecx
mov    -0x18(%rbp),%rax
mov    %ecx,(%rax)
mov    -0x38(%rbp),%edi
mov    -0x3c(%rbp),%esi
mov    $0x31,%edx
call   1040 <_mm256_permute2x128_si256@plt>
mov    %eax,%ecx
mov    -0x20(%rbp),%rax
mov    %ecx,(%rax)
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<filter_16x9_pixels>:
push   %rbp
push   %r15
push   %r14
push   %r12
push   %rbx
sub    $0x10,%rsp
mov    %rcx,%r14
mov    %rdx,%r15
mov    %rsi,%r12
mov    %rdi,%rbx
mov    %rsp,%rdx
call   1050 <filter_8x1_pixels@plt>
lea    0x10(%rbx),%rdi
lea    0x4(%rsp),%rdx
mov    %r12,%rsi
call   1050 <filter_8x1_pixels@plt>
lea    0x20(%rbx),%rdi
lea    0x8(%rsp),%rdx
mov    %r12,%rsi
call   1050 <filter_8x1_pixels@plt>
add    $0x30,%rbx
lea    0xc(%rsp),%rdx
mov    %rbx,%rdi
mov    %r12,%rsi
call   1050 <filter_8x1_pixels@plt>
mov    (%rsp),%edi
mov    0x4(%rsp),%esi
call   1030 <_mm256_packus_epi32@plt>
mov    %eax,%ebx
mov    0x8(%rsp),%edi
mov    0xc(%rsp),%esi
call   1030 <_mm256_packus_epi32@plt>
mov    %eax,%ebp
mov    %ebx,%edi
mov    %eax,%esi
mov    $0x20,%edx
call   1040 <_mm256_permute2x128_si256@plt>
mov    %eax,(%r15)
mov    %ebx,%edi
mov    %ebp,%esi
mov    $0x31,%edx
call   1040 <_mm256_permute2x128_si256@plt>
mov    %eax,(%r14)
add    $0x10,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
define void @filter_16x9_pixels(i32* %0, i32* %1, i32* %2, i32* %3) {
%5 = alloca i32*
%6 = alloca i32*
%7 = alloca i32*
%8 = alloca i32*
%9 = alloca [4 x i32]
%10 = alloca i32
%11 = alloca i32
%12 = alloca i32
store i32* %0, i32** %5
store i32* %1, i32** %6
store i32* %2, i32** %7
store i32* %3, i32** %8
store i32 0, i32* %10
br label %13
13: ; preds = %27, %4
%14 = load i32, i32* %10
%15 = icmp slt i32 %14, 4
br i1 %15, label %16, label %30
16: ; preds = %13
%17 = load i32*, i32** %5
%18 = load i32, i32* %10
%19 = shl i32 %18, 2
%20 = sext i32 %19 to i64
%21 = getelementptr inbounds i32, i32* %17, i64 %20
%22 = load i32*, i32** %6
%23 = load i32, i32* %10
%24 = sext i32 %23 to i64
%25 = getelementptr inbounds [4 x i32], [4 x i32]* %9, i64 0, i64 %24
%26 = call i32 @filter_8x1_pixels(i32* %21, i32* %22, i32* %25)
br label %27
27: ; preds = %16
%28 = load i32, i32* %10
%29 = add nsw i32 %28, 1
store i32 %29, i32* %10
br label %13
30: ; preds = %13
%31 = getelementptr inbounds [4 x i32], [4 x i32]* %9, i64 0, i64 0
%32 = load i32, i32* %31
%33 = getelementptr inbounds [4 x i32], [4 x i32]* %9, i64 0, i64 1
%34 = load i32, i32* %33
%35 = call i32 @_mm256_packus_epi32(i32 %32, i32 %34)
store i32 %35, i32* %11
%36 = getelementptr inbounds [4 x i32], [4 x i32]* %9, i64 0, i64 2
%37 = load i32, i32* %36
%38 = getelementptr inbounds [4 x i32], [4 x i32]* %9, i64 0, i64 3
%39 = load i32, i32* %38
%40 = call i32 @_mm256_packus_epi32(i32 %37, i32 %39)
store i32 %40, i32* %12
%41 = load i32, i32* %11
%42 = load i32, i32* %12
%43 = call i32 @_mm256_permute2x128_si256(i32 %41, i32 %42, i32 32)
%44 = load i32*, i32** %7
store i32 %43, i32* %44
%45 = load i32, i32* %11
%46 = load i32, i32* %12
%47 = call i32 @_mm256_permute2x128_si256(i32 %45, i32 %46, i32 49)
%48 = load i32*, i32** %8
store i32 %47, i32* %48
ret void
}

LLVM IR (-O2):
define void @filter_16x9_pixels(i32* %0, i32* %1, i32* nocapture writeonly %2, i32* nocapture writeonly %3) {
%5 = alloca [4 x i32]
%6 = bitcast [4 x i32]* %5 to i8*
%7 = getelementptr inbounds [4 x i32], [4 x i32]* %5, i64 0, i64 0
%8 = call i32 @filter_8x1_pixels(i32* %0, i32* %1, i32* %7)
%9 = getelementptr inbounds i32, i32* %0, i64 4
%10 = getelementptr inbounds [4 x i32], [4 x i32]* %5, i64 0, i64 1
%11 = call i32 @filter_8x1_pixels(i32* %9, i32* %1, i32* %10)
%12 = getelementptr inbounds i32, i32* %0, i64 8
%13 = getelementptr inbounds [4 x i32], [4 x i32]* %5, i64 0, i64 2
%14 = call i32 @filter_8x1_pixels(i32* %12, i32* %1, i32* %13)
%15 = getelementptr inbounds i32, i32* %0, i64 12
%16 = getelementptr inbounds [4 x i32], [4 x i32]* %5, i64 0, i64 3
%17 = call i32 @filter_8x1_pixels(i32* %15, i32* %1, i32* %16)
%18 = load i32, i32* %7
%19 = load i32, i32* %10
%20 = call i32 @_mm256_packus_epi32(i32 %18, i32 %19)
%21 = load i32, i32* %13
%22 = load i32, i32* %16
%23 = call i32 @_mm256_packus_epi32(i32 %21, i32 %22)
%24 = call i32 @_mm256_permute2x128_si256(i32 %20, i32 %23, i32 32)
store i32 %24, i32* %2
%25 = call i32 @_mm256_permute2x128_si256(i32 %20, i32 %23, i32 49)
store i32 %25, i32* %3
ret void
}