#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 */
typedef struct TYPE_16__ TYPE_1__;

/* Type definitions */
struct TYPE_16__ {
  int member_0;
  int member_1;
};
typedef TYPE_1__ __m128i;

/* Variables and functions */
TYPE_1__ _mm_loadu_si128(TYPE_1__ *);
int /*<<< orphan*/ _mm_storeu_si128(TYPE_1__ *, TYPE_1__);
TYPE_1__ _mm_unpackhi_epi8(TYPE_1__, TYPE_1__);
TYPE_1__ _mm_unpacklo_epi8(TYPE_1__, TYPE_1__);
extern void unaligned_src_unaligned_dst_repack_yuv422p_to_uyvy_sse2(
    __m128i *y_input, __m128i *u_input, __m128i *v_input, __m128i *uyvy_out) {
  __m128i scratch = {0x0LL, 0x0LL};
  __m128i aligned_u_vector = _mm_loadu_si128(u_input);
  __m128i aligned_v_vector = _mm_loadu_si128(v_input);
  __m128i aligned_y_vector[2];
  (aligned_y_vector)[0] = _mm_loadu_si128(y_input);
  (aligned_y_vector)[1] = _mm_loadu_si128(&y_input[1]);
  (scratch) = _mm_unpacklo_epi8(*(&aligned_u_vector), *(&aligned_v_vector));
  _mm_storeu_si128(&(uyvy_out[0]),
                   (_mm_unpacklo_epi8((scratch), (aligned_y_vector)[0])));
  _mm_storeu_si128(&(uyvy_out[1]),
                   (_mm_unpackhi_epi8((scratch), (aligned_y_vector)[0])));
  (scratch) = _mm_unpackhi_epi8(*(&aligned_u_vector), *(&aligned_v_vector));
  _mm_storeu_si128(&(uyvy_out[2]),
                   (_mm_unpacklo_epi8((scratch), (aligned_y_vector)[1])));
  _mm_storeu_si128(&(uyvy_out[3]),
                   (_mm_unpackhi_epi8((scratch), (aligned_y_vector)[1])));
}


x86 assembly (clang, -O0):
<unaligned_src_unaligned_dst_repack_yuv422p_to_uyvy_sse2>:
push   %rbp
mov    %rsp,%rbp
sub    $0xb0,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
mov    %rcx,-0x20(%rbp)
lea    -0x28(%rbp),%rdi
xor    %esi,%esi
mov    $0x8,%edx
call   1050 <memset@plt>
mov    -0x10(%rbp),%rdi
call   1070 <_mm_loadu_si128@plt>
mov    %rax,-0x30(%rbp)
mov    -0x18(%rbp),%rdi
call   1070 <_mm_loadu_si128@plt>
mov    %rax,-0x38(%rbp)
mov    -0x8(%rbp),%rdi
call   1070 <_mm_loadu_si128@plt>
mov    %rax,-0x58(%rbp)
mov    -0x58(%rbp),%rax
mov    %rax,-0x50(%rbp)
mov    -0x8(%rbp),%rdi
add    $0x8,%rdi
call   1070 <_mm_loadu_si128@plt>
mov    %rax,-0x60(%rbp)
mov    -0x60(%rbp),%rax
mov    %rax,-0x48(%rbp)
mov    -0x30(%rbp),%rdi
mov    -0x38(%rbp),%rsi
call   1030 <_mm_unpacklo_epi8@plt>
mov    %rax,-0x68(%rbp)
mov    -0x68(%rbp),%rax
mov    %rax,-0x28(%rbp)
mov    -0x20(%rbp),%rax
mov    %rax,-0xb0(%rbp)
mov    -0x28(%rbp),%rdi
mov    -0x50(%rbp),%rsi
call   1030 <_mm_unpacklo_epi8@plt>
mov    -0xb0(%rbp),%rdi
mov    %rax,-0x70(%rbp)
mov    -0x70(%rbp),%rsi
call   1060 <_mm_storeu_si128@plt>
mov    -0x20(%rbp),%rax
add    $0x8,%rax
mov    %rax,-0xa8(%rbp)
mov    -0x28(%rbp),%rdi
mov    -0x50(%rbp),%rsi
call   1040 <_mm_unpackhi_epi8@plt>
mov    -0xa8(%rbp),%rdi
mov    %rax,-0x78(%rbp)
mov    -0x78(%rbp),%rsi
call   1060 <_mm_storeu_si128@plt>
mov    -0x30(%rbp),%rdi
mov    -0x38(%rbp),%rsi
call   1040 <_mm_unpackhi_epi8@plt>
mov    %rax,-0x80(%rbp)
mov    -0x80(%rbp),%rax
mov    %rax,-0x28(%rbp)
mov    -0x20(%rbp),%rax
add    $0x10,%rax
mov    %rax,-0xa0(%rbp)
mov    -0x28(%rbp),%rdi
mov    -0x48(%rbp),%rsi
call   1030 <_mm_unpacklo_epi8@plt>
mov    -0xa0(%rbp),%rdi
mov    %rax,-0x88(%rbp)
mov    -0x88(%rbp),%rsi
call   1060 <_mm_storeu_si128@plt>
mov    -0x20(%rbp),%rax
add    $0x18,%rax
mov    %rax,-0x98(%rbp)
mov    -0x28(%rbp),%rdi
mov    -0x48(%rbp),%rsi
call   1040 <_mm_unpackhi_epi8@plt>
mov    -0x98(%rbp),%rdi
mov    %rax,-0x90(%rbp)
mov    -0x90(%rbp),%rsi
call   1060 <_mm_storeu_si128@plt>
add    $0xb0,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<unaligned_src_unaligned_dst_repack_yuv422p_to_uyvy_sse2>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
mov    %rcx,%r13
mov    %rdx,%r14
mov    %rdi,%rbx
mov    %rsi,%rdi
call   1060 <_mm_loadu_si128@plt>
mov    %rax,%r15
mov    %r14,%rdi
call   1060 <_mm_loadu_si128@plt>
mov    %rax,%r12
mov    %rbx,%rdi
call   1060 <_mm_loadu_si128@plt>
mov    %rax,%rbp
add    $0x8,%rbx
mov    %rbx,%rdi
call   1060 <_mm_loadu_si128@plt>
mov    %rax,(%rsp)
mov    %r15,%rdi
mov    %r12,%rsi
call   1030 <_mm_unpacklo_epi8@plt>
mov    %rax,%rbx
mov    %rax,%rdi
mov    %rbp,%rsi
call   1030 <_mm_unpacklo_epi8@plt>
mov    %r13,%rdi
mov    %rax,%rsi
call   1050 <_mm_storeu_si128@plt>
lea    0x8(%r13),%r14
mov    %rbx,%rdi
mov    %rbp,%rsi
call   1040 <_mm_unpackhi_epi8@plt>
mov    %r14,%rdi
mov    %rax,%rsi
call   1050 <_mm_storeu_si128@plt>
mov    %r15,%rdi
mov    %r12,%rsi
call   1040 <_mm_unpackhi_epi8@plt>
mov    %rax,%rbx
lea    0x10(%r13),%r14
mov    %rax,%rdi
mov    (%rsp),%rbp
mov    %rbp,%rsi
call   1030 <_mm_unpacklo_epi8@plt>
mov    %r14,%rdi
mov    %rax,%rsi
call   1050 <_mm_storeu_si128@plt>
add    $0x18,%r13
mov    %rbx,%rdi
mov    %rbp,%rsi
call   1040 <_mm_unpackhi_epi8@plt>
mov    %r13,%rdi
mov    %rax,%rsi
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
jmp    1050 <_mm_storeu_si128@plt>

LLVM IR (-O0):
%struct.TYPE_16__ = type { i32, i32 }
define void @unaligned_src_unaligned_dst_repack_yuv422p_to_uyvy_sse2(%struct.TYPE_16__* %0, %struct.TYPE_16__* %1, %struct.TYPE_16__* %2, %struct.TYPE_16__* %3) {
%5 = alloca %struct.TYPE_16__*
%6 = alloca %struct.TYPE_16__*
%7 = alloca %struct.TYPE_16__*
%8 = alloca %struct.TYPE_16__*
%9 = alloca %struct.TYPE_16__
%10 = alloca %struct.TYPE_16__
%11 = alloca %struct.TYPE_16__
%12 = alloca [2 x %struct.TYPE_16__]
%13 = alloca %struct.TYPE_16__
%14 = alloca %struct.TYPE_16__
%15 = alloca %struct.TYPE_16__
%16 = alloca %struct.TYPE_16__
%17 = alloca %struct.TYPE_16__
%18 = alloca %struct.TYPE_16__
%19 = alloca %struct.TYPE_16__
%20 = alloca %struct.TYPE_16__
store %struct.TYPE_16__* %0, %struct.TYPE_16__** %5
store %struct.TYPE_16__* %1, %struct.TYPE_16__** %6
store %struct.TYPE_16__* %2, %struct.TYPE_16__** %7
store %struct.TYPE_16__* %3, %struct.TYPE_16__** %8
%21 = bitcast %struct.TYPE_16__* %9 to i8*
%22 = load %struct.TYPE_16__*, %struct.TYPE_16__** %6
%23 = call i64 @_mm_loadu_si128(%struct.TYPE_16__* %22)
%24 = bitcast %struct.TYPE_16__* %10 to i64*
store i64 %23, i64* %24
%25 = load %struct.TYPE_16__*, %struct.TYPE_16__** %7
%26 = call i64 @_mm_loadu_si128(%struct.TYPE_16__* %25)
%27 = bitcast %struct.TYPE_16__* %11 to i64*
store i64 %26, i64* %27
%28 = getelementptr inbounds [2 x %struct.TYPE_16__], [2 x %struct.TYPE_16__]* %12, i64 0, i64 0
%29 = load %struct.TYPE_16__*, %struct.TYPE_16__** %5
%30 = call i64 @_mm_loadu_si128(%struct.TYPE_16__* %29)
%31 = bitcast %struct.TYPE_16__* %13 to i64*
store i64 %30, i64* %31
%32 = bitcast %struct.TYPE_16__* %28 to i8*
%33 = bitcast %struct.TYPE_16__* %13 to i8*
%34 = getelementptr inbounds [2 x %struct.TYPE_16__], [2 x %struct.TYPE_16__]* %12, i64 0, i64 1
%35 = load %struct.TYPE_16__*, %struct.TYPE_16__** %5
%36 = getelementptr inbounds %struct.TYPE_16__, %struct.TYPE_16__* %35, i64 1
%37 = call i64 @_mm_loadu_si128(%struct.TYPE_16__* %36)
%38 = bitcast %struct.TYPE_16__* %14 to i64*
store i64 %37, i64* %38
%39 = bitcast %struct.TYPE_16__* %34 to i8*
%40 = bitcast %struct.TYPE_16__* %14 to i8*
%41 = bitcast %struct.TYPE_16__* %10 to i64*
%42 = load i64, i64* %41
%43 = bitcast %struct.TYPE_16__* %11 to i64*
%44 = load i64, i64* %43
%45 = call i64 @_mm_unpacklo_epi8(i64 %42, i64 %44)
%46 = bitcast %struct.TYPE_16__* %15 to i64*
store i64 %45, i64* %46
%47 = bitcast %struct.TYPE_16__* %9 to i8*
%48 = bitcast %struct.TYPE_16__* %15 to i8*
%49 = load %struct.TYPE_16__*, %struct.TYPE_16__** %8
%50 = getelementptr inbounds %struct.TYPE_16__, %struct.TYPE_16__* %49, i64 0
%51 = getelementptr inbounds [2 x %struct.TYPE_16__], [2 x %struct.TYPE_16__]* %12, i64 0, i64 0
%52 = bitcast %struct.TYPE_16__* %9 to i64*
%53 = load i64, i64* %52
%54 = bitcast %struct.TYPE_16__* %51 to i64*
%55 = load i64, i64* %54
%56 = call i64 @_mm_unpacklo_epi8(i64 %53, i64 %55)
%57 = bitcast %struct.TYPE_16__* %16 to i64*
store i64 %56, i64* %57
%58 = bitcast %struct.TYPE_16__* %16 to i64*
%59 = load i64, i64* %58
%60 = call i32 @_mm_storeu_si128(%struct.TYPE_16__* %50, i64 %59)
%61 = load %struct.TYPE_16__*, %struct.TYPE_16__** %8
%62 = getelementptr inbounds %struct.TYPE_16__, %struct.TYPE_16__* %61, i64 1
%63 = getelementptr inbounds [2 x %struct.TYPE_16__], [2 x %struct.TYPE_16__]* %12, i64 0, i64 0
%64 = bitcast %struct.TYPE_16__* %9 to i64*
%65 = load i64, i64* %64
%66 = bitcast %struct.TYPE_16__* %63 to i64*
%67 = load i64, i64* %66
%68 = call i64 @_mm_unpackhi_epi8(i64 %65, i64 %67)
%69 = bitcast %struct.TYPE_16__* %17 to i64*
store i64 %68, i64* %69
%70 = bitcast %struct.TYPE_16__* %17 to i64*
%71 = load i64, i64* %70
%72 = call i32 @_mm_storeu_si128(%struct.TYPE_16__* %62, i64 %71)
%73 = bitcast %struct.TYPE_16__* %10 to i64*
%74 = load i64, i64* %73
%75 = bitcast %struct.TYPE_16__* %11 to i64*
%76 = load i64, i64* %75
%77 = call i64 @_mm_unpackhi_epi8(i64 %74, i64 %76)
%78 = bitcast %struct.TYPE_16__* %18 to i64*
store i64 %77, i64* %78
%79 = bitcast %struct.TYPE_16__* %9 to i8*
%80 = bitcast %struct.TYPE_16__* %18 to i8*
%81 = load %struct.TYPE_16__*, %struct.TYPE_16__** %8
%82 = getelementptr inbounds %struct.TYPE_16__, %struct.TYPE_16__* %81, i64 2
%83 = getelementptr inbounds [2 x %struct.TYPE_16__], [2 x %struct.TYPE_16__]* %12, i64 0, i64 1
%84 = bitcast %struct.TYPE_16__* %9 to i64*
%85 = load i64, i64* %84
%86 = bitcast %struct.TYPE_16__* %83 to i64*
%87 = load i64, i64* %86
%88 = call i64 @_mm_unpacklo_epi8(i64 %85, i64 %87)
%89 = bitcast %struct.TYPE_16__* %19 to i64*
store i64 %88, i64* %89
%90 = bitcast %struct.TYPE_16__* %19 to i64*
%91 = load i64, i64* %90
%92 = call i32 @_mm_storeu_si128(%struct.TYPE_16__* %82, i64 %91)
%93 = load %struct.TYPE_16__*, %struct.TYPE_16__** %8
%94 = getelementptr inbounds %struct.TYPE_16__, %struct.TYPE_16__* %93, i64 3
%95 = getelementptr inbounds [2 x %struct.TYPE_16__], [2 x %struct.TYPE_16__]* %12, i64 0, i64 1
%96 = bitcast %struct.TYPE_16__* %9 to i64*
%97 = load i64, i64* %96
%98 = bitcast %struct.TYPE_16__* %95 to i64*
%99 = load i64, i64* %98
%100 = call i64 @_mm_unpackhi_epi8(i64 %97, i64 %99)
%101 = bitcast %struct.TYPE_16__* %20 to i64*
store i64 %100, i64* %101
%102 = bitcast %struct.TYPE_16__* %20 to i64*
%103 = load i64, i64* %102
%104 = call i32 @_mm_storeu_si128(%struct.TYPE_16__* %94, i64 %103)
ret void
}

LLVM IR (-O2):
%struct.TYPE_16__ = type { i32, i32 }
define void @unaligned_src_unaligned_dst_repack_yuv422p_to_uyvy_sse2(%struct.TYPE_16__* %0, %struct.TYPE_16__* %1, %struct.TYPE_16__* %2, %struct.TYPE_16__* %3) {
%5 = tail call i64 @_mm_loadu_si128(%struct.TYPE_16__* %1)
%6 = tail call i64 @_mm_loadu_si128(%struct.TYPE_16__* %2)
%7 = tail call i64 @_mm_loadu_si128(%struct.TYPE_16__* %0)
%8 = getelementptr inbounds %struct.TYPE_16__, %struct.TYPE_16__* %0, i64 1
%9 = tail call i64 @_mm_loadu_si128(%struct.TYPE_16__* %8)
%10 = tail call i64 @_mm_unpacklo_epi8(i64 %5, i64 %6)
%11 = tail call i64 @_mm_unpacklo_epi8(i64 %10, i64 %7)
%12 = tail call i32 @_mm_storeu_si128(%struct.TYPE_16__* %3, i64 %11)
%13 = getelementptr inbounds %struct.TYPE_16__, %struct.TYPE_16__* %3, i64 1
%14 = tail call i64 @_mm_unpackhi_epi8(i64 %10, i64 %7)
%15 = tail call i32 @_mm_storeu_si128(%struct.TYPE_16__* %13, i64 %14)
%16 = tail call i64 @_mm_unpackhi_epi8(i64 %5, i64 %6)
%17 = getelementptr inbounds %struct.TYPE_16__, %struct.TYPE_16__* %3, i64 2
%18 = tail call i64 @_mm_unpacklo_epi8(i64 %16, i64 %9)
%19 = tail call i32 @_mm_storeu_si128(%struct.TYPE_16__* %17, i64 %18)
%20 = getelementptr inbounds %struct.TYPE_16__, %struct.TYPE_16__* %3, i64 3
%21 = tail call i64 @_mm_unpackhi_epi8(i64 %16, i64 %9)
%22 = tail call i32 @_mm_storeu_si128(%struct.TYPE_16__* %20, i64 %21)
ret void
}