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

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

/* Variables and functions */
TYPE_1__ _mm_add_epi16(TYPE_1__, TYPE_1__);
TYPE_1__ _mm_mulhi_epu16(TYPE_1__, TYPE_1__ const);
extern void
convert_r_g_b_vectors_to_y_vector_sse2(__m128i *in_3_v16i_r_g_b_vectors,
                                       __m128i *out_1_v16i_y_vector) {
  static const __m128i rYCoeffs = {0x4C8B4C8B4C8B4C8BLL, 0x4C8B4C8B4C8B4C8BLL};
  static const __m128i gYCoeffs = {0x9646964696469646LL, 0x9646964696469646LL};
  static const __m128i bYCoeffs = {0x1D2F1D2F1D2F1D2FLL, 0x1D2F1D2F1D2F1D2FLL};
  __m128i rScratch = {0x0LL, 0x0LL};
  __m128i gScratch = {0x0LL, 0x0LL};
  __m128i bScratch = {0x0LL, 0x0LL};
  (rScratch) = _mm_mulhi_epu16(in_3_v16i_r_g_b_vectors[0], (rYCoeffs));
  (gScratch) = _mm_mulhi_epu16(in_3_v16i_r_g_b_vectors[1], (gYCoeffs));
  (bScratch) = _mm_mulhi_epu16(in_3_v16i_r_g_b_vectors[2], (bYCoeffs));
  (rScratch) = _mm_add_epi16((rScratch), (gScratch));
  *out_1_v16i_y_vector = _mm_add_epi16((rScratch), (bScratch));
}


x86 assembly (clang, -O0):
<convert_r_g_b_vectors_to_y_vector_sse2>:
push   %rbp
mov    %rsp,%rbp
sub    $0x60,%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>
lea    -0x28(%rbp),%rdi
xor    %esi,%esi
mov    $0x8,%edx
call   1050 <memset@plt>
mov    -0x8(%rbp),%rax
mov    (%rax),%rdi
mov    0xe82(%rip),%rsi
call   1040 <_mm_mulhi_epu16@plt>
mov    %rax,-0x30(%rbp)
mov    -0x30(%rbp),%rax
mov    %rax,-0x18(%rbp)
mov    -0x8(%rbp),%rax
mov    0x8(%rax),%rdi
mov    0xe6a(%rip),%rsi
call   1040 <_mm_mulhi_epu16@plt>
mov    %rax,-0x38(%rbp)
mov    -0x38(%rbp),%rax
mov    %rax,-0x20(%rbp)
mov    -0x8(%rbp),%rax
mov    0x10(%rax),%rdi
mov    0xe52(%rip),%rsi
call   1040 <_mm_mulhi_epu16@plt>
mov    %rax,-0x40(%rbp)
mov    -0x40(%rbp),%rax
mov    %rax,-0x28(%rbp)
mov    -0x18(%rbp),%rdi
mov    -0x20(%rbp),%rsi
call   1030 <_mm_add_epi16@plt>
mov    %rax,-0x48(%rbp)
mov    -0x48(%rbp),%rax
mov    %rax,-0x18(%rbp)
mov    -0x10(%rbp),%rax
mov    %rax,-0x58(%rbp)
mov    -0x18(%rbp),%rdi
mov    -0x28(%rbp),%rsi
call   1030 <_mm_add_epi16@plt>
mov    %rax,%rcx
mov    -0x58(%rbp),%rax
mov    %rcx,-0x50(%rbp)
mov    -0x50(%rbp),%rcx
mov    %rcx,(%rax)
add    $0x60,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<convert_r_g_b_vectors_to_y_vector_sse2>:
push   %r15
push   %r14
push   %r12
push   %rbx
push   %rax
mov    %rsi,%r14
mov    %rdi,%rbx
mov    (%rdi),%rdi
movabs $0x4c8b4c8b4c8b4c8b,%rsi
4c 8b 4c
call   1040 <_mm_mulhi_epu16@plt>
mov    %rax,%r15
mov    0x8(%rbx),%rdi
movabs $0x9646964696469646,%rsi
96 46 96
call   1040 <_mm_mulhi_epu16@plt>
mov    %rax,%r12
mov    0x10(%rbx),%rdi
movabs $0x1d2f1d2f1d2f1d2f,%rsi
1d 2f 1d
call   1040 <_mm_mulhi_epu16@plt>
mov    %rax,%rbx
mov    %r15,%rdi
mov    %r12,%rsi
call   1030 <_mm_add_epi16@plt>
mov    %rax,%rdi
mov    %rbx,%rsi
call   1030 <_mm_add_epi16@plt>
mov    %rax,(%r14)
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
%struct.TYPE_10__ = type { i32, i32 }
@convert_r_g_b_vectors_to_y_vector_sse2.rYCoeffs = internal constant %struct.TYPE_10__ { i32 1284197515, i32 1284197515 }
@convert_r_g_b_vectors_to_y_vector_sse2.gYCoeffs = internal constant %struct.TYPE_10__ { i32 -1773758906, i32 -1773758906 }
@convert_r_g_b_vectors_to_y_vector_sse2.bYCoeffs = internal constant %struct.TYPE_10__ { i32 489626927, i32 489626927 }
define void @convert_r_g_b_vectors_to_y_vector_sse2(%struct.TYPE_10__* %0, %struct.TYPE_10__* %1) {
%3 = alloca %struct.TYPE_10__*
%4 = alloca %struct.TYPE_10__*
%5 = alloca %struct.TYPE_10__
%6 = alloca %struct.TYPE_10__
%7 = alloca %struct.TYPE_10__
%8 = alloca %struct.TYPE_10__
%9 = alloca %struct.TYPE_10__
%10 = alloca %struct.TYPE_10__
%11 = alloca %struct.TYPE_10__
%12 = alloca %struct.TYPE_10__
store %struct.TYPE_10__* %0, %struct.TYPE_10__** %3
store %struct.TYPE_10__* %1, %struct.TYPE_10__** %4
%13 = bitcast %struct.TYPE_10__* %5 to i8*
%14 = bitcast %struct.TYPE_10__* %6 to i8*
%15 = bitcast %struct.TYPE_10__* %7 to i8*
%16 = load %struct.TYPE_10__*, %struct.TYPE_10__** %3
%17 = getelementptr inbounds %struct.TYPE_10__, %struct.TYPE_10__* %16, i64 0
%18 = bitcast %struct.TYPE_10__* %17 to i64*
%19 = load i64, i64* %18
%20 = load i64, i64* bitcast (%struct.TYPE_10__* @convert_r_g_b_vectors_to_y_vector_sse2.rYCoeffs to i64*)
%21 = call i64 @_mm_mulhi_epu16(i64 %19, i64 %20)
%22 = bitcast %struct.TYPE_10__* %8 to i64*
store i64 %21, i64* %22
%23 = bitcast %struct.TYPE_10__* %5 to i8*
%24 = bitcast %struct.TYPE_10__* %8 to i8*
%25 = load %struct.TYPE_10__*, %struct.TYPE_10__** %3
%26 = getelementptr inbounds %struct.TYPE_10__, %struct.TYPE_10__* %25, i64 1
%27 = bitcast %struct.TYPE_10__* %26 to i64*
%28 = load i64, i64* %27
%29 = load i64, i64* bitcast (%struct.TYPE_10__* @convert_r_g_b_vectors_to_y_vector_sse2.gYCoeffs to i64*)
%30 = call i64 @_mm_mulhi_epu16(i64 %28, i64 %29)
%31 = bitcast %struct.TYPE_10__* %9 to i64*
store i64 %30, i64* %31
%32 = bitcast %struct.TYPE_10__* %6 to i8*
%33 = bitcast %struct.TYPE_10__* %9 to i8*
%34 = load %struct.TYPE_10__*, %struct.TYPE_10__** %3
%35 = getelementptr inbounds %struct.TYPE_10__, %struct.TYPE_10__* %34, i64 2
%36 = bitcast %struct.TYPE_10__* %35 to i64*
%37 = load i64, i64* %36
%38 = load i64, i64* bitcast (%struct.TYPE_10__* @convert_r_g_b_vectors_to_y_vector_sse2.bYCoeffs to i64*)
%39 = call i64 @_mm_mulhi_epu16(i64 %37, i64 %38)
%40 = bitcast %struct.TYPE_10__* %10 to i64*
store i64 %39, i64* %40
%41 = bitcast %struct.TYPE_10__* %7 to i8*
%42 = bitcast %struct.TYPE_10__* %10 to i8*
%43 = bitcast %struct.TYPE_10__* %5 to i64*
%44 = load i64, i64* %43
%45 = bitcast %struct.TYPE_10__* %6 to i64*
%46 = load i64, i64* %45
%47 = call i64 @_mm_add_epi16(i64 %44, i64 %46)
%48 = bitcast %struct.TYPE_10__* %11 to i64*
store i64 %47, i64* %48
%49 = bitcast %struct.TYPE_10__* %5 to i8*
%50 = bitcast %struct.TYPE_10__* %11 to i8*
%51 = load %struct.TYPE_10__*, %struct.TYPE_10__** %4
%52 = bitcast %struct.TYPE_10__* %5 to i64*
%53 = load i64, i64* %52
%54 = bitcast %struct.TYPE_10__* %7 to i64*
%55 = load i64, i64* %54
%56 = call i64 @_mm_add_epi16(i64 %53, i64 %55)
%57 = bitcast %struct.TYPE_10__* %12 to i64*
store i64 %56, i64* %57
%58 = bitcast %struct.TYPE_10__* %51 to i8*
%59 = bitcast %struct.TYPE_10__* %12 to i8*
ret void
}

LLVM IR (-O2):
%struct.TYPE_10__ = type { i32, i32 }
define void @convert_r_g_b_vectors_to_y_vector_sse2(%struct.TYPE_10__* nocapture %0, %struct.TYPE_10__* nocapture writeonly %1) {
%3 = bitcast %struct.TYPE_10__* %0 to i64*
%4 = load i64, i64* %3
%5 = tail call i64 @_mm_mulhi_epu16(i64 %4, i64 5515586329813666955)
%6 = getelementptr inbounds %struct.TYPE_10__, %struct.TYPE_10__* %0, i64 1
%7 = bitcast %struct.TYPE_10__* %6 to i64*
%8 = load i64, i64* %7
%9 = tail call i64 @_mm_mulhi_epu16(i64 %8, i64 -7618236489737529786)
%10 = getelementptr inbounds %struct.TYPE_10__, %struct.TYPE_10__* %0, i64 2
%11 = bitcast %struct.TYPE_10__* %10 to i64*
%12 = load i64, i64* %11
%13 = tail call i64 @_mm_mulhi_epu16(i64 %12, i64 2102931639195606319)
%14 = tail call i64 @_mm_add_epi16(i64 %5, i64 %9)
%15 = tail call i64 @_mm_add_epi16(i64 %14, i64 %13)
%16 = bitcast %struct.TYPE_10__* %1 to i64*
store i64 %15, i64* %16
ret void
}