#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_14__ TYPE_1__;

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

/* Variables and functions */
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_dst_repack_yuv422p_to_uyvy_sse2(__m128i *y_input,
                                                      __m128i *u_input,
                                                      __m128i *v_input,
                                                      __m128i *uyvy_out) {
  __m128i scratch = {0x0LL, 0x0LL};
  ;
  (scratch) = _mm_unpacklo_epi8(*(u_input), *(v_input));
  _mm_storeu_si128(&(uyvy_out[0]),
                   (_mm_unpacklo_epi8((scratch), (y_input)[0])));
  _mm_storeu_si128(&(uyvy_out[1]),
                   (_mm_unpackhi_epi8((scratch), (y_input)[0])));
  (scratch) = _mm_unpackhi_epi8(*(u_input), *(v_input));
  _mm_storeu_si128(&(uyvy_out[2]),
                   (_mm_unpacklo_epi8((scratch), (y_input)[1])));
  _mm_storeu_si128(&(uyvy_out[3]),
                   (_mm_unpackhi_epi8((scratch), (y_input)[1])));
}


x86 assembly (clang, -O0):
<unaligned_dst_repack_yuv422p_to_uyvy_sse2>:
push   %rbp
mov    %rsp,%rbp
sub    $0x80,%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),%rcx
mov    -0x18(%rbp),%rax
mov    (%rcx),%rdi
mov    (%rax),%rsi
call   1030 <_mm_unpacklo_epi8@plt>
mov    %rax,-0x30(%rbp)
mov    -0x30(%rbp),%rax
mov    %rax,-0x28(%rbp)
mov    -0x20(%rbp),%rax
mov    %rax,-0x78(%rbp)
mov    -0x8(%rbp),%rax
mov    -0x28(%rbp),%rdi
mov    (%rax),%rsi
call   1030 <_mm_unpacklo_epi8@plt>
mov    -0x78(%rbp),%rdi
mov    %rax,-0x38(%rbp)
mov    -0x38(%rbp),%rsi
call   1060 <_mm_storeu_si128@plt>
mov    -0x20(%rbp),%rax
add    $0x8,%rax
mov    %rax,-0x70(%rbp)
mov    -0x8(%rbp),%rax
mov    -0x28(%rbp),%rdi
mov    (%rax),%rsi
call   1040 <_mm_unpackhi_epi8@plt>
mov    -0x70(%rbp),%rdi
mov    %rax,-0x40(%rbp)
mov    -0x40(%rbp),%rsi
call   1060 <_mm_storeu_si128@plt>
mov    -0x10(%rbp),%rcx
mov    -0x18(%rbp),%rax
mov    (%rcx),%rdi
mov    (%rax),%rsi
call   1040 <_mm_unpackhi_epi8@plt>
mov    %rax,-0x48(%rbp)
mov    -0x48(%rbp),%rax
mov    %rax,-0x28(%rbp)
mov    -0x20(%rbp),%rax
add    $0x10,%rax
mov    %rax,-0x68(%rbp)
mov    -0x8(%rbp),%rax
mov    -0x28(%rbp),%rdi
mov    0x8(%rax),%rsi
call   1030 <_mm_unpacklo_epi8@plt>
mov    -0x68(%rbp),%rdi
mov    %rax,-0x50(%rbp)
mov    -0x50(%rbp),%rsi
call   1060 <_mm_storeu_si128@plt>
mov    -0x20(%rbp),%rax
add    $0x18,%rax
mov    %rax,-0x60(%rbp)
mov    -0x8(%rbp),%rax
mov    -0x28(%rbp),%rdi
mov    0x8(%rax),%rsi
call   1040 <_mm_unpackhi_epi8@plt>
mov    -0x60(%rbp),%rdi
mov    %rax,-0x58(%rbp)
mov    -0x58(%rbp),%rsi
call   1060 <_mm_storeu_si128@plt>
add    $0x80,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<unaligned_dst_repack_yuv422p_to_uyvy_sse2>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
mov    %rcx,%rbx
mov    %rdx,%r15
mov    %rsi,%r12
mov    %rdi,%r14
mov    (%rsi),%rdi
mov    (%rdx),%rsi
call   1030 <_mm_unpacklo_epi8@plt>
mov    %rax,%r13
mov    (%r14),%rsi
mov    %rax,%rdi
call   1030 <_mm_unpacklo_epi8@plt>
mov    %rbx,%rdi
mov    %rax,%rsi
call   1050 <_mm_storeu_si128@plt>
lea    0x8(%rbx),%rbp
mov    (%r14),%rsi
mov    %r13,%rdi
call   1040 <_mm_unpackhi_epi8@plt>
mov    %rbp,%rdi
mov    %rax,%rsi
call   1050 <_mm_storeu_si128@plt>
mov    (%r12),%rdi
mov    (%r15),%rsi
call   1040 <_mm_unpackhi_epi8@plt>
mov    %rax,%rbp
lea    0x10(%rbx),%r15
mov    0x8(%r14),%rsi
mov    %rax,%rdi
call   1030 <_mm_unpacklo_epi8@plt>
mov    %r15,%rdi
mov    %rax,%rsi
call   1050 <_mm_storeu_si128@plt>
add    $0x18,%rbx
mov    0x8(%r14),%rsi
mov    %rbp,%rdi
call   1040 <_mm_unpackhi_epi8@plt>
mov    %rbx,%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_14__ = type { i32, i32 }
define void @unaligned_dst_repack_yuv422p_to_uyvy_sse2(%struct.TYPE_14__* %0, %struct.TYPE_14__* %1, %struct.TYPE_14__* %2, %struct.TYPE_14__* %3) {
%5 = alloca %struct.TYPE_14__*
%6 = alloca %struct.TYPE_14__*
%7 = alloca %struct.TYPE_14__*
%8 = alloca %struct.TYPE_14__*
%9 = alloca %struct.TYPE_14__
%10 = alloca %struct.TYPE_14__
%11 = alloca %struct.TYPE_14__
%12 = alloca %struct.TYPE_14__
%13 = alloca %struct.TYPE_14__
%14 = alloca %struct.TYPE_14__
%15 = alloca %struct.TYPE_14__
store %struct.TYPE_14__* %0, %struct.TYPE_14__** %5
store %struct.TYPE_14__* %1, %struct.TYPE_14__** %6
store %struct.TYPE_14__* %2, %struct.TYPE_14__** %7
store %struct.TYPE_14__* %3, %struct.TYPE_14__** %8
%16 = bitcast %struct.TYPE_14__* %9 to i8*
%17 = load %struct.TYPE_14__*, %struct.TYPE_14__** %6
%18 = load %struct.TYPE_14__*, %struct.TYPE_14__** %7
%19 = bitcast %struct.TYPE_14__* %17 to i64*
%20 = load i64, i64* %19
%21 = bitcast %struct.TYPE_14__* %18 to i64*
%22 = load i64, i64* %21
%23 = call i64 @_mm_unpacklo_epi8(i64 %20, i64 %22)
%24 = bitcast %struct.TYPE_14__* %10 to i64*
store i64 %23, i64* %24
%25 = bitcast %struct.TYPE_14__* %9 to i8*
%26 = bitcast %struct.TYPE_14__* %10 to i8*
%27 = load %struct.TYPE_14__*, %struct.TYPE_14__** %8
%28 = getelementptr inbounds %struct.TYPE_14__, %struct.TYPE_14__* %27, i64 0
%29 = load %struct.TYPE_14__*, %struct.TYPE_14__** %5
%30 = getelementptr inbounds %struct.TYPE_14__, %struct.TYPE_14__* %29, i64 0
%31 = bitcast %struct.TYPE_14__* %9 to i64*
%32 = load i64, i64* %31
%33 = bitcast %struct.TYPE_14__* %30 to i64*
%34 = load i64, i64* %33
%35 = call i64 @_mm_unpacklo_epi8(i64 %32, i64 %34)
%36 = bitcast %struct.TYPE_14__* %11 to i64*
store i64 %35, i64* %36
%37 = bitcast %struct.TYPE_14__* %11 to i64*
%38 = load i64, i64* %37
%39 = call i32 @_mm_storeu_si128(%struct.TYPE_14__* %28, i64 %38)
%40 = load %struct.TYPE_14__*, %struct.TYPE_14__** %8
%41 = getelementptr inbounds %struct.TYPE_14__, %struct.TYPE_14__* %40, i64 1
%42 = load %struct.TYPE_14__*, %struct.TYPE_14__** %5
%43 = getelementptr inbounds %struct.TYPE_14__, %struct.TYPE_14__* %42, i64 0
%44 = bitcast %struct.TYPE_14__* %9 to i64*
%45 = load i64, i64* %44
%46 = bitcast %struct.TYPE_14__* %43 to i64*
%47 = load i64, i64* %46
%48 = call i64 @_mm_unpackhi_epi8(i64 %45, i64 %47)
%49 = bitcast %struct.TYPE_14__* %12 to i64*
store i64 %48, i64* %49
%50 = bitcast %struct.TYPE_14__* %12 to i64*
%51 = load i64, i64* %50
%52 = call i32 @_mm_storeu_si128(%struct.TYPE_14__* %41, i64 %51)
%53 = load %struct.TYPE_14__*, %struct.TYPE_14__** %6
%54 = load %struct.TYPE_14__*, %struct.TYPE_14__** %7
%55 = bitcast %struct.TYPE_14__* %53 to i64*
%56 = load i64, i64* %55
%57 = bitcast %struct.TYPE_14__* %54 to i64*
%58 = load i64, i64* %57
%59 = call i64 @_mm_unpackhi_epi8(i64 %56, i64 %58)
%60 = bitcast %struct.TYPE_14__* %13 to i64*
store i64 %59, i64* %60
%61 = bitcast %struct.TYPE_14__* %9 to i8*
%62 = bitcast %struct.TYPE_14__* %13 to i8*
%63 = load %struct.TYPE_14__*, %struct.TYPE_14__** %8
%64 = getelementptr inbounds %struct.TYPE_14__, %struct.TYPE_14__* %63, i64 2
%65 = load %struct.TYPE_14__*, %struct.TYPE_14__** %5
%66 = getelementptr inbounds %struct.TYPE_14__, %struct.TYPE_14__* %65, i64 1
%67 = bitcast %struct.TYPE_14__* %9 to i64*
%68 = load i64, i64* %67
%69 = bitcast %struct.TYPE_14__* %66 to i64*
%70 = load i64, i64* %69
%71 = call i64 @_mm_unpacklo_epi8(i64 %68, i64 %70)
%72 = bitcast %struct.TYPE_14__* %14 to i64*
store i64 %71, i64* %72
%73 = bitcast %struct.TYPE_14__* %14 to i64*
%74 = load i64, i64* %73
%75 = call i32 @_mm_storeu_si128(%struct.TYPE_14__* %64, i64 %74)
%76 = load %struct.TYPE_14__*, %struct.TYPE_14__** %8
%77 = getelementptr inbounds %struct.TYPE_14__, %struct.TYPE_14__* %76, i64 3
%78 = load %struct.TYPE_14__*, %struct.TYPE_14__** %5
%79 = getelementptr inbounds %struct.TYPE_14__, %struct.TYPE_14__* %78, i64 1
%80 = bitcast %struct.TYPE_14__* %9 to i64*
%81 = load i64, i64* %80
%82 = bitcast %struct.TYPE_14__* %79 to i64*
%83 = load i64, i64* %82
%84 = call i64 @_mm_unpackhi_epi8(i64 %81, i64 %83)
%85 = bitcast %struct.TYPE_14__* %15 to i64*
store i64 %84, i64* %85
%86 = bitcast %struct.TYPE_14__* %15 to i64*
%87 = load i64, i64* %86
%88 = call i32 @_mm_storeu_si128(%struct.TYPE_14__* %77, i64 %87)
ret void
}

LLVM IR (-O2):
%struct.TYPE_14__ = type { i32, i32 }
define void @unaligned_dst_repack_yuv422p_to_uyvy_sse2(%struct.TYPE_14__* nocapture %0, %struct.TYPE_14__* nocapture %1, %struct.TYPE_14__* nocapture %2, %struct.TYPE_14__* %3) {
%5 = bitcast %struct.TYPE_14__* %1 to i64*
%6 = load i64, i64* %5
%7 = bitcast %struct.TYPE_14__* %2 to i64*
%8 = load i64, i64* %7
%9 = tail call i64 @_mm_unpacklo_epi8(i64 %6, i64 %8)
%10 = bitcast %struct.TYPE_14__* %0 to i64*
%11 = load i64, i64* %10
%12 = tail call i64 @_mm_unpacklo_epi8(i64 %9, i64 %11)
%13 = tail call i32 @_mm_storeu_si128(%struct.TYPE_14__* %3, i64 %12)
%14 = getelementptr inbounds %struct.TYPE_14__, %struct.TYPE_14__* %3, i64 1
%15 = load i64, i64* %10
%16 = tail call i64 @_mm_unpackhi_epi8(i64 %9, i64 %15)
%17 = tail call i32 @_mm_storeu_si128(%struct.TYPE_14__* %14, i64 %16)
%18 = load i64, i64* %5
%19 = load i64, i64* %7
%20 = tail call i64 @_mm_unpackhi_epi8(i64 %18, i64 %19)
%21 = getelementptr inbounds %struct.TYPE_14__, %struct.TYPE_14__* %3, i64 2
%22 = getelementptr inbounds %struct.TYPE_14__, %struct.TYPE_14__* %0, i64 1
%23 = bitcast %struct.TYPE_14__* %22 to i64*
%24 = load i64, i64* %23
%25 = tail call i64 @_mm_unpacklo_epi8(i64 %20, i64 %24)
%26 = tail call i32 @_mm_storeu_si128(%struct.TYPE_14__* %21, i64 %25)
%27 = getelementptr inbounds %struct.TYPE_14__, %struct.TYPE_14__* %3, i64 3
%28 = load i64, i64* %23
%29 = tail call i64 @_mm_unpackhi_epi8(i64 %20, i64 %28)
%30 = tail call i32 @_mm_storeu_si128(%struct.TYPE_14__* %27, i64 %29)
ret void
}