#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 vpx_sse_to_psnr(double samples, double peak, double sse) {
  if (sse > 0.0) {
    const double psnr = 10.0 * log10(samples * peak * peak / sse);
    return psnr > 100.0 ? 100.0 : psnr;
  } else {
    return 100.0;
  }
}


x86 assembly (clang, -O0):
<vpx_sse_to_psnr>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
movsd  %xmm0,-0x10(%rbp)
movsd  %xmm1,-0x18(%rbp)
movsd  %xmm2,-0x20(%rbp)
movsd  -0x20(%rbp),%xmm0
xorps  %xmm1,%xmm1
ucomisd %xmm1,%xmm0
jbe    11a8 <vpx_sse_to_psnr+0x98>
movsd  -0x10(%rbp),%xmm0
mulsd  -0x18(%rbp),%xmm0
mulsd  -0x18(%rbp),%xmm0
divsd  -0x20(%rbp),%xmm0
call   1030 <log10@plt>
movaps %xmm0,%xmm1
movsd  0xeab(%rip),%xmm0
mulsd  %xmm1,%xmm0
movsd  %xmm0,-0x28(%rbp)
movsd  -0x28(%rbp),%xmm0
movsd  0xe8d(%rip),%xmm1
ucomisd %xmm1,%xmm0
jbe    118f <vpx_sse_to_psnr+0x7f>
movsd  0xe7b(%rip),%xmm0
movsd  %xmm0,-0x30(%rbp)
jmp    1199 <vpx_sse_to_psnr+0x89>
movsd  -0x28(%rbp),%xmm0
movsd  %xmm0,-0x30(%rbp)
movsd  -0x30(%rbp),%xmm0
movsd  %xmm0,-0x8(%rbp)
jmp    11b5 <vpx_sse_to_psnr+0xa5>
movsd  0xe50(%rip),%xmm0
movsd  %xmm0,-0x8(%rbp)
movsd  -0x8(%rbp),%xmm0
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<vpx_sse_to_psnr>:
push   %rax
xorpd  %xmm3,%xmm3
ucomisd %xmm3,%xmm2
jbe    1146 <vpx_sse_to_psnr+0x36>
mulsd  %xmm1,%xmm0
mulsd  %xmm1,%xmm0
divsd  %xmm2,%xmm0
call   1030 <log10@plt>
movapd %xmm0,%xmm1
mulsd  0xed0(%rip),%xmm1
movsd  0xec0(%rip),%xmm0
minsd  %xmm1,%xmm0
pop    %rax
ret
movsd  0xeb2(%rip),%xmm0
pop    %rax
ret

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

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