double randlc(double *x, double a) {
  double t1, t2, t3, t4, a1, a2, x1, x2, z;
  t1 = (0.5 * 0.5 * 0.5 * 0.5 * 0.5 * 0.5 * 0.5 * 0.5 * 0.5 * 0.5 * 0.5 * 0.5 *
        0.5 * 0.5 * 0.5 * 0.5 * 0.5 * 0.5 * 0.5 * 0.5 * 0.5 * 0.5 * 0.5) *
       a;
  a1 = (int)t1;
  a2 = a -
       (2.0 * 2.0 * 2.0 * 2.0 * 2.0 * 2.0 * 2.0 * 2.0 * 2.0 * 2.0 * 2.0 * 2.0 *
        2.0 * 2.0 * 2.0 * 2.0 * 2.0 * 2.0 * 2.0 * 2.0 * 2.0 * 2.0 * 2.0) *
           a1;
  t1 = (0.5 * 0.5 * 0.5 * 0.5 * 0.5 * 0.5 * 0.5 * 0.5 * 0.5 * 0.5 * 0.5 * 0.5 *
        0.5 * 0.5 * 0.5 * 0.5 * 0.5 * 0.5 * 0.5 * 0.5 * 0.5 * 0.5 * 0.5) *
       (*x);
  x1 = (int)t1;
  x2 = (*x) -
       (2.0 * 2.0 * 2.0 * 2.0 * 2.0 * 2.0 * 2.0 * 2.0 * 2.0 * 2.0 * 2.0 * 2.0 *
        2.0 * 2.0 * 2.0 * 2.0 * 2.0 * 2.0 * 2.0 * 2.0 * 2.0 * 2.0 * 2.0) *
           x1;
  t1 = a1 * x2 + a2 * x1;
  t2 = (int)((0.5 * 0.5 * 0.5 * 0.5 * 0.5 * 0.5 * 0.5 * 0.5 * 0.5 * 0.5 * 0.5 *
              0.5 * 0.5 * 0.5 * 0.5 * 0.5 * 0.5 * 0.5 * 0.5 * 0.5 * 0.5 * 0.5 *
              0.5) *
             t1);
  z = t1 -
      (2.0 * 2.0 * 2.0 * 2.0 * 2.0 * 2.0 * 2.0 * 2.0 * 2.0 * 2.0 * 2.0 * 2.0 *
       2.0 * 2.0 * 2.0 * 2.0 * 2.0 * 2.0 * 2.0 * 2.0 * 2.0 * 2.0 * 2.0) *
          t2;
  t3 = (2.0 * 2.0 * 2.0 * 2.0 * 2.0 * 2.0 * 2.0 * 2.0 * 2.0 * 2.0 * 2.0 * 2.0 *
        2.0 * 2.0 * 2.0 * 2.0 * 2.0 * 2.0 * 2.0 * 2.0 * 2.0 * 2.0 * 2.0) *
           z +
       a2 * x2;
  t4 = (int)(((0.5 * 0.5 * 0.5 * 0.5 * 0.5 * 0.5 * 0.5 * 0.5 * 0.5 * 0.5 * 0.5 *
               0.5 * 0.5 * 0.5 * 0.5 * 0.5 * 0.5 * 0.5 * 0.5 * 0.5 * 0.5 * 0.5 *
               0.5) *
              (0.5 * 0.5 * 0.5 * 0.5 * 0.5 * 0.5 * 0.5 * 0.5 * 0.5 * 0.5 * 0.5 *
               0.5 * 0.5 * 0.5 * 0.5 * 0.5 * 0.5 * 0.5 * 0.5 * 0.5 * 0.5 * 0.5 *
               0.5)) *
             t3);
  (*x) =
      t3 -
      ((2.0 * 2.0 * 2.0 * 2.0 * 2.0 * 2.0 * 2.0 * 2.0 * 2.0 * 2.0 * 2.0 * 2.0 *
        2.0 * 2.0 * 2.0 * 2.0 * 2.0 * 2.0 * 2.0 * 2.0 * 2.0 * 2.0 * 2.0) *
       (2.0 * 2.0 * 2.0 * 2.0 * 2.0 * 2.0 * 2.0 * 2.0 * 2.0 * 2.0 * 2.0 * 2.0 *
        2.0 * 2.0 * 2.0 * 2.0 * 2.0 * 2.0 * 2.0 * 2.0 * 2.0 * 2.0 * 2.0)) *
          t4;
  return (
      ((0.5 * 0.5 * 0.5 * 0.5 * 0.5 * 0.5 * 0.5 * 0.5 * 0.5 * 0.5 * 0.5 * 0.5 *
        0.5 * 0.5 * 0.5 * 0.5 * 0.5 * 0.5 * 0.5 * 0.5 * 0.5 * 0.5 * 0.5) *
       (0.5 * 0.5 * 0.5 * 0.5 * 0.5 * 0.5 * 0.5 * 0.5 * 0.5 * 0.5 * 0.5 * 0.5 *
        0.5 * 0.5 * 0.5 * 0.5 * 0.5 * 0.5 * 0.5 * 0.5 * 0.5 * 0.5 * 0.5)) *
      (*x));
}


x86 assembly (clang, -O0):
<randlc>:
push   %rbp
mov    %rsp,%rbp
mov    %rdi,-0x8(%rbp)
movsd  %xmm0,-0x10(%rbp)
movsd  0xf0b(%rip),%xmm0
mulsd  -0x10(%rbp),%xmm0
movsd  %xmm0,-0x18(%rbp)
cvttsd2si -0x18(%rbp),%eax
cvtsi2sd %eax,%xmm0
movsd  %xmm0,-0x38(%rbp)
movsd  -0x10(%rbp),%xmm1
movsd  -0x38(%rbp),%xmm0
movsd  0xed9(%rip),%xmm2
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
movsd  %xmm0,-0x40(%rbp)
mov    -0x8(%rbp),%rax
movsd  0xec8(%rip),%xmm0
mulsd  (%rax),%xmm0
movsd  %xmm0,-0x18(%rbp)
cvttsd2si -0x18(%rbp),%eax
cvtsi2sd %eax,%xmm0
movsd  %xmm0,-0x48(%rbp)
mov    -0x8(%rbp),%rax
movsd  (%rax),%xmm1
movsd  -0x48(%rbp),%xmm0
movsd  0xe94(%rip),%xmm2
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
movsd  %xmm0,-0x50(%rbp)
movsd  -0x38(%rbp),%xmm0
movsd  -0x50(%rbp),%xmm2
movsd  -0x40(%rbp),%xmm1
mulsd  -0x48(%rbp),%xmm1
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
movsd  %xmm0,-0x18(%rbp)
movsd  0xe66(%rip),%xmm0
mulsd  -0x18(%rbp),%xmm0
cvttsd2si %xmm0,%eax
cvtsi2sd %eax,%xmm0
movsd  %xmm0,-0x20(%rbp)
movsd  -0x18(%rbp),%xmm1
movsd  -0x20(%rbp),%xmm0
movsd  0xe3a(%rip),%xmm2
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
movsd  %xmm0,-0x58(%rbp)
movsd  -0x58(%rbp),%xmm0
movsd  -0x40(%rbp),%xmm1
mulsd  -0x50(%rbp),%xmm1
movsd  0xe0e(%rip),%xmm2
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
movsd  %xmm0,-0x28(%rbp)
movsd  0xde9(%rip),%xmm0
mulsd  -0x28(%rbp),%xmm0
cvttsd2si %xmm0,%eax
cvtsi2sd %eax,%xmm0
movsd  %xmm0,-0x30(%rbp)
movsd  -0x28(%rbp),%xmm1
movsd  -0x30(%rbp),%xmm0
movsd  0xdcd(%rip),%xmm2
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
mov    -0x8(%rbp),%rax
movsd  %xmm0,(%rax)
mov    -0x8(%rbp),%rax
movsd  0xda9(%rip),%xmm0
mulsd  (%rax),%xmm0
pop    %rbp
ret

x86 assembly (clang, -O2):
<randlc>:
movhpd (%rdi),%xmm0
movapd 0xef4(%rip),%xmm1
mulpd  %xmm0,%xmm1
cvttpd2dq %xmm1,%xmm1
cvtdq2pd %xmm1,%xmm1
movapd 0xef0(%rip),%xmm2
mulpd  %xmm1,%xmm2
addpd  %xmm2,%xmm0
movapd %xmm1,%xmm2
unpckhpd %xmm1,%xmm2
mulsd  %xmm0,%xmm2
movapd %xmm0,%xmm3
unpckhpd %xmm0,%xmm3
mulsd  %xmm3,%xmm1
addsd  %xmm2,%xmm1
movsd  0xed4(%rip),%xmm2
mulsd  %xmm1,%xmm2
cvttpd2dq %xmm2,%xmm2
cvtdq2pd %xmm2,%xmm2
mulsd  0xec8(%rip),%xmm2
addsd  %xmm1,%xmm2
mulsd  %xmm3,%xmm0
mulsd  0xec0(%rip),%xmm2
addsd  %xmm2,%xmm0
movsd  0xebc(%rip),%xmm1
movapd %xmm0,%xmm2
mulsd  %xmm1,%xmm2
cvttpd2dq %xmm2,%xmm2
cvtdq2pd %xmm2,%xmm2
mulsd  0xeac(%rip),%xmm2
addsd  %xmm2,%xmm0
movsd  %xmm0,(%rdi)
mulsd  %xmm1,%xmm0
ret

LLVM IR (-O0):
define double @randlc(double* %0, double %1) {
%3 = alloca double*
%4 = alloca double
%5 = alloca double
%6 = alloca double
%7 = alloca double
%8 = alloca double
%9 = alloca double
%10 = alloca double
%11 = alloca double
%12 = alloca double
%13 = alloca double
store double* %0, double** %3
store double %1, double* %4
%14 = load double, double* %4
%15 = fmul double 0x3E80000000000000, %14
store double %15, double* %5
%16 = load double, double* %5
%17 = fptosi double %16 to i32
%18 = sitofp i32 %17 to double
store double %18, double* %9
%19 = load double, double* %4
%20 = load double, double* %9
%21 = call double @llvm.fmuladd.f64(double 0xC160000000000000, double %20, double %19)
store double %21, double* %10
%22 = load double*, double** %3
%23 = load double, double* %22
%24 = fmul double 0x3E80000000000000, %23
store double %24, double* %5
%25 = load double, double* %5
%26 = fptosi double %25 to i32
%27 = sitofp i32 %26 to double
store double %27, double* %11
%28 = load double*, double** %3
%29 = load double, double* %28
%30 = load double, double* %11
%31 = call double @llvm.fmuladd.f64(double 0xC160000000000000, double %30, double %29)
store double %31, double* %12
%32 = load double, double* %9
%33 = load double, double* %12
%34 = load double, double* %10
%35 = load double, double* %11
%36 = fmul double %34, %35
%37 = call double @llvm.fmuladd.f64(double %32, double %33, double %36)
store double %37, double* %5
%38 = load double, double* %5
%39 = fmul double 0x3E80000000000000, %38
%40 = fptosi double %39 to i32
%41 = sitofp i32 %40 to double
store double %41, double* %6
%42 = load double, double* %5
%43 = load double, double* %6
%44 = call double @llvm.fmuladd.f64(double 0xC160000000000000, double %43, double %42)
store double %44, double* %13
%45 = load double, double* %13
%46 = load double, double* %10
%47 = load double, double* %12
%48 = fmul double %46, %47
%49 = call double @llvm.fmuladd.f64(double 0x4160000000000000, double %45, double %48)
store double %49, double* %7
%50 = load double, double* %7
%51 = fmul double 0x3D10000000000000, %50
%52 = fptosi double %51 to i32
%53 = sitofp i32 %52 to double
store double %53, double* %8
%54 = load double, double* %7
%55 = load double, double* %8
%56 = call double @llvm.fmuladd.f64(double 0xC2D0000000000000, double %55, double %54)
%57 = load double*, double** %3
store double %56, double* %57
%58 = load double*, double** %3
%59 = load double, double* %58
%60 = fmul double 0x3D10000000000000, %59
ret double %60
}

LLVM IR (-O2):
define double @randlc(double* nocapture %0, double %1) {
%3 = load double, double* %0
%4 = insertelement <2 x double> poison, double %1, i64 0
%5 = insertelement <2 x double> %4, double %3, i64 1
%6 = fmul <2 x double> %5, <double 0x3E80000000000000, double 0x3E80000000000000>
%7 = fptosi <2 x double> %6 to <2 x i32>
%8 = sitofp <2 x i32> %7 to <2 x double>
%9 = call <2 x double> @llvm.fmuladd.v2f64(<2 x double> %8, <2 x double> <double 0xC160000000000000, double 0xC160000000000000>, <2 x double> %5)
%10 = extractelement <2 x double> %9, i64 0
%11 = shufflevector <2 x double> %8, <2 x double> poison, <2 x i32> <i32 1, i32 undef>
%12 = fmul <2 x double> %9, %11
%13 = extractelement <2 x double> %12, i64 0
%14 = extractelement <2 x double> %9, i64 1
%15 = extractelement <2 x double> %8, i64 0
%16 = tail call double @llvm.fmuladd.f64(double %15, double %14, double %13)
%17 = fmul double %16, 0x3E80000000000000
%18 = fptosi double %17 to i32
%19 = sitofp i32 %18 to double
%20 = tail call double @llvm.fmuladd.f64(double %19, double 0xC160000000000000, double %16)
%21 = fmul double %10, %14
%22 = tail call double @llvm.fmuladd.f64(double %20, double 0x4160000000000000, double %21)
%23 = fmul double %22, 0x3D10000000000000
%24 = fptosi double %23 to i32
%25 = sitofp i32 %24 to double
%26 = tail call double @llvm.fmuladd.f64(double %25, double 0xC2D0000000000000, double %22)
store double %26, double* %0
%27 = fmul double %26, 0x3D10000000000000
ret double %27
}