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

/* Type definitions */
struct TYPE_16__ {
  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_shuffle_epi32(TYPE_1__, int);
TYPE_1__ _mm_unpackhi_epi64(TYPE_1__, TYPE_1__);
TYPE_1__ _mm_unpacklo_epi64(TYPE_1__, TYPE_1__);
extern void avg_420_downsample_ag_rb_vectors_sse2(
    __m128i *in_4_v16i_current_ag_rb_vectors_1,
    __m128i *in_4_v16i_current_ag_rb_vectors_2,
    __m128i *out_2_v16i_avg_420_ag_rb_vectors) {
  __m128i scratch1 = {0x0LL, 0x0LL};
  __m128i scratch2 = {0x0LL, 0x0LL};
  __m128i scratch3 = {0x0LL, 0x0LL};
  __m128i scratch4 = {0x0LL, 0x0LL};
  (scratch1) = _mm_avg_epu16(in_4_v16i_current_ag_rb_vectors_1[0],
                             in_4_v16i_current_ag_rb_vectors_2[0]);
  (scratch2) = _mm_avg_epu16(in_4_v16i_current_ag_rb_vectors_1[2],
                             in_4_v16i_current_ag_rb_vectors_2[2]);
  (scratch1) = _mm_shuffle_epi32((scratch1), 0x8D);
  (scratch2) = _mm_shuffle_epi32((scratch2), 0x8D);
  (scratch3) = _mm_unpacklo_epi64((scratch1), (scratch2));
  (scratch4) = _mm_unpackhi_epi64((scratch1), (scratch2));
  out_2_v16i_avg_420_ag_rb_vectors[0] = _mm_avg_epu16((scratch3), (scratch4));
  (scratch1) = _mm_avg_epu16(in_4_v16i_current_ag_rb_vectors_1[1],
                             in_4_v16i_current_ag_rb_vectors_2[1]);
  (scratch2) = _mm_avg_epu16(in_4_v16i_current_ag_rb_vectors_1[3],
                             in_4_v16i_current_ag_rb_vectors_2[3]);
  (scratch1) = _mm_shuffle_epi32((scratch1), 0x8D);
  (scratch2) = _mm_shuffle_epi32((scratch2), 0x8D);
  (scratch3) = _mm_unpacklo_epi64((scratch1), (scratch2));
  (scratch4) = _mm_unpackhi_epi64((scratch1), (scratch2));
  out_2_v16i_avg_420_ag_rb_vectors[1] = _mm_avg_epu16((scratch3), (scratch4));
}


x86 assembly (clang, -O0):
<avg_420_downsample_ag_rb_vectors_sse2>:
push   %rbp
mov    %rsp,%rbp
sub    $0xc0,%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>
lea    -0x30(%rbp),%rdi
xor    %esi,%esi
mov    $0x8,%edx
call   1030 <memset@plt>
lea    -0x38(%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   1060 <_mm_avg_epu16@plt>
mov    %rax,-0x40(%rbp)
mov    -0x40(%rbp),%rax
mov    %rax,-0x20(%rbp)
mov    -0x8(%rbp),%rcx
mov    -0x10(%rbp),%rax
mov    0x10(%rcx),%rdi
mov    0x10(%rax),%rsi
call   1060 <_mm_avg_epu16@plt>
mov    %rax,-0x48(%rbp)
mov    -0x48(%rbp),%rax
mov    %rax,-0x28(%rbp)
mov    -0x20(%rbp),%rdi
mov    $0x8d,%esi
call   1050 <_mm_shuffle_epi32@plt>
mov    %rax,-0x50(%rbp)
mov    -0x50(%rbp),%rax
mov    %rax,-0x20(%rbp)
mov    -0x28(%rbp),%rdi
mov    $0x8d,%esi
call   1050 <_mm_shuffle_epi32@plt>
mov    %rax,-0x58(%rbp)
mov    -0x58(%rbp),%rax
mov    %rax,-0x28(%rbp)
mov    -0x20(%rbp),%rdi
mov    -0x28(%rbp),%rsi
call   1070 <_mm_unpacklo_epi64@plt>
mov    %rax,-0x60(%rbp)
mov    -0x60(%rbp),%rax
mov    %rax,-0x30(%rbp)
mov    -0x20(%rbp),%rdi
mov    -0x28(%rbp),%rsi
call   1040 <_mm_unpackhi_epi64@plt>
mov    %rax,-0x68(%rbp)
mov    -0x68(%rbp),%rax
mov    %rax,-0x38(%rbp)
mov    -0x18(%rbp),%rax
mov    %rax,-0xb8(%rbp)
mov    -0x30(%rbp),%rdi
mov    -0x38(%rbp),%rsi
call   1060 <_mm_avg_epu16@plt>
mov    %rax,%rcx
mov    -0xb8(%rbp),%rax
mov    %rcx,-0x70(%rbp)
mov    -0x70(%rbp),%rcx
mov    %rcx,(%rax)
mov    -0x8(%rbp),%rcx
mov    -0x10(%rbp),%rax
mov    0x8(%rcx),%rdi
mov    0x8(%rax),%rsi
call   1060 <_mm_avg_epu16@plt>
mov    %rax,-0x78(%rbp)
mov    -0x78(%rbp),%rax
mov    %rax,-0x20(%rbp)
mov    -0x8(%rbp),%rcx
mov    -0x10(%rbp),%rax
mov    0x18(%rcx),%rdi
mov    0x18(%rax),%rsi
call   1060 <_mm_avg_epu16@plt>
mov    %rax,-0x80(%rbp)
mov    -0x80(%rbp),%rax
mov    %rax,-0x28(%rbp)
mov    -0x20(%rbp),%rdi
mov    $0x8d,%esi
call   1050 <_mm_shuffle_epi32@plt>
mov    %rax,-0x88(%rbp)
mov    -0x88(%rbp),%rax
mov    %rax,-0x20(%rbp)
mov    -0x28(%rbp),%rdi
mov    $0x8d,%esi
call   1050 <_mm_shuffle_epi32@plt>
mov    %rax,-0x90(%rbp)
mov    -0x90(%rbp),%rax
mov    %rax,-0x28(%rbp)
mov    -0x20(%rbp),%rdi
mov    -0x28(%rbp),%rsi
call   1070 <_mm_unpacklo_epi64@plt>
mov    %rax,-0x98(%rbp)
mov    -0x98(%rbp),%rax
mov    %rax,-0x30(%rbp)
mov    -0x20(%rbp),%rdi
mov    -0x28(%rbp),%rsi
call   1040 <_mm_unpackhi_epi64@plt>
mov    %rax,-0xa0(%rbp)
mov    -0xa0(%rbp),%rax
mov    %rax,-0x38(%rbp)
mov    -0x18(%rbp),%rax
mov    %rax,-0xb0(%rbp)
mov    -0x30(%rbp),%rdi
mov    -0x38(%rbp),%rsi
call   1060 <_mm_avg_epu16@plt>
mov    %rax,%rcx
mov    -0xb0(%rbp),%rax
mov    %rcx,-0xa8(%rbp)
mov    -0xa8(%rbp),%rcx
mov    %rcx,0x8(%rax)
add    $0xc0,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<avg_420_downsample_ag_rb_vectors_sse2>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
mov    %rdx,(%rsp)
mov    %rsi,%r15
mov    %rdi,%r14
mov    (%rdi),%rdi
mov    (%rsi),%rsi
call   1050 <_mm_avg_epu16@plt>
mov    %rax,%r12
mov    0x10(%r14),%rdi
mov    0x10(%r15),%rsi
call   1050 <_mm_avg_epu16@plt>
mov    %rax,%r13
mov    %r12,%rdi
mov    $0x8d,%esi
call   1040 <_mm_shuffle_epi32@plt>
mov    %rax,%rbx
mov    %r13,%rdi
mov    $0x8d,%esi
call   1040 <_mm_shuffle_epi32@plt>
mov    %rax,%rbp
mov    %rbx,%rdi
mov    %rax,%rsi
call   1060 <_mm_unpacklo_epi64@plt>
mov    %rax,%r12
mov    %rbx,%rdi
mov    %rbp,%rsi
call   1030 <_mm_unpackhi_epi64@plt>
mov    %r12,%rdi
mov    %rax,%rsi
call   1050 <_mm_avg_epu16@plt>
mov    (%rsp),%r12
mov    %rax,(%r12)
mov    0x8(%r14),%rdi
mov    0x8(%r15),%rsi
call   1050 <_mm_avg_epu16@plt>
mov    %rax,%rbx
mov    0x18(%r14),%rdi
mov    0x18(%r15),%rsi
call   1050 <_mm_avg_epu16@plt>
mov    %rax,%rbp
mov    %rbx,%rdi
mov    $0x8d,%esi
call   1040 <_mm_shuffle_epi32@plt>
mov    %rax,%rbx
mov    %rbp,%rdi
mov    $0x8d,%esi
call   1040 <_mm_shuffle_epi32@plt>
mov    %rax,%rbp
mov    %rbx,%rdi
mov    %rax,%rsi
call   1060 <_mm_unpacklo_epi64@plt>
mov    %rax,%r14
mov    %rbx,%rdi
mov    %rbp,%rsi
call   1030 <_mm_unpackhi_epi64@plt>
mov    %r14,%rdi
mov    %rax,%rsi
call   1050 <_mm_avg_epu16@plt>
mov    %rax,0x8(%r12)
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
%struct.TYPE_16__ = type { i32, i32 }
define void @avg_420_downsample_ag_rb_vectors_sse2(%struct.TYPE_16__* %0, %struct.TYPE_16__* %1, %struct.TYPE_16__* %2) {
%4 = alloca %struct.TYPE_16__*
%5 = alloca %struct.TYPE_16__*
%6 = alloca %struct.TYPE_16__*
%7 = alloca %struct.TYPE_16__
%8 = alloca %struct.TYPE_16__
%9 = alloca %struct.TYPE_16__
%10 = alloca %struct.TYPE_16__
%11 = alloca %struct.TYPE_16__
%12 = alloca %struct.TYPE_16__
%13 = alloca %struct.TYPE_16__
%14 = alloca %struct.TYPE_16__
%15 = alloca %struct.TYPE_16__
%16 = alloca %struct.TYPE_16__
%17 = alloca %struct.TYPE_16__
%18 = alloca %struct.TYPE_16__
%19 = alloca %struct.TYPE_16__
%20 = alloca %struct.TYPE_16__
%21 = alloca %struct.TYPE_16__
%22 = alloca %struct.TYPE_16__
%23 = alloca %struct.TYPE_16__
%24 = alloca %struct.TYPE_16__
store %struct.TYPE_16__* %0, %struct.TYPE_16__** %4
store %struct.TYPE_16__* %1, %struct.TYPE_16__** %5
store %struct.TYPE_16__* %2, %struct.TYPE_16__** %6
%25 = bitcast %struct.TYPE_16__* %7 to i8*
%26 = bitcast %struct.TYPE_16__* %8 to i8*
%27 = bitcast %struct.TYPE_16__* %9 to i8*
%28 = bitcast %struct.TYPE_16__* %10 to i8*
%29 = load %struct.TYPE_16__*, %struct.TYPE_16__** %4
%30 = getelementptr inbounds %struct.TYPE_16__, %struct.TYPE_16__* %29, i64 0
%31 = load %struct.TYPE_16__*, %struct.TYPE_16__** %5
%32 = getelementptr inbounds %struct.TYPE_16__, %struct.TYPE_16__* %31, i64 0
%33 = bitcast %struct.TYPE_16__* %30 to i64*
%34 = load i64, i64* %33
%35 = bitcast %struct.TYPE_16__* %32 to i64*
%36 = load i64, i64* %35
%37 = call i64 @_mm_avg_epu16(i64 %34, i64 %36)
%38 = bitcast %struct.TYPE_16__* %11 to i64*
store i64 %37, i64* %38
%39 = bitcast %struct.TYPE_16__* %7 to i8*
%40 = bitcast %struct.TYPE_16__* %11 to i8*
%41 = load %struct.TYPE_16__*, %struct.TYPE_16__** %4
%42 = getelementptr inbounds %struct.TYPE_16__, %struct.TYPE_16__* %41, i64 2
%43 = load %struct.TYPE_16__*, %struct.TYPE_16__** %5
%44 = getelementptr inbounds %struct.TYPE_16__, %struct.TYPE_16__* %43, i64 2
%45 = bitcast %struct.TYPE_16__* %42 to i64*
%46 = load i64, i64* %45
%47 = bitcast %struct.TYPE_16__* %44 to i64*
%48 = load i64, i64* %47
%49 = call i64 @_mm_avg_epu16(i64 %46, i64 %48)
%50 = bitcast %struct.TYPE_16__* %12 to i64*
store i64 %49, i64* %50
%51 = bitcast %struct.TYPE_16__* %8 to i8*
%52 = bitcast %struct.TYPE_16__* %12 to i8*
%53 = bitcast %struct.TYPE_16__* %7 to i64*
%54 = load i64, i64* %53
%55 = call i64 @_mm_shuffle_epi32(i64 %54, i32 141)
%56 = bitcast %struct.TYPE_16__* %13 to i64*
store i64 %55, i64* %56
%57 = bitcast %struct.TYPE_16__* %7 to i8*
%58 = bitcast %struct.TYPE_16__* %13 to i8*
%59 = bitcast %struct.TYPE_16__* %8 to i64*
%60 = load i64, i64* %59
%61 = call i64 @_mm_shuffle_epi32(i64 %60, i32 141)
%62 = bitcast %struct.TYPE_16__* %14 to i64*
store i64 %61, i64* %62
%63 = bitcast %struct.TYPE_16__* %8 to i8*
%64 = bitcast %struct.TYPE_16__* %14 to i8*
%65 = bitcast %struct.TYPE_16__* %7 to i64*
%66 = load i64, i64* %65
%67 = bitcast %struct.TYPE_16__* %8 to i64*
%68 = load i64, i64* %67
%69 = call i64 @_mm_unpacklo_epi64(i64 %66, i64 %68)
%70 = bitcast %struct.TYPE_16__* %15 to i64*
store i64 %69, i64* %70
%71 = bitcast %struct.TYPE_16__* %9 to i8*
%72 = bitcast %struct.TYPE_16__* %15 to i8*
%73 = bitcast %struct.TYPE_16__* %7 to i64*
%74 = load i64, i64* %73
%75 = bitcast %struct.TYPE_16__* %8 to i64*
%76 = load i64, i64* %75
%77 = call i64 @_mm_unpackhi_epi64(i64 %74, i64 %76)
%78 = bitcast %struct.TYPE_16__* %16 to i64*
store i64 %77, i64* %78
%79 = bitcast %struct.TYPE_16__* %10 to i8*
%80 = bitcast %struct.TYPE_16__* %16 to i8*
%81 = load %struct.TYPE_16__*, %struct.TYPE_16__** %6
%82 = getelementptr inbounds %struct.TYPE_16__, %struct.TYPE_16__* %81, i64 0
%83 = bitcast %struct.TYPE_16__* %9 to i64*
%84 = load i64, i64* %83
%85 = bitcast %struct.TYPE_16__* %10 to i64*
%86 = load i64, i64* %85
%87 = call i64 @_mm_avg_epu16(i64 %84, i64 %86)
%88 = bitcast %struct.TYPE_16__* %17 to i64*
store i64 %87, i64* %88
%89 = bitcast %struct.TYPE_16__* %82 to i8*
%90 = bitcast %struct.TYPE_16__* %17 to i8*
%91 = load %struct.TYPE_16__*, %struct.TYPE_16__** %4
%92 = getelementptr inbounds %struct.TYPE_16__, %struct.TYPE_16__* %91, i64 1
%93 = load %struct.TYPE_16__*, %struct.TYPE_16__** %5
%94 = getelementptr inbounds %struct.TYPE_16__, %struct.TYPE_16__* %93, i64 1
%95 = bitcast %struct.TYPE_16__* %92 to i64*
%96 = load i64, i64* %95
%97 = bitcast %struct.TYPE_16__* %94 to i64*
%98 = load i64, i64* %97
%99 = call i64 @_mm_avg_epu16(i64 %96, i64 %98)
%100 = bitcast %struct.TYPE_16__* %18 to i64*
store i64 %99, i64* %100
%101 = bitcast %struct.TYPE_16__* %7 to i8*
%102 = bitcast %struct.TYPE_16__* %18 to i8*
%103 = load %struct.TYPE_16__*, %struct.TYPE_16__** %4
%104 = getelementptr inbounds %struct.TYPE_16__, %struct.TYPE_16__* %103, i64 3
%105 = load %struct.TYPE_16__*, %struct.TYPE_16__** %5
%106 = getelementptr inbounds %struct.TYPE_16__, %struct.TYPE_16__* %105, i64 3
%107 = bitcast %struct.TYPE_16__* %104 to i64*
%108 = load i64, i64* %107
%109 = bitcast %struct.TYPE_16__* %106 to i64*
%110 = load i64, i64* %109
%111 = call i64 @_mm_avg_epu16(i64 %108, i64 %110)
%112 = bitcast %struct.TYPE_16__* %19 to i64*
store i64 %111, i64* %112
%113 = bitcast %struct.TYPE_16__* %8 to i8*
%114 = bitcast %struct.TYPE_16__* %19 to i8*
%115 = bitcast %struct.TYPE_16__* %7 to i64*
%116 = load i64, i64* %115
%117 = call i64 @_mm_shuffle_epi32(i64 %116, i32 141)
%118 = bitcast %struct.TYPE_16__* %20 to i64*
store i64 %117, i64* %118
%119 = bitcast %struct.TYPE_16__* %7 to i8*
%120 = bitcast %struct.TYPE_16__* %20 to i8*
%121 = bitcast %struct.TYPE_16__* %8 to i64*
%122 = load i64, i64* %121
%123 = call i64 @_mm_shuffle_epi32(i64 %122, i32 141)
%124 = bitcast %struct.TYPE_16__* %21 to i64*
store i64 %123, i64* %124
%125 = bitcast %struct.TYPE_16__* %8 to i8*
%126 = bitcast %struct.TYPE_16__* %21 to i8*
%127 = bitcast %struct.TYPE_16__* %7 to i64*
%128 = load i64, i64* %127
%129 = bitcast %struct.TYPE_16__* %8 to i64*
%130 = load i64, i64* %129
%131 = call i64 @_mm_unpacklo_epi64(i64 %128, i64 %130)
%132 = bitcast %struct.TYPE_16__* %22 to i64*
store i64 %131, i64* %132
%133 = bitcast %struct.TYPE_16__* %9 to i8*
%134 = bitcast %struct.TYPE_16__* %22 to i8*
%135 = bitcast %struct.TYPE_16__* %7 to i64*
%136 = load i64, i64* %135
%137 = bitcast %struct.TYPE_16__* %8 to i64*
%138 = load i64, i64* %137
%139 = call i64 @_mm_unpackhi_epi64(i64 %136, i64 %138)
%140 = bitcast %struct.TYPE_16__* %23 to i64*
store i64 %139, i64* %140
%141 = bitcast %struct.TYPE_16__* %10 to i8*
%142 = bitcast %struct.TYPE_16__* %23 to i8*
%143 = load %struct.TYPE_16__*, %struct.TYPE_16__** %6
%144 = getelementptr inbounds %struct.TYPE_16__, %struct.TYPE_16__* %143, i64 1
%145 = bitcast %struct.TYPE_16__* %9 to i64*
%146 = load i64, i64* %145
%147 = bitcast %struct.TYPE_16__* %10 to i64*
%148 = load i64, i64* %147
%149 = call i64 @_mm_avg_epu16(i64 %146, i64 %148)
%150 = bitcast %struct.TYPE_16__* %24 to i64*
store i64 %149, i64* %150
%151 = bitcast %struct.TYPE_16__* %144 to i8*
%152 = bitcast %struct.TYPE_16__* %24 to i8*
ret void
}

LLVM IR (-O2):
%struct.TYPE_16__ = type { i32, i32 }
define void @avg_420_downsample_ag_rb_vectors_sse2(%struct.TYPE_16__* nocapture %0, %struct.TYPE_16__* nocapture %1, %struct.TYPE_16__* nocapture writeonly %2) {
%4 = bitcast %struct.TYPE_16__* %0 to i64*
%5 = load i64, i64* %4
%6 = bitcast %struct.TYPE_16__* %1 to i64*
%7 = load i64, i64* %6
%8 = tail call i64 @_mm_avg_epu16(i64 %5, i64 %7)
%9 = getelementptr inbounds %struct.TYPE_16__, %struct.TYPE_16__* %0, i64 2
%10 = getelementptr inbounds %struct.TYPE_16__, %struct.TYPE_16__* %1, i64 2
%11 = bitcast %struct.TYPE_16__* %9 to i64*
%12 = load i64, i64* %11
%13 = bitcast %struct.TYPE_16__* %10 to i64*
%14 = load i64, i64* %13
%15 = tail call i64 @_mm_avg_epu16(i64 %12, i64 %14)
%16 = tail call i64 @_mm_shuffle_epi32(i64 %8, i32 141)
%17 = tail call i64 @_mm_shuffle_epi32(i64 %15, i32 141)
%18 = tail call i64 @_mm_unpacklo_epi64(i64 %16, i64 %17)
%19 = tail call i64 @_mm_unpackhi_epi64(i64 %16, i64 %17)
%20 = tail call i64 @_mm_avg_epu16(i64 %18, i64 %19)
%21 = bitcast %struct.TYPE_16__* %2 to i64*
store i64 %20, i64* %21
%22 = getelementptr inbounds %struct.TYPE_16__, %struct.TYPE_16__* %0, i64 1
%23 = getelementptr inbounds %struct.TYPE_16__, %struct.TYPE_16__* %1, i64 1
%24 = bitcast %struct.TYPE_16__* %22 to i64*
%25 = load i64, i64* %24
%26 = bitcast %struct.TYPE_16__* %23 to i64*
%27 = load i64, i64* %26
%28 = tail call i64 @_mm_avg_epu16(i64 %25, i64 %27)
%29 = getelementptr inbounds %struct.TYPE_16__, %struct.TYPE_16__* %0, i64 3
%30 = getelementptr inbounds %struct.TYPE_16__, %struct.TYPE_16__* %1, i64 3
%31 = bitcast %struct.TYPE_16__* %29 to i64*
%32 = load i64, i64* %31
%33 = bitcast %struct.TYPE_16__* %30 to i64*
%34 = load i64, i64* %33
%35 = tail call i64 @_mm_avg_epu16(i64 %32, i64 %34)
%36 = tail call i64 @_mm_shuffle_epi32(i64 %28, i32 141)
%37 = tail call i64 @_mm_shuffle_epi32(i64 %35, i32 141)
%38 = tail call i64 @_mm_unpacklo_epi64(i64 %36, i64 %37)
%39 = tail call i64 @_mm_unpackhi_epi64(i64 %36, i64 %37)
%40 = tail call i64 @_mm_avg_epu16(i64 %38, i64 %39)
%41 = getelementptr inbounds %struct.TYPE_16__, %struct.TYPE_16__* %2, i64 1
%42 = bitcast %struct.TYPE_16__* %41 to i64*
store i64 %40, i64* %42
ret void
}