#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 */

/* Type definitions */
typedef int /*<<< orphan*/ __m128i;

/* Variables and functions */
int /*<<< orphan*/ _mm_add_epi16(int /*<<< orphan*/, int /*<<< orphan*/ const);
int /*<<< orphan*/ _mm_maddubs_epi16(int /*<<< orphan*/,
                                     int /*<<< orphan*/ const);
int /*<<< orphan*/ _mm_set1_epi16(int);
int /*<<< orphan*/ _mm_srai_epi16(int /*<<< orphan*/, int);
int /*<<< orphan*/ _mm_unpacklo_epi8(int /*<<< orphan*/ const,
                                     int /*<<< orphan*/ const);
void apply_filter_lo(const __m128i v_a_lo_b, const __m128i v_b_lo_b,
                     const __m128i v_filter_b, __m128i *v_res_w) {
  const __m128i v_rounding_w = _mm_set1_epi16(1 << (7 - 1));
  __m128i v_input_b = _mm_unpacklo_epi8(v_a_lo_b, v_b_lo_b);
  __m128i v_temp0_w = _mm_maddubs_epi16(v_input_b, v_filter_b);
  *v_res_w = _mm_srai_epi16(_mm_add_epi16(v_temp0_w, v_rounding_w), 7);
}


x86 assembly (clang, -O0):
<apply_filter_lo>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %edi,-0x4(%rbp)
mov    %esi,-0x8(%rbp)
mov    %edx,-0xc(%rbp)
mov    %rcx,-0x18(%rbp)
mov    $0x40,%edi
call   1060 <_mm_set1_epi16@plt>
mov    %eax,-0x1c(%rbp)
mov    -0x4(%rbp),%edi
mov    -0x8(%rbp),%esi
call   1040 <_mm_unpacklo_epi8@plt>
mov    %eax,-0x20(%rbp)
mov    -0x20(%rbp),%edi
mov    -0xc(%rbp),%esi
call   1050 <_mm_maddubs_epi16@plt>
mov    %eax,-0x24(%rbp)
mov    -0x24(%rbp),%edi
mov    -0x1c(%rbp),%esi
call   1030 <_mm_add_epi16@plt>
mov    %eax,%edi
mov    $0x7,%esi
call   1070 <_mm_srai_epi16@plt>
mov    %eax,%ecx
mov    -0x18(%rbp),%rax
mov    %ecx,(%rax)
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<apply_filter_lo>:
push   %rbp
push   %r15
push   %r14
push   %r12
push   %rbx
mov    %rcx,%r14
mov    %edx,%r15d
mov    %esi,%ebx
mov    %edi,%ebp
mov    $0x40,%edi
call   1060 <_mm_set1_epi16@plt>
mov    %eax,%r12d
mov    %ebp,%edi
mov    %ebx,%esi
call   1040 <_mm_unpacklo_epi8@plt>
mov    %eax,%edi
mov    %r15d,%esi
call   1050 <_mm_maddubs_epi16@plt>
mov    %eax,%edi
mov    %r12d,%esi
call   1030 <_mm_add_epi16@plt>
mov    %eax,%edi
mov    $0x7,%esi
call   1070 <_mm_srai_epi16@plt>
mov    %eax,(%r14)
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
define void @apply_filter_lo(i32 %0, i32 %1, i32 %2, i32* %3) {
%5 = alloca i32
%6 = alloca i32
%7 = alloca i32
%8 = alloca i32*
%9 = alloca i32
%10 = alloca i32
%11 = alloca i32
store i32 %0, i32* %5
store i32 %1, i32* %6
store i32 %2, i32* %7
store i32* %3, i32** %8
%12 = call i32 @_mm_set1_epi16(i32 64)
store i32 %12, i32* %9
%13 = load i32, i32* %5
%14 = load i32, i32* %6
%15 = call i32 @_mm_unpacklo_epi8(i32 %13, i32 %14)
store i32 %15, i32* %10
%16 = load i32, i32* %10
%17 = load i32, i32* %7
%18 = call i32 @_mm_maddubs_epi16(i32 %16, i32 %17)
store i32 %18, i32* %11
%19 = load i32, i32* %11
%20 = load i32, i32* %9
%21 = call i32 @_mm_add_epi16(i32 %19, i32 %20)
%22 = call i32 @_mm_srai_epi16(i32 %21, i32 7)
%23 = load i32*, i32** %8
store i32 %22, i32* %23
ret void
}

LLVM IR (-O2):
define void @apply_filter_lo(i32 %0, i32 %1, i32 %2, i32* nocapture writeonly %3) {
%5 = tail call i32 @_mm_set1_epi16(i32 64)
%6 = tail call i32 @_mm_unpacklo_epi8(i32 %0, i32 %1)
%7 = tail call i32 @_mm_maddubs_epi16(i32 %6, i32 %2)
%8 = tail call i32 @_mm_add_epi16(i32 %7, i32 %5)
%9 = tail call i32 @_mm_srai_epi16(i32 %8, i32 7)
store i32 %9, i32* %3
ret void
}