#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_adds_epi8(int /*<<< orphan*/ const,
                                 int /*<<< orphan*/ const);
int /*<<< orphan*/ _mm_subs_epi8(int /*<<< orphan*/ const,
                                 int /*<<< orphan*/ const);
void GetBaseDelta(const __m128i *const p1, const __m128i *const p0,
                  const __m128i *const q0, const __m128i *const q1,
                  __m128i *const delta) {
  const __m128i p1_q1 = _mm_subs_epi8(*p1, *q1);
  const __m128i q0_p0 = _mm_subs_epi8(*q0, *p0);
  const __m128i s1 = _mm_adds_epi8(p1_q1, q0_p0);
  const __m128i s2 = _mm_adds_epi8(q0_p0, s1);
  const __m128i s3 = _mm_adds_epi8(q0_p0, s2);
  *delta = s3;
}


x86 assembly (clang, -O0):
<GetBaseDelta>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
mov    %rcx,-0x20(%rbp)
mov    %r8,-0x28(%rbp)
mov    -0x8(%rbp),%rax
mov    (%rax),%edi
mov    -0x20(%rbp),%rax
mov    (%rax),%esi
call   1040 <_mm_subs_epi8@plt>
mov    %eax,-0x2c(%rbp)
mov    -0x18(%rbp),%rax
mov    (%rax),%edi
mov    -0x10(%rbp),%rax
mov    (%rax),%esi
call   1040 <_mm_subs_epi8@plt>
mov    %eax,-0x30(%rbp)
mov    -0x2c(%rbp),%edi
mov    -0x30(%rbp),%esi
call   1030 <_mm_adds_epi8@plt>
mov    %eax,-0x34(%rbp)
mov    -0x30(%rbp),%edi
mov    -0x34(%rbp),%esi
call   1030 <_mm_adds_epi8@plt>
mov    %eax,-0x38(%rbp)
mov    -0x30(%rbp),%edi
mov    -0x38(%rbp),%esi
call   1030 <_mm_adds_epi8@plt>
mov    %eax,-0x3c(%rbp)
mov    -0x3c(%rbp),%ecx
mov    -0x28(%rbp),%rax
mov    %ecx,(%rax)
add    $0x40,%rsp
pop    %rbp
ret

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

LLVM IR (-O0):
define void @GetBaseDelta(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
%12 = alloca i32
%13 = alloca i32
%14 = alloca i32
%15 = 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
%16 = load i32*, i32** %6
%17 = load i32, i32* %16
%18 = load i32*, i32** %9
%19 = load i32, i32* %18
%20 = call i32 @_mm_subs_epi8(i32 %17, i32 %19)
store i32 %20, i32* %11
%21 = load i32*, i32** %8
%22 = load i32, i32* %21
%23 = load i32*, i32** %7
%24 = load i32, i32* %23
%25 = call i32 @_mm_subs_epi8(i32 %22, i32 %24)
store i32 %25, i32* %12
%26 = load i32, i32* %11
%27 = load i32, i32* %12
%28 = call i32 @_mm_adds_epi8(i32 %26, i32 %27)
store i32 %28, i32* %13
%29 = load i32, i32* %12
%30 = load i32, i32* %13
%31 = call i32 @_mm_adds_epi8(i32 %29, i32 %30)
store i32 %31, i32* %14
%32 = load i32, i32* %12
%33 = load i32, i32* %14
%34 = call i32 @_mm_adds_epi8(i32 %32, i32 %33)
store i32 %34, i32* %15
%35 = load i32, i32* %15
%36 = load i32*, i32** %10
store i32 %35, i32* %36
ret void
}

LLVM IR (-O2):
define void @GetBaseDelta(i32* nocapture %0, i32* nocapture %1, i32* nocapture %2, i32* nocapture %3, i32* nocapture writeonly %4) {
%6 = load i32, i32* %0
%7 = load i32, i32* %3
%8 = tail call i32 @_mm_subs_epi8(i32 %6, i32 %7)
%9 = load i32, i32* %2
%10 = load i32, i32* %1
%11 = tail call i32 @_mm_subs_epi8(i32 %9, i32 %10)
%12 = tail call i32 @_mm_adds_epi8(i32 %8, i32 %11)
%13 = tail call i32 @_mm_adds_epi8(i32 %11, i32 %12)
%14 = tail call i32 @_mm_adds_epi8(i32 %11, i32 %13)
store i32 %14, i32* %4
ret void
}