#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 */
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);
char vp8_hevmask(unsigned char const, unsigned char, unsigned char,
                 unsigned char, unsigned char);
int /*<<< orphan*/ vp8_mbfilter(char, char, unsigned char *, unsigned char *,
                                unsigned char *, unsigned char *,
                                unsigned char *, unsigned char *);
void vp8_mbloop_filter_vertical_edge_simd(unsigned char *s, int p,
                                          const unsigned char *blimit,
                                          const unsigned char *limit,
                                          const unsigned char *thresh,
                                          int count) {
  signed char hev = 0;
  signed char mask = 0;
  int i = 0;
  do {
    mask = vp8_filter_mask(limit[0], blimit[0], s[-4], s[-3], s[-2], s[-1],
                           s[0], s[1], s[2], s[3]);
    hev = vp8_hevmask(thresh[0], s[-2], s[-1], s[0], s[1]);
    vp8_mbfilter(mask, hev, s - 3, s - 2, s - 1, s, s + 1, s + 2);
    s += p;
  } while (++i < count * 8);
}


x86 assembly (clang, -O0):
<vp8_mbloop_filter_vertical_edge_simd>:
push   %rbp
mov    %rsp,%rbp
push   %rbx
sub    $0x58,%rsp
mov    %rdi,-0x10(%rbp)
mov    %esi,-0x14(%rbp)
mov    %rdx,-0x20(%rbp)
mov    %rcx,-0x28(%rbp)
mov    %r8,-0x30(%rbp)
mov    %r9d,-0x34(%rbp)
movb   $0x0,-0x35(%rbp)
movb   $0x0,-0x36(%rbp)
movl   $0x0,-0x3c(%rbp)
mov    -0x28(%rbp),%rax
mov    (%rax),%dil
mov    -0x20(%rbp),%rax
mov    (%rax),%sil
mov    -0x10(%rbp),%rax
mov    -0x4(%rax),%dl
mov    -0x10(%rbp),%rax
mov    -0x3(%rax),%cl
mov    -0x10(%rbp),%rax
mov    -0x2(%rax),%r8b
mov    -0x10(%rbp),%rax
mov    -0x1(%rax),%r9b
mov    -0x10(%rbp),%rax
mov    (%rax),%bl
mov    -0x10(%rbp),%rax
mov    0x1(%rax),%r11b
mov    -0x10(%rbp),%rax
mov    0x2(%rax),%r10b
mov    -0x10(%rbp),%rax
movzbl %dil,%edi
movzbl %sil,%esi
movzbl %dl,%edx
movzbl %cl,%ecx
movzbl %r8b,%r8d
movzbl %r9b,%r9d
movzbl %bl,%ebx
mov    %ebx,(%rsp)
movzbl %r11b,%r11d
mov    %r11d,0x8(%rsp)
movzbl %r10b,%r10d
mov    %r10d,0x10(%rsp)
movzbl 0x3(%rax),%eax
mov    %eax,0x18(%rsp)
call   1040 <vp8_filter_mask@plt>
mov    %al,-0x36(%rbp)
mov    -0x30(%rbp),%rax
mov    (%rax),%dil
mov    -0x10(%rbp),%rax
mov    -0x2(%rax),%sil
mov    -0x10(%rbp),%rax
mov    -0x1(%rax),%dl
mov    -0x10(%rbp),%rax
mov    (%rax),%cl
mov    -0x10(%rbp),%rax
movzbl %dil,%edi
movzbl %sil,%esi
movzbl %dl,%edx
movzbl %cl,%ecx
movzbl 0x1(%rax),%r8d
call   1050 <vp8_hevmask@plt>
mov    %al,-0x35(%rbp)
mov    -0x36(%rbp),%dil
mov    -0x35(%rbp),%sil
mov    -0x10(%rbp),%rdx
add    $0xfffffffffffffffd,%rdx
mov    -0x10(%rbp),%rcx
add    $0xfffffffffffffffe,%rcx
mov    -0x10(%rbp),%r8
add    $0xffffffffffffffff,%r8
mov    -0x10(%rbp),%r9
mov    -0x10(%rbp),%r10
add    $0x1,%r10
mov    -0x10(%rbp),%rax
add    $0x2,%rax
movsbl %dil,%edi
movsbl %sil,%esi
mov    %r10,(%rsp)
mov    %rax,0x8(%rsp)
call   1030 <vp8_mbfilter@plt>
mov    -0x14(%rbp),%ecx
mov    -0x10(%rbp),%rax
movslq %ecx,%rcx
add    %rcx,%rax
mov    %rax,-0x10(%rbp)
mov    -0x3c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x3c(%rbp)
mov    -0x34(%rbp),%ecx
shl    $0x3,%ecx
cmp    %ecx,%eax
jl     115f <vp8_mbloop_filter_vertical_edge_simd+0x2f>
add    $0x58,%rsp
pop    %rbx
pop    %rbp
ret

x86 assembly (clang, -O2):
<vp8_mbloop_filter_vertical_edge_simd>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x38,%rsp
mov    %r8,0x18(%rsp)
mov    %rcx,0x10(%rsp)
mov    %rdx,0x8(%rsp)
mov    %rdi,%rbx
movslq %esi,%rax
mov    %rax,(%rsp)
shl    $0x3,%r9d
cmp    $0x2,%r9d
mov    $0x1,%r12d
cmovge %r9d,%r12d
nopl   0x0(%rax)
mov    0x10(%rsp),%rax
movzbl (%rax),%edi
mov    0x8(%rsp),%rax
movzbl (%rax),%esi
movzbl -0x4(%rbx),%edx
lea    -0x3(%rbx),%rax
mov    %rax,0x30(%rsp)
movzbl -0x3(%rbx),%ecx
lea    -0x2(%rbx),%rax
mov    %rax,0x28(%rsp)
movzbl -0x2(%rbx),%r8d
lea    -0x1(%rbx),%r14
movzbl -0x1(%rbx),%r9d
movzbl (%rbx),%r10d
lea    0x1(%rbx),%rax
mov    %rax,0x20(%rsp)
movzbl 0x1(%rbx),%r11d
lea    0x2(%rbx),%r13
movzbl 0x2(%rbx),%eax
movzbl 0x3(%rbx),%ebp
push   %rbp
push   %rax
push   %r11
push   %r10
call   1040 <vp8_filter_mask@plt>
add    $0x20,%rsp
mov    %eax,%r15d
mov    0x18(%rsp),%rax
movzbl (%rax),%edi
movzbl -0x2(%rbx),%esi
movzbl -0x1(%rbx),%edx
movzbl (%rbx),%ecx
movzbl 0x1(%rbx),%r8d
call   1050 <vp8_hevmask@plt>
movsbl %r15b,%edi
movsbl %al,%esi
mov    0x30(%rsp),%rdx
mov    0x28(%rsp),%rcx
mov    %r14,%r8
mov    %rbx,%r9
push   %r13
push   0x28(%rsp)
call   1030 <vp8_mbfilter@plt>
add    $0x10,%rsp
add    (%rsp),%rbx
add    $0xffffffff,%r12d
jne    1170 <vp8_mbloop_filter_vertical_edge_simd+0x40>
add    $0x38,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
define void @vp8_mbloop_filter_vertical_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 i8
%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 i8 0, i8* %13
store i8 0, i8* %14
store i32 0, i32* %15
br label %16
16: ; preds = %82, %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 = getelementptr inbounds i8, i8* %23, i64 -4
%25 = load i8, i8* %24
%26 = load i8*, i8** %7
%27 = getelementptr inbounds i8, i8* %26, i64 -3
%28 = load i8, i8* %27
%29 = load i8*, i8** %7
%30 = getelementptr inbounds i8, i8* %29, i64 -2
%31 = load i8, i8* %30
%32 = load i8*, i8** %7
%33 = getelementptr inbounds i8, i8* %32, i64 -1
%34 = load i8, i8* %33
%35 = load i8*, i8** %7
%36 = getelementptr inbounds i8, i8* %35, i64 0
%37 = load i8, i8* %36
%38 = load i8*, i8** %7
%39 = getelementptr inbounds i8, i8* %38, i64 1
%40 = load i8, i8* %39
%41 = load i8*, i8** %7
%42 = getelementptr inbounds i8, i8* %41, i64 2
%43 = load i8, i8* %42
%44 = load i8*, i8** %7
%45 = getelementptr inbounds i8, i8* %44, i64 3
%46 = load i8, i8* %45
%47 = call signext i8 @vp8_filter_mask(i8 zeroext %19, i8 zeroext %22, i8 zeroext %25, i8 zeroext %28, i8 zeroext %31, i8 zeroext %34, i8 zeroext %37, i8 zeroext %40, i8 zeroext %43, i8 zeroext %46)
store i8 %47, i8* %14
%48 = load i8*, i8** %11
%49 = getelementptr inbounds i8, i8* %48, i64 0
%50 = load i8, i8* %49
%51 = load i8*, i8** %7
%52 = getelementptr inbounds i8, i8* %51, i64 -2
%53 = load i8, i8* %52
%54 = load i8*, i8** %7
%55 = getelementptr inbounds i8, i8* %54, i64 -1
%56 = load i8, i8* %55
%57 = load i8*, i8** %7
%58 = getelementptr inbounds i8, i8* %57, i64 0
%59 = load i8, i8* %58
%60 = load i8*, i8** %7
%61 = getelementptr inbounds i8, i8* %60, i64 1
%62 = load i8, i8* %61
%63 = call signext i8 @vp8_hevmask(i8 zeroext %50, i8 zeroext %53, i8 zeroext %56, i8 zeroext %59, i8 zeroext %62)
store i8 %63, i8* %13
%64 = load i8, i8* %14
%65 = load i8, i8* %13
%66 = load i8*, i8** %7
%67 = getelementptr inbounds i8, i8* %66, i64 -3
%68 = load i8*, i8** %7
%69 = getelementptr inbounds i8, i8* %68, i64 -2
%70 = load i8*, i8** %7
%71 = getelementptr inbounds i8, i8* %70, i64 -1
%72 = load i8*, i8** %7
%73 = load i8*, i8** %7
%74 = getelementptr inbounds i8, i8* %73, i64 1
%75 = load i8*, i8** %7
%76 = getelementptr inbounds i8, i8* %75, i64 2
%77 = call i32 @vp8_mbfilter(i8 signext %64, i8 signext %65, i8* %67, i8* %69, i8* %71, i8* %72, i8* %74, i8* %76)
%78 = load i32, i32* %8
%79 = load i8*, i8** %7
%80 = sext i32 %78 to i64
%81 = getelementptr inbounds i8, i8* %79, i64 %80
store i8* %81, i8** %7
br label %82
82: ; preds = %16
%83 = load i32, i32* %15
%84 = add nsw i32 %83, 1
store i32 %84, i32* %15
%85 = load i32, i32* %12
%86 = mul nsw i32 %85, 8
%87 = icmp slt i32 %84, %86
br i1 %87, label %16, label %88
88: ; preds = %82
ret void
}

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