#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*/ const,
                                 int /*<<< orphan*/ const);
int /*<<< orphan*/ const _mm_sub_epi16(int /*<<< orphan*/, int /*<<< orphan*/);
__m128i filter_add2_sub2(const __m128i *const total, const __m128i *const a1,
                         const __m128i *const a2, const __m128i *const s1,
                         const __m128i *const s2) {
  __m128i x = _mm_add_epi16(*a1, *total);
  x = _mm_add_epi16(_mm_sub_epi16(x, _mm_add_epi16(*s1, *s2)), *a2);
  return x;
}


x86 assembly (clang, -O0):
<filter_add2_sub2>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
mov    %rcx,-0x20(%rbp)
mov    %r8,-0x28(%rbp)
mov    -0x10(%rbp),%rax
mov    (%rax),%edi
mov    -0x8(%rbp),%rax
mov    (%rax),%esi
call   1030 <_mm_add_epi16@plt>
mov    %eax,-0x2c(%rbp)
mov    -0x2c(%rbp),%eax
mov    %eax,-0x30(%rbp)
mov    -0x20(%rbp),%rax
mov    (%rax),%edi
mov    -0x28(%rbp),%rax
mov    (%rax),%esi
call   1030 <_mm_add_epi16@plt>
mov    -0x30(%rbp),%edi
mov    %eax,%esi
call   1040 <_mm_sub_epi16@plt>
mov    %eax,%edi
mov    -0x18(%rbp),%rax
mov    (%rax),%esi
call   1030 <_mm_add_epi16@plt>
mov    %eax,-0x2c(%rbp)
mov    -0x2c(%rbp),%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<filter_add2_sub2>:
push   %rbp
push   %r15
push   %r14
push   %rbx
push   %rax
mov    %r8,%r14
mov    %rcx,%rbx
mov    %rdx,%r15
mov    (%rsi),%eax
mov    (%rdi),%esi
mov    %eax,%edi
call   1030 <_mm_add_epi16@plt>
mov    %eax,%ebp
mov    (%rbx),%edi
mov    (%r14),%esi
call   1030 <_mm_add_epi16@plt>
mov    %ebp,%edi
mov    %eax,%esi
call   1040 <_mm_sub_epi16@plt>
mov    (%r15),%esi
mov    %eax,%edi
add    $0x8,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
jmp    1030 <_mm_add_epi16@plt>

LLVM IR (-O0):
define i32 @filter_add2_sub2(i32* %0, i32* %1, i32* %2, i32* %3, i32* %4) {
%6 = alloca i32*
%7 = alloca i32*
%8 = alloca i32*
%9 = alloca i32*
%10 = alloca i32*
%11 = alloca i32
store i32* %0, i32** %6
store i32* %1, i32** %7
store i32* %2, i32** %8
store i32* %3, i32** %9
store i32* %4, i32** %10
%12 = load i32*, i32** %7
%13 = load i32, i32* %12
%14 = load i32*, i32** %6
%15 = load i32, i32* %14
%16 = call i32 @_mm_add_epi16(i32 %13, i32 %15)
store i32 %16, i32* %11
%17 = load i32, i32* %11
%18 = load i32*, i32** %9
%19 = load i32, i32* %18
%20 = load i32*, i32** %10
%21 = load i32, i32* %20
%22 = call i32 @_mm_add_epi16(i32 %19, i32 %21)
%23 = call i32 @_mm_sub_epi16(i32 %17, i32 %22)
%24 = load i32*, i32** %8
%25 = load i32, i32* %24
%26 = call i32 @_mm_add_epi16(i32 %23, i32 %25)
store i32 %26, i32* %11
%27 = load i32, i32* %11
ret i32 %27
}

LLVM IR (-O2):
define i32 @filter_add2_sub2(i32* nocapture %0, i32* nocapture %1, i32* nocapture %2, i32* nocapture %3, i32* nocapture %4) {
%6 = load i32, i32* %1
%7 = load i32, i32* %0
%8 = tail call i32 @_mm_add_epi16(i32 %6, i32 %7)
%9 = load i32, i32* %3
%10 = load i32, i32* %4
%11 = tail call i32 @_mm_add_epi16(i32 %9, i32 %10)
%12 = tail call i32 @_mm_sub_epi16(i32 %8, i32 %11)
%13 = load i32, i32* %2
%14 = tail call i32 @_mm_add_epi16(i32 %12, i32 %13)
ret i32 %14
}