#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 cdflib_rlog(double *x) {
  static const double a = .566749439387324e-01;
  static const double b = .456512608815524e-01;
  static const double p0 = .333333333333333e+00;
  static const double p1 = -.224696413112536e+00;
  static const double p2 = .620886815375787e-02;
  static const double q1 = -.127408923933623e+01;
  static const double q2 = .354508718369557e+00;
  double rlog, r, t, u, w, w1;
  if (*x < 0.61e0 || *x > 1.57e0) {
    goto S40;
  }
  if (*x < 0.82e0) {
    goto S10;
  }
  if (*x > 1.18e0) {
    goto S20;
  }
  u = *x - 0.5e0 - 0.5e0;
  w1 = 0.0e0;
  goto S30;
S10:
  u = *x - 0.7e0;
  u /= 0.7e0;
  w1 = a - u * 0.3e0;
  goto S30;
S20:
  u = 0.75e0 * *x - 1.e0;
  w1 = b + u / 3.0e0;
S30:
  r = u / (u + 2.0e0);
  t = r * r;
  w = ((p2 * t + p1) * t + p0) / ((q2 * t + q1) * t + 1.0e0);
  rlog = 2.0e0 * t * (1.0e0 / (1.0e0 - r) - r * w) + w1;
  return rlog;
S40:
  r = *x - 0.5e0 - 0.5e0;
  rlog = r - log(*x);
  return rlog;
}


x86 assembly (clang, -O0):
<cdflib_rlog>:
push   %rbp
mov    %rsp,%rbp
sub    $0x50,%rsp
mov    %rdi,-0x10(%rbp)
mov    -0x10(%rbp),%rax
movsd  0xed8(%rip),%xmm0
ucomisd (%rax),%xmm0
ja     114c <cdflib_rlog+0x3c>
mov    -0x10(%rbp),%rax
movsd  (%rax),%xmm0
movsd  0xec6(%rip),%xmm1
ucomisd %xmm1,%xmm0
jbe    1151 <cdflib_rlog+0x41>
jmp    1378 <cdflib_rlog+0x268>
mov    -0x10(%rbp),%rax
movsd  0xeb3(%rip),%xmm0
ucomisd (%rax),%xmm0
jbe    116c <cdflib_rlog+0x5c>
jmp    11bd <cdflib_rlog+0xad>
mov    -0x10(%rbp),%rax
movsd  (%rax),%xmm0
movsd  0xe9c(%rip),%xmm1
ucomisd %xmm1,%xmm0
jbe    118b <cdflib_rlog+0x7b>
jmp    122a <cdflib_rlog+0x11a>
mov    -0x10(%rbp),%rax
movsd  (%rax),%xmm0
movsd  0xe85(%rip),%xmm1
subsd  %xmm1,%xmm0
movsd  0xe79(%rip),%xmm1
subsd  %xmm1,%xmm0
movsd  %xmm0,-0x30(%rbp)
xorps  %xmm0,%xmm0
movsd  %xmm0,-0x40(%rbp)
jmp    1271 <cdflib_rlog+0x161>
mov    -0x10(%rbp),%rax
movsd  (%rax),%xmm0
movsd  0xe8b(%rip),%xmm1
subsd  %xmm1,%xmm0
movsd  %xmm0,-0x30(%rbp)
movsd  -0x30(%rbp),%xmm0
movsd  0xe75(%rip),%xmm1
divsd  %xmm1,%xmm0
movsd  %xmm0,-0x30(%rbp)
movsd  -0x30(%rbp),%xmm0
movq   %xmm0,%rax
movabs $0x8000000000000000,%rcx
xor    %rcx,%rax
movq   %rax,%xmm0
movsd  0xe38(%rip),%xmm1
mulsd  %xmm1,%xmm0
movsd  0xe34(%rip),%xmm1
addsd  %xmm1,%xmm0
movsd  %xmm0,-0x40(%rbp)
jmp    1271 <cdflib_rlog+0x161>
mov    -0x10(%rbp),%rax
movsd  (%rax),%xmm0
movsd  0xdfe(%rip),%xmm1
mulsd  %xmm1,%xmm0
movsd  0xdfa(%rip),%xmm1
addsd  %xmm1,%xmm0
movsd  %xmm0,-0x30(%rbp)
movsd  -0x30(%rbp),%xmm1
movsd  0xdd4(%rip),%xmm0
divsd  %xmm0,%xmm1
movsd  0xdc0(%rip),%xmm0
addsd  %xmm1,%xmm0
movsd  %xmm0,-0x40(%rbp)
movsd  -0x30(%rbp),%xmm0
movsd  0xdea(%rip),%xmm1
addsd  -0x30(%rbp),%xmm1
divsd  %xmm1,%xmm0
movsd  %xmm0,-0x20(%rbp)
movsd  -0x20(%rbp),%xmm0
mulsd  -0x20(%rbp),%xmm0
movsd  %xmm0,-0x28(%rbp)
movsd  -0x28(%rbp),%xmm0
movsd  0xde0(%rip),%xmm1
mulsd  %xmm1,%xmm0
movsd  0xddc(%rip),%xmm1
addsd  %xmm1,%xmm0
movsd  -0x28(%rbp),%xmm1
mulsd  %xmm1,%xmm0
movsd  0xdb7(%rip),%xmm1
addsd  %xmm1,%xmm0
movsd  -0x28(%rbp),%xmm1
movsd  0xd96(%rip),%xmm2
mulsd  %xmm2,%xmm1
movsd  0xd92(%rip),%xmm2
addsd  %xmm2,%xmm1
movsd  -0x28(%rbp),%xmm2
mulsd  %xmm2,%xmm1
movsd  0xd65(%rip),%xmm2
addsd  %xmm2,%xmm1
divsd  %xmm1,%xmm0
movsd  %xmm0,-0x38(%rbp)
movsd  0xd58(%rip),%xmm0
mulsd  -0x28(%rbp),%xmm0
movsd  0xd43(%rip),%xmm2
subsd  -0x20(%rbp),%xmm2
movsd  0xd36(%rip),%xmm1
divsd  %xmm2,%xmm1
movsd  -0x20(%rbp),%xmm2
movsd  -0x38(%rbp),%xmm3
movq   %xmm2,%rax
movabs $0x8000000000000000,%rcx
xor    %rcx,%rax
movq   %rax,%xmm2
mulsd  %xmm3,%xmm2
addsd  %xmm1,%xmm2
movsd  -0x40(%rbp),%xmm1
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
movsd  %xmm0,-0x18(%rbp)
movsd  -0x18(%rbp),%xmm0
movsd  %xmm0,-0x8(%rbp)
jmp    13cf <cdflib_rlog+0x2bf>
mov    -0x10(%rbp),%rax
movsd  (%rax),%xmm0
movsd  0xc98(%rip),%xmm1
subsd  %xmm1,%xmm0
movsd  0xc8c(%rip),%xmm1
subsd  %xmm1,%xmm0
movsd  %xmm0,-0x20(%rbp)
movsd  -0x20(%rbp),%xmm0
movsd  %xmm0,-0x48(%rbp)
mov    -0x10(%rbp),%rax
movsd  (%rax),%xmm0
call   1030 <log@plt>
movaps %xmm0,%xmm1
movsd  -0x48(%rbp),%xmm0
subsd  %xmm1,%xmm0
movsd  %xmm0,-0x18(%rbp)
movsd  -0x18(%rbp),%xmm0
movsd  %xmm0,-0x8(%rbp)
movsd  -0x8(%rbp),%xmm0
add    $0x50,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<cdflib_rlog>:
push   %rax
movsd  (%rdi),%xmm0
movsd  0xee3(%rip),%xmm1
ucomisd %xmm0,%xmm1
ja     1161 <cdflib_rlog+0x51>
ucomisd 0xedd(%rip),%xmm0
ja     1161 <cdflib_rlog+0x51>
movsd  0xedb(%rip),%xmm1
ucomisd %xmm0,%xmm1
jbe    118d <cdflib_rlog+0x7d>
addsd  0xf05(%rip),%xmm0
divsd  0xf05(%rip),%xmm0
movsd  0xf05(%rip),%xmm2
mulsd  %xmm0,%xmm2
addsd  0xf01(%rip),%xmm2
jmp    11d1 <cdflib_rlog+0xc1>
movsd  0xeb7(%rip),%xmm1
movapd %xmm0,%xmm2
addsd  %xmm1,%xmm2
addsd  %xmm1,%xmm2
movsd  %xmm2,(%rsp)
call   1030 <log@plt>
movsd  (%rsp),%xmm1
subsd  %xmm0,%xmm1
jmp    1245 <cdflib_rlog+0x135>
ucomisd 0xe83(%rip),%xmm0
jbe    11bd <cdflib_rlog+0xad>
mulsd  0xe89(%rip),%xmm0
addsd  0xe89(%rip),%xmm0
movapd %xmm0,%xmm2
divsd  0xe85(%rip),%xmm2
addsd  0xe85(%rip),%xmm2
jmp    11d1 <cdflib_rlog+0xc1>
movsd  0xe5b(%rip),%xmm1
addsd  %xmm1,%xmm0
addsd  %xmm1,%xmm0
xorpd  %xmm2,%xmm2
movsd  0xe8f(%rip),%xmm1
addsd  %xmm0,%xmm1
divsd  %xmm1,%xmm0
movapd %xmm0,%xmm3
mulsd  %xmm0,%xmm3
movapd %xmm3,%xmm1
unpcklpd %xmm3,%xmm1
movapd 0xe87(%rip),%xmm4
mulpd  %xmm1,%xmm4
addpd  0xe8b(%rip),%xmm4
mulpd  %xmm1,%xmm4
addpd  0xe8f(%rip),%xmm4
movapd %xmm4,%xmm1
unpckhpd %xmm4,%xmm1
divsd  %xmm1,%xmm4
addsd  %xmm3,%xmm3
movsd  0xe47(%rip),%xmm1
movapd %xmm1,%xmm5
subsd  %xmm0,%xmm5
divsd  %xmm5,%xmm1
mulsd  %xmm0,%xmm4
subsd  %xmm4,%xmm1
mulsd  %xmm3,%xmm1
addsd  %xmm2,%xmm1
movapd %xmm1,%xmm0
pop    %rax
ret

LLVM IR (-O0):
@cdflib_rlog.a = internal constant double 0x3FAD047F8D7060E0
@cdflib_rlog.b = internal constant double 0x3FA75F9A2103CE16
@cdflib_rlog.p0 = internal constant double 0x3FD555555555554F
@cdflib_rlog.p1 = internal constant double 0xBFCCC2DA20EC6581
@cdflib_rlog.p2 = internal constant double 0x3F796E785AA6287C
@cdflib_rlog.q1 = internal constant double 0xBFF462AB65F2276C
@cdflib_rlog.q2 = internal constant double 0x3FD6B04555E2D2E4
define double @cdflib_rlog(double* %0) {
%2 = alloca double
%3 = alloca double*
%4 = alloca double
%5 = alloca double
%6 = alloca double
%7 = alloca double
%8 = alloca double
%9 = alloca double
store double* %0, double** %3
%10 = load double*, double** %3
%11 = load double, double* %10
%12 = fcmp olt double %11, 6.100000e-01
br i1 %12, label %17, label %13
13: ; preds = %1
%14 = load double*, double** %3
%15 = load double, double* %14
%16 = fcmp ogt double %15, 1.570000e+00
br i1 %16, label %17, label %18
17: ; preds = %13, %1
br label %78
18: ; preds = %13
%19 = load double*, double** %3
%20 = load double, double* %19
%21 = fcmp olt double %20, 8.200000e-01
br i1 %21, label %22, label %23
22: ; preds = %18
br label %33
23: ; preds = %18
%24 = load double*, double** %3
%25 = load double, double* %24
%26 = fcmp ogt double %25, 1.180000e+00
br i1 %26, label %27, label %28
27: ; preds = %23
br label %42
28: ; preds = %23
%29 = load double*, double** %3
%30 = load double, double* %29
%31 = fsub double %30, 5.000000e-01
%32 = fsub double %31, 5.000000e-01
store double %32, double* %7
store double 0.000000e+00, double* %9
br label %49
33: ; preds = %22
%34 = load double*, double** %3
%35 = load double, double* %34
%36 = fsub double %35, 0x3FE6666666666666
store double %36, double* %7
%37 = load double, double* %7
%38 = fdiv double %37, 0x3FE6666666666666
store double %38, double* %7
%39 = load double, double* %7
%40 = fneg double %39
%41 = call double @llvm.fmuladd.f64(double %40, double 3.000000e-01, double 0x3FAD047F8D7060E0)
store double %41, double* %9
br label %49
42: ; preds = %27
%43 = load double*, double** %3
%44 = load double, double* %43
%45 = call double @llvm.fmuladd.f64(double 7.500000e-01, double %44, double -1.000000e+00)
store double %45, double* %7
%46 = load double, double* %7
%47 = fdiv double %46, 3.000000e+00
%48 = fadd double 0x3FA75F9A2103CE16, %47
store double %48, double* %9
br label %49
49: ; preds = %42, %33, %28
%50 = load double, double* %7
%51 = load double, double* %7
%52 = fadd double %51, 2.000000e+00
%53 = fdiv double %50, %52
store double %53, double* %5
%54 = load double, double* %5
%55 = load double, double* %5
%56 = fmul double %54, %55
store double %56, double* %6
%57 = load double, double* %6
%58 = call double @llvm.fmuladd.f64(double 0x3F796E785AA6287C, double %57, double 0xBFCCC2DA20EC6581)
%59 = load double, double* %6
%60 = call double @llvm.fmuladd.f64(double %58, double %59, double 0x3FD555555555554F)
%61 = load double, double* %6
%62 = call double @llvm.fmuladd.f64(double 0x3FD6B04555E2D2E4, double %61, double 0xBFF462AB65F2276C)
%63 = load double, double* %6
%64 = call double @llvm.fmuladd.f64(double %62, double %63, double 1.000000e+00)
%65 = fdiv double %60, %64
store double %65, double* %8
%66 = load double, double* %6
%67 = fmul double 2.000000e+00, %66
%68 = load double, double* %5
%69 = fsub double 1.000000e+00, %68
%70 = fdiv double 1.000000e+00, %69
%71 = load double, double* %5
%72 = load double, double* %8
%73 = fneg double %71
%74 = call double @llvm.fmuladd.f64(double %73, double %72, double %70)
%75 = load double, double* %9
%76 = call double @llvm.fmuladd.f64(double %67, double %74, double %75)
store double %76, double* %4
%77 = load double, double* %4
store double %77, double* %2
br label %89
78: ; preds = %17
%79 = load double*, double** %3
%80 = load double, double* %79
%81 = fsub double %80, 5.000000e-01
%82 = fsub double %81, 5.000000e-01
store double %82, double* %5
%83 = load double, double* %5
%84 = load double*, double** %3
%85 = load double, double* %84
%86 = call double @log(double %85)
%87 = fsub double %83, %86
store double %87, double* %4
%88 = load double, double* %4
store double %88, double* %2
br label %89
89: ; preds = %78, %49
%90 = load double, double* %2
ret double %90
}

LLVM IR (-O2):
define double @cdflib_rlog(double* nocapture %0) {
%2 = load double, double* %0
%3 = fcmp olt double %2, 6.100000e-01
%4 = fcmp ogt double %2, 1.570000e+00
%5 = or i1 %3, %4
br i1 %5, label %41, label %6
6: ; preds = %1
%7 = fcmp olt double %2, 8.200000e-01
br i1 %7, label %13, label %8
8: ; preds = %6
%9 = fcmp ogt double %2, 1.180000e+00
br i1 %9, label %18, label %10
10: ; preds = %8
%11 = fadd double %2, -5.000000e-01
%12 = fadd double %11, -5.000000e-01
br label %22
13: ; preds = %6
%14 = fadd double %2, 0xBFE6666666666666
%15 = fdiv double %14, 0x3FE6666666666666
%16 = fneg double %15
%17 = tail call double @llvm.fmuladd.f64(double %16, double 3.000000e-01, double 0x3FAD047F8D7060E0)
br label %22
18: ; preds = %8
%19 = tail call double @llvm.fmuladd.f64(double %2, double 7.500000e-01, double -1.000000e+00)
%20 = fdiv double %19, 3.000000e+00
%21 = fadd double %20, 0x3FA75F9A2103CE16
br label %22
22: ; preds = %18, %13, %10
%23 = phi double [ %15, %13 ], [ %19, %18 ], [ %12, %10 ]
%24 = phi double [ %17, %13 ], [ %21, %18 ], [ 0.000000e+00, %10 ]
%25 = fadd double %23, 2.000000e+00
%26 = fdiv double %23, %25
%27 = fmul double %26, %26
%28 = insertelement <2 x double> poison, double %27, i64 0
%29 = shufflevector <2 x double> %28, <2 x double> poison, <2 x i32> zeroinitializer
%30 = call <2 x double> @llvm.fmuladd.v2f64(<2 x double> %29, <2 x double> <double 0x3F796E785AA6287C, double 0x3FD6B04555E2D2E4>, <2 x double> <double 0xBFCCC2DA20EC6581, double 0xBFF462AB65F2276C>)
%31 = call <2 x double> @llvm.fmuladd.v2f64(<2 x double> %30, <2 x double> %29, <2 x double> <double 0x3FD555555555554F, double 1.000000e+00>)
%32 = extractelement <2 x double> %31, i64 0
%33 = extractelement <2 x double> %31, i64 1
%34 = fdiv double %32, %33
%35 = fmul double %27, 2.000000e+00
%36 = fsub double 1.000000e+00, %26
%37 = fdiv double 1.000000e+00, %36
%38 = fneg double %26
%39 = tail call double @llvm.fmuladd.f64(double %38, double %34, double %37)
%40 = tail call double @llvm.fmuladd.f64(double %35, double %39, double %24)
br label %46
41: ; preds = %1
%42 = fadd double %2, -5.000000e-01
%43 = fadd double %42, -5.000000e-01
%44 = tail call double @log(double %2)
%45 = fsub double %43, %44
br label %46
46: ; preds = %41, %22
%47 = phi double [ %45, %41 ], [ %40, %22 ]
ret double %47
}