#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 */
typedef int /*<<< orphan*/ uint8_t;

/* Variables and functions */
double aae_factor(int /*<<< orphan*/ *, int /*<<< orphan*/ *, int, int, int,
                  int, int /*<<< orphan*/);
int /*<<< orphan*/ maxluma(int /*<<< orphan*/ *, int, int, int);
double psnr_factor(int /*<<< orphan*/ *, int /*<<< orphan*/ *, int, int, int,
                   int, int /*<<< orphan*/);
double getmetric(uint8_t *inbuf, uint8_t *outbuf, int width, int height) {
  double p, a, b;
  uint8_t max;
  max = maxluma(inbuf, width, width, height);
  p = psnr_factor(inbuf, outbuf, width, width, width, height, max);
  a = aae_factor(inbuf, outbuf, width, width, width, height, max);
  b = p * 37.1891885161239 + a * 78.5328607296973;
  return b;
}


x86 assembly (clang, -O0):
<getmetric>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %edx,-0x14(%rbp)
mov    %ecx,-0x18(%rbp)
mov    -0x8(%rbp),%rdi
mov    -0x14(%rbp),%esi
mov    -0x14(%rbp),%edx
mov    -0x18(%rbp),%ecx
call   1040 <maxluma@plt>
mov    %eax,-0x34(%rbp)
mov    -0x8(%rbp),%rdi
mov    -0x10(%rbp),%rsi
mov    -0x14(%rbp),%edx
mov    -0x14(%rbp),%ecx
mov    -0x14(%rbp),%r8d
mov    -0x18(%rbp),%r9d
mov    -0x34(%rbp),%eax
mov    %eax,(%rsp)
call   1050 <psnr_factor@plt>
movsd  %xmm0,-0x20(%rbp)
mov    -0x8(%rbp),%rdi
mov    -0x10(%rbp),%rsi
mov    -0x14(%rbp),%edx
mov    -0x14(%rbp),%ecx
mov    -0x14(%rbp),%r8d
mov    -0x18(%rbp),%r9d
mov    -0x34(%rbp),%eax
mov    %eax,(%rsp)
call   1030 <aae_factor@plt>
movsd  %xmm0,-0x28(%rbp)
movsd  -0x20(%rbp),%xmm0
movsd  0xe54(%rip),%xmm1
mulsd  -0x28(%rbp),%xmm1
movsd  0xe3f(%rip),%xmm2
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
movsd  %xmm0,-0x30(%rbp)
movsd  -0x30(%rbp),%xmm0
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<getmetric>:
push   %rbp
push   %r15
push   %r14
push   %r12
push   %rbx
sub    $0x10,%rsp
mov    %ecx,%r15d
mov    %edx,%ebp
mov    %rsi,%r14
mov    %rdi,%rbx
mov    %edx,%esi
call   1040 <maxluma@plt>
mov    %eax,%r12d
mov    %eax,(%rsp)
mov    %rbx,%rdi
mov    %r14,%rsi
mov    %ebp,%edx
mov    %ebp,%ecx
mov    %ebp,%r8d
mov    %r15d,%r9d
call   1050 <psnr_factor@plt>
movsd  %xmm0,0x8(%rsp)
mov    %r12d,(%rsp)
mov    %rbx,%rdi
mov    %r14,%rsi
mov    %ebp,%edx
mov    %ebp,%ecx
mov    %ebp,%r8d
mov    %r15d,%r9d
call   1030 <aae_factor@plt>
mulsd  0xe70(%rip),%xmm0
movsd  0x8(%rsp),%xmm1
mulsd  0xe6a(%rip),%xmm1
addsd  %xmm1,%xmm0
add    $0x10,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
define double @getmetric(i32* %0, i32* %1, i32 %2, i32 %3) {
%5 = alloca i32*
%6 = alloca i32*
%7 = alloca i32
%8 = alloca i32
%9 = alloca double
%10 = alloca double
%11 = alloca double
%12 = alloca i32
store i32* %0, i32** %5
store i32* %1, i32** %6
store i32 %2, i32* %7
store i32 %3, i32* %8
%13 = load i32*, i32** %5
%14 = load i32, i32* %7
%15 = load i32, i32* %7
%16 = load i32, i32* %8
%17 = call i32 @maxluma(i32* %13, i32 %14, i32 %15, i32 %16)
store i32 %17, i32* %12
%18 = load i32*, i32** %5
%19 = load i32*, i32** %6
%20 = load i32, i32* %7
%21 = load i32, i32* %7
%22 = load i32, i32* %7
%23 = load i32, i32* %8
%24 = load i32, i32* %12
%25 = call double @psnr_factor(i32* %18, i32* %19, i32 %20, i32 %21, i32 %22, i32 %23, i32 %24)
store double %25, double* %9
%26 = load i32*, i32** %5
%27 = load i32*, i32** %6
%28 = load i32, i32* %7
%29 = load i32, i32* %7
%30 = load i32, i32* %7
%31 = load i32, i32* %8
%32 = load i32, i32* %12
%33 = call double @aae_factor(i32* %26, i32* %27, i32 %28, i32 %29, i32 %30, i32 %31, i32 %32)
store double %33, double* %10
%34 = load double, double* %9
%35 = load double, double* %10
%36 = fmul double %35, 0x4053A21A63E3D7D9
%37 = call double @llvm.fmuladd.f64(double %34, double 0x40429837544CC3F5, double %36)
store double %37, double* %11
%38 = load double, double* %11
ret double %38
}

LLVM IR (-O2):
define double @getmetric(i32* %0, i32* %1, i32 %2, i32 %3) {
%5 = tail call i32 @maxluma(i32* %0, i32 %2, i32 %2, i32 %3)
%6 = tail call double @psnr_factor(i32* %0, i32* %1, i32 %2, i32 %2, i32 %2, i32 %3, i32 %5)
%7 = tail call double @aae_factor(i32* %0, i32* %1, i32 %2, i32 %2, i32 %2, i32 %3, i32 %5)
%8 = fmul double %7, 0x4053A21A63E3D7D9
%9 = tail call double @llvm.fmuladd.f64(double %6, double 0x40429837544CC3F5, double %8)
ret double %9
}