double randlc(double *X, double *A) {
  static int KS;
  static double R23, R46, T23, T46;
  double T1, T2, T3, T4;
  double A1;
  double A2;
  double X1;
  double X2;
  double Z;
  int i, j;
  if (KS == 0) {
    R23 = 1.0;
    R46 = 1.0;
    T23 = 1.0;
    T46 = 1.0;
    for (i = 1; i <= 23; i++) {
      R23 = 0.50 * R23;
      T23 = 2.0 * T23;
    }
    for (i = 1; i <= 46; i++) {
      R46 = 0.50 * R46;
      T46 = 2.0 * T46;
    }
    KS = 1;
  }
  T1 = R23 * *A;
  j = (int)T1;
  A1 = j;
  A2 = *A - T23 * A1;
  T1 = R23 * *X;
  j = (int)T1;
  X1 = j;
  X2 = *X - T23 * X1;
  T1 = A1 * X2 + A2 * X1;
  j = (int)(R23 * T1);
  T2 = j;
  Z = T1 - T23 * T2;
  T3 = T23 * Z + A2 * X2;
  j = (int)(R46 * T3);
  T4 = j;
  *X = T3 - T46 * T4;
  return (R46 * *X);
}


x86 assembly (clang, -O0):
<randlc>:
push   %rbp
mov    %rsp,%rbp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
cmpl   $0x0,0x2f15(%rip)
jne    1201 <randlc+0x101>
movsd  0xedf(%rip),%xmm0
movsd  %xmm0,0x2f07(%rip)
movsd  0xecf(%rip),%xmm0
movsd  %xmm0,0x2eff(%rip)
movsd  0xebf(%rip),%xmm0
movsd  %xmm0,0x2ef7(%rip)
movsd  0xeaf(%rip),%xmm0
movsd  %xmm0,0x2eef(%rip)
movl   $0x1,-0x5c(%rbp)
cmpl   $0x17,-0x5c(%rbp)
jg     11a8 <randlc+0xa8>
movsd  0xe9e(%rip),%xmm0
mulsd  0x2eb6(%rip),%xmm0
movsd  %xmm0,0x2eae(%rip)
movsd  0xe7e(%rip),%xmm0
mulsd  0x2eae(%rip),%xmm0
movsd  %xmm0,0x2ea6(%rip)
mov    -0x5c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x5c(%rbp)
jmp    1160 <randlc+0x60>
movl   $0x1,-0x5c(%rbp)
cmpl   $0x2e,-0x5c(%rbp)
jg     11f7 <randlc+0xf7>
movsd  0xe4f(%rip),%xmm0
mulsd  0x2e6f(%rip),%xmm0
movsd  %xmm0,0x2e67(%rip)
movsd  0xe2f(%rip),%xmm0
mulsd  0x2e67(%rip),%xmm0
movsd  %xmm0,0x2e5f(%rip)
mov    -0x5c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x5c(%rbp)
jmp    11af <randlc+0xaf>
movl   $0x1,0x2e27(%rip)
movsd  0x2e27(%rip),%xmm0
mov    -0x10(%rbp),%rax
mulsd  (%rax),%xmm0
movsd  %xmm0,-0x18(%rbp)
cvttsd2si -0x18(%rbp),%eax
mov    %eax,-0x60(%rbp)
cvtsi2sdl -0x60(%rbp),%xmm0
movsd  %xmm0,-0x38(%rbp)
mov    -0x10(%rbp),%rax
movsd  (%rax),%xmm1
movsd  0x2e08(%rip),%xmm0
movsd  -0x38(%rbp),%xmm2
movq   %xmm0,%rax
movabs $0x8000000000000000,%rcx
xor    %rcx,%rax
movq   %rax,%xmm0
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
movsd  %xmm0,-0x40(%rbp)
movsd  0x2dc7(%rip),%xmm0
mov    -0x8(%rbp),%rax
mulsd  (%rax),%xmm0
movsd  %xmm0,-0x18(%rbp)
cvttsd2si -0x18(%rbp),%eax
mov    %eax,-0x60(%rbp)
cvtsi2sdl -0x60(%rbp),%xmm0
movsd  %xmm0,-0x48(%rbp)
mov    -0x8(%rbp),%rax
movsd  (%rax),%xmm1
movsd  0x2da8(%rip),%xmm0
movsd  -0x48(%rbp),%xmm2
movq   %xmm0,%rax
movabs $0x8000000000000000,%rcx
xor    %rcx,%rax
movq   %rax,%xmm0
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  0x2d46(%rip),%xmm0
mulsd  -0x18(%rbp),%xmm0
cvttsd2si %xmm0,%eax
mov    %eax,-0x60(%rbp)
cvtsi2sdl -0x60(%rbp),%xmm0
movsd  %xmm0,-0x20(%rbp)
movsd  -0x18(%rbp),%xmm1
movsd  0x2d33(%rip),%xmm0
movsd  -0x20(%rbp),%xmm2
movq   %xmm0,%rax
movabs $0x8000000000000000,%rcx
xor    %rcx,%rax
movq   %rax,%xmm0
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
movsd  %xmm0,-0x58(%rbp)
movsd  0x2d02(%rip),%xmm0
movsd  -0x58(%rbp),%xmm2
movsd  -0x40(%rbp),%xmm1
mulsd  -0x50(%rbp),%xmm1
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
movsd  %xmm0,-0x28(%rbp)
movsd  0x2cd6(%rip),%xmm0
mulsd  -0x28(%rbp),%xmm0
cvttsd2si %xmm0,%eax
mov    %eax,-0x60(%rbp)
cvtsi2sdl -0x60(%rbp),%xmm0
movsd  %xmm0,-0x30(%rbp)
movsd  -0x28(%rbp),%xmm1
movsd  0x2cc3(%rip),%xmm0
movsd  -0x30(%rbp),%xmm2
movq   %xmm0,%rax
movabs $0x8000000000000000,%rcx
xor    %rcx,%rax
movq   %rax,%xmm0
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
mov    -0x8(%rbp),%rax
movsd  %xmm0,(%rax)
movsd  0x2c7f(%rip),%xmm0
mov    -0x8(%rbp),%rax
mulsd  (%rax),%xmm0
pop    %rbp
ret

x86 assembly (clang, -O2):
<randlc>:
cmpb   $0x1,0x2f21(%rip)
jne    112b <randlc+0x2b>
movsd  0x2f1f(%rip),%xmm4
movsd  0x2f27(%rip),%xmm3
movsd  0x2f17(%rip),%xmm1
movsd  0x2f1f(%rip),%xmm2
jmp    1196 <randlc+0x96>
movabs $0x3e80000000000000,%rax
mov    %rax,0x2ef4(%rip)
movabs $0x4160000000000000,%rax
mov    %rax,0x2ef3(%rip)
movabs $0x3d10000000000000,%rax
mov    %rax,0x2eda(%rip)
movabs $0x42d0000000000000,%rax
mov    %rax,0x2ed9(%rip)
movb   $0x1,0x2eb2(%rip)
movsd  0xe82(%rip),%xmm4
movsd  0xe82(%rip),%xmm3
movsd  0xe82(%rip),%xmm1
movsd  0xe82(%rip),%xmm2
movapd %xmm4,%xmm0
unpcklpd %xmm4,%xmm0
movsd  (%rsi),%xmm5
movhpd (%rdi),%xmm5
mulpd  %xmm5,%xmm0
cvttpd2dq %xmm0,%xmm0
cvtdq2pd %xmm0,%xmm0
movapd %xmm3,%xmm6
unpcklpd %xmm3,%xmm6
mulpd  %xmm0,%xmm6
subpd  %xmm6,%xmm5
movapd %xmm0,%xmm6
unpckhpd %xmm0,%xmm6
mulsd  %xmm5,%xmm6
movapd %xmm5,%xmm7
unpckhpd %xmm5,%xmm7
mulsd  %xmm7,%xmm0
addsd  %xmm6,%xmm0
mulsd  %xmm0,%xmm4
cvttpd2dq %xmm4,%xmm4
cvtdq2pd %xmm4,%xmm4
mulsd  %xmm3,%xmm4
subsd  %xmm4,%xmm0
mulsd  %xmm5,%xmm7
mulsd  %xmm3,%xmm0
addsd  %xmm7,%xmm0
movapd %xmm1,%xmm3
mulsd  %xmm0,%xmm3
cvttpd2dq %xmm3,%xmm3
cvtdq2pd %xmm3,%xmm3
mulsd  %xmm2,%xmm3
subsd  %xmm3,%xmm0
movsd  %xmm0,(%rdi)
mulsd  %xmm1,%xmm0
ret

LLVM IR (-O0):
@randlc.KS = internal global i32 0
@randlc.R23 = internal global double 0.000000e+00
@randlc.R46 = internal global double 0.000000e+00
@randlc.T23 = internal global double 0.000000e+00
@randlc.T46 = internal global double 0.000000e+00
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
%14 = alloca i32
%15 = alloca i32
store double* %0, double** %3
store double* %1, double** %4
%16 = load i32, i32* @randlc.KS
%17 = icmp eq i32 %16, 0
br i1 %17, label %18, label %43
18: ; preds = %2
store double 1.000000e+00, double* @randlc.R23
store double 1.000000e+00, double* @randlc.R46
store double 1.000000e+00, double* @randlc.T23
store double 1.000000e+00, double* @randlc.T46
store i32 1, i32* %14
br label %19
19: ; preds = %27, %18
%20 = load i32, i32* %14
%21 = icmp sle i32 %20, 23
br i1 %21, label %22, label %30
22: ; preds = %19
%23 = load double, double* @randlc.R23
%24 = fmul double 5.000000e-01, %23
store double %24, double* @randlc.R23
%25 = load double, double* @randlc.T23
%26 = fmul double 2.000000e+00, %25
store double %26, double* @randlc.T23
br label %27
27: ; preds = %22
%28 = load i32, i32* %14
%29 = add nsw i32 %28, 1
store i32 %29, i32* %14
br label %19
30: ; preds = %19
store i32 1, i32* %14
br label %31
31: ; preds = %39, %30
%32 = load i32, i32* %14
%33 = icmp sle i32 %32, 46
br i1 %33, label %34, label %42
34: ; preds = %31
%35 = load double, double* @randlc.R46
%36 = fmul double 5.000000e-01, %35
store double %36, double* @randlc.R46
%37 = load double, double* @randlc.T46
%38 = fmul double 2.000000e+00, %37
store double %38, double* @randlc.T46
br label %39
39: ; preds = %34
%40 = load i32, i32* %14
%41 = add nsw i32 %40, 1
store i32 %41, i32* %14
br label %31
42: ; preds = %31
store i32 1, i32* @randlc.KS
br label %43
43: ; preds = %42, %2
%44 = load double, double* @randlc.R23
%45 = load double*, double** %4
%46 = load double, double* %45
%47 = fmul double %44, %46
store double %47, double* %5
%48 = load double, double* %5
%49 = fptosi double %48 to i32
store i32 %49, i32* %15
%50 = load i32, i32* %15
%51 = sitofp i32 %50 to double
store double %51, double* %9
%52 = load double*, double** %4
%53 = load double, double* %52
%54 = load double, double* @randlc.T23
%55 = load double, double* %9
%56 = fneg double %54
%57 = call double @llvm.fmuladd.f64(double %56, double %55, double %53)
store double %57, double* %10
%58 = load double, double* @randlc.R23
%59 = load double*, double** %3
%60 = load double, double* %59
%61 = fmul double %58, %60
store double %61, double* %5
%62 = load double, double* %5
%63 = fptosi double %62 to i32
store i32 %63, i32* %15
%64 = load i32, i32* %15
%65 = sitofp i32 %64 to double
store double %65, double* %11
%66 = load double*, double** %3
%67 = load double, double* %66
%68 = load double, double* @randlc.T23
%69 = load double, double* %11
%70 = fneg double %68
%71 = call double @llvm.fmuladd.f64(double %70, double %69, double %67)
store double %71, double* %12
%72 = load double, double* %9
%73 = load double, double* %12
%74 = load double, double* %10
%75 = load double, double* %11
%76 = fmul double %74, %75
%77 = call double @llvm.fmuladd.f64(double %72, double %73, double %76)
store double %77, double* %5
%78 = load double, double* @randlc.R23
%79 = load double, double* %5
%80 = fmul double %78, %79
%81 = fptosi double %80 to i32
store i32 %81, i32* %15
%82 = load i32, i32* %15
%83 = sitofp i32 %82 to double
store double %83, double* %6
%84 = load double, double* %5
%85 = load double, double* @randlc.T23
%86 = load double, double* %6
%87 = fneg double %85
%88 = call double @llvm.fmuladd.f64(double %87, double %86, double %84)
store double %88, double* %13
%89 = load double, double* @randlc.T23
%90 = load double, double* %13
%91 = load double, double* %10
%92 = load double, double* %12
%93 = fmul double %91, %92
%94 = call double @llvm.fmuladd.f64(double %89, double %90, double %93)
store double %94, double* %7
%95 = load double, double* @randlc.R46
%96 = load double, double* %7
%97 = fmul double %95, %96
%98 = fptosi double %97 to i32
store i32 %98, i32* %15
%99 = load i32, i32* %15
%100 = sitofp i32 %99 to double
store double %100, double* %8
%101 = load double, double* %7
%102 = load double, double* @randlc.T46
%103 = load double, double* %8
%104 = fneg double %102
%105 = call double @llvm.fmuladd.f64(double %104, double %103, double %101)
%106 = load double*, double** %3
store double %105, double* %106
%107 = load double, double* @randlc.R46
%108 = load double*, double** %3
%109 = load double, double* %108
%110 = fmul double %107, %109
ret double %110
}

LLVM IR (-O2):
@randlc.KS = internal unnamed_addr global i1 false
@randlc.R23 = internal unnamed_addr global double 0.000000e+00
@randlc.R46 = internal unnamed_addr global double 0.000000e+00
@randlc.T23 = internal unnamed_addr global double 0.000000e+00
@randlc.T46 = internal unnamed_addr global double 0.000000e+00
define double @randlc(double* nocapture %0, double* nocapture %1) {
%3 = load i1, i1* @randlc.KS
br i1 %3, label %4, label %9
4: ; preds = %2
%5 = load double, double* @randlc.R23
%6 = load double, double* @randlc.T23
%7 = load double, double* @randlc.R46
%8 = load double, double* @randlc.T46
br label %10
9: ; preds = %2
store double 0x3E80000000000000, double* @randlc.R23
store double 0x4160000000000000, double* @randlc.T23
store double 0x3D10000000000000, double* @randlc.R46
store double 0x42D0000000000000, double* @randlc.T46
store i1 true, i1* @randlc.KS
br label %10
10: ; preds = %4, %9
%11 = phi double [ %8, %4 ], [ 0x42D0000000000000, %9 ]
%12 = phi double [ %7, %4 ], [ 0x3D10000000000000, %9 ]
%13 = phi double [ %6, %4 ], [ 0x4160000000000000, %9 ]
%14 = phi double [ %5, %4 ], [ 0x3E80000000000000, %9 ]
%15 = load double, double* %1
%16 = fneg double %13
%17 = load double, double* %0
%18 = insertelement <2 x double> poison, double %14, i64 0
%19 = shufflevector <2 x double> %18, <2 x double> poison, <2 x i32> zeroinitializer
%20 = insertelement <2 x double> poison, double %15, i64 0
%21 = insertelement <2 x double> %20, double %17, i64 1
%22 = fmul <2 x double> %19, %21
%23 = fptosi <2 x double> %22 to <2 x i32>
%24 = sitofp <2 x i32> %23 to <2 x double>
%25 = insertelement <2 x double> poison, double %16, 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> %24, <2 x double> %21)
%28 = extractelement <2 x double> %27, i64 0
%29 = shufflevector <2 x double> %24, <2 x double> poison, <2 x i32> <i32 1, i32 undef>
%30 = fmul <2 x double> %27, %29
%31 = extractelement <2 x double> %30, i64 0
%32 = extractelement <2 x double> %27, i64 1
%33 = extractelement <2 x double> %24, i64 0
%34 = tail call double @llvm.fmuladd.f64(double %33, double %32, double %31)
%35 = fmul double %14, %34
%36 = fptosi double %35 to i32
%37 = sitofp i32 %36 to double
%38 = tail call double @llvm.fmuladd.f64(double %16, double %37, double %34)
%39 = fmul double %28, %32
%40 = tail call double @llvm.fmuladd.f64(double %13, double %38, double %39)
%41 = fmul double %12, %40
%42 = fptosi double %41 to i32
%43 = sitofp i32 %42 to double
%44 = fneg double %11
%45 = tail call double @llvm.fmuladd.f64(double %44, double %43, double %40)
store double %45, double* %0
%46 = fmul double %12, %45
ret double %46
}