#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_variance(unsigned char const *, int,
                                unsigned char const *, int, int, int,
                                unsigned int *, int *);
unsigned int vp8_variance4x4_c(const unsigned char *src_ptr, int source_stride,
                               const unsigned char *ref_ptr, int recon_stride,
                               unsigned int *sse) {
  unsigned int var;
  int avg;
  vp8_variance(src_ptr, source_stride, ref_ptr, recon_stride, 4, 4, &var, &avg);
  *sse = var;
  return (var - ((avg * avg) >> 4));
}


x86 assembly (clang, -O0):
<vp8_variance4x4_c>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%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    $0x4,%r9d
lea    -0x2c(%rbp),%r10
lea    -0x30(%rbp),%rax
mov    %r9d,%r8d
mov    %r10,(%rsp)
mov    %rax,0x8(%rsp)
call   1030 <vp8_variance@plt>
mov    -0x2c(%rbp),%ecx
mov    -0x28(%rbp),%rax
mov    %ecx,(%rax)
mov    -0x2c(%rbp),%eax
mov    -0x30(%rbp),%ecx
imul   -0x30(%rbp),%ecx
sar    $0x4,%ecx
sub    %ecx,%eax
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<vp8_variance4x4_c>:
push   %rbx
sub    $0x10,%rsp
mov    %r8,%rbx
lea    0x8(%rsp),%rax
lea    0xc(%rsp),%r10
mov    $0x4,%r8d
mov    $0x4,%r9d
push   %rax
push   %r10
call   1030 <vp8_variance@plt>
add    $0x10,%rsp
mov    0xc(%rsp),%eax
mov    %eax,(%rbx)
mov    0x8(%rsp),%ecx
imul   %ecx,%ecx
shr    $0x4,%ecx
sub    %ecx,%eax
add    $0x10,%rsp
pop    %rbx
ret

LLVM IR (-O0):
define i32 @vp8_variance4x4_c(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
%12 = 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
%13 = load i8*, i8** %6
%14 = load i32, i32* %7
%15 = load i8*, i8** %8
%16 = load i32, i32* %9
%17 = call i32 @vp8_variance(i8* %13, i32 %14, i8* %15, i32 %16, i32 4, i32 4, i32* %11, i32* %12)
%18 = load i32, i32* %11
%19 = load i32*, i32** %10
store i32 %18, i32* %19
%20 = load i32, i32* %11
%21 = load i32, i32* %12
%22 = load i32, i32* %12
%23 = mul nsw i32 %21, %22
%24 = ashr i32 %23, 4
%25 = sub i32 %20, %24
ret i32 %25
}

LLVM IR (-O2):
define i32 @vp8_variance4x4_c(i8* %0, i32 %1, i8* %2, i32 %3, i32* nocapture writeonly %4) {
%6 = alloca i32
%7 = alloca i32
%8 = bitcast i32* %6 to i8*
%9 = bitcast i32* %7 to i8*
%10 = call i32 @vp8_variance(i8* %0, i32 %1, i8* %2, i32 %3, i32 4, i32 4, i32* %6, i32* %7)
%11 = load i32, i32* %6
store i32 %11, i32* %4
%12 = load i32, i32* %7
%13 = mul nsw i32 %12, %12
%14 = lshr i32 %13, 4
%15 = sub i32 %11, %14
ret i32 %15
}