#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_avg_epu16(TYPE_1__, TYPE_1__);
TYPE_1__ _mm_shufflehi_epi16(TYPE_1__, int);
TYPE_1__ _mm_shufflelo_epi16(TYPE_1__, int);
extern void avg_420_downsample_r_g_b_vectors_sse2(
    __m128i *in_3_v16i_current_r_g_b_vectors_1,
    __m128i *in_3_v16i_current_r_g_b_vectors_2,
    __m128i *out_3_v16i_avg_420_r_g_b_vectors) {
  __m128i scratch1 = {0x0LL, 0x0LL};
  __m128i scratch2 = {0x0LL, 0x0LL};
  (scratch1) = _mm_avg_epu16(in_3_v16i_current_r_g_b_vectors_1[0],
                             in_3_v16i_current_r_g_b_vectors_2[0]);
  (scratch2) = _mm_shufflehi_epi16((scratch1), 0xB1);
  (scratch2) = _mm_shufflelo_epi16((scratch2), 0xB1);
  out_3_v16i_avg_420_r_g_b_vectors[0] = _mm_avg_epu16((scratch1), (scratch2));
  (scratch1) = _mm_avg_epu16(in_3_v16i_current_r_g_b_vectors_1[1],
                             in_3_v16i_current_r_g_b_vectors_2[1]);
  (scratch2) = _mm_shufflehi_epi16((scratch1), 0xB1);
  (scratch2) = _mm_shufflelo_epi16((scratch2), 0xB1);
  out_3_v16i_avg_420_r_g_b_vectors[1] = _mm_avg_epu16((scratch1), (scratch2));
  (scratch1) = _mm_avg_epu16(in_3_v16i_current_r_g_b_vectors_1[2],
                             in_3_v16i_current_r_g_b_vectors_2[2]);
  (scratch2) = _mm_shufflehi_epi16((scratch1), 0xB1);
  (scratch2) = _mm_shufflelo_epi16((scratch2), 0xB1);
  out_3_v16i_avg_420_r_g_b_vectors[2] = _mm_avg_epu16((scratch1), (scratch2));
}


x86 assembly (clang, -O0):
<avg_420_downsample_r_g_b_vectors_sse2>:
push   %rbp
mov    %rsp,%rbp
sub    $0xa0,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
lea    -0x20(%rbp),%rdi
xor    %esi,%esi
mov    $0x8,%edx
call   1030 <memset@plt>
lea    -0x28(%rbp),%rdi
xor    %esi,%esi
mov    $0x8,%edx
call   1030 <memset@plt>
mov    -0x8(%rbp),%rcx
mov    -0x10(%rbp),%rax
mov    (%rcx),%rdi
mov    (%rax),%rsi
call   1050 <_mm_avg_epu16@plt>
mov    %rax,-0x30(%rbp)
mov    -0x30(%rbp),%rax
mov    %rax,-0x20(%rbp)
mov    -0x20(%rbp),%rdi
mov    $0xb1,%esi
call   1060 <_mm_shufflehi_epi16@plt>
mov    %rax,-0x38(%rbp)
mov    -0x38(%rbp),%rax
mov    %rax,-0x28(%rbp)
mov    -0x28(%rbp),%rdi
mov    $0xb1,%esi
call   1040 <_mm_shufflelo_epi16@plt>
mov    %rax,-0x40(%rbp)
mov    -0x40(%rbp),%rax
mov    %rax,-0x28(%rbp)
mov    -0x18(%rbp),%rax
mov    %rax,-0xa0(%rbp)
mov    -0x20(%rbp),%rdi
mov    -0x28(%rbp),%rsi
call   1050 <_mm_avg_epu16@plt>
mov    %rax,%rcx
mov    -0xa0(%rbp),%rax
mov    %rcx,-0x48(%rbp)
mov    -0x48(%rbp),%rcx
mov    %rcx,(%rax)
mov    -0x8(%rbp),%rcx
mov    -0x10(%rbp),%rax
mov    0x8(%rcx),%rdi
mov    0x8(%rax),%rsi
call   1050 <_mm_avg_epu16@plt>
mov    %rax,-0x50(%rbp)
mov    -0x50(%rbp),%rax
mov    %rax,-0x20(%rbp)
mov    -0x20(%rbp),%rdi
mov    $0xb1,%esi
call   1060 <_mm_shufflehi_epi16@plt>
mov    %rax,-0x58(%rbp)
mov    -0x58(%rbp),%rax
mov    %rax,-0x28(%rbp)
mov    -0x28(%rbp),%rdi
mov    $0xb1,%esi
call   1040 <_mm_shufflelo_epi16@plt>
mov    %rax,-0x60(%rbp)
mov    -0x60(%rbp),%rax
mov    %rax,-0x28(%rbp)
mov    -0x18(%rbp),%rax
mov    %rax,-0x98(%rbp)
mov    -0x20(%rbp),%rdi
mov    -0x28(%rbp),%rsi
call   1050 <_mm_avg_epu16@plt>
mov    %rax,%rcx
mov    -0x98(%rbp),%rax
mov    %rcx,-0x68(%rbp)
mov    -0x68(%rbp),%rcx
mov    %rcx,0x8(%rax)
mov    -0x8(%rbp),%rcx
mov    -0x10(%rbp),%rax
mov    0x10(%rcx),%rdi
mov    0x10(%rax),%rsi
call   1050 <_mm_avg_epu16@plt>
mov    %rax,-0x70(%rbp)
mov    -0x70(%rbp),%rax
mov    %rax,-0x20(%rbp)
mov    -0x20(%rbp),%rdi
mov    $0xb1,%esi
call   1060 <_mm_shufflehi_epi16@plt>
mov    %rax,-0x78(%rbp)
mov    -0x78(%rbp),%rax
mov    %rax,-0x28(%rbp)
mov    -0x28(%rbp),%rdi
mov    $0xb1,%esi
call   1040 <_mm_shufflelo_epi16@plt>
mov    %rax,-0x80(%rbp)
mov    -0x80(%rbp),%rax
mov    %rax,-0x28(%rbp)
mov    -0x18(%rbp),%rax
mov    %rax,-0x90(%rbp)
mov    -0x20(%rbp),%rdi
mov    -0x28(%rbp),%rsi
call   1050 <_mm_avg_epu16@plt>
mov    %rax,%rcx
mov    -0x90(%rbp),%rax
mov    %rcx,-0x88(%rbp)
mov    -0x88(%rbp),%rcx
mov    %rcx,0x10(%rax)
add    $0xa0,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<avg_420_downsample_r_g_b_vectors_sse2>:
push   %r15
push   %r14
push   %r12
push   %rbx
push   %rax
mov    %rdx,%r14
mov    %rsi,%r15
mov    %rdi,%r12
mov    (%rdi),%rdi
mov    (%rsi),%rsi
call   1040 <_mm_avg_epu16@plt>
mov    %rax,%rbx
mov    %rax,%rdi
mov    $0xb1,%esi
call   1050 <_mm_shufflehi_epi16@plt>
mov    %rax,%rdi
mov    $0xb1,%esi
call   1030 <_mm_shufflelo_epi16@plt>
mov    %rbx,%rdi
mov    %rax,%rsi
call   1040 <_mm_avg_epu16@plt>
mov    %rax,(%r14)
mov    0x8(%r12),%rdi
mov    0x8(%r15),%rsi
call   1040 <_mm_avg_epu16@plt>
mov    %rax,%rbx
mov    %rax,%rdi
mov    $0xb1,%esi
call   1050 <_mm_shufflehi_epi16@plt>
mov    %rax,%rdi
mov    $0xb1,%esi
call   1030 <_mm_shufflelo_epi16@plt>
mov    %rbx,%rdi
mov    %rax,%rsi
call   1040 <_mm_avg_epu16@plt>
mov    %rax,0x8(%r14)
mov    0x10(%r12),%rdi
mov    0x10(%r15),%rsi
call   1040 <_mm_avg_epu16@plt>
mov    %rax,%rbx
mov    %rax,%rdi
mov    $0xb1,%esi
call   1050 <_mm_shufflehi_epi16@plt>
mov    %rax,%rdi
mov    $0xb1,%esi
call   1030 <_mm_shufflelo_epi16@plt>
mov    %rbx,%rdi
mov    %rax,%rsi
call   1040 <_mm_avg_epu16@plt>
mov    %rax,0x10(%r14)
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
%struct.TYPE_12__ = type { i32, i32 }
define void @avg_420_downsample_r_g_b_vectors_sse2(%struct.TYPE_12__* %0, %struct.TYPE_12__* %1, %struct.TYPE_12__* %2) {
%4 = alloca %struct.TYPE_12__*
%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__
%16 = alloca %struct.TYPE_12__
%17 = alloca %struct.TYPE_12__
%18 = alloca %struct.TYPE_12__
%19 = alloca %struct.TYPE_12__
%20 = alloca %struct.TYPE_12__
store %struct.TYPE_12__* %0, %struct.TYPE_12__** %4
store %struct.TYPE_12__* %1, %struct.TYPE_12__** %5
store %struct.TYPE_12__* %2, %struct.TYPE_12__** %6
%21 = bitcast %struct.TYPE_12__* %7 to i8*
%22 = bitcast %struct.TYPE_12__* %8 to i8*
%23 = load %struct.TYPE_12__*, %struct.TYPE_12__** %4
%24 = getelementptr inbounds %struct.TYPE_12__, %struct.TYPE_12__* %23, i64 0
%25 = load %struct.TYPE_12__*, %struct.TYPE_12__** %5
%26 = getelementptr inbounds %struct.TYPE_12__, %struct.TYPE_12__* %25, i64 0
%27 = bitcast %struct.TYPE_12__* %24 to i64*
%28 = load i64, i64* %27
%29 = bitcast %struct.TYPE_12__* %26 to i64*
%30 = load i64, i64* %29
%31 = call i64 @_mm_avg_epu16(i64 %28, i64 %30)
%32 = bitcast %struct.TYPE_12__* %9 to i64*
store i64 %31, i64* %32
%33 = bitcast %struct.TYPE_12__* %7 to i8*
%34 = bitcast %struct.TYPE_12__* %9 to i8*
%35 = bitcast %struct.TYPE_12__* %7 to i64*
%36 = load i64, i64* %35
%37 = call i64 @_mm_shufflehi_epi16(i64 %36, i32 177)
%38 = bitcast %struct.TYPE_12__* %10 to i64*
store i64 %37, i64* %38
%39 = bitcast %struct.TYPE_12__* %8 to i8*
%40 = bitcast %struct.TYPE_12__* %10 to i8*
%41 = bitcast %struct.TYPE_12__* %8 to i64*
%42 = load i64, i64* %41
%43 = call i64 @_mm_shufflelo_epi16(i64 %42, i32 177)
%44 = bitcast %struct.TYPE_12__* %11 to i64*
store i64 %43, i64* %44
%45 = bitcast %struct.TYPE_12__* %8 to i8*
%46 = bitcast %struct.TYPE_12__* %11 to i8*
%47 = load %struct.TYPE_12__*, %struct.TYPE_12__** %6
%48 = getelementptr inbounds %struct.TYPE_12__, %struct.TYPE_12__* %47, i64 0
%49 = bitcast %struct.TYPE_12__* %7 to i64*
%50 = load i64, i64* %49
%51 = bitcast %struct.TYPE_12__* %8 to i64*
%52 = load i64, i64* %51
%53 = call i64 @_mm_avg_epu16(i64 %50, i64 %52)
%54 = bitcast %struct.TYPE_12__* %12 to i64*
store i64 %53, i64* %54
%55 = bitcast %struct.TYPE_12__* %48 to i8*
%56 = bitcast %struct.TYPE_12__* %12 to i8*
%57 = load %struct.TYPE_12__*, %struct.TYPE_12__** %4
%58 = getelementptr inbounds %struct.TYPE_12__, %struct.TYPE_12__* %57, i64 1
%59 = load %struct.TYPE_12__*, %struct.TYPE_12__** %5
%60 = getelementptr inbounds %struct.TYPE_12__, %struct.TYPE_12__* %59, i64 1
%61 = bitcast %struct.TYPE_12__* %58 to i64*
%62 = load i64, i64* %61
%63 = bitcast %struct.TYPE_12__* %60 to i64*
%64 = load i64, i64* %63
%65 = call i64 @_mm_avg_epu16(i64 %62, i64 %64)
%66 = bitcast %struct.TYPE_12__* %13 to i64*
store i64 %65, i64* %66
%67 = bitcast %struct.TYPE_12__* %7 to i8*
%68 = bitcast %struct.TYPE_12__* %13 to i8*
%69 = bitcast %struct.TYPE_12__* %7 to i64*
%70 = load i64, i64* %69
%71 = call i64 @_mm_shufflehi_epi16(i64 %70, i32 177)
%72 = bitcast %struct.TYPE_12__* %14 to i64*
store i64 %71, i64* %72
%73 = bitcast %struct.TYPE_12__* %8 to i8*
%74 = bitcast %struct.TYPE_12__* %14 to i8*
%75 = bitcast %struct.TYPE_12__* %8 to i64*
%76 = load i64, i64* %75
%77 = call i64 @_mm_shufflelo_epi16(i64 %76, i32 177)
%78 = bitcast %struct.TYPE_12__* %15 to i64*
store i64 %77, i64* %78
%79 = bitcast %struct.TYPE_12__* %8 to i8*
%80 = bitcast %struct.TYPE_12__* %15 to i8*
%81 = load %struct.TYPE_12__*, %struct.TYPE_12__** %6
%82 = getelementptr inbounds %struct.TYPE_12__, %struct.TYPE_12__* %81, i64 1
%83 = bitcast %struct.TYPE_12__* %7 to i64*
%84 = load i64, i64* %83
%85 = bitcast %struct.TYPE_12__* %8 to i64*
%86 = load i64, i64* %85
%87 = call i64 @_mm_avg_epu16(i64 %84, i64 %86)
%88 = bitcast %struct.TYPE_12__* %16 to i64*
store i64 %87, i64* %88
%89 = bitcast %struct.TYPE_12__* %82 to i8*
%90 = bitcast %struct.TYPE_12__* %16 to i8*
%91 = load %struct.TYPE_12__*, %struct.TYPE_12__** %4
%92 = getelementptr inbounds %struct.TYPE_12__, %struct.TYPE_12__* %91, i64 2
%93 = load %struct.TYPE_12__*, %struct.TYPE_12__** %5
%94 = getelementptr inbounds %struct.TYPE_12__, %struct.TYPE_12__* %93, i64 2
%95 = bitcast %struct.TYPE_12__* %92 to i64*
%96 = load i64, i64* %95
%97 = bitcast %struct.TYPE_12__* %94 to i64*
%98 = load i64, i64* %97
%99 = call i64 @_mm_avg_epu16(i64 %96, i64 %98)
%100 = bitcast %struct.TYPE_12__* %17 to i64*
store i64 %99, i64* %100
%101 = bitcast %struct.TYPE_12__* %7 to i8*
%102 = bitcast %struct.TYPE_12__* %17 to i8*
%103 = bitcast %struct.TYPE_12__* %7 to i64*
%104 = load i64, i64* %103
%105 = call i64 @_mm_shufflehi_epi16(i64 %104, i32 177)
%106 = bitcast %struct.TYPE_12__* %18 to i64*
store i64 %105, i64* %106
%107 = bitcast %struct.TYPE_12__* %8 to i8*
%108 = bitcast %struct.TYPE_12__* %18 to i8*
%109 = bitcast %struct.TYPE_12__* %8 to i64*
%110 = load i64, i64* %109
%111 = call i64 @_mm_shufflelo_epi16(i64 %110, i32 177)
%112 = bitcast %struct.TYPE_12__* %19 to i64*
store i64 %111, i64* %112
%113 = bitcast %struct.TYPE_12__* %8 to i8*
%114 = bitcast %struct.TYPE_12__* %19 to i8*
%115 = load %struct.TYPE_12__*, %struct.TYPE_12__** %6
%116 = getelementptr inbounds %struct.TYPE_12__, %struct.TYPE_12__* %115, i64 2
%117 = bitcast %struct.TYPE_12__* %7 to i64*
%118 = load i64, i64* %117
%119 = bitcast %struct.TYPE_12__* %8 to i64*
%120 = load i64, i64* %119
%121 = call i64 @_mm_avg_epu16(i64 %118, i64 %120)
%122 = bitcast %struct.TYPE_12__* %20 to i64*
store i64 %121, i64* %122
%123 = bitcast %struct.TYPE_12__* %116 to i8*
%124 = bitcast %struct.TYPE_12__* %20 to i8*
ret void
}

LLVM IR (-O2):
%struct.TYPE_12__ = type { i32, i32 }
define void @avg_420_downsample_r_g_b_vectors_sse2(%struct.TYPE_12__* nocapture %0, %struct.TYPE_12__* nocapture %1, %struct.TYPE_12__* nocapture writeonly %2) {
%4 = bitcast %struct.TYPE_12__* %0 to i64*
%5 = load i64, i64* %4
%6 = bitcast %struct.TYPE_12__* %1 to i64*
%7 = load i64, i64* %6
%8 = tail call i64 @_mm_avg_epu16(i64 %5, i64 %7)
%9 = tail call i64 @_mm_shufflehi_epi16(i64 %8, i32 177)
%10 = tail call i64 @_mm_shufflelo_epi16(i64 %9, i32 177)
%11 = tail call i64 @_mm_avg_epu16(i64 %8, i64 %10)
%12 = bitcast %struct.TYPE_12__* %2 to i64*
store i64 %11, i64* %12
%13 = getelementptr inbounds %struct.TYPE_12__, %struct.TYPE_12__* %0, i64 1
%14 = getelementptr inbounds %struct.TYPE_12__, %struct.TYPE_12__* %1, i64 1
%15 = bitcast %struct.TYPE_12__* %13 to i64*
%16 = load i64, i64* %15
%17 = bitcast %struct.TYPE_12__* %14 to i64*
%18 = load i64, i64* %17
%19 = tail call i64 @_mm_avg_epu16(i64 %16, i64 %18)
%20 = tail call i64 @_mm_shufflehi_epi16(i64 %19, i32 177)
%21 = tail call i64 @_mm_shufflelo_epi16(i64 %20, i32 177)
%22 = tail call i64 @_mm_avg_epu16(i64 %19, i64 %21)
%23 = getelementptr inbounds %struct.TYPE_12__, %struct.TYPE_12__* %2, i64 1
%24 = bitcast %struct.TYPE_12__* %23 to i64*
store i64 %22, i64* %24
%25 = getelementptr inbounds %struct.TYPE_12__, %struct.TYPE_12__* %0, i64 2
%26 = getelementptr inbounds %struct.TYPE_12__, %struct.TYPE_12__* %1, i64 2
%27 = bitcast %struct.TYPE_12__* %25 to i64*
%28 = load i64, i64* %27
%29 = bitcast %struct.TYPE_12__* %26 to i64*
%30 = load i64, i64* %29
%31 = tail call i64 @_mm_avg_epu16(i64 %28, i64 %30)
%32 = tail call i64 @_mm_shufflehi_epi16(i64 %31, i32 177)
%33 = tail call i64 @_mm_shufflelo_epi16(i64 %32, i32 177)
%34 = tail call i64 @_mm_avg_epu16(i64 %31, i64 %33)
%35 = getelementptr inbounds %struct.TYPE_12__, %struct.TYPE_12__* %2, i64 2
%36 = bitcast %struct.TYPE_12__* %35 to i64*
store i64 %34, i64* %36
ret void
}