#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_rlog1(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 rlog1, h, r, t, w, w1;
  if (*x < -0.39e0 || *x > 0.57e0) {
    goto S40;
  }
  if (*x < -0.18e0) {
    goto S10;
  }
  if (*x > 0.18e0) {
    goto S20;
  }
  h = *x;
  w1 = 0.0e0;
  goto S30;
S10:
  h = *x + 0.3e0;
  h /= 0.7e0;
  w1 = a - h * 0.3e0;
  goto S30;
S20:
  h = 0.75e0 * *x - 0.25e0;
  w1 = b + h / 3.0e0;
S30:
  r = h / (h + 2.0e0);
  t = r * r;
  w = ((p2 * t + p1) * t + p0) / ((q2 * t + q1) * t + 1.0e0);
  rlog1 = 2.0e0 * t * (1.0e0 / (1.0e0 - r) - r * w) + w1;
  return rlog1;
S40:
  w = *x + 0.5e0 + 0.5e0;
  rlog1 = *x - log(w);
  return rlog1;
}


x86 assembly (clang, -O0):
<cdflib_rlog1>:
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_rlog1+0x3c>
mov    -0x10(%rbp),%rax
movsd  (%rax),%xmm0
movsd  0xec6(%rip),%xmm1
ucomisd %xmm1,%xmm0
jbe    1151 <cdflib_rlog1+0x41>
jmp    135c <cdflib_rlog1+0x24c>
mov    -0x10(%rbp),%rax
movsd  0xeb3(%rip),%xmm0
ucomisd (%rax),%xmm0
jbe    116c <cdflib_rlog1+0x5c>
jmp    11a5 <cdflib_rlog1+0x95>
mov    -0x10(%rbp),%rax
movsd  (%rax),%xmm0
movsd  0xe9c(%rip),%xmm1
ucomisd %xmm1,%xmm0
jbe    118b <cdflib_rlog1+0x7b>
jmp    120e <cdflib_rlog1+0xfe>
mov    -0x10(%rbp),%rax
movsd  (%rax),%xmm0
movsd  %xmm0,-0x20(%rbp)
xorps  %xmm0,%xmm0
movsd  %xmm0,-0x40(%rbp)
jmp    1255 <cdflib_rlog1+0x145>
mov    -0x10(%rbp),%rax
movsd  0xe8f(%rip),%xmm0
addsd  (%rax),%xmm0
movsd  %xmm0,-0x20(%rbp)
movsd  -0x20(%rbp),%xmm0
movsd  0xe89(%rip),%xmm1
divsd  %xmm1,%xmm0
movsd  %xmm0,-0x20(%rbp)
movsd  -0x20(%rbp),%xmm0
movq   %xmm0,%rax
movabs $0x8000000000000000,%rcx
xor    %rcx,%rax
movq   %rax,%xmm0
movsd  0xe4c(%rip),%xmm1
mulsd  %xmm1,%xmm0
movsd  0xe48(%rip),%xmm1
addsd  %xmm1,%xmm0
movsd  %xmm0,-0x40(%rbp)
jmp    1255 <cdflib_rlog1+0x145>
mov    -0x10(%rbp),%rax
movsd  (%rax),%xmm0
movsd  0xe12(%rip),%xmm1
mulsd  %xmm1,%xmm0
movsd  0xe0e(%rip),%xmm1
addsd  %xmm1,%xmm0
movsd  %xmm0,-0x20(%rbp)
movsd  -0x20(%rbp),%xmm1
movsd  0xde8(%rip),%xmm0
divsd  %xmm0,%xmm1
movsd  0xdd4(%rip),%xmm0
addsd  %xmm1,%xmm0
movsd  %xmm0,-0x40(%rbp)
movsd  -0x20(%rbp),%xmm0
movsd  0xdfe(%rip),%xmm1
addsd  -0x20(%rbp),%xmm1
divsd  %xmm1,%xmm0
movsd  %xmm0,-0x28(%rbp)
movsd  -0x28(%rbp),%xmm0
mulsd  -0x28(%rbp),%xmm0
movsd  %xmm0,-0x30(%rbp)
movsd  -0x30(%rbp),%xmm0
movsd  0xdf4(%rip),%xmm1
mulsd  %xmm1,%xmm0
movsd  0xdf0(%rip),%xmm1
addsd  %xmm1,%xmm0
movsd  -0x30(%rbp),%xmm1
mulsd  %xmm1,%xmm0
movsd  0xdcb(%rip),%xmm1
addsd  %xmm1,%xmm0
movsd  -0x30(%rbp),%xmm1
movsd  0xdaa(%rip),%xmm2
mulsd  %xmm2,%xmm1
movsd  0xda6(%rip),%xmm2
addsd  %xmm2,%xmm1
movsd  -0x30(%rbp),%xmm2
mulsd  %xmm2,%xmm1
movsd  0xd79(%rip),%xmm2
addsd  %xmm2,%xmm1
divsd  %xmm1,%xmm0
movsd  %xmm0,-0x38(%rbp)
movsd  0xd6c(%rip),%xmm0
mulsd  -0x30(%rbp),%xmm0
movsd  0xd57(%rip),%xmm2
subsd  -0x28(%rbp),%xmm2
movsd  0xd4a(%rip),%xmm1
divsd  %xmm2,%xmm1
movsd  -0x28(%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    13af <cdflib_rlog1+0x29f>
mov    -0x10(%rbp),%rax
movsd  0xd28(%rip),%xmm0
addsd  (%rax),%xmm0
movsd  0xd1c(%rip),%xmm1
addsd  %xmm1,%xmm0
movsd  %xmm0,-0x38(%rbp)
mov    -0x10(%rbp),%rax
movsd  (%rax),%xmm0
movsd  %xmm0,-0x48(%rbp)
movsd  -0x38(%rbp),%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_rlog1>:
push   %rax
movsd  (%rdi),%xmm5
movsd  0xee3(%rip),%xmm0
ucomisd %xmm5,%xmm0
ja     1161 <cdflib_rlog1+0x51>
ucomisd 0xedd(%rip),%xmm5
ja     1161 <cdflib_rlog1+0x51>
movsd  0xedb(%rip),%xmm0
ucomisd %xmm5,%xmm0
jbe    118e <cdflib_rlog1+0x7e>
movsd  0xefd(%rip),%xmm0
addsd  %xmm0,%xmm5
divsd  0xef9(%rip),%xmm5
mulsd  %xmm5,%xmm0
movsd  0xef5(%rip),%xmm1
subsd  %xmm0,%xmm1
jmp    11c0 <cdflib_rlog1+0xb0>
movsd  0xeff(%rip),%xmm1
movapd %xmm5,%xmm0
addsd  %xmm1,%xmm0
addsd  %xmm1,%xmm0
movsd  %xmm5,(%rsp)
call   1030 <log@plt>
movsd  (%rsp),%xmm1
subsd  %xmm0,%xmm1
movapd %xmm1,%xmm0
pop    %rax
ret
xorpd  %xmm1,%xmm1
ucomisd 0xe7e(%rip),%xmm5
jbe    11c0 <cdflib_rlog1+0xb0>
mulsd  0xe7c(%rip),%xmm5
addsd  0xe7c(%rip),%xmm5
movapd %xmm5,%xmm1
divsd  0xe78(%rip),%xmm1
addsd  0xe78(%rip),%xmm1
movsd  0xe90(%rip),%xmm0
addsd  %xmm5,%xmm0
divsd  %xmm0,%xmm5
movapd %xmm5,%xmm2
mulsd  %xmm5,%xmm2
movapd %xmm2,%xmm0
unpcklpd %xmm2,%xmm0
movapd 0xe88(%rip),%xmm3
mulpd  %xmm0,%xmm3
addpd  0xe8c(%rip),%xmm3
mulpd  %xmm0,%xmm3
addpd  0xe90(%rip),%xmm3
movapd %xmm3,%xmm0
unpckhpd %xmm3,%xmm0
divsd  %xmm0,%xmm3
addsd  %xmm2,%xmm2
movsd  0xe48(%rip),%xmm0
movapd %xmm0,%xmm4
subsd  %xmm5,%xmm4
divsd  %xmm4,%xmm0
mulsd  %xmm5,%xmm3
subsd  %xmm3,%xmm0
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
pop    %rax
ret

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

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