#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*/ aom_get8x8var_sse2(unsigned char const *, int,
                                      unsigned char const *, int,
                                      unsigned int *, int *);
int /*<<< orphan*/ assert(int);
unsigned int aom_variance8x8_sse2(const unsigned char *src, int src_stride,
                                  const unsigned char *ref, int ref_stride,
                                  unsigned int *sse) {
  int sum;
  aom_get8x8var_sse2(src, src_stride, ref, ref_stride, sse, &sum);
  assert(sum <= 255 * 8 * 8);
  assert(sum >= -255 * 8 * 8);
  return *sse - ((sum * sum) >> 6);
}


x86 assembly (clang, -O0):
<aom_variance8x8_sse2>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
mov    %rdx,-0x18(%rbp)
mov    %ecx,-0x1c(%rbp)
mov    %r8,-0x28(%rbp)
mov    -0x8(%rbp),%rdi
mov    -0xc(%rbp),%esi
mov    -0x18(%rbp),%rdx
mov    -0x1c(%rbp),%ecx
mov    -0x28(%rbp),%r8
lea    -0x2c(%rbp),%r9
call   1040 <aom_get8x8var_sse2@plt>
cmpl   $0x3fc0,-0x2c(%rbp)
setle  %al
and    $0x1,%al
movzbl %al,%edi
call   1030 <assert@plt>
cmpl   $0xffffc040,-0x2c(%rbp)
setge  %al
and    $0x1,%al
movzbl %al,%edi
call   1030 <assert@plt>
mov    -0x28(%rbp),%rax
mov    (%rax),%eax
mov    -0x2c(%rbp),%ecx
imul   -0x2c(%rbp),%ecx
sar    $0x6,%ecx
sub    %ecx,%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<aom_variance8x8_sse2>:
push   %rbx
sub    $0x10,%rsp
mov    %r8,%rbx
lea    0xc(%rsp),%r9
call   1040 <aom_get8x8var_sse2@plt>
xor    %edi,%edi
cmpl   $0x3fc1,0xc(%rsp)
setl   %dil
call   1030 <assert@plt>
xor    %edi,%edi
cmpl   $0xffffc040,0xc(%rsp)
ff
setge  %dil
call   1030 <assert@plt>
mov    (%rbx),%eax
mov    0xc(%rsp),%ecx
imul   %ecx,%ecx
shr    $0x6,%ecx
sub    %ecx,%eax
add    $0x10,%rsp
pop    %rbx
ret

LLVM IR (-O0):
define i32 @aom_variance8x8_sse2(i8* %0, i32 %1, i8* %2, i32 %3, i32* %4) {
%6 = alloca i8*
%7 = alloca i32
%8 = alloca i8*
%9 = alloca i32
%10 = alloca i32*
%11 = alloca i32
store i8* %0, i8** %6
store i32 %1, i32* %7
store i8* %2, i8** %8
store i32 %3, i32* %9
store i32* %4, i32** %10
%12 = load i8*, i8** %6
%13 = load i32, i32* %7
%14 = load i8*, i8** %8
%15 = load i32, i32* %9
%16 = load i32*, i32** %10
%17 = call i32 @aom_get8x8var_sse2(i8* %12, i32 %13, i8* %14, i32 %15, i32* %16, i32* %11)
%18 = load i32, i32* %11
%19 = icmp sle i32 %18, 16320
%20 = zext i1 %19 to i32
%21 = call i32 @assert(i32 %20)
%22 = load i32, i32* %11
%23 = icmp sge i32 %22, -16320
%24 = zext i1 %23 to i32
%25 = call i32 @assert(i32 %24)
%26 = load i32*, i32** %10
%27 = load i32, i32* %26
%28 = load i32, i32* %11
%29 = load i32, i32* %11
%30 = mul nsw i32 %28, %29
%31 = ashr i32 %30, 6
%32 = sub i32 %27, %31
ret i32 %32
}

LLVM IR (-O2):
define i32 @aom_variance8x8_sse2(i8* %0, i32 %1, i8* %2, i32 %3, i32* %4) {
%6 = alloca i32
%7 = bitcast i32* %6 to i8*
%8 = call i32 @aom_get8x8var_sse2(i8* %0, i32 %1, i8* %2, i32 %3, i32* %4, i32* %6)
%9 = load i32, i32* %6
%10 = icmp slt i32 %9, 16321
%11 = zext i1 %10 to i32
%12 = call i32 @assert(i32 %11)
%13 = load i32, i32* %6
%14 = icmp sgt i32 %13, -16321
%15 = zext i1 %14 to i32
%16 = call i32 @assert(i32 %15)
%17 = load i32, i32* %4
%18 = load i32, i32* %6
%19 = mul nsw i32 %18, %18
%20 = lshr i32 %19, 6
%21 = sub i32 %17, %20
ret i32 %21
}