#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*/ vp9_filter_block2d_bil_var_sse2(unsigned char const *, int,
                                                   unsigned char const *, int,
                                                   int, int, int, int *,
                                                   unsigned int *);
int /*<<< orphan*/ vp9_half_horiz_variance16x_h_sse2(unsigned char const *, int,
                                                     unsigned char const *, int,
                                                     int, int *,
                                                     unsigned int *);
int /*<<< orphan*/ vp9_half_horiz_vert_variance16x_h_sse2(unsigned char const *,
                                                          int,
                                                          unsigned char const *,
                                                          int, int, int *,
                                                          unsigned int *);
int /*<<< orphan*/ vp9_half_vert_variance16x_h_sse2(unsigned char const *, int,
                                                    unsigned char const *, int,
                                                    int, int *, unsigned int *);
unsigned int vp9_sub_pixel_variance16x2_sse2(const unsigned char *src_ptr,
                                             int src_pixels_per_line,
                                             int xoffset, int yoffset,
                                             const unsigned char *dst_ptr,
                                             int dst_pixels_per_line,
                                             unsigned int *sse) {
  int xsum0, xsum1;
  unsigned int xxsum0, xxsum1;
  if (xoffset == 8 && yoffset == 0) {
    vp9_half_horiz_variance16x_h_sse2(src_ptr, src_pixels_per_line, dst_ptr,
                                      dst_pixels_per_line, 2, &xsum0, &xxsum0);
  } else if (xoffset == 0 && yoffset == 8) {
    vp9_half_vert_variance16x_h_sse2(src_ptr, src_pixels_per_line, dst_ptr,
                                     dst_pixels_per_line, 2, &xsum0, &xxsum0);
  } else if (xoffset == 8 && yoffset == 8) {
    vp9_half_horiz_vert_variance16x_h_sse2(src_ptr, src_pixels_per_line,
                                           dst_ptr, dst_pixels_per_line, 2,
                                           &xsum0, &xxsum0);
  } else {
    vp9_filter_block2d_bil_var_sse2(src_ptr, src_pixels_per_line, dst_ptr,
                                    dst_pixels_per_line, 2, xoffset, yoffset,
                                    &xsum0, &xxsum0);
    vp9_filter_block2d_bil_var_sse2(src_ptr + 8, src_pixels_per_line,
                                    dst_ptr + 8, dst_pixels_per_line, 2,
                                    xoffset, yoffset, &xsum1, &xxsum1);
    xsum0 += xsum1;
    xxsum0 += xxsum1;
  }
  *sse = xxsum0;
  return (xxsum0 - (((unsigned int)xsum0 * xsum0) >> 5));
}


x86 assembly (clang, -O0):
<vp9_sub_pixel_variance16x2_sse2>:
push   %rbp
mov    %rsp,%rbp
sub    $0x50,%rsp
mov    0x10(%rbp),%rax
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
mov    %edx,-0x10(%rbp)
mov    %ecx,-0x14(%rbp)
mov    %r8,-0x20(%rbp)
mov    %r9d,-0x24(%rbp)
cmpl   $0x8,-0x10(%rbp)
jne    119f <vp9_sub_pixel_variance16x2_sse2+0x5f>
cmpl   $0x0,-0x14(%rbp)
jne    119f <vp9_sub_pixel_variance16x2_sse2+0x5f>
mov    -0x8(%rbp),%rdi
mov    -0xc(%rbp),%esi
mov    -0x20(%rbp),%rdx
mov    -0x24(%rbp),%ecx
mov    $0x2,%r8d
lea    -0x28(%rbp),%r9
lea    -0x30(%rbp),%rax
mov    %rax,(%rsp)
call   1060 <vp9_half_horiz_variance16x_h_sse2@plt>
jmp    12ad <vp9_sub_pixel_variance16x2_sse2+0x16d>
cmpl   $0x0,-0x10(%rbp)
jne    11dd <vp9_sub_pixel_variance16x2_sse2+0x9d>
cmpl   $0x8,-0x14(%rbp)
jne    11dd <vp9_sub_pixel_variance16x2_sse2+0x9d>
mov    -0x8(%rbp),%rdi
mov    -0xc(%rbp),%esi
mov    -0x20(%rbp),%rdx
mov    -0x24(%rbp),%ecx
mov    $0x2,%r8d
lea    -0x28(%rbp),%r9
lea    -0x30(%rbp),%rax
mov    %rax,(%rsp)
call   1050 <vp9_half_vert_variance16x_h_sse2@plt>
jmp    12a8 <vp9_sub_pixel_variance16x2_sse2+0x168>
cmpl   $0x8,-0x10(%rbp)
jne    121b <vp9_sub_pixel_variance16x2_sse2+0xdb>
cmpl   $0x8,-0x14(%rbp)
jne    121b <vp9_sub_pixel_variance16x2_sse2+0xdb>
mov    -0x8(%rbp),%rdi
mov    -0xc(%rbp),%esi
mov    -0x20(%rbp),%rdx
mov    -0x24(%rbp),%ecx
mov    $0x2,%r8d
lea    -0x28(%rbp),%r9
lea    -0x30(%rbp),%rax
mov    %rax,(%rsp)
call   1040 <vp9_half_horiz_vert_variance16x_h_sse2@plt>
jmp    12a3 <vp9_sub_pixel_variance16x2_sse2+0x163>
mov    -0x8(%rbp),%rdi
mov    -0xc(%rbp),%esi
mov    -0x20(%rbp),%rdx
mov    -0x24(%rbp),%ecx
mov    -0x10(%rbp),%r9d
mov    -0x14(%rbp),%r11d
mov    $0x2,%r8d
lea    -0x28(%rbp),%r10
lea    -0x30(%rbp),%rax
mov    %r11d,(%rsp)
mov    %r10,0x8(%rsp)
mov    %rax,0x10(%rsp)
call   1030 <vp9_filter_block2d_bil_var_sse2@plt>
mov    -0x8(%rbp),%rdi
add    $0x8,%rdi
mov    -0xc(%rbp),%esi
mov    -0x20(%rbp),%rdx
add    $0x8,%rdx
mov    -0x24(%rbp),%ecx
mov    -0x10(%rbp),%r9d
mov    -0x14(%rbp),%r11d
mov    $0x2,%r8d
lea    -0x2c(%rbp),%r10
lea    -0x34(%rbp),%rax
mov    %r11d,(%rsp)
mov    %r10,0x8(%rsp)
mov    %rax,0x10(%rsp)
call   1030 <vp9_filter_block2d_bil_var_sse2@plt>
mov    -0x2c(%rbp),%eax
add    -0x28(%rbp),%eax
mov    %eax,-0x28(%rbp)
mov    -0x34(%rbp),%eax
add    -0x30(%rbp),%eax
mov    %eax,-0x30(%rbp)
jmp    12a8 <vp9_sub_pixel_variance16x2_sse2+0x168>
jmp    12ad <vp9_sub_pixel_variance16x2_sse2+0x16d>
mov    -0x30(%rbp),%ecx
mov    0x10(%rbp),%rax
mov    %ecx,(%rax)
mov    -0x30(%rbp),%eax
mov    -0x28(%rbp),%ecx
imul   -0x28(%rbp),%ecx
shr    $0x5,%ecx
sub    %ecx,%eax
add    $0x50,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<vp9_sub_pixel_variance16x2_sse2>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x28,%rsp
mov    %r9d,%r14d
mov    %r8,%r12
mov    %ecx,%ebp
mov    %edx,%ebx
mov    %esi,%r15d
mov    %rdi,%r13
mov    0x60(%rsp),%rcx
cmp    $0x8,%edx
jne    119c <vp9_sub_pixel_variance16x2_sse2+0x5c>
test   %ebp,%ebp
jne    119c <vp9_sub_pixel_variance16x2_sse2+0x5c>
lea    0x18(%rsp),%rax
mov    %rax,(%rsp)
lea    0x1c(%rsp),%r9
mov    %r13,%rdi
mov    %r15d,%esi
mov    %r12,%rdx
mov    %rcx,%rbx
mov    %r14d,%ecx
mov    $0x2,%r8d
call   1060 <vp9_half_horiz_variance16x_h_sse2@plt>
mov    %rbx,%rcx
jmp    1285 <vp9_sub_pixel_variance16x2_sse2+0x145>
test   %ebx,%ebx
jne    11d5 <vp9_sub_pixel_variance16x2_sse2+0x95>
cmp    $0x8,%ebp
jne    11d5 <vp9_sub_pixel_variance16x2_sse2+0x95>
lea    0x18(%rsp),%rax
mov    %rax,(%rsp)
lea    0x1c(%rsp),%r9
mov    %r13,%rdi
mov    %r15d,%esi
mov    %r12,%rdx
mov    %rcx,%rbx
mov    %r14d,%ecx
mov    $0x2,%r8d
call   1050 <vp9_half_vert_variance16x_h_sse2@plt>
mov    %rbx,%rcx
jmp    1285 <vp9_sub_pixel_variance16x2_sse2+0x145>
cmp    $0x8,%ebx
jne    1206 <vp9_sub_pixel_variance16x2_sse2+0xc6>
cmp    $0x8,%ebp
jne    1206 <vp9_sub_pixel_variance16x2_sse2+0xc6>
lea    0x18(%rsp),%rax
mov    %rax,(%rsp)
lea    0x1c(%rsp),%r9
mov    %r13,%rdi
mov    %r15d,%esi
mov    %r12,%rdx
mov    %r14d,%ecx
mov    $0x2,%r8d
call   1040 <vp9_half_horiz_vert_variance16x_h_sse2@plt>
jmp    1280 <vp9_sub_pixel_variance16x2_sse2+0x140>
lea    0x18(%rsp),%rax
mov    %rax,0x10(%rsp)
lea    0x1c(%rsp),%rax
mov    %rax,0x8(%rsp)
mov    %ebp,(%rsp)
mov    %r13,%rdi
mov    %r15d,%esi
mov    %r12,%rdx
mov    %r14d,%ecx
mov    $0x2,%r8d
mov    %ebx,%r9d
call   1030 <vp9_filter_block2d_bil_var_sse2@plt>
add    $0x8,%r13
add    $0x8,%r12
lea    0x20(%rsp),%rax
mov    %rax,0x10(%rsp)
lea    0x24(%rsp),%rax
mov    %rax,0x8(%rsp)
mov    %ebp,(%rsp)
mov    %r13,%rdi
mov    %r15d,%esi
mov    %r12,%rdx
mov    %r14d,%ecx
mov    $0x2,%r8d
mov    %ebx,%r9d
call   1030 <vp9_filter_block2d_bil_var_sse2@plt>
mov    0x24(%rsp),%eax
add    %eax,0x1c(%rsp)
mov    0x20(%rsp),%eax
add    %eax,0x18(%rsp)
mov    0x60(%rsp),%rcx
mov    0x18(%rsp),%eax
mov    %eax,(%rcx)
mov    0x1c(%rsp),%ecx
imul   %ecx,%ecx
shr    $0x5,%ecx
sub    %ecx,%eax
add    $0x28,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
define i32 @vp9_sub_pixel_variance16x2_sse2(i8* %0, i32 %1, i32 %2, i32 %3, i8* %4, i32 %5, i32* %6) {
%8 = alloca i8*
%9 = alloca i32
%10 = alloca i32
%11 = alloca i32
%12 = alloca i8*
%13 = alloca i32
%14 = alloca i32*
%15 = alloca i32
%16 = alloca i32
%17 = alloca i32
%18 = alloca i32
store i8* %0, i8** %8
store i32 %1, i32* %9
store i32 %2, i32* %10
store i32 %3, i32* %11
store i8* %4, i8** %12
store i32 %5, i32* %13
store i32* %6, i32** %14
%19 = load i32, i32* %10
%20 = icmp eq i32 %19, 8
br i1 %20, label %21, label %30
21: ; preds = %7
%22 = load i32, i32* %11
%23 = icmp eq i32 %22, 0
br i1 %23, label %24, label %30
24: ; preds = %21
%25 = load i8*, i8** %8
%26 = load i32, i32* %9
%27 = load i8*, i8** %12
%28 = load i32, i32* %13
%29 = call i32 @vp9_half_horiz_variance16x_h_sse2(i8* %25, i32 %26, i8* %27, i32 %28, i32 2, i32* %15, i32* %17)
br label %79
30: ; preds = %21, %7
%31 = load i32, i32* %10
%32 = icmp eq i32 %31, 0
br i1 %32, label %33, label %42
33: ; preds = %30
%34 = load i32, i32* %11
%35 = icmp eq i32 %34, 8
br i1 %35, label %36, label %42
36: ; preds = %33
%37 = load i8*, i8** %8
%38 = load i32, i32* %9
%39 = load i8*, i8** %12
%40 = load i32, i32* %13
%41 = call i32 @vp9_half_vert_variance16x_h_sse2(i8* %37, i32 %38, i8* %39, i32 %40, i32 2, i32* %15, i32* %17)
br label %78
42: ; preds = %33, %30
%43 = load i32, i32* %10
%44 = icmp eq i32 %43, 8
br i1 %44, label %45, label %54
45: ; preds = %42
%46 = load i32, i32* %11
%47 = icmp eq i32 %46, 8
br i1 %47, label %48, label %54
48: ; preds = %45
%49 = load i8*, i8** %8
%50 = load i32, i32* %9
%51 = load i8*, i8** %12
%52 = load i32, i32* %13
%53 = call i32 @vp9_half_horiz_vert_variance16x_h_sse2(i8* %49, i32 %50, i8* %51, i32 %52, i32 2, i32* %15, i32* %17)
br label %77
54: ; preds = %45, %42
%55 = load i8*, i8** %8
%56 = load i32, i32* %9
%57 = load i8*, i8** %12
%58 = load i32, i32* %13
%59 = load i32, i32* %10
%60 = load i32, i32* %11
%61 = call i32 @vp9_filter_block2d_bil_var_sse2(i8* %55, i32 %56, i8* %57, i32 %58, i32 2, i32 %59, i32 %60, i32* %15, i32* %17)
%62 = load i8*, i8** %8
%63 = getelementptr inbounds i8, i8* %62, i64 8
%64 = load i32, i32* %9
%65 = load i8*, i8** %12
%66 = getelementptr inbounds i8, i8* %65, i64 8
%67 = load i32, i32* %13
%68 = load i32, i32* %10
%69 = load i32, i32* %11
%70 = call i32 @vp9_filter_block2d_bil_var_sse2(i8* %63, i32 %64, i8* %66, i32 %67, i32 2, i32 %68, i32 %69, i32* %16, i32* %18)
%71 = load i32, i32* %16
%72 = load i32, i32* %15
%73 = add nsw i32 %72, %71
store i32 %73, i32* %15
%74 = load i32, i32* %18
%75 = load i32, i32* %17
%76 = add i32 %75, %74
store i32 %76, i32* %17
br label %77
77: ; preds = %54, %48
br label %78
78: ; preds = %77, %36
br label %79
79: ; preds = %78, %24
%80 = load i32, i32* %17
%81 = load i32*, i32** %14
store i32 %80, i32* %81
%82 = load i32, i32* %17
%83 = load i32, i32* %15
%84 = load i32, i32* %15
%85 = mul i32 %83, %84
%86 = lshr i32 %85, 5
%87 = sub i32 %82, %86
ret i32 %87
}

LLVM IR (-O2):
define i32 @vp9_sub_pixel_variance16x2_sse2(i8* %0, i32 %1, i32 %2, i32 %3, i8* %4, i32 %5, i32* nocapture writeonly %6) {
%8 = alloca i32
%9 = alloca i32
%10 = alloca i32
%11 = alloca i32
%12 = bitcast i32* %8 to i8*
%13 = bitcast i32* %9 to i8*
%14 = bitcast i32* %10 to i8*
%15 = bitcast i32* %11 to i8*
%16 = icmp eq i32 %2, 8
%17 = icmp eq i32 %3, 0
%18 = and i1 %16, %17
br i1 %18, label %19, label %21
19: ; preds = %7
%20 = call i32 @vp9_half_horiz_variance16x_h_sse2(i8* %0, i32 %1, i8* %4, i32 %5, i32 2, i32* %8, i32* %10)
br label %42
21: ; preds = %7
%22 = icmp eq i32 %2, 0
%23 = icmp eq i32 %3, 8
%24 = and i1 %22, %23
br i1 %24, label %25, label %27
25: ; preds = %21
%26 = call i32 @vp9_half_vert_variance16x_h_sse2(i8* %0, i32 %1, i8* %4, i32 %5, i32 2, i32* %8, i32* %10)
br label %42
27: ; preds = %21
%28 = and i1 %16, %23
br i1 %28, label %29, label %31
29: ; preds = %27
%30 = call i32 @vp9_half_horiz_vert_variance16x_h_sse2(i8* %0, i32 %1, i8* %4, i32 %5, i32 2, i32* %8, i32* %10)
br label %42
31: ; preds = %27
%32 = call i32 @vp9_filter_block2d_bil_var_sse2(i8* %0, i32 %1, i8* %4, i32 %5, i32 2, i32 %2, i32 %3, i32* %8, i32* %10)
%33 = getelementptr inbounds i8, i8* %0, i64 8
%34 = getelementptr inbounds i8, i8* %4, i64 8
%35 = call i32 @vp9_filter_block2d_bil_var_sse2(i8* %33, i32 %1, i8* %34, i32 %5, i32 2, i32 %2, i32 %3, i32* %9, i32* %11)
%36 = load i32, i32* %9
%37 = load i32, i32* %8
%38 = add nsw i32 %37, %36
store i32 %38, i32* %8
%39 = load i32, i32* %11
%40 = load i32, i32* %10
%41 = add i32 %40, %39
store i32 %41, i32* %10
br label %42
42: ; preds = %25, %31, %29, %19
%43 = load i32, i32* %10
store i32 %43, i32* %6
%44 = load i32, i32* %8
%45 = mul i32 %44, %44
%46 = lshr i32 %45, 5
%47 = sub i32 %43, %46
ret i32 %47
}