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

/* Variables and functions */
int /*<<< orphan*/ vp8_filter(char, int, unsigned char *, unsigned char *,
                              unsigned char *, unsigned char *);
char vp8_filter_mask(unsigned char const, unsigned char const, unsigned char,
                     unsigned char, unsigned char, unsigned char, unsigned char,
                     unsigned char, unsigned char, unsigned char);
int vp8_hevmask(unsigned char const, unsigned char, unsigned char,
                unsigned char, unsigned char);
void vp8_loop_filter_horizontal_edge_simd(unsigned char *s, int p,
                                          const unsigned char *blimit,
                                          const unsigned char *limit,
                                          const unsigned char *thresh,
                                          int count) {
  int hev = 0;
  signed char mask = 0;
  int i = 0;
  do {
    mask = vp8_filter_mask(limit[0], blimit[0], s[-4 * p], s[-3 * p], s[-2 * p],
                           s[-1 * p], s[0 * p], s[1 * p], s[2 * p], s[3 * p]);
    hev = vp8_hevmask(thresh[0], s[-2 * p], s[-1 * p], s[0 * p], s[1 * p]);
    vp8_filter(mask, hev, s - 2 * p, s - 1 * p, s, s + 1 * p);
    ++s;
  } while (++i < count * 8);
}


x86 assembly (clang, -O0):
<vp8_loop_filter_horizontal_edge_simd>:
push   %rbp
mov    %rsp,%rbp
push   %r14
push   %rbx
sub    $0x60,%rsp
mov    %rdi,-0x18(%rbp)
mov    %esi,-0x1c(%rbp)
mov    %rdx,-0x28(%rbp)
mov    %rcx,-0x30(%rbp)
mov    %r8,-0x38(%rbp)
mov    %r9d,-0x3c(%rbp)
movl   $0x0,-0x40(%rbp)
movb   $0x0,-0x41(%rbp)
movl   $0x0,-0x48(%rbp)
mov    -0x30(%rbp),%rax
mov    (%rax),%dil
mov    -0x28(%rbp),%rax
mov    (%rax),%sil
mov    -0x18(%rbp),%rax
imul   $0xfffffffc,-0x1c(%rbp),%ecx
movslq %ecx,%rcx
mov    (%rax,%rcx,1),%dl
mov    -0x18(%rbp),%rax
imul   $0xfffffffd,-0x1c(%rbp),%ecx
movslq %ecx,%rcx
mov    (%rax,%rcx,1),%cl
mov    -0x18(%rbp),%rax
imul   $0xfffffffe,-0x1c(%rbp),%r8d
ff
movslq %r8d,%r8
mov    (%rax,%r8,1),%r8b
mov    -0x18(%rbp),%rax
imul   $0xffffffff,-0x1c(%rbp),%r9d
ff
movslq %r9d,%r9
mov    (%rax,%r9,1),%r9b
mov    -0x18(%rbp),%rax
imul   $0x0,-0x1c(%rbp),%r10d
movslq %r10d,%r10
mov    (%rax,%r10,1),%r14b
mov    -0x18(%rbp),%rax
mov    -0x1c(%rbp),%r10d
shl    $0x0,%r10d
movslq %r10d,%r10
mov    (%rax,%r10,1),%bl
mov    -0x18(%rbp),%rax
mov    -0x1c(%rbp),%r10d
shl    $0x1,%r10d
movslq %r10d,%r10
mov    (%rax,%r10,1),%r11b
mov    -0x18(%rbp),%rax
imul   $0x3,-0x1c(%rbp),%r10d
movslq %r10d,%r10
movzbl %dil,%edi
movzbl %sil,%esi
movzbl %dl,%edx
movzbl %cl,%ecx
movzbl %r8b,%r8d
movzbl %r9b,%r9d
movzbl %r14b,%r14d
mov    %r14d,(%rsp)
movzbl %bl,%ebx
mov    %ebx,0x8(%rsp)
movzbl %r11b,%r11d
mov    %r11d,0x10(%rsp)
movzbl (%rax,%r10,1),%eax
mov    %eax,0x18(%rsp)
call   1040 <vp8_filter_mask@plt>
mov    %al,-0x41(%rbp)
mov    -0x38(%rbp),%rax
mov    (%rax),%dil
mov    -0x18(%rbp),%rax
imul   $0xfffffffe,-0x1c(%rbp),%ecx
movslq %ecx,%rcx
mov    (%rax,%rcx,1),%sil
mov    -0x18(%rbp),%rax
imul   $0xffffffff,-0x1c(%rbp),%ecx
movslq %ecx,%rcx
mov    (%rax,%rcx,1),%dl
mov    -0x18(%rbp),%rax
imul   $0x0,-0x1c(%rbp),%ecx
movslq %ecx,%rcx
mov    (%rax,%rcx,1),%cl
mov    -0x18(%rbp),%rax
mov    -0x1c(%rbp),%r8d
shl    $0x0,%r8d
movslq %r8d,%r8
movzbl %dil,%edi
movzbl %sil,%esi
movzbl %dl,%edx
movzbl %cl,%ecx
movzbl (%rax,%r8,1),%r8d
call   1050 <vp8_hevmask@plt>
mov    %eax,-0x40(%rbp)
mov    -0x41(%rbp),%al
mov    -0x40(%rbp),%esi
mov    -0x18(%rbp),%rdx
mov    -0x1c(%rbp),%ecx
shl    $0x1,%ecx
movslq %ecx,%rdi
xor    %ecx,%ecx
sub    %rdi,%rcx
add    %rcx,%rdx
mov    -0x18(%rbp),%rcx
mov    -0x1c(%rbp),%edi
shl    $0x0,%edi
movslq %edi,%r8
xor    %edi,%edi
sub    %r8,%rdi
add    %rdi,%rcx
mov    -0x18(%rbp),%r8
mov    -0x18(%rbp),%r9
mov    -0x1c(%rbp),%edi
shl    $0x0,%edi
movslq %edi,%rdi
add    %rdi,%r9
movsbl %al,%edi
call   1030 <vp8_filter@plt>
mov    -0x18(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x18(%rbp)
mov    -0x48(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x48(%rbp)
mov    -0x3c(%rbp),%ecx
shl    $0x3,%ecx
cmp    %ecx,%eax
jl     1164 <vp8_loop_filter_horizontal_edge_simd+0x34>
add    $0x60,%rsp
pop    %rbx
pop    %r14
pop    %rbp
ret

x86 assembly (clang, -O2):
<vp8_loop_filter_horizontal_edge_simd>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x78,%rsp
mov    %r8,0x58(%rsp)
mov    %rcx,0x50(%rsp)
mov    %rdx,0x48(%rsp)
movslq %esi,%rsi
lea    0x0(,%rsi,4),%rax
lea    (%rsi,%rsi,2),%rcx
lea    (%rsi,%rsi,1),%rdx
shl    $0x3,%r9d
cmp    $0x2,%r9d
mov    $0x1,%ebp
cmovge %r9d,%ebp
mov    %rbp,0x30(%rsp)
mov    %rdi,%rbp
sub    %rsi,%rbp
mov    %rbp,0x28(%rsp)
mov    %rdi,%rbp
sub    %rdx,%rbp
mov    %rbp,0x20(%rsp)
lea    (%rdi,%rcx,1),%rdx
mov    %rdx,0x18(%rsp)
lea    (%rdi,%rsi,2),%rdx
mov    %rdx,0x10(%rsp)
add    %rdi,%rsi
mov    %rsi,0x38(%rsp)
mov    %rdi,%rdx
sub    %rcx,%rdx
mov    %rdx,0x8(%rsp)
mov    %rdi,0x40(%rsp)
sub    %rax,%rdi
mov    %rdi,(%rsp)
xor    %r12d,%r12d
mov    0x40(%rsp),%r14
mov    0x20(%rsp),%r15
mov    0x28(%rsp),%rbp
mov    0x38(%rsp),%r13
cs nopw 0x0(%rax,%rax,1)
xchg   %ax,%ax
lea    (%r14,%r12,1),%rax
mov    %rax,0x70(%rsp)
mov    0x50(%rsp),%rax
movzbl (%rax),%edi
mov    0x48(%rsp),%rax
movzbl (%rax),%esi
mov    (%rsp),%rax
movzbl (%rax,%r12,1),%edx
mov    0x8(%rsp),%rax
movzbl (%rax,%r12,1),%ecx
movzbl (%r15,%r12,1),%r8d
lea    0x0(%rbp,%r12,1),%rax
mov    %rax,0x68(%rsp)
movzbl 0x0(%rbp,%r12,1),%r9d
movzbl (%r14,%r12,1),%r10d
lea    0x0(%r13,%r12,1),%rax
mov    %rax,0x60(%rsp)
movzbl 0x0(%r13,%r12,1),%r11d
mov    0x10(%rsp),%rax
movzbl (%rax,%r12,1),%ebx
mov    0x18(%rsp),%rax
movzbl (%rax,%r12,1),%eax
push   %rax
push   %rbx
push   %r11
push   %r10
call   1040 <vp8_filter_mask@plt>
add    $0x20,%rsp
mov    %eax,%ebx
mov    0x58(%rsp),%rax
movzbl (%rax),%edi
movzbl (%r15,%r12,1),%esi
movzbl 0x0(%rbp,%r12,1),%edx
movzbl (%r14,%r12,1),%ecx
movzbl 0x0(%r13,%r12,1),%r8d
call   1050 <vp8_hevmask@plt>
lea    (%r15,%r12,1),%rdx
movsbl %bl,%edi
mov    %eax,%esi
mov    0x68(%rsp),%rcx
mov    0x70(%rsp),%r8
mov    0x60(%rsp),%r9
call   1030 <vp8_filter@plt>
add    $0x1,%r12
cmp    %r12d,0x30(%rsp)
jne    11e0 <vp8_loop_filter_horizontal_edge_simd+0xb0>
add    $0x78,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
define void @vp8_loop_filter_horizontal_edge_simd(i8* %0, i32 %1, i8* %2, i8* %3, i8* %4, i32 %5) {
%7 = alloca i8*
%8 = alloca i32
%9 = alloca i8*
%10 = alloca i8*
%11 = alloca i8*
%12 = alloca i32
%13 = alloca i32
%14 = alloca i8
%15 = alloca i32
store i8* %0, i8** %7
store i32 %1, i32* %8
store i8* %2, i8** %9
store i8* %3, i8** %10
store i8* %4, i8** %11
store i32 %5, i32* %12
store i32 0, i32* %13
store i8 0, i8* %14
store i32 0, i32* %15
br label %16
16: ; preds = %123, %6
%17 = load i8*, i8** %10
%18 = getelementptr inbounds i8, i8* %17, i64 0
%19 = load i8, i8* %18
%20 = load i8*, i8** %9
%21 = getelementptr inbounds i8, i8* %20, i64 0
%22 = load i8, i8* %21
%23 = load i8*, i8** %7
%24 = load i32, i32* %8
%25 = mul nsw i32 -4, %24
%26 = sext i32 %25 to i64
%27 = getelementptr inbounds i8, i8* %23, i64 %26
%28 = load i8, i8* %27
%29 = load i8*, i8** %7
%30 = load i32, i32* %8
%31 = mul nsw i32 -3, %30
%32 = sext i32 %31 to i64
%33 = getelementptr inbounds i8, i8* %29, i64 %32
%34 = load i8, i8* %33
%35 = load i8*, i8** %7
%36 = load i32, i32* %8
%37 = mul nsw i32 -2, %36
%38 = sext i32 %37 to i64
%39 = getelementptr inbounds i8, i8* %35, i64 %38
%40 = load i8, i8* %39
%41 = load i8*, i8** %7
%42 = load i32, i32* %8
%43 = mul nsw i32 -1, %42
%44 = sext i32 %43 to i64
%45 = getelementptr inbounds i8, i8* %41, i64 %44
%46 = load i8, i8* %45
%47 = load i8*, i8** %7
%48 = load i32, i32* %8
%49 = mul nsw i32 0, %48
%50 = sext i32 %49 to i64
%51 = getelementptr inbounds i8, i8* %47, i64 %50
%52 = load i8, i8* %51
%53 = load i8*, i8** %7
%54 = load i32, i32* %8
%55 = mul nsw i32 1, %54
%56 = sext i32 %55 to i64
%57 = getelementptr inbounds i8, i8* %53, i64 %56
%58 = load i8, i8* %57
%59 = load i8*, i8** %7
%60 = load i32, i32* %8
%61 = mul nsw i32 2, %60
%62 = sext i32 %61 to i64
%63 = getelementptr inbounds i8, i8* %59, i64 %62
%64 = load i8, i8* %63
%65 = load i8*, i8** %7
%66 = load i32, i32* %8
%67 = mul nsw i32 3, %66
%68 = sext i32 %67 to i64
%69 = getelementptr inbounds i8, i8* %65, i64 %68
%70 = load i8, i8* %69
%71 = call signext i8 @vp8_filter_mask(i8 zeroext %19, i8 zeroext %22, i8 zeroext %28, i8 zeroext %34, i8 zeroext %40, i8 zeroext %46, i8 zeroext %52, i8 zeroext %58, i8 zeroext %64, i8 zeroext %70)
store i8 %71, i8* %14
%72 = load i8*, i8** %11
%73 = getelementptr inbounds i8, i8* %72, i64 0
%74 = load i8, i8* %73
%75 = load i8*, i8** %7
%76 = load i32, i32* %8
%77 = mul nsw i32 -2, %76
%78 = sext i32 %77 to i64
%79 = getelementptr inbounds i8, i8* %75, i64 %78
%80 = load i8, i8* %79
%81 = load i8*, i8** %7
%82 = load i32, i32* %8
%83 = mul nsw i32 -1, %82
%84 = sext i32 %83 to i64
%85 = getelementptr inbounds i8, i8* %81, i64 %84
%86 = load i8, i8* %85
%87 = load i8*, i8** %7
%88 = load i32, i32* %8
%89 = mul nsw i32 0, %88
%90 = sext i32 %89 to i64
%91 = getelementptr inbounds i8, i8* %87, i64 %90
%92 = load i8, i8* %91
%93 = load i8*, i8** %7
%94 = load i32, i32* %8
%95 = mul nsw i32 1, %94
%96 = sext i32 %95 to i64
%97 = getelementptr inbounds i8, i8* %93, i64 %96
%98 = load i8, i8* %97
%99 = call i32 @vp8_hevmask(i8 zeroext %74, i8 zeroext %80, i8 zeroext %86, i8 zeroext %92, i8 zeroext %98)
store i32 %99, i32* %13
%100 = load i8, i8* %14
%101 = load i32, i32* %13
%102 = load i8*, i8** %7
%103 = load i32, i32* %8
%104 = mul nsw i32 2, %103
%105 = sext i32 %104 to i64
%106 = sub i64 0, %105
%107 = getelementptr inbounds i8, i8* %102, i64 %106
%108 = load i8*, i8** %7
%109 = load i32, i32* %8
%110 = mul nsw i32 1, %109
%111 = sext i32 %110 to i64
%112 = sub i64 0, %111
%113 = getelementptr inbounds i8, i8* %108, i64 %112
%114 = load i8*, i8** %7
%115 = load i8*, i8** %7
%116 = load i32, i32* %8
%117 = mul nsw i32 1, %116
%118 = sext i32 %117 to i64
%119 = getelementptr inbounds i8, i8* %115, i64 %118
%120 = call i32 @vp8_filter(i8 signext %100, i32 %101, i8* %107, i8* %113, i8* %114, i8* %119)
%121 = load i8*, i8** %7
%122 = getelementptr inbounds i8, i8* %121, i32 1
store i8* %122, i8** %7
br label %123
123: ; preds = %16
%124 = load i32, i32* %15
%125 = add nsw i32 %124, 1
store i32 %125, i32* %15
%126 = load i32, i32* %12
%127 = mul nsw i32 %126, 8
%128 = icmp slt i32 %125, %127
br i1 %128, label %16, label %129
129: ; preds = %123
ret void
}

LLVM IR (-O2):
define void @vp8_loop_filter_horizontal_edge_simd(i8* %0, i32 %1, i8* nocapture %2, i8* nocapture %3, i8* nocapture %4, i32 %5) {
%7 = mul nsw i32 %1, -4
%8 = sext i32 %7 to i64
%9 = mul nsw i32 %1, -3
%10 = sext i32 %9 to i64
%11 = mul nsw i32 %1, -2
%12 = sext i32 %11 to i64
%13 = sub nsw i32 0, %1
%14 = sext i32 %13 to i64
%15 = sext i32 %1 to i64
%16 = shl nsw i32 %1, 1
%17 = sext i32 %16 to i64
%18 = mul nsw i32 %1, 3
%19 = sext i32 %18 to i64
%20 = sub nsw i64 0, %17
%21 = sub nsw i64 0, %15
%22 = shl i32 %5, 3
%23 = call i32 @llvm.smax.i32(i32 %22, i32 1)
br label %24
24: ; preds = %24, %6
%25 = phi i8* [ %0, %6 ], [ %54, %24 ]
%26 = phi i32 [ 0, %6 ], [ %55, %24 ]
%27 = load i8, i8* %3
%28 = load i8, i8* %2
%29 = getelementptr inbounds i8, i8* %25, i64 %8
%30 = load i8, i8* %29
%31 = getelementptr inbounds i8, i8* %25, i64 %10
%32 = load i8, i8* %31
%33 = getelementptr inbounds i8, i8* %25, i64 %12
%34 = load i8, i8* %33
%35 = getelementptr inbounds i8, i8* %25, i64 %14
%36 = load i8, i8* %35
%37 = load i8, i8* %25
%38 = getelementptr inbounds i8, i8* %25, i64 %15
%39 = load i8, i8* %38
%40 = getelementptr inbounds i8, i8* %25, i64 %17
%41 = load i8, i8* %40
%42 = getelementptr inbounds i8, i8* %25, i64 %19
%43 = load i8, i8* %42
%44 = tail call signext i8 @vp8_filter_mask(i8 zeroext %27, i8 zeroext %28, i8 zeroext %30, i8 zeroext %32, i8 zeroext %34, i8 zeroext %36, i8 zeroext %37, i8 zeroext %39, i8 zeroext %41, i8 zeroext %43)
%45 = load i8, i8* %4
%46 = load i8, i8* %33
%47 = load i8, i8* %35
%48 = load i8, i8* %25
%49 = load i8, i8* %38
%50 = tail call i32 @vp8_hevmask(i8 zeroext %45, i8 zeroext %46, i8 zeroext %47, i8 zeroext %48, i8 zeroext %49)
%51 = getelementptr inbounds i8, i8* %25, i64 %20
%52 = getelementptr inbounds i8, i8* %25, i64 %21
%53 = tail call i32 @vp8_filter(i8 signext %44, i32 %50, i8* %51, i8* %52, i8* %25, i8* %38)
%54 = getelementptr inbounds i8, i8* %25, i64 1
%55 = add nuw nsw i32 %26, 1
%56 = icmp eq i32 %55, %23
br i1 %56, label %57, label %24
57: ; preds = %24
ret void
}