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

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

/* Variables and functions */
TYPE_1__ _mm_unpackhi_epi8(TYPE_1__, TYPE_1__);
TYPE_1__ _mm_unpacklo_epi8(TYPE_1__, TYPE_1__);
extern void repack_yuv422p_to_yuyv_sse2(__m128i *y_input, __m128i *u_input,
                                        __m128i *v_input, __m128i *yuyv_out) {
  __m128i scratch = {0x0LL, 0x0LL};
  ;
  (scratch) = _mm_unpacklo_epi8(*(u_input), *(v_input));
  (yuyv_out[0]) = (_mm_unpacklo_epi8((y_input)[0], (scratch)));
  (yuyv_out[1]) = (_mm_unpackhi_epi8((y_input)[0], (scratch)));
  (scratch) = _mm_unpackhi_epi8(*(u_input), *(v_input));
  (yuyv_out[2]) = (_mm_unpacklo_epi8((y_input)[1], (scratch)));
  (yuyv_out[3]) = (_mm_unpackhi_epi8((y_input)[1], (scratch)));
}


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

x86 assembly (clang, -O2):
<repack_yuv422p_to_yuyv_sse2>:
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
mov    %rcx,%r14
mov    %rdx,%r15
mov    %rsi,%r12
mov    %rdi,%r13
mov    (%rsi),%rdi
mov    (%rdx),%rsi
call   1030 <_mm_unpacklo_epi8@plt>
mov    %rax,%rbx
mov    0x0(%r13),%rdi
mov    %rax,%rsi
call   1030 <_mm_unpacklo_epi8@plt>
mov    %rax,(%r14)
mov    0x0(%r13),%rdi
mov    %rbx,%rsi
call   1040 <_mm_unpackhi_epi8@plt>
mov    %rax,0x8(%r14)
mov    (%r12),%rdi
mov    (%r15),%rsi
call   1040 <_mm_unpackhi_epi8@plt>
mov    %rax,%rbx
mov    0x8(%r13),%rdi
mov    %rax,%rsi
call   1030 <_mm_unpacklo_epi8@plt>
mov    %rax,0x10(%r14)
mov    0x8(%r13),%rdi
mov    %rbx,%rsi
call   1040 <_mm_unpackhi_epi8@plt>
mov    %rax,0x18(%r14)
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
ret

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

LLVM IR (-O2):
%struct.TYPE_12__ = type { i32, i32 }
define void @repack_yuv422p_to_yuyv_sse2(%struct.TYPE_12__* nocapture %0, %struct.TYPE_12__* nocapture %1, %struct.TYPE_12__* nocapture %2, %struct.TYPE_12__* nocapture writeonly %3) {
%5 = bitcast %struct.TYPE_12__* %1 to i64*
%6 = load i64, i64* %5
%7 = bitcast %struct.TYPE_12__* %2 to i64*
%8 = load i64, i64* %7
%9 = tail call i64 @_mm_unpacklo_epi8(i64 %6, i64 %8)
%10 = bitcast %struct.TYPE_12__* %0 to i64*
%11 = load i64, i64* %10
%12 = tail call i64 @_mm_unpacklo_epi8(i64 %11, i64 %9)
%13 = bitcast %struct.TYPE_12__* %3 to i64*
store i64 %12, i64* %13
%14 = load i64, i64* %10
%15 = tail call i64 @_mm_unpackhi_epi8(i64 %14, i64 %9)
%16 = getelementptr inbounds %struct.TYPE_12__, %struct.TYPE_12__* %3, i64 1
%17 = bitcast %struct.TYPE_12__* %16 to i64*
store i64 %15, i64* %17
%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_12__, %struct.TYPE_12__* %0, i64 1
%22 = bitcast %struct.TYPE_12__* %21 to i64*
%23 = load i64, i64* %22
%24 = tail call i64 @_mm_unpacklo_epi8(i64 %23, i64 %20)
%25 = getelementptr inbounds %struct.TYPE_12__, %struct.TYPE_12__* %3, i64 2
%26 = bitcast %struct.TYPE_12__* %25 to i64*
store i64 %24, i64* %26
%27 = load i64, i64* %22
%28 = tail call i64 @_mm_unpackhi_epi8(i64 %27, i64 %20)
%29 = getelementptr inbounds %struct.TYPE_12__, %struct.TYPE_12__* %3, i64 3
%30 = bitcast %struct.TYPE_12__* %29 to i64*
store i64 %28, i64* %30
ret void
}