double kolmogorov(y)
double y;
{
  double p, t, r, sign, x;
  x = -2.0 * y * y;
  sign = 1.0;
  p = 0.0;
  r = 1.0;
  do {
    t = exp(x * r * r);
    p += sign * t;
    if (t == 0.0)
      break;
    r += 1.0;
    sign = -sign;
  } while ((t / p) > 1.1e-16);
  return (p + p);
}


x86 assembly (clang, -O0):
<kolmogorov>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
movsd  %xmm0,-0x8(%rbp)
movsd  0xee3(%rip),%xmm0
mulsd  -0x8(%rbp),%xmm0
mulsd  -0x8(%rbp),%xmm0
movsd  %xmm0,-0x30(%rbp)
movsd  0xec4(%rip),%xmm0
movsd  %xmm0,-0x28(%rbp)
xorps  %xmm0,%xmm0
movsd  %xmm0,-0x10(%rbp)
movsd  0xeaf(%rip),%xmm0
movsd  %xmm0,-0x20(%rbp)
movsd  -0x30(%rbp),%xmm0
mulsd  -0x20(%rbp),%xmm0
mulsd  -0x20(%rbp),%xmm0
call   1030 <exp@plt>
movsd  %xmm0,-0x18(%rbp)
movsd  -0x28(%rbp),%xmm0
movsd  -0x18(%rbp),%xmm2
movsd  -0x10(%rbp),%xmm1
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
movsd  %xmm0,-0x10(%rbp)
movsd  -0x18(%rbp),%xmm0
xorps  %xmm1,%xmm1
ucomisd %xmm1,%xmm0
jne    11a8 <kolmogorov+0x98>
jp     11a8 <kolmogorov+0x98>
jmp    11f7 <kolmogorov+0xe7>
movsd  0xe50(%rip),%xmm0
addsd  -0x20(%rbp),%xmm0
movsd  %xmm0,-0x20(%rbp)
movsd  -0x28(%rbp),%xmm0
movq   %xmm0,%rax
movabs $0x8000000000000000,%rcx
xor    %rcx,%rax
movq   %rax,%xmm0
movsd  %xmm0,-0x28(%rbp)
movsd  -0x18(%rbp),%xmm0
divsd  -0x10(%rbp),%xmm0
movsd  0xe23(%rip),%xmm1
ucomisd %xmm1,%xmm0
ja     1156 <kolmogorov+0x46>
movsd  -0x10(%rbp),%xmm0
addsd  -0x10(%rbp),%xmm0
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<kolmogorov>:
sub    $0x38,%rsp
movsd  0xee4(%rip),%xmm1
mulsd  %xmm0,%xmm1
mulsd  %xmm0,%xmm1
movsd  %xmm1,0x8(%rsp)
movsd  0xed6(%rip),%xmm0
movapd %xmm0,%xmm2
movapd %xmm0,%xmm3
xorpd  %xmm0,%xmm0
xchg   %ax,%ax
movapd %xmm3,0x20(%rsp)
movsd  %xmm2,0x18(%rsp)
movsd  %xmm0,0x10(%rsp)
movsd  0x8(%rsp),%xmm0
mulsd  %xmm2,%xmm0
mulsd  %xmm2,%xmm0
call   1030 <exp@plt>
movapd 0x20(%rsp),%xmm3
movsd  0x18(%rsp),%xmm2
movapd %xmm0,%xmm1
movapd %xmm3,%xmm0
mulsd  %xmm1,%xmm0
addsd  0x10(%rsp),%xmm0
ucomisd 0xe8d(%rip),%xmm1
jne    118f <kolmogorov+0x7f>
jnp    11ad <kolmogorov+0x9d>
addsd  0xe71(%rip),%xmm2
xorpd  0xe81(%rip),%xmm3
divsd  %xmm0,%xmm1
ucomisd 0xe65(%rip),%xmm1
ja     1140 <kolmogorov+0x30>
addsd  %xmm0,%xmm0
add    $0x38,%rsp
ret

LLVM IR (-O0):
define double @kolmogorov(double %0) {
%2 = alloca double
%3 = alloca double
%4 = alloca double
%5 = alloca double
%6 = alloca double
%7 = alloca double
store double %0, double* %2
%8 = load double, double* %2
%9 = fmul double -2.000000e+00, %8
%10 = load double, double* %2
%11 = fmul double %9, %10
store double %11, double* %7
store double 1.000000e+00, double* %6
store double 0.000000e+00, double* %3
store double 1.000000e+00, double* %5
br label %12
12: ; preds = %31, %1
%13 = load double, double* %7
%14 = load double, double* %5
%15 = fmul double %13, %14
%16 = load double, double* %5
%17 = fmul double %15, %16
%18 = call double @exp(double %17)
store double %18, double* %4
%19 = load double, double* %6
%20 = load double, double* %4
%21 = load double, double* %3
%22 = call double @llvm.fmuladd.f64(double %19, double %20, double %21)
store double %22, double* %3
%23 = load double, double* %4
%24 = fcmp oeq double %23, 0.000000e+00
br i1 %24, label %25, label %26
25: ; preds = %12
br label %36
26: ; preds = %12
%27 = load double, double* %5
%28 = fadd double %27, 1.000000e+00
store double %28, double* %5
%29 = load double, double* %6
%30 = fneg double %29
store double %30, double* %6
br label %31
31: ; preds = %26
%32 = load double, double* %4
%33 = load double, double* %3
%34 = fdiv double %32, %33
%35 = fcmp ogt double %34, 1.100000e-16
br i1 %35, label %12, label %36
36: ; preds = %31, %25
%37 = load double, double* %3
%38 = load double, double* %3
%39 = fadd double %37, %38
ret double %39
}

LLVM IR (-O2):
define double @kolmogorov(double %0) {
%2 = fmul double %0, -2.000000e+00
%3 = fmul double %2, %0
br label %4
4: ; preds = %13, %1
%5 = phi double [ 1.000000e+00, %1 ], [ %14, %13 ]
%6 = phi double [ 1.000000e+00, %1 ], [ %15, %13 ]
%7 = phi double [ 0.000000e+00, %1 ], [ %11, %13 ]
%8 = fmul double %3, %5
%9 = fmul double %5, %8
%10 = tail call double @exp(double %9)
%11 = tail call double @llvm.fmuladd.f64(double %6, double %10, double %7)
%12 = fcmp oeq double %10, 0.000000e+00
br i1 %12, label %18, label %13
13: ; preds = %4
%14 = fadd double %5, 1.000000e+00
%15 = fneg double %6
%16 = fdiv double %10, %11
%17 = fcmp ogt double %16, 1.100000e-16
br i1 %17, label %4, label %18
18: ; preds = %4, %13
%19 = fadd double %11, %11
ret double %19
}