#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 */
TYPE_1__ _mm_loadu_si128(TYPE_1__ *);
TYPE_1__ _mm_unpackhi_epi8(TYPE_1__, TYPE_1__);
TYPE_1__ _mm_unpacklo_epi8(TYPE_1__, TYPE_1__);
extern void unaligned_src_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));
  (uyvy_out[0]) = (_mm_unpacklo_epi8((scratch), (aligned_y_vector)[0]));
  (uyvy_out[1]) = (_mm_unpackhi_epi8((scratch), (aligned_y_vector)[0]));
  (scratch) = _mm_unpackhi_epi8(*(&aligned_u_vector), *(&aligned_v_vector));
  (uyvy_out[2]) = (_mm_unpacklo_epi8((scratch), (aligned_y_vector)[1]));
  (uyvy_out[3]) = (_mm_unpackhi_epi8((scratch), (aligned_y_vector)[1]));
}


x86 assembly (clang, -O0):
<unaligned_src_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   1060 <_mm_loadu_si128@plt>
mov    %rax,-0x30(%rbp)
mov    -0x18(%rbp),%rdi
call   1060 <_mm_loadu_si128@plt>
mov    %rax,-0x38(%rbp)
mov    -0x8(%rbp),%rdi
call   1060 <_mm_loadu_si128@plt>
mov    %rax,-0x58(%rbp)
mov    -0x58(%rbp),%rax
mov    %rax,-0x50(%rbp)
mov    -0x8(%rbp),%rdi
add    $0x8,%rdi
call   1060 <_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    %rax,%rcx
mov    -0xb0(%rbp),%rax
mov    %rcx,-0x70(%rbp)
mov    -0x70(%rbp),%rcx
mov    %rcx,(%rax)
mov    -0x20(%rbp),%rax
mov    %rax,-0xa8(%rbp)
mov    -0x28(%rbp),%rdi
mov    -0x50(%rbp),%rsi
call   1040 <_mm_unpackhi_epi8@plt>
mov    %rax,%rcx
mov    -0xa8(%rbp),%rax
mov    %rcx,-0x78(%rbp)
mov    -0x78(%rbp),%rcx
mov    %rcx,0x8(%rax)
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
mov    %rax,-0xa0(%rbp)
mov    -0x28(%rbp),%rdi
mov    -0x48(%rbp),%rsi
call   1030 <_mm_unpacklo_epi8@plt>
mov    %rax,%rcx
mov    -0xa0(%rbp),%rax
mov    %rcx,-0x88(%rbp)
mov    -0x88(%rbp),%rcx
mov    %rcx,0x10(%rax)
mov    -0x20(%rbp),%rax
mov    %rax,-0x98(%rbp)
mov    -0x28(%rbp),%rdi
mov    -0x48(%rbp),%rsi
call   1040 <_mm_unpackhi_epi8@plt>
mov    %rax,%rcx
mov    -0x98(%rbp),%rax
mov    %rcx,-0x90(%rbp)
mov    -0x90(%rbp),%rcx
mov    %rcx,0x18(%rax)
add    $0xb0,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<unaligned_src_repack_yuv422p_to_uyvy_sse2>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
mov    %rcx,%r13
mov    %rdx,%r15
mov    %rdi,%rbx
mov    %rsi,%rdi
call   1050 <_mm_loadu_si128@plt>
mov    %rax,%r14
mov    %r15,%rdi
call   1050 <_mm_loadu_si128@plt>
mov    %rax,%r12
mov    %rbx,%rdi
call   1050 <_mm_loadu_si128@plt>
mov    %rax,%rbp
add    $0x8,%rbx
mov    %rbx,%rdi
call   1050 <_mm_loadu_si128@plt>
mov    %rax,%r15
mov    %r14,%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    %rax,0x0(%r13)
mov    %rbx,%rdi
mov    %rbp,%rsi
call   1040 <_mm_unpackhi_epi8@plt>
mov    %rax,0x8(%r13)
mov    %r14,%rdi
mov    %r12,%rsi
call   1040 <_mm_unpackhi_epi8@plt>
mov    %rax,%rbx
mov    %rax,%rdi
mov    %r15,%rsi
call   1030 <_mm_unpacklo_epi8@plt>
mov    %rax,0x10(%r13)
mov    %rbx,%rdi
mov    %r15,%rsi
call   1040 <_mm_unpackhi_epi8@plt>
mov    %rax,0x18(%r13)
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

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

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