#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_vertical_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], 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_filter(mask, hev, s - 2, s - 1, s, s + 1);
    s += p;
  } while (++i < count * 8);
}


x86 assembly (clang, -O0):
<vp8_loop_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)
movl   $0x0,-0x38(%rbp)
movb   $0x0,-0x39(%rbp)
movl   $0x0,-0x40(%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,-0x39(%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    %eax,-0x38(%rbp)
mov    -0x39(%rbp),%al
mov    -0x38(%rbp),%esi
mov    -0x10(%rbp),%rdx
add    $0xfffffffffffffffe,%rdx
mov    -0x10(%rbp),%rcx
add    $0xffffffffffffffff,%rcx
mov    -0x10(%rbp),%r8
mov    -0x10(%rbp),%r9
add    $0x1,%r9
movsbl %al,%edi
call   1030 <vp8_filter@plt>
mov    -0x14(%rbp),%ecx
mov    -0x10(%rbp),%rax
movslq %ecx,%rcx
add    %rcx,%rax
mov    %rax,-0x10(%rbp)
mov    -0x40(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x40(%rbp)
mov    -0x34(%rbp),%ecx
shl    $0x3,%ecx
cmp    %ecx,%eax
jl     1162 <vp8_loop_filter_vertical_edge_simd+0x32>
add    $0x58,%rsp
pop    %rbx
pop    %rbp
ret

x86 assembly (clang, -O2):
<vp8_loop_filter_vertical_edge_simd>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x28,%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
movzbl -0x3(%rbx),%ecx
lea    -0x2(%rbx),%rax
mov    %rax,0x20(%rsp)
movzbl -0x2(%rbx),%r8d
lea    -0x1(%rbx),%r13
movzbl -0x1(%rbx),%r9d
movzbl (%rbx),%r10d
lea    0x1(%rbx),%r14
movzbl 0x1(%rbx),%r11d
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
mov    %eax,%esi
mov    0x20(%rsp),%rdx
mov    %r13,%rcx
mov    %rbx,%r8
mov    %r14,%r9
call   1030 <vp8_filter@plt>
add    (%rsp),%rbx
add    $0xffffffff,%r12d
jne    1170 <vp8_loop_filter_vertical_edge_simd+0x40>
add    $0x28,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
define void @vp8_loop_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 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 = %78, %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 i32 @vp8_hevmask(i8 zeroext %50, i8 zeroext %53, i8 zeroext %56, i8 zeroext %59, i8 zeroext %62)
store i32 %63, i32* %13
%64 = load i8, i8* %14
%65 = load i32, i32* %13
%66 = load i8*, i8** %7
%67 = getelementptr inbounds i8, i8* %66, i64 -2
%68 = load i8*, i8** %7
%69 = getelementptr inbounds i8, i8* %68, i64 -1
%70 = load i8*, i8** %7
%71 = load i8*, i8** %7
%72 = getelementptr inbounds i8, i8* %71, i64 1
%73 = call i32 @vp8_filter(i8 signext %64, i32 %65, i8* %67, i8* %69, i8* %70, i8* %72)
%74 = load i32, i32* %8
%75 = load i8*, i8** %7
%76 = sext i32 %74 to i64
%77 = getelementptr inbounds i8, i8* %75, i64 %76
store i8* %77, i8** %7
br label %78
78: ; preds = %16
%79 = load i32, i32* %15
%80 = add nsw i32 %79, 1
store i32 %80, i32* %15
%81 = load i32, i32* %12
%82 = mul nsw i32 %81, 8
%83 = icmp slt i32 %80, %82
br i1 %83, label %16, label %84
84: ; preds = %78
ret void
}

LLVM IR (-O2):
define void @vp8_loop_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 i32 @vp8_hevmask(i8 zeroext %31, i8 zeroext %32, i8 zeroext %33, i8 zeroext %34, i8 zeroext %35)
%37 = tail call i32 @vp8_filter(i8 signext %30, i32 %36, i8* %19, i8* %21, i8* %11, i8* %24)
%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
}