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

/* Type definitions */
struct TYPE_14__ {
  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_or_si128(TYPE_1__, TYPE_1__);
TYPE_1__ _mm_shufflehi_epi16(TYPE_1__, int);
TYPE_1__ _mm_srli_si128(TYPE_1__, int);
extern void reconstruct_last_missing_uv_sse2(__m128i *current_uv,
                                             __m128i *out) {
  __m128i avgB = {0x0LL, 0x0LL};
  (avgB) = _mm_srli_si128(*current_uv, 4);
  (avgB) = _mm_shufflehi_epi16((avgB), 0x44);
  (avgB) = _mm_or_si128((avgB), (avgB));
  *out = _mm_avg_epu16(*current_uv, (avgB));
}


x86 assembly (clang, -O0):
<reconstruct_last_missing_uv_sse2>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
lea    -0x18(%rbp),%rdi
xor    %esi,%esi
mov    $0x8,%edx
call   1030 <memset@plt>
mov    -0x8(%rbp),%rax
mov    (%rax),%rdi
mov    $0x4,%esi
call   1040 <_mm_srli_si128@plt>
mov    %rax,-0x20(%rbp)
mov    -0x20(%rbp),%rax
mov    %rax,-0x18(%rbp)
mov    -0x18(%rbp),%rdi
mov    $0x44,%esi
call   1070 <_mm_shufflehi_epi16@plt>
mov    %rax,-0x28(%rbp)
mov    -0x28(%rbp),%rax
mov    %rax,-0x18(%rbp)
mov    -0x18(%rbp),%rdi
mov    -0x18(%rbp),%rsi
call   1050 <_mm_or_si128@plt>
mov    %rax,-0x30(%rbp)
mov    -0x30(%rbp),%rax
mov    %rax,-0x18(%rbp)
mov    -0x10(%rbp),%rax
mov    %rax,-0x40(%rbp)
mov    -0x8(%rbp),%rax
mov    (%rax),%rdi
mov    -0x18(%rbp),%rsi
call   1060 <_mm_avg_epu16@plt>
mov    %rax,%rcx
mov    -0x40(%rbp),%rax
mov    %rcx,-0x38(%rbp)
mov    -0x38(%rbp),%rcx
mov    %rcx,(%rax)
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<reconstruct_last_missing_uv_sse2>:
push   %r14
push   %rbx
push   %rax
mov    %rsi,%r14
mov    %rdi,%rbx
mov    (%rdi),%rdi
mov    $0x4,%esi
call   1030 <_mm_srli_si128@plt>
mov    %rax,%rdi
mov    $0x44,%esi
call   1060 <_mm_shufflehi_epi16@plt>
mov    %rax,%rdi
mov    %rax,%rsi
call   1040 <_mm_or_si128@plt>
mov    (%rbx),%rdi
mov    %rax,%rsi
call   1050 <_mm_avg_epu16@plt>
mov    %rax,(%r14)
add    $0x8,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
%struct.TYPE_14__ = type { i32, i32 }
define void @reconstruct_last_missing_uv_sse2(%struct.TYPE_14__* %0, %struct.TYPE_14__* %1) {
%3 = alloca %struct.TYPE_14__*
%4 = alloca %struct.TYPE_14__*
%5 = alloca %struct.TYPE_14__
%6 = alloca %struct.TYPE_14__
%7 = alloca %struct.TYPE_14__
%8 = alloca %struct.TYPE_14__
%9 = alloca %struct.TYPE_14__
store %struct.TYPE_14__* %0, %struct.TYPE_14__** %3
store %struct.TYPE_14__* %1, %struct.TYPE_14__** %4
%10 = bitcast %struct.TYPE_14__* %5 to i8*
%11 = load %struct.TYPE_14__*, %struct.TYPE_14__** %3
%12 = bitcast %struct.TYPE_14__* %11 to i64*
%13 = load i64, i64* %12
%14 = call i64 @_mm_srli_si128(i64 %13, i32 4)
%15 = bitcast %struct.TYPE_14__* %6 to i64*
store i64 %14, i64* %15
%16 = bitcast %struct.TYPE_14__* %5 to i8*
%17 = bitcast %struct.TYPE_14__* %6 to i8*
%18 = bitcast %struct.TYPE_14__* %5 to i64*
%19 = load i64, i64* %18
%20 = call i64 @_mm_shufflehi_epi16(i64 %19, i32 68)
%21 = bitcast %struct.TYPE_14__* %7 to i64*
store i64 %20, i64* %21
%22 = bitcast %struct.TYPE_14__* %5 to i8*
%23 = bitcast %struct.TYPE_14__* %7 to i8*
%24 = bitcast %struct.TYPE_14__* %5 to i64*
%25 = load i64, i64* %24
%26 = bitcast %struct.TYPE_14__* %5 to i64*
%27 = load i64, i64* %26
%28 = call i64 @_mm_or_si128(i64 %25, i64 %27)
%29 = bitcast %struct.TYPE_14__* %8 to i64*
store i64 %28, i64* %29
%30 = bitcast %struct.TYPE_14__* %5 to i8*
%31 = bitcast %struct.TYPE_14__* %8 to i8*
%32 = load %struct.TYPE_14__*, %struct.TYPE_14__** %4
%33 = load %struct.TYPE_14__*, %struct.TYPE_14__** %3
%34 = bitcast %struct.TYPE_14__* %33 to i64*
%35 = load i64, i64* %34
%36 = bitcast %struct.TYPE_14__* %5 to i64*
%37 = load i64, i64* %36
%38 = call i64 @_mm_avg_epu16(i64 %35, i64 %37)
%39 = bitcast %struct.TYPE_14__* %9 to i64*
store i64 %38, i64* %39
%40 = bitcast %struct.TYPE_14__* %32 to i8*
%41 = bitcast %struct.TYPE_14__* %9 to i8*
ret void
}

LLVM IR (-O2):
%struct.TYPE_14__ = type { i32, i32 }
define void @reconstruct_last_missing_uv_sse2(%struct.TYPE_14__* nocapture %0, %struct.TYPE_14__* nocapture writeonly %1) {
%3 = bitcast %struct.TYPE_14__* %0 to i64*
%4 = load i64, i64* %3
%5 = tail call i64 @_mm_srli_si128(i64 %4, i32 4)
%6 = tail call i64 @_mm_shufflehi_epi16(i64 %5, i32 68)
%7 = tail call i64 @_mm_or_si128(i64 %6, i64 %6)
%8 = load i64, i64* %3
%9 = tail call i64 @_mm_avg_epu16(i64 %8, i64 %7)
%10 = bitcast %struct.TYPE_14__* %1 to i64*
store i64 %9, i64* %10
ret void
}