#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 log(double);
double glb_likelihood(double true_rate, double fit_rate) {
  double res;
  res = fit_rate - true_rate;
  if (fit_rate <= 0.0)
    res = 1e100;
  else if (true_rate > 0)
    res += true_rate * log(true_rate / fit_rate);
  return 2.0 * res;
}


x86 assembly (clang, -O0):
<glb_likelihood>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movsd  %xmm0,-0x8(%rbp)
movsd  %xmm1,-0x10(%rbp)
movsd  -0x10(%rbp),%xmm0
subsd  -0x8(%rbp),%xmm0
movsd  %xmm0,-0x18(%rbp)
xorps  %xmm0,%xmm0
ucomisd -0x10(%rbp),%xmm0
jb     1151 <glb_likelihood+0x41>
movsd  0xeb9(%rip),%xmm0
movsd  %xmm0,-0x18(%rbp)
jmp    119b <glb_likelihood+0x8b>
movsd  -0x8(%rbp),%xmm0
xorps  %xmm1,%xmm1
ucomisd %xmm1,%xmm0
jbe    1196 <glb_likelihood+0x86>
movsd  -0x8(%rbp),%xmm0
movsd  %xmm0,-0x20(%rbp)
movsd  -0x8(%rbp),%xmm0
divsd  -0x10(%rbp),%xmm0
call   1030 <log@plt>
movaps %xmm0,%xmm2
movsd  -0x20(%rbp),%xmm0
movsd  -0x18(%rbp),%xmm1
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
movsd  %xmm0,-0x18(%rbp)
jmp    119b <glb_likelihood+0x8b>
movsd  0xe65(%rip),%xmm0
mulsd  -0x18(%rbp),%xmm0
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<glb_likelihood>:
sub    $0x18,%rsp
movapd %xmm0,%xmm3
xorpd  %xmm0,%xmm0
ucomisd %xmm1,%xmm0
jae    115b <glb_likelihood+0x4b>
movapd %xmm1,%xmm2
subsd  %xmm3,%xmm2
ucomisd %xmm0,%xmm3
jbe    1163 <glb_likelihood+0x53>
movapd %xmm3,%xmm0
divsd  %xmm1,%xmm0
movsd  %xmm2,0x10(%rsp)
movsd  %xmm3,0x8(%rsp)
call   1030 <log@plt>
movsd  0x10(%rsp),%xmm2
mulsd  0x8(%rsp),%xmm0
addsd  %xmm0,%xmm2
jmp    1163 <glb_likelihood+0x53>
movsd  0xe9d(%rip),%xmm2
addsd  %xmm2,%xmm2
movapd %xmm2,%xmm0
add    $0x18,%rsp
ret

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

LLVM IR (-O2):
define double @glb_likelihood(double %0, double %1) {
%3 = fsub double %1, %0
%4 = fcmp ugt double %1, 0.000000e+00
br i1 %4, label %5, label %11
5: ; preds = %2
%6 = fcmp ogt double %0, 0.000000e+00
br i1 %6, label %7, label %11
7: ; preds = %5
%8 = fdiv double %0, %1
%9 = tail call double @log(double %8)
%10 = tail call double @llvm.fmuladd.f64(double %0, double %9, double %3)
br label %11
11: ; preds = %2, %5, %7
%12 = phi double [ %10, %7 ], [ %3, %5 ], [ 1.000000e+100, %2 ]
%13 = fmul double %12, 2.000000e+00
ret double %13
}