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

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

/* Variables and functions */
TYPE_1__ _mm_add_epi16(TYPE_1__, TYPE_1__ const);
TYPE_1__ _mm_add_epi32(TYPE_1__, TYPE_1__);
TYPE_1__ _mm_and_si128(TYPE_1__, TYPE_1__ const);
TYPE_1__ _mm_madd_epi16(TYPE_1__, TYPE_1__ const);
TYPE_1__ _mm_or_si128(TYPE_1__, TYPE_1__);
TYPE_1__ _mm_srli_epi32(TYPE_1__, int);
extern void convert_downsampled_422_ag_rb_vectors_to_uv_vector_sse2(
    __m128i *in_2_v16i_ga_br_vectors, __m128i *out_1_v16i_uv_vector) {
  static const __m128i resultOffset = {0x0080008000800080LL,
                                       0x0080008000800080LL};
  static const __m128i gaUCoeffs = {0xAB440000AB440000LL, 0xAB440000AB440000LL};
  static const __m128i brUCoeffs = {0x7FFFD4BC7FFFD4BCLL, 0x7FFFD4BC7FFFD4BCLL};
  static const __m128i gaVCoeffs = {0x94BC000094BC0000LL, 0x94BC000094BC0000LL};
  static const __m128i brVCoeffs = {0xEB447FFFEB447FFFLL, 0xEB447FFFEB447FFFLL};
  static const __m128i zeroLowWord = {0xFFFF0000FFFF0000LL,
                                      0xFFFF0000FFFF0000LL};
  __m128i brScratch = {0x0LL, 0x0LL};
  __m128i gaScratch = {0x0LL, 0x0LL};
  (gaScratch) = _mm_madd_epi16(in_2_v16i_ga_br_vectors[0], (gaUCoeffs));
  (brScratch) = _mm_madd_epi16(in_2_v16i_ga_br_vectors[1], (brUCoeffs));
  (gaScratch) = _mm_add_epi32((gaScratch), (brScratch));
  *out_1_v16i_uv_vector = _mm_srli_epi32((gaScratch), 16);
  (gaScratch) = _mm_madd_epi16(in_2_v16i_ga_br_vectors[0], (gaVCoeffs));
  (brScratch) = _mm_madd_epi16(in_2_v16i_ga_br_vectors[1], (brVCoeffs));
  (gaScratch) = _mm_add_epi32((gaScratch), (brScratch));
  (gaScratch) = _mm_and_si128((gaScratch), (zeroLowWord));
  (gaScratch) = _mm_or_si128(*out_1_v16i_uv_vector, (gaScratch));
  *out_1_v16i_uv_vector = _mm_add_epi16((gaScratch), (resultOffset));
}


x86 assembly (clang, -O0):
<convert_downsampled_422_ag_rb_vectors_to_uv_vector_sse2>:
push   %rbp
mov    %rsp,%rbp
sub    $0x80,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
lea    -0x18(%rbp),%rdi
xor    %esi,%esi
mov    $0x8,%edx
call   1050 <memset@plt>
lea    -0x20(%rbp),%rdi
xor    %esi,%esi
mov    $0x8,%edx
call   1050 <memset@plt>
mov    -0x8(%rbp),%rax
mov    (%rax),%rdi
mov    0xe57(%rip),%rsi
call   1060 <_mm_madd_epi16@plt>
mov    %rax,-0x28(%rbp)
mov    -0x28(%rbp),%rax
mov    %rax,-0x20(%rbp)
mov    -0x8(%rbp),%rax
mov    0x8(%rax),%rdi
mov    0xe3f(%rip),%rsi
call   1060 <_mm_madd_epi16@plt>
mov    %rax,-0x30(%rbp)
mov    -0x30(%rbp),%rax
mov    %rax,-0x18(%rbp)
mov    -0x20(%rbp),%rdi
mov    -0x18(%rbp),%rsi
call   1040 <_mm_add_epi32@plt>
mov    %rax,-0x38(%rbp)
mov    -0x38(%rbp),%rax
mov    %rax,-0x20(%rbp)
mov    -0x10(%rbp),%rax
mov    %rax,-0x80(%rbp)
mov    -0x20(%rbp),%rdi
mov    $0x10,%esi
call   1080 <_mm_srli_epi32@plt>
mov    %rax,%rcx
mov    -0x80(%rbp),%rax
mov    %rcx,-0x40(%rbp)
mov    -0x40(%rbp),%rcx
mov    %rcx,(%rax)
mov    -0x8(%rbp),%rax
mov    (%rax),%rdi
mov    0xde7(%rip),%rsi
call   1060 <_mm_madd_epi16@plt>
mov    %rax,-0x48(%rbp)
mov    -0x48(%rbp),%rax
mov    %rax,-0x20(%rbp)
mov    -0x8(%rbp),%rax
mov    0x8(%rax),%rdi
mov    0xdcf(%rip),%rsi
call   1060 <_mm_madd_epi16@plt>
mov    %rax,-0x50(%rbp)
mov    -0x50(%rbp),%rax
mov    %rax,-0x18(%rbp)
mov    -0x20(%rbp),%rdi
mov    -0x18(%rbp),%rsi
call   1040 <_mm_add_epi32@plt>
mov    %rax,-0x58(%rbp)
mov    -0x58(%rbp),%rax
mov    %rax,-0x20(%rbp)
mov    -0x20(%rbp),%rdi
mov    0xda2(%rip),%rsi
call   1090 <_mm_and_si128@plt>
mov    %rax,-0x60(%rbp)
mov    -0x60(%rbp),%rax
mov    %rax,-0x20(%rbp)
mov    -0x10(%rbp),%rax
mov    (%rax),%rdi
mov    -0x20(%rbp),%rsi
call   1070 <_mm_or_si128@plt>
mov    %rax,-0x68(%rbp)
mov    -0x68(%rbp),%rax
mov    %rax,-0x20(%rbp)
mov    -0x10(%rbp),%rax
mov    %rax,-0x78(%rbp)
mov    -0x20(%rbp),%rdi
mov    0xd3a(%rip),%rsi
call   1030 <_mm_add_epi16@plt>
mov    %rax,%rcx
mov    -0x78(%rbp),%rax
mov    %rcx,-0x70(%rbp)
mov    -0x70(%rbp),%rcx
mov    %rcx,(%rax)
add    $0x80,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<convert_downsampled_422_ag_rb_vectors_to_uv_vector_sse2>:
push   %r15
push   %r14
push   %rbx
mov    %rsi,%r14
mov    %rdi,%rbx
mov    (%rdi),%rdi
movabs $0xab440000ab440000,%rsi
call   1050 <_mm_madd_epi16@plt>
mov    %rax,%r15
mov    0x8(%rbx),%rdi
movabs $0x7fffd4bc7fffd4bc,%rsi
d4 ff 7f
call   1050 <_mm_madd_epi16@plt>
mov    %r15,%rdi
mov    %rax,%rsi
call   1040 <_mm_add_epi32@plt>
mov    %rax,%rdi
mov    $0x10,%esi
call   1070 <_mm_srli_epi32@plt>
mov    %rax,(%r14)
mov    (%rbx),%rdi
movabs $0x94bc000094bc0000,%rsi
call   1050 <_mm_madd_epi16@plt>
mov    %rax,%r15
mov    0x8(%rbx),%rdi
movabs $0xeb447fffeb447fff,%rsi
7f 44 eb
call   1050 <_mm_madd_epi16@plt>
mov    %r15,%rdi
mov    %rax,%rsi
call   1040 <_mm_add_epi32@plt>
movabs $0xffff0000ffff0000,%rsi
mov    %rax,%rdi
call   1080 <_mm_and_si128@plt>
mov    (%r14),%rdi
mov    %rax,%rsi
call   1060 <_mm_or_si128@plt>
movabs $0x80008000800080,%rsi
mov    %rax,%rdi
call   1030 <_mm_add_epi16@plt>
mov    %rax,(%r14)
pop    %rbx
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
%struct.TYPE_21__ = type { i32, i32 }
@convert_downsampled_422_ag_rb_vectors_to_uv_vector_sse2.resultOffset = internal constant %struct.TYPE_21__ { i32 8388736, i32 8388736 }
@convert_downsampled_422_ag_rb_vectors_to_uv_vector_sse2.gaUCoeffs = internal constant %struct.TYPE_21__ { i32 -1421606912, i32 -1421606912 }
@convert_downsampled_422_ag_rb_vectors_to_uv_vector_sse2.brUCoeffs = internal constant %struct.TYPE_21__ { i32 2147472572, i32 2147472572 }
@convert_downsampled_422_ag_rb_vectors_to_uv_vector_sse2.gaVCoeffs = internal constant %struct.TYPE_21__ { i32 -1799618560, i32 -1799618560 }
@convert_downsampled_422_ag_rb_vectors_to_uv_vector_sse2.brVCoeffs = internal constant %struct.TYPE_21__ { i32 -347832321, i32 -347832321 }
@convert_downsampled_422_ag_rb_vectors_to_uv_vector_sse2.zeroLowWord = internal constant %struct.TYPE_21__ { i32 -65536, i32 -65536 }
define void @convert_downsampled_422_ag_rb_vectors_to_uv_vector_sse2(%struct.TYPE_21__* %0, %struct.TYPE_21__* %1) {
%3 = alloca %struct.TYPE_21__*
%4 = alloca %struct.TYPE_21__*
%5 = alloca %struct.TYPE_21__
%6 = alloca %struct.TYPE_21__
%7 = alloca %struct.TYPE_21__
%8 = alloca %struct.TYPE_21__
%9 = alloca %struct.TYPE_21__
%10 = alloca %struct.TYPE_21__
%11 = alloca %struct.TYPE_21__
%12 = alloca %struct.TYPE_21__
%13 = alloca %struct.TYPE_21__
%14 = alloca %struct.TYPE_21__
%15 = alloca %struct.TYPE_21__
%16 = alloca %struct.TYPE_21__
store %struct.TYPE_21__* %0, %struct.TYPE_21__** %3
store %struct.TYPE_21__* %1, %struct.TYPE_21__** %4
%17 = bitcast %struct.TYPE_21__* %5 to i8*
%18 = bitcast %struct.TYPE_21__* %6 to i8*
%19 = load %struct.TYPE_21__*, %struct.TYPE_21__** %3
%20 = getelementptr inbounds %struct.TYPE_21__, %struct.TYPE_21__* %19, i64 0
%21 = bitcast %struct.TYPE_21__* %20 to i64*
%22 = load i64, i64* %21
%23 = load i64, i64* bitcast (%struct.TYPE_21__* @convert_downsampled_422_ag_rb_vectors_to_uv_vector_sse2.gaUCoeffs to i64*)
%24 = call i64 @_mm_madd_epi16(i64 %22, i64 %23)
%25 = bitcast %struct.TYPE_21__* %7 to i64*
store i64 %24, i64* %25
%26 = bitcast %struct.TYPE_21__* %6 to i8*
%27 = bitcast %struct.TYPE_21__* %7 to i8*
%28 = load %struct.TYPE_21__*, %struct.TYPE_21__** %3
%29 = getelementptr inbounds %struct.TYPE_21__, %struct.TYPE_21__* %28, i64 1
%30 = bitcast %struct.TYPE_21__* %29 to i64*
%31 = load i64, i64* %30
%32 = load i64, i64* bitcast (%struct.TYPE_21__* @convert_downsampled_422_ag_rb_vectors_to_uv_vector_sse2.brUCoeffs to i64*)
%33 = call i64 @_mm_madd_epi16(i64 %31, i64 %32)
%34 = bitcast %struct.TYPE_21__* %8 to i64*
store i64 %33, i64* %34
%35 = bitcast %struct.TYPE_21__* %5 to i8*
%36 = bitcast %struct.TYPE_21__* %8 to i8*
%37 = bitcast %struct.TYPE_21__* %6 to i64*
%38 = load i64, i64* %37
%39 = bitcast %struct.TYPE_21__* %5 to i64*
%40 = load i64, i64* %39
%41 = call i64 @_mm_add_epi32(i64 %38, i64 %40)
%42 = bitcast %struct.TYPE_21__* %9 to i64*
store i64 %41, i64* %42
%43 = bitcast %struct.TYPE_21__* %6 to i8*
%44 = bitcast %struct.TYPE_21__* %9 to i8*
%45 = load %struct.TYPE_21__*, %struct.TYPE_21__** %4
%46 = bitcast %struct.TYPE_21__* %6 to i64*
%47 = load i64, i64* %46
%48 = call i64 @_mm_srli_epi32(i64 %47, i32 16)
%49 = bitcast %struct.TYPE_21__* %10 to i64*
store i64 %48, i64* %49
%50 = bitcast %struct.TYPE_21__* %45 to i8*
%51 = bitcast %struct.TYPE_21__* %10 to i8*
%52 = load %struct.TYPE_21__*, %struct.TYPE_21__** %3
%53 = getelementptr inbounds %struct.TYPE_21__, %struct.TYPE_21__* %52, i64 0
%54 = bitcast %struct.TYPE_21__* %53 to i64*
%55 = load i64, i64* %54
%56 = load i64, i64* bitcast (%struct.TYPE_21__* @convert_downsampled_422_ag_rb_vectors_to_uv_vector_sse2.gaVCoeffs to i64*)
%57 = call i64 @_mm_madd_epi16(i64 %55, i64 %56)
%58 = bitcast %struct.TYPE_21__* %11 to i64*
store i64 %57, i64* %58
%59 = bitcast %struct.TYPE_21__* %6 to i8*
%60 = bitcast %struct.TYPE_21__* %11 to i8*
%61 = load %struct.TYPE_21__*, %struct.TYPE_21__** %3
%62 = getelementptr inbounds %struct.TYPE_21__, %struct.TYPE_21__* %61, i64 1
%63 = bitcast %struct.TYPE_21__* %62 to i64*
%64 = load i64, i64* %63
%65 = load i64, i64* bitcast (%struct.TYPE_21__* @convert_downsampled_422_ag_rb_vectors_to_uv_vector_sse2.brVCoeffs to i64*)
%66 = call i64 @_mm_madd_epi16(i64 %64, i64 %65)
%67 = bitcast %struct.TYPE_21__* %12 to i64*
store i64 %66, i64* %67
%68 = bitcast %struct.TYPE_21__* %5 to i8*
%69 = bitcast %struct.TYPE_21__* %12 to i8*
%70 = bitcast %struct.TYPE_21__* %6 to i64*
%71 = load i64, i64* %70
%72 = bitcast %struct.TYPE_21__* %5 to i64*
%73 = load i64, i64* %72
%74 = call i64 @_mm_add_epi32(i64 %71, i64 %73)
%75 = bitcast %struct.TYPE_21__* %13 to i64*
store i64 %74, i64* %75
%76 = bitcast %struct.TYPE_21__* %6 to i8*
%77 = bitcast %struct.TYPE_21__* %13 to i8*
%78 = bitcast %struct.TYPE_21__* %6 to i64*
%79 = load i64, i64* %78
%80 = load i64, i64* bitcast (%struct.TYPE_21__* @convert_downsampled_422_ag_rb_vectors_to_uv_vector_sse2.zeroLowWord to i64*)
%81 = call i64 @_mm_and_si128(i64 %79, i64 %80)
%82 = bitcast %struct.TYPE_21__* %14 to i64*
store i64 %81, i64* %82
%83 = bitcast %struct.TYPE_21__* %6 to i8*
%84 = bitcast %struct.TYPE_21__* %14 to i8*
%85 = load %struct.TYPE_21__*, %struct.TYPE_21__** %4
%86 = bitcast %struct.TYPE_21__* %85 to i64*
%87 = load i64, i64* %86
%88 = bitcast %struct.TYPE_21__* %6 to i64*
%89 = load i64, i64* %88
%90 = call i64 @_mm_or_si128(i64 %87, i64 %89)
%91 = bitcast %struct.TYPE_21__* %15 to i64*
store i64 %90, i64* %91
%92 = bitcast %struct.TYPE_21__* %6 to i8*
%93 = bitcast %struct.TYPE_21__* %15 to i8*
%94 = load %struct.TYPE_21__*, %struct.TYPE_21__** %4
%95 = bitcast %struct.TYPE_21__* %6 to i64*
%96 = load i64, i64* %95
%97 = load i64, i64* bitcast (%struct.TYPE_21__* @convert_downsampled_422_ag_rb_vectors_to_uv_vector_sse2.resultOffset to i64*)
%98 = call i64 @_mm_add_epi16(i64 %96, i64 %97)
%99 = bitcast %struct.TYPE_21__* %16 to i64*
store i64 %98, i64* %99
%100 = bitcast %struct.TYPE_21__* %94 to i8*
%101 = bitcast %struct.TYPE_21__* %16 to i8*
ret void
}

LLVM IR (-O2):
%struct.TYPE_21__ = type { i32, i32 }
define void @convert_downsampled_422_ag_rb_vectors_to_uv_vector_sse2(%struct.TYPE_21__* nocapture %0, %struct.TYPE_21__* nocapture %1) {
%3 = bitcast %struct.TYPE_21__* %0 to i64*
%4 = load i64, i64* %3
%5 = tail call i64 @_mm_madd_epi16(i64 %4, i64 -6105755191934189568)
%6 = getelementptr inbounds %struct.TYPE_21__, %struct.TYPE_21__* %0, i64 1
%7 = bitcast %struct.TYPE_21__* %6 to i64*
%8 = load i64, i64* %7
%9 = tail call i64 @_mm_madd_epi16(i64 %8, i64 9223324467944477884)
%10 = tail call i64 @_mm_add_epi32(i64 %5, i64 %9)
%11 = tail call i64 @_mm_srli_epi32(i64 %10, i32 16)
%12 = bitcast %struct.TYPE_21__* %1 to i64*
store i64 %11, i64* %12
%13 = load i64, i64* %3
%14 = tail call i64 @_mm_madd_epi16(i64 %13, i64 -7729302857979265024)
%15 = load i64, i64* %7
%16 = tail call i64 @_mm_madd_epi16(i64 %15, i64 -1493928439239639041)
%17 = tail call i64 @_mm_add_epi32(i64 %14, i64 %16)
%18 = tail call i64 @_mm_and_si128(i64 %17, i64 -281470681808896)
%19 = load i64, i64* %12
%20 = tail call i64 @_mm_or_si128(i64 %19, i64 %18)
%21 = tail call i64 @_mm_add_epi16(i64 %20, i64 36029346783166592)
store i64 %21, i64* %12
ret void
}