#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 void *__m128i;

/* Variables and functions */
int /*<<< orphan*/ DoSimpleFilter(void **const, void **const, void **);
int /*<<< orphan*/ GetBaseDelta(void *const *, void **const, void **const,
                                void *const *, void **);
int /*<<< orphan*/ NeedsFilter(void **const, void **const, void **const,
                               void **const, int, void **);
void *_mm_and_si128(void *, void *);
void *_mm_set1_epi8(int);
void *_mm_xor_si128(void *, void *const);
void DoFilter2(__m128i *const p1, __m128i *const p0, __m128i *const q0,
               __m128i *const q1, int thresh) {
  __m128i a, mask;
  const __m128i sign_bit = _mm_set1_epi8(0x80);
  const __m128i p1s = _mm_xor_si128(*p1, sign_bit);
  const __m128i q1s = _mm_xor_si128(*q1, sign_bit);
  NeedsFilter(p1, p0, q0, q1, thresh, &mask);
  {
    *p0 = _mm_xor_si128(*p0, sign_bit);
    *q0 = _mm_xor_si128(*q0, sign_bit);
  };
  GetBaseDelta(&p1s, p0, q0, &q1s, &a);
  a = _mm_and_si128(a, mask);
  DoSimpleFilter(p0, q0, &a);
  {
    *p0 = _mm_xor_si128(*p0, sign_bit);
    *q0 = _mm_xor_si128(*q0, sign_bit);
  };
}


x86 assembly (clang, -O0):
<DoFilter2>:
push   %rbp
mov    %rsp,%rbp
sub    $0x50,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
mov    %rcx,-0x20(%rbp)
mov    %r8d,-0x24(%rbp)
mov    $0x80,%edi
call   1030 <_mm_set1_epi8@plt>
mov    %rax,-0x40(%rbp)
mov    -0x8(%rbp),%rax
mov    (%rax),%rdi
mov    -0x40(%rbp),%rsi
call   1070 <_mm_xor_si128@plt>
mov    %rax,-0x48(%rbp)
mov    -0x20(%rbp),%rax
mov    (%rax),%rdi
mov    -0x40(%rbp),%rsi
call   1070 <_mm_xor_si128@plt>
mov    %rax,-0x50(%rbp)
mov    -0x8(%rbp),%rdi
mov    -0x10(%rbp),%rsi
mov    -0x18(%rbp),%rdx
mov    -0x20(%rbp),%rcx
mov    -0x24(%rbp),%r8d
lea    -0x38(%rbp),%r9
call   1040 <NeedsFilter@plt>
mov    -0x10(%rbp),%rax
mov    (%rax),%rdi
mov    -0x40(%rbp),%rsi
call   1070 <_mm_xor_si128@plt>
mov    %rax,%rcx
mov    -0x10(%rbp),%rax
mov    %rcx,(%rax)
mov    -0x18(%rbp),%rax
mov    (%rax),%rdi
mov    -0x40(%rbp),%rsi
call   1070 <_mm_xor_si128@plt>
mov    %rax,%rcx
mov    -0x18(%rbp),%rax
mov    %rcx,(%rax)
mov    -0x10(%rbp),%rsi
mov    -0x18(%rbp),%rdx
lea    -0x48(%rbp),%rdi
lea    -0x50(%rbp),%rcx
lea    -0x30(%rbp),%r8
call   1050 <GetBaseDelta@plt>
mov    -0x30(%rbp),%rdi
mov    -0x38(%rbp),%rsi
call   1080 <_mm_and_si128@plt>
mov    %rax,-0x30(%rbp)
mov    -0x10(%rbp),%rdi
mov    -0x18(%rbp),%rsi
lea    -0x30(%rbp),%rdx
call   1060 <DoSimpleFilter@plt>
mov    -0x10(%rbp),%rax
mov    (%rax),%rdi
mov    -0x40(%rbp),%rsi
call   1070 <_mm_xor_si128@plt>
mov    %rax,%rcx
mov    -0x10(%rbp),%rax
mov    %rcx,(%rax)
mov    -0x18(%rbp),%rax
mov    (%rax),%rdi
mov    -0x40(%rbp),%rsi
call   1070 <_mm_xor_si128@plt>
mov    %rax,%rcx
mov    -0x18(%rbp),%rax
mov    %rcx,(%rax)
add    $0x50,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<DoFilter2>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x28,%rsp
mov    %r8d,%r12d
mov    %rcx,%r13
mov    %rdx,%r14
mov    %rsi,%rbx
mov    %rdi,%rbp
mov    $0x80,%edi
call   1030 <_mm_set1_epi8@plt>
mov    %rax,%r15
mov    0x0(%rbp),%rdi
mov    %rax,%rsi
call   1070 <_mm_xor_si128@plt>
mov    %rax,0x18(%rsp)
mov    0x0(%r13),%rdi
mov    %r15,%rsi
call   1070 <_mm_xor_si128@plt>
mov    %rax,0x10(%rsp)
lea    0x20(%rsp),%r9
mov    %rbp,%rdi
mov    %rbx,%rsi
mov    %r14,%rdx
mov    %r13,%rcx
mov    %r12d,%r8d
call   1040 <NeedsFilter@plt>
mov    (%rbx),%rdi
mov    %r15,%rsi
call   1070 <_mm_xor_si128@plt>
mov    %rax,(%rbx)
mov    (%r14),%rdi
mov    %r15,%rsi
call   1070 <_mm_xor_si128@plt>
mov    %rax,(%r14)
lea    0x18(%rsp),%rdi
lea    0x10(%rsp),%rcx
lea    0x8(%rsp),%rbp
mov    %rbx,%rsi
mov    %r14,%rdx
mov    %rbp,%r8
call   1050 <GetBaseDelta@plt>
mov    0x8(%rsp),%rdi
mov    0x20(%rsp),%rsi
call   1080 <_mm_and_si128@plt>
mov    %rax,0x8(%rsp)
mov    %rbx,%rdi
mov    %r14,%rsi
mov    %rbp,%rdx
call   1060 <DoSimpleFilter@plt>
mov    (%rbx),%rdi
mov    %r15,%rsi
call   1070 <_mm_xor_si128@plt>
mov    %rax,(%rbx)
mov    (%r14),%rdi
mov    %r15,%rsi
call   1070 <_mm_xor_si128@plt>
mov    %rax,(%r14)
add    $0x28,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
define void @DoFilter2(i8** %0, i8** %1, i8** %2, i8** %3, i32 %4) {
%6 = alloca i8**
%7 = alloca i8**
%8 = alloca i8**
%9 = alloca i8**
%10 = alloca i32
%11 = alloca i8*
%12 = alloca i8*
%13 = alloca i8*
%14 = alloca i8*
%15 = alloca i8*
store i8** %0, i8*** %6
store i8** %1, i8*** %7
store i8** %2, i8*** %8
store i8** %3, i8*** %9
store i32 %4, i32* %10
%16 = call i8* @_mm_set1_epi8(i32 128)
store i8* %16, i8** %13
%17 = load i8**, i8*** %6
%18 = load i8*, i8** %17
%19 = load i8*, i8** %13
%20 = call i8* @_mm_xor_si128(i8* %18, i8* %19)
store i8* %20, i8** %14
%21 = load i8**, i8*** %9
%22 = load i8*, i8** %21
%23 = load i8*, i8** %13
%24 = call i8* @_mm_xor_si128(i8* %22, i8* %23)
store i8* %24, i8** %15
%25 = load i8**, i8*** %6
%26 = load i8**, i8*** %7
%27 = load i8**, i8*** %8
%28 = load i8**, i8*** %9
%29 = load i32, i32* %10
%30 = call i32 @NeedsFilter(i8** %25, i8** %26, i8** %27, i8** %28, i32 %29, i8** %12)
%31 = load i8**, i8*** %7
%32 = load i8*, i8** %31
%33 = load i8*, i8** %13
%34 = call i8* @_mm_xor_si128(i8* %32, i8* %33)
%35 = load i8**, i8*** %7
store i8* %34, i8** %35
%36 = load i8**, i8*** %8
%37 = load i8*, i8** %36
%38 = load i8*, i8** %13
%39 = call i8* @_mm_xor_si128(i8* %37, i8* %38)
%40 = load i8**, i8*** %8
store i8* %39, i8** %40
%41 = load i8**, i8*** %7
%42 = load i8**, i8*** %8
%43 = call i32 @GetBaseDelta(i8** %14, i8** %41, i8** %42, i8** %15, i8** %11)
%44 = load i8*, i8** %11
%45 = load i8*, i8** %12
%46 = call i8* @_mm_and_si128(i8* %44, i8* %45)
store i8* %46, i8** %11
%47 = load i8**, i8*** %7
%48 = load i8**, i8*** %8
%49 = call i32 @DoSimpleFilter(i8** %47, i8** %48, i8** %11)
%50 = load i8**, i8*** %7
%51 = load i8*, i8** %50
%52 = load i8*, i8** %13
%53 = call i8* @_mm_xor_si128(i8* %51, i8* %52)
%54 = load i8**, i8*** %7
store i8* %53, i8** %54
%55 = load i8**, i8*** %8
%56 = load i8*, i8** %55
%57 = load i8*, i8** %13
%58 = call i8* @_mm_xor_si128(i8* %56, i8* %57)
%59 = load i8**, i8*** %8
store i8* %58, i8** %59
ret void
}

LLVM IR (-O2):
define void @DoFilter2(i8** %0, i8** %1, i8** %2, i8** %3, i32 %4) {
%6 = alloca i8*
%7 = alloca i8*
%8 = alloca i8*
%9 = alloca i8*
%10 = bitcast i8** %6 to i8*
%11 = bitcast i8** %7 to i8*
%12 = tail call i8* @_mm_set1_epi8(i32 128)
%13 = bitcast i8** %8 to i8*
%14 = load i8*, i8** %0
%15 = tail call i8* @_mm_xor_si128(i8* %14, i8* %12)
store i8* %15, i8** %8
%16 = bitcast i8** %9 to i8*
%17 = load i8*, i8** %3
%18 = tail call i8* @_mm_xor_si128(i8* %17, i8* %12)
store i8* %18, i8** %9
%19 = call i32 @NeedsFilter(i8** %0, i8** %1, i8** %2, i8** %3, i32 %4, i8** %7)
%20 = load i8*, i8** %1
%21 = call i8* @_mm_xor_si128(i8* %20, i8* %12)
store i8* %21, i8** %1
%22 = load i8*, i8** %2
%23 = call i8* @_mm_xor_si128(i8* %22, i8* %12)
store i8* %23, i8** %2
%24 = call i32 @GetBaseDelta(i8** %8, i8** %1, i8** %2, i8** %9, i8** %6)
%25 = load i8*, i8** %6
%26 = load i8*, i8** %7
%27 = call i8* @_mm_and_si128(i8* %25, i8* %26)
store i8* %27, i8** %6
%28 = call i32 @DoSimpleFilter(i8** %1, i8** %2, i8** %6)
%29 = load i8*, i8** %1
%30 = call i8* @_mm_xor_si128(i8* %29, i8* %12)
store i8* %30, i8** %1
%31 = load i8*, i8** %2
%32 = call i8* @_mm_xor_si128(i8* %31, i8* %12)
store i8* %32, i8** %2
ret void
}