#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 */
void *_mm_cmpeq_epi8(void *, void *const);
void *_mm_or_si128(void *const, void *const);
void *_mm_set1_epi8(int);
void *_mm_setzero_si128();
void *const _mm_subs_epu8(void *const, void *const);
void GetNotHEV(const __m128i *const p1, const __m128i *const p0,
               const __m128i *const q0, const __m128i *const q1, int hev_thresh,
               __m128i *const not_hev) {
  const __m128i zero = _mm_setzero_si128();
  const __m128i t_1 =
      _mm_or_si128(_mm_subs_epu8((*p0), (*p1)), _mm_subs_epu8((*p1), (*p0)));
  const __m128i t_2 =
      _mm_or_si128(_mm_subs_epu8((*q0), (*q1)), _mm_subs_epu8((*q1), (*q0)));
  const __m128i h = _mm_set1_epi8(hev_thresh);
  const __m128i t_3 = _mm_subs_epu8(t_1, h);
  const __m128i t_4 = _mm_subs_epu8(t_2, h);
  *not_hev = _mm_or_si128(t_3, t_4);
  *not_hev = _mm_cmpeq_epi8(*not_hev, zero);
}


x86 assembly (clang, -O0):
<GetNotHEV>:
push   %rbp
mov    %rsp,%rbp
sub    $0x70,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
mov    %rcx,-0x20(%rbp)
mov    %r8d,-0x24(%rbp)
mov    %r9,-0x30(%rbp)
mov    $0x0,%al
call   1030 <_mm_setzero_si128@plt>
mov    %rax,-0x38(%rbp)
mov    -0x10(%rbp),%rax
mov    (%rax),%rdi
mov    -0x8(%rbp),%rax
mov    (%rax),%rsi
call   1050 <_mm_subs_epu8@plt>
mov    %rax,-0x70(%rbp)
mov    -0x8(%rbp),%rax
mov    (%rax),%rdi
mov    -0x10(%rbp),%rax
mov    (%rax),%rsi
call   1050 <_mm_subs_epu8@plt>
mov    -0x70(%rbp),%rdi
mov    %rax,%rsi
call   1060 <_mm_or_si128@plt>
mov    %rax,-0x40(%rbp)
mov    -0x18(%rbp),%rax
mov    (%rax),%rdi
mov    -0x20(%rbp),%rax
mov    (%rax),%rsi
call   1050 <_mm_subs_epu8@plt>
mov    %rax,-0x68(%rbp)
mov    -0x20(%rbp),%rax
mov    (%rax),%rdi
mov    -0x18(%rbp),%rax
mov    (%rax),%rsi
call   1050 <_mm_subs_epu8@plt>
mov    -0x68(%rbp),%rdi
mov    %rax,%rsi
call   1060 <_mm_or_si128@plt>
mov    %rax,-0x48(%rbp)
mov    -0x24(%rbp),%edi
call   1040 <_mm_set1_epi8@plt>
mov    %rax,-0x50(%rbp)
mov    -0x40(%rbp),%rdi
mov    -0x50(%rbp),%rsi
call   1050 <_mm_subs_epu8@plt>
mov    %rax,-0x58(%rbp)
mov    -0x48(%rbp),%rdi
mov    -0x50(%rbp),%rsi
call   1050 <_mm_subs_epu8@plt>
mov    %rax,-0x60(%rbp)
mov    -0x58(%rbp),%rdi
mov    -0x60(%rbp),%rsi
call   1060 <_mm_or_si128@plt>
mov    %rax,%rcx
mov    -0x30(%rbp),%rax
mov    %rcx,(%rax)
mov    -0x30(%rbp),%rax
mov    (%rax),%rdi
mov    -0x38(%rbp),%rsi
call   1070 <_mm_cmpeq_epi8@plt>
mov    %rax,%rcx
mov    -0x30(%rbp),%rax
mov    %rcx,(%rax)
add    $0x70,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<GetNotHEV>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x18,%rsp
mov    %r9,%r12
mov    %r8d,0xc(%rsp)
mov    %rcx,%r13
mov    %rdx,%rbp
mov    %rsi,%rbx
mov    %rdi,%r14
xor    %eax,%eax
call   1030 <_mm_setzero_si128@plt>
mov    %rax,0x10(%rsp)
mov    (%rbx),%rdi
mov    (%r14),%rsi
call   1050 <_mm_subs_epu8@plt>
mov    %rax,%r15
mov    (%r14),%rdi
mov    (%rbx),%rsi
call   1050 <_mm_subs_epu8@plt>
mov    %r15,%rdi
mov    %rax,%rsi
call   1060 <_mm_or_si128@plt>
mov    %rax,%r14
mov    0x0(%rbp),%rdi
mov    0x0(%r13),%rsi
call   1050 <_mm_subs_epu8@plt>
mov    %rax,%rbx
mov    0x0(%r13),%rdi
mov    0x0(%rbp),%rsi
call   1050 <_mm_subs_epu8@plt>
mov    %rbx,%rdi
mov    %rax,%rsi
call   1060 <_mm_or_si128@plt>
mov    %rax,%r15
mov    0xc(%rsp),%edi
call   1040 <_mm_set1_epi8@plt>
mov    %rax,%rbp
mov    %r14,%rdi
mov    %rax,%rsi
call   1050 <_mm_subs_epu8@plt>
mov    %rax,%rbx
mov    %r15,%rdi
mov    %rbp,%rsi
call   1050 <_mm_subs_epu8@plt>
mov    %rbx,%rdi
mov    %rax,%rsi
call   1060 <_mm_or_si128@plt>
mov    %rax,(%r12)
mov    %rax,%rdi
mov    0x10(%rsp),%rsi
call   1070 <_mm_cmpeq_epi8@plt>
mov    %rax,(%r12)
add    $0x18,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

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

LLVM IR (-O2):
define void @GetNotHEV(i8** nocapture %0, i8** nocapture %1, i8** nocapture %2, i8** nocapture %3, i32 %4, i8** nocapture writeonly %5) {
%7 = tail call i8* (...) @_mm_setzero_si128()
%8 = load i8*, i8** %1
%9 = load i8*, i8** %0
%10 = tail call i8* @_mm_subs_epu8(i8* %8, i8* %9)
%11 = load i8*, i8** %0
%12 = load i8*, i8** %1
%13 = tail call i8* @_mm_subs_epu8(i8* %11, i8* %12)
%14 = tail call i8* @_mm_or_si128(i8* %10, i8* %13)
%15 = load i8*, i8** %2
%16 = load i8*, i8** %3
%17 = tail call i8* @_mm_subs_epu8(i8* %15, i8* %16)
%18 = load i8*, i8** %3
%19 = load i8*, i8** %2
%20 = tail call i8* @_mm_subs_epu8(i8* %18, i8* %19)
%21 = tail call i8* @_mm_or_si128(i8* %17, i8* %20)
%22 = tail call i8* @_mm_set1_epi8(i32 %4)
%23 = tail call i8* @_mm_subs_epu8(i8* %14, i8* %22)
%24 = tail call i8* @_mm_subs_epu8(i8* %21, i8* %22)
%25 = tail call i8* @_mm_or_si128(i8* %23, i8* %24)
store i8* %25, i8** %5
%26 = tail call i8* @_mm_cmpeq_epi8(i8* %25, i8* %7)
store i8* %26, i8** %5
ret void
}