#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 */
double log10(double);
double vp9_mse2psnr(double samples, double peak, double mse) {
  double psnr;
  if (mse > 0.0)
    psnr = 10.0 * log10(peak * peak * samples / mse);
  else
    psnr = 100;
  if (psnr > 100)
    psnr = 100;
  return psnr;
}


x86 assembly (clang, -O0):
<vp9_mse2psnr>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movsd  %xmm0,-0x8(%rbp)
movsd  %xmm1,-0x10(%rbp)
movsd  %xmm2,-0x18(%rbp)
movsd  -0x18(%rbp),%xmm0
xorps  %xmm1,%xmm1
ucomisd %xmm1,%xmm0
jbe    116b <vp9_mse2psnr+0x5b>
movsd  -0x10(%rbp),%xmm0
mulsd  -0x10(%rbp),%xmm0
mulsd  -0x8(%rbp),%xmm0
divsd  -0x18(%rbp),%xmm0
call   1030 <log10@plt>
movaps %xmm0,%xmm1
movsd  0xeab(%rip),%xmm0
mulsd  %xmm1,%xmm0
movsd  %xmm0,-0x20(%rbp)
jmp    1178 <vp9_mse2psnr+0x68>
movsd  0xe8d(%rip),%xmm0
movsd  %xmm0,-0x20(%rbp)
movsd  -0x20(%rbp),%xmm0
movsd  0xe7b(%rip),%xmm1
ucomisd %xmm1,%xmm0
jbe    119c <vp9_mse2psnr+0x8c>
movsd  0xe69(%rip),%xmm0
movsd  %xmm0,-0x20(%rbp)
movsd  -0x20(%rbp),%xmm0
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<vp9_mse2psnr>:
push   %rax
movsd  0xee7(%rip),%xmm4
xorpd  %xmm3,%xmm3
ucomisd %xmm3,%xmm2
movapd %xmm4,%xmm3
jbe    1150 <vp9_mse2psnr+0x40>
mulsd  %xmm1,%xmm1
mulsd  %xmm0,%xmm1
divsd  %xmm2,%xmm1
movapd %xmm1,%xmm0
call   1030 <log10@plt>
movsd  0xebc(%rip),%xmm4
movapd %xmm0,%xmm3
mulsd  0xeb8(%rip),%xmm3
minsd  %xmm3,%xmm4
movapd %xmm4,%xmm0
pop    %rax
ret

LLVM IR (-O0):
define double @vp9_mse2psnr(double %0, double %1, double %2) {
%4 = alloca double
%5 = alloca double
%6 = alloca double
%7 = alloca double
store double %0, double* %4
store double %1, double* %5
store double %2, double* %6
%8 = load double, double* %6
%9 = fcmp ogt double %8, 0.000000e+00
br i1 %9, label %10, label %20
10: ; preds = %3
%11 = load double, double* %5
%12 = load double, double* %5
%13 = fmul double %11, %12
%14 = load double, double* %4
%15 = fmul double %13, %14
%16 = load double, double* %6
%17 = fdiv double %15, %16
%18 = call double @log10(double %17)
%19 = fmul double 1.000000e+01, %18
store double %19, double* %7
br label %21
20: ; preds = %3
store double 1.000000e+02, double* %7
br label %21
21: ; preds = %20, %10
%22 = load double, double* %7
%23 = fcmp ogt double %22, 1.000000e+02
br i1 %23, label %24, label %25
24: ; preds = %21
store double 1.000000e+02, double* %7
br label %25
25: ; preds = %24, %21
%26 = load double, double* %7
ret double %26
}

LLVM IR (-O2):
define double @vp9_mse2psnr(double %0, double %1, double %2) {
%4 = fcmp ogt double %2, 0.000000e+00
br i1 %4, label %5, label %11
5: ; preds = %3
%6 = fmul double %1, %1
%7 = fmul double %6, %0
%8 = fdiv double %7, %2
%9 = tail call double @log10(double %8)
%10 = fmul double %9, 1.000000e+01
br label %11
11: ; preds = %3, %5
%12 = phi double [ %10, %5 ], [ 1.000000e+02, %3 ]
%13 = fcmp ogt double %12, 1.000000e+02
%14 = select i1 %13, double 1.000000e+02, double %12
ret double %14
}