#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_permute2x128_si256(int /*<<< orphan*/,
                                             int /*<<< orphan*/, int);
int /*<<< orphan*/ pack_pixels(int /*<<< orphan*/ const *,
                               int /*<<< orphan*/ *);
void pack_16_pixels(const __m256i *s0, const __m256i *s1, __m256i *x) {
  __m256i pp[8];
  pack_pixels(s0, pp);
  pack_pixels(s1, &pp[4]);
  x[0] = _mm256_permute2x128_si256(pp[0], pp[4], 0x20);
  x[1] = _mm256_permute2x128_si256(pp[1], pp[5], 0x20);
  x[2] = _mm256_permute2x128_si256(pp[2], pp[6], 0x20);
  x[3] = _mm256_permute2x128_si256(pp[3], pp[7], 0x20);
  x[4] = x[2];
  x[5] = x[3];
  x[6] = _mm256_permute2x128_si256(pp[0], pp[4], 0x31);
  x[7] = _mm256_permute2x128_si256(pp[1], pp[5], 0x31);
}


x86 assembly (clang, -O0):
<pack_16_pixels>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
mov    -0x8(%rbp),%rdi
lea    -0x40(%rbp),%rsi
call   1030 <pack_pixels@plt>
mov    -0x10(%rbp),%rdi
lea    -0x40(%rbp),%rsi
add    $0x10,%rsi
call   1030 <pack_pixels@plt>
mov    -0x40(%rbp),%edi
mov    -0x30(%rbp),%esi
mov    $0x20,%edx
call   1040 <_mm256_permute2x128_si256@plt>
mov    %eax,%ecx
mov    -0x18(%rbp),%rax
mov    %ecx,(%rax)
mov    -0x3c(%rbp),%edi
mov    -0x2c(%rbp),%esi
mov    $0x20,%edx
call   1040 <_mm256_permute2x128_si256@plt>
mov    %eax,%ecx
mov    -0x18(%rbp),%rax
mov    %ecx,0x4(%rax)
mov    -0x38(%rbp),%edi
mov    -0x28(%rbp),%esi
mov    $0x20,%edx
call   1040 <_mm256_permute2x128_si256@plt>
mov    %eax,%ecx
mov    -0x18(%rbp),%rax
mov    %ecx,0x8(%rax)
mov    -0x34(%rbp),%edi
mov    -0x24(%rbp),%esi
mov    $0x20,%edx
call   1040 <_mm256_permute2x128_si256@plt>
mov    %eax,%ecx
mov    -0x18(%rbp),%rax
mov    %ecx,0xc(%rax)
mov    -0x18(%rbp),%rax
mov    0x8(%rax),%ecx
mov    -0x18(%rbp),%rax
mov    %ecx,0x10(%rax)
mov    -0x18(%rbp),%rax
mov    0xc(%rax),%ecx
mov    -0x18(%rbp),%rax
mov    %ecx,0x14(%rax)
mov    -0x40(%rbp),%edi
mov    -0x30(%rbp),%esi
mov    $0x31,%edx
call   1040 <_mm256_permute2x128_si256@plt>
mov    %eax,%ecx
mov    -0x18(%rbp),%rax
mov    %ecx,0x18(%rax)
mov    -0x3c(%rbp),%edi
mov    -0x2c(%rbp),%esi
mov    $0x31,%edx
call   1040 <_mm256_permute2x128_si256@plt>
mov    %eax,%ecx
mov    -0x18(%rbp),%rax
mov    %ecx,0x1c(%rax)
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<pack_16_pixels>:
push   %r14
push   %rbx
sub    $0x28,%rsp
mov    %rdx,%rbx
mov    %rsi,%r14
mov    %rsp,%rsi
call   1030 <pack_pixels@plt>
lea    0x10(%rsp),%rsi
mov    %r14,%rdi
call   1030 <pack_pixels@plt>
mov    (%rsp),%edi
mov    0x10(%rsp),%esi
mov    $0x20,%edx
call   1040 <_mm256_permute2x128_si256@plt>
mov    %eax,(%rbx)
mov    0x4(%rsp),%edi
mov    0x14(%rsp),%esi
mov    $0x20,%edx
call   1040 <_mm256_permute2x128_si256@plt>
mov    %eax,0x4(%rbx)
mov    0x8(%rsp),%edi
mov    0x18(%rsp),%esi
mov    $0x20,%edx
call   1040 <_mm256_permute2x128_si256@plt>
mov    %eax,0x8(%rbx)
mov    0xc(%rsp),%edi
mov    0x1c(%rsp),%esi
mov    $0x20,%edx
call   1040 <_mm256_permute2x128_si256@plt>
mov    %eax,0xc(%rbx)
mov    0x8(%rbx),%ecx
mov    %ecx,0x10(%rbx)
mov    %eax,0x14(%rbx)
mov    (%rsp),%edi
mov    0x10(%rsp),%esi
mov    $0x31,%edx
call   1040 <_mm256_permute2x128_si256@plt>
mov    %eax,0x18(%rbx)
mov    0x4(%rsp),%edi
mov    0x14(%rsp),%esi
mov    $0x31,%edx
call   1040 <_mm256_permute2x128_si256@plt>
mov    %eax,0x1c(%rbx)
add    $0x28,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
define void @pack_16_pixels(i32* %0, i32* %1, i32* %2) {
%4 = alloca i32*
%5 = alloca i32*
%6 = alloca i32*
%7 = alloca [8 x i32]
store i32* %0, i32** %4
store i32* %1, i32** %5
store i32* %2, i32** %6
%8 = load i32*, i32** %4
%9 = getelementptr inbounds [8 x i32], [8 x i32]* %7, i64 0, i64 0
%10 = call i32 @pack_pixels(i32* %8, i32* %9)
%11 = load i32*, i32** %5
%12 = getelementptr inbounds [8 x i32], [8 x i32]* %7, i64 0, i64 4
%13 = call i32 @pack_pixels(i32* %11, i32* %12)
%14 = getelementptr inbounds [8 x i32], [8 x i32]* %7, i64 0, i64 0
%15 = load i32, i32* %14
%16 = getelementptr inbounds [8 x i32], [8 x i32]* %7, i64 0, i64 4
%17 = load i32, i32* %16
%18 = call i32 @_mm256_permute2x128_si256(i32 %15, i32 %17, i32 32)
%19 = load i32*, i32** %6
%20 = getelementptr inbounds i32, i32* %19, i64 0
store i32 %18, i32* %20
%21 = getelementptr inbounds [8 x i32], [8 x i32]* %7, i64 0, i64 1
%22 = load i32, i32* %21
%23 = getelementptr inbounds [8 x i32], [8 x i32]* %7, i64 0, i64 5
%24 = load i32, i32* %23
%25 = call i32 @_mm256_permute2x128_si256(i32 %22, i32 %24, i32 32)
%26 = load i32*, i32** %6
%27 = getelementptr inbounds i32, i32* %26, i64 1
store i32 %25, i32* %27
%28 = getelementptr inbounds [8 x i32], [8 x i32]* %7, i64 0, i64 2
%29 = load i32, i32* %28
%30 = getelementptr inbounds [8 x i32], [8 x i32]* %7, i64 0, i64 6
%31 = load i32, i32* %30
%32 = call i32 @_mm256_permute2x128_si256(i32 %29, i32 %31, i32 32)
%33 = load i32*, i32** %6
%34 = getelementptr inbounds i32, i32* %33, i64 2
store i32 %32, i32* %34
%35 = getelementptr inbounds [8 x i32], [8 x i32]* %7, i64 0, i64 3
%36 = load i32, i32* %35
%37 = getelementptr inbounds [8 x i32], [8 x i32]* %7, i64 0, i64 7
%38 = load i32, i32* %37
%39 = call i32 @_mm256_permute2x128_si256(i32 %36, i32 %38, i32 32)
%40 = load i32*, i32** %6
%41 = getelementptr inbounds i32, i32* %40, i64 3
store i32 %39, i32* %41
%42 = load i32*, i32** %6
%43 = getelementptr inbounds i32, i32* %42, i64 2
%44 = load i32, i32* %43
%45 = load i32*, i32** %6
%46 = getelementptr inbounds i32, i32* %45, i64 4
store i32 %44, i32* %46
%47 = load i32*, i32** %6
%48 = getelementptr inbounds i32, i32* %47, i64 3
%49 = load i32, i32* %48
%50 = load i32*, i32** %6
%51 = getelementptr inbounds i32, i32* %50, i64 5
store i32 %49, i32* %51
%52 = getelementptr inbounds [8 x i32], [8 x i32]* %7, i64 0, i64 0
%53 = load i32, i32* %52
%54 = getelementptr inbounds [8 x i32], [8 x i32]* %7, i64 0, i64 4
%55 = load i32, i32* %54
%56 = call i32 @_mm256_permute2x128_si256(i32 %53, i32 %55, i32 49)
%57 = load i32*, i32** %6
%58 = getelementptr inbounds i32, i32* %57, i64 6
store i32 %56, i32* %58
%59 = getelementptr inbounds [8 x i32], [8 x i32]* %7, i64 0, i64 1
%60 = load i32, i32* %59
%61 = getelementptr inbounds [8 x i32], [8 x i32]* %7, i64 0, i64 5
%62 = load i32, i32* %61
%63 = call i32 @_mm256_permute2x128_si256(i32 %60, i32 %62, i32 49)
%64 = load i32*, i32** %6
%65 = getelementptr inbounds i32, i32* %64, i64 7
store i32 %63, i32* %65
ret void
}

LLVM IR (-O2):
define void @pack_16_pixels(i32* %0, i32* %1, i32* nocapture %2) {
%4 = alloca [8 x i32]
%5 = bitcast [8 x i32]* %4 to i8*
%6 = getelementptr inbounds [8 x i32], [8 x i32]* %4, i64 0, i64 0
%7 = call i32 @pack_pixels(i32* %0, i32* %6)
%8 = getelementptr inbounds [8 x i32], [8 x i32]* %4, i64 0, i64 4
%9 = call i32 @pack_pixels(i32* %1, i32* %8)
%10 = load i32, i32* %6
%11 = load i32, i32* %8
%12 = call i32 @_mm256_permute2x128_si256(i32 %10, i32 %11, i32 32)
store i32 %12, i32* %2
%13 = getelementptr inbounds [8 x i32], [8 x i32]* %4, i64 0, i64 1
%14 = load i32, i32* %13
%15 = getelementptr inbounds [8 x i32], [8 x i32]* %4, i64 0, i64 5
%16 = load i32, i32* %15
%17 = call i32 @_mm256_permute2x128_si256(i32 %14, i32 %16, i32 32)
%18 = getelementptr inbounds i32, i32* %2, i64 1
store i32 %17, i32* %18
%19 = getelementptr inbounds [8 x i32], [8 x i32]* %4, i64 0, i64 2
%20 = load i32, i32* %19
%21 = getelementptr inbounds [8 x i32], [8 x i32]* %4, i64 0, i64 6
%22 = load i32, i32* %21
%23 = call i32 @_mm256_permute2x128_si256(i32 %20, i32 %22, i32 32)
%24 = getelementptr inbounds i32, i32* %2, i64 2
store i32 %23, i32* %24
%25 = getelementptr inbounds [8 x i32], [8 x i32]* %4, i64 0, i64 3
%26 = load i32, i32* %25
%27 = getelementptr inbounds [8 x i32], [8 x i32]* %4, i64 0, i64 7
%28 = load i32, i32* %27
%29 = call i32 @_mm256_permute2x128_si256(i32 %26, i32 %28, i32 32)
%30 = getelementptr inbounds i32, i32* %2, i64 3
store i32 %29, i32* %30
%31 = load i32, i32* %24
%32 = getelementptr inbounds i32, i32* %2, i64 4
store i32 %31, i32* %32
%33 = getelementptr inbounds i32, i32* %2, i64 5
store i32 %29, i32* %33
%34 = load i32, i32* %6
%35 = load i32, i32* %8
%36 = call i32 @_mm256_permute2x128_si256(i32 %34, i32 %35, i32 49)
%37 = getelementptr inbounds i32, i32* %2, i64 6
store i32 %36, i32* %37
%38 = load i32, i32* %13
%39 = load i32, i32* %15
%40 = call i32 @_mm256_permute2x128_si256(i32 %38, i32 %39, i32 49)
%41 = getelementptr inbounds i32, i32* %2, i64 7
store i32 %40, i32* %41
ret void
}