double smirnovi(n, p)
int n;
double p;
{
  double e, t, dpde;
  if (p <= 0.0 || p > 1.0) {
    mtherr("smirnovi", 1);
    return 0.0;
  }
  e = sqrt(-log(p) / (2.0 * n));
  do {
    t = -2.0 * n * e;
    dpde = 2.0 * t * exp(t * e);
    if (fabs(dpde) > 0.0)
      t = (p - smirnov(n, e)) / dpde;
    else {
      mtherr("smirnovi", 4);
      return 0.0;
    }
    e = e + t;
    if (e >= 1.0 || e <= 0.0) {
      mtherr("smirnovi", 3);
      return 0.0;
    }
  } while (fabs(t / e) > 1e-10);
  return (e);
}


x86 assembly (clang, -O0):
<smirnovi>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
mov    %edi,-0xc(%rbp)
movsd  %xmm0,-0x18(%rbp)
xorps  %xmm0,%xmm0
ucomisd -0x18(%rbp),%xmm0
jae    1185 <smirnovi+0x35>
movsd  -0x18(%rbp),%xmm0
movsd  0xe85(%rip),%xmm1
ucomisd %xmm1,%xmm0
jbe    11a5 <smirnovi+0x55>
lea    0xea4(%rip),%rdi
mov    $0x1,%esi
mov    $0x0,%al
call   1070 <mtherr@plt>
xorps  %xmm0,%xmm0
movsd  %xmm0,-0x8(%rbp)
jmp    132e <smirnovi+0x1de>
movsd  -0x18(%rbp),%xmm0
call   1050 <log@plt>
movq   %xmm0,%rax
movabs $0x8000000000000000,%rcx
xor    %rcx,%rax
movq   %rax,%xmm0
cvtsi2sdl -0xc(%rbp),%xmm2
movsd  0xe35(%rip),%xmm1
mulsd  %xmm2,%xmm1
divsd  %xmm1,%xmm0
call   1060 <sqrt@plt>
movsd  %xmm0,-0x20(%rbp)
cvtsi2sdl -0xc(%rbp),%xmm1
movsd  0xe1e(%rip),%xmm0
mulsd  %xmm1,%xmm0
mulsd  -0x20(%rbp),%xmm0
movsd  %xmm0,-0x28(%rbp)
movsd  0xe00(%rip),%xmm0
mulsd  -0x28(%rbp),%xmm0
movsd  %xmm0,-0x38(%rbp)
movsd  -0x28(%rbp),%xmm0
mulsd  -0x20(%rbp),%xmm0
call   1040 <exp@plt>
movaps %xmm0,%xmm1
movsd  -0x38(%rbp),%xmm0
mulsd  %xmm1,%xmm0
movsd  %xmm0,-0x30(%rbp)
movsd  -0x30(%rbp),%xmm0
movaps 0xde2(%rip),%xmm1
pand   %xmm1,%xmm0
xorps  %xmm1,%xmm1
ucomisd %xmm1,%xmm0
jbe    1284 <smirnovi+0x134>
movsd  -0x18(%rbp),%xmm0
movsd  %xmm0,-0x40(%rbp)
mov    -0xc(%rbp),%edi
movsd  -0x20(%rbp),%xmm0
mov    $0x1,%al
call   1030 <smirnov@plt>
movsd  -0x40(%rbp),%xmm0
cvtsi2sd %eax,%xmm1
subsd  %xmm1,%xmm0
divsd  -0x30(%rbp),%xmm0
movsd  %xmm0,-0x28(%rbp)
jmp    12a4 <smirnovi+0x154>
lea    0xda5(%rip),%rdi
mov    $0x4,%esi
mov    $0x0,%al
call   1070 <mtherr@plt>
xorps  %xmm0,%xmm0
movsd  %xmm0,-0x8(%rbp)
jmp    132e <smirnovi+0x1de>
movsd  -0x20(%rbp),%xmm0
addsd  -0x28(%rbp),%xmm0
movsd  %xmm0,-0x20(%rbp)
movsd  -0x20(%rbp),%xmm0
movsd  0xd40(%rip),%xmm1
ucomisd %xmm1,%xmm0
jae    12d8 <smirnovi+0x188>
xorps  %xmm0,%xmm0
ucomisd -0x20(%rbp),%xmm0
jb     12f8 <smirnovi+0x1a8>
lea    0xd51(%rip),%rdi
mov    $0x3,%esi
mov    $0x0,%al
call   1070 <mtherr@plt>
xorps  %xmm0,%xmm0
movsd  %xmm0,-0x8(%rbp)
jmp    132e <smirnovi+0x1de>
jmp    12fd <smirnovi+0x1ad>
movsd  -0x28(%rbp),%xmm0
divsd  -0x20(%rbp),%xmm0
movaps 0xd12(%rip),%xmm1
pand   %xmm1,%xmm0
movsd  0xcfe(%rip),%xmm1
ucomisd %xmm1,%xmm0
ja     11e5 <smirnovi+0x95>
movsd  -0x20(%rbp),%xmm0
movsd  %xmm0,-0x8(%rbp)
movsd  -0x8(%rbp),%xmm0
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<smirnovi>:
push   %rbx
sub    $0x20,%rsp
xorpd  %xmm1,%xmm1
ucomisd %xmm0,%xmm1
mov    $0x1,%esi
jae    1276 <smirnovi+0x126>
ucomisd 0xe90(%rip),%xmm0
ja     1276 <smirnovi+0x126>
mov    %edi,%ebx
movsd  %xmm0,0x18(%rsp)
call   1050 <log@plt>
xorpd  0xe95(%rip),%xmm0
xorps  %xmm1,%xmm1
cvtsi2sd %ebx,%xmm1
movsd  %xmm1,(%rsp)
addsd  %xmm1,%xmm1
divsd  %xmm1,%xmm0
xorpd  %xmm1,%xmm1
ucomisd %xmm1,%xmm0
jb     11af <smirnovi+0x5f>
sqrtsd %xmm0,%xmm2
jmp    11b8 <smirnovi+0x68>
call   1060 <sqrt@plt>
movapd %xmm0,%xmm2
movsd  (%rsp),%xmm0
mulsd  0xe43(%rip),%xmm0
movsd  %xmm0,(%rsp)
nopw   0x0(%rax,%rax,1)
movsd  %xmm2,0x10(%rsp)
movsd  (%rsp),%xmm1
mulsd  %xmm2,%xmm1
mulsd  %xmm1,%xmm2
addsd  %xmm1,%xmm1
movsd  %xmm1,0x8(%rsp)
movapd %xmm2,%xmm0
call   1040 <exp@plt>
mulsd  0x8(%rsp),%xmm0
ucomisd 0xe14(%rip),%xmm0
je     1271 <smirnovi+0x121>
mov    %ebx,%edi
movsd  %xmm0,0x8(%rsp)
movsd  0x10(%rsp),%xmm0
mov    $0x1,%al
call   1030 <smirnov@plt>
xorps  %xmm1,%xmm1
cvtsi2sd %eax,%xmm1
movsd  0x18(%rsp),%xmm0
subsd  %xmm1,%xmm0
divsd  0x8(%rsp),%xmm0
movsd  0x10(%rsp),%xmm2
addsd  %xmm0,%xmm2
ucomisd 0xdbc(%rip),%xmm2
mov    $0x3,%esi
jae    1276 <smirnovi+0x126>
xorpd  %xmm1,%xmm1
ucomisd %xmm2,%xmm1
jae    1276 <smirnovi+0x126>
divsd  %xmm2,%xmm0
andpd  0xdcf(%rip),%xmm0
ucomisd 0xda7(%rip),%xmm0
ja     11d0 <smirnovi+0x80>
jmp    1288 <smirnovi+0x138>
mov    $0x4,%esi
lea    0xdc3(%rip),%rdi
xor    %eax,%eax
call   1070 <mtherr@plt>
xorpd  %xmm2,%xmm2
movapd %xmm2,%xmm0
add    $0x20,%rsp
pop    %rbx
ret

LLVM IR (-O0):
@.str = [9 x i8] c"smirnovi\00"
define double @smirnovi(i32 %0, double %1) {
%3 = alloca double
%4 = alloca i32
%5 = alloca double
%6 = alloca double
%7 = alloca double
%8 = alloca double
store i32 %0, i32* %4
store double %1, double* %5
%9 = load double, double* %5
%10 = fcmp ole double %9, 0.000000e+00
br i1 %10, label %14, label %11
11: ; preds = %2
%12 = load double, double* %5
%13 = fcmp ogt double %12, 1.000000e+00
br i1 %13, label %14, label %16
14: ; preds = %11, %2
%15 = call i32 (i8*, i32, ...) bitcast (i32 (...)* @mtherr to i32 (i8*, i32, ...)*)(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str, i64 0, i64 0), i32 1)
store double 0.000000e+00, double* %3
br label %72
16: ; preds = %11
%17 = load double, double* %5
%18 = call double @log(double %17)
%19 = fneg double %18
%20 = load i32, i32* %4
%21 = sitofp i32 %20 to double
%22 = fmul double 2.000000e+00, %21
%23 = fdiv double %19, %22
%24 = call double @sqrt(double %23)
store double %24, double* %6
br label %25
25: ; preds = %64, %16
%26 = load i32, i32* %4
%27 = sitofp i32 %26 to double
%28 = fmul double -2.000000e+00, %27
%29 = load double, double* %6
%30 = fmul double %28, %29
store double %30, double* %7
%31 = load double, double* %7
%32 = fmul double 2.000000e+00, %31
%33 = load double, double* %7
%34 = load double, double* %6
%35 = fmul double %33, %34
%36 = call double @exp(double %35)
%37 = fmul double %32, %36
store double %37, double* %8
%38 = load double, double* %8
%39 = call double @llvm.fabs.f64(double %38)
%40 = fcmp ogt double %39, 0.000000e+00
br i1 %40, label %41, label %50
41: ; preds = %25
%42 = load double, double* %5
%43 = load i32, i32* %4
%44 = load double, double* %6
%45 = call i32 (i32, double, ...) bitcast (i32 (...)* @smirnov to i32 (i32, double, ...)*)(i32 %43, double %44)
%46 = sitofp i32 %45 to double
%47 = fsub double %42, %46
%48 = load double, double* %8
%49 = fdiv double %47, %48
store double %49, double* %7
br label %52
50: ; preds = %25
%51 = call i32 (i8*, i32, ...) bitcast (i32 (...)* @mtherr to i32 (i8*, i32, ...)*)(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str, i64 0, i64 0), i32 4)
store double 0.000000e+00, double* %3
br label %72
52: ; preds = %41
%53 = load double, double* %6
%54 = load double, double* %7
%55 = fadd double %53, %54
store double %55, double* %6
%56 = load double, double* %6
%57 = fcmp oge double %56, 1.000000e+00
br i1 %57, label %61, label %58
58: ; preds = %52
%59 = load double, double* %6
%60 = fcmp ole double %59, 0.000000e+00
br i1 %60, label %61, label %63
61: ; preds = %58, %52
%62 = call i32 (i8*, i32, ...) bitcast (i32 (...)* @mtherr to i32 (i8*, i32, ...)*)(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str, i64 0, i64 0), i32 3)
store double 0.000000e+00, double* %3
br label %72
63: ; preds = %58
br label %64
64: ; preds = %63
%65 = load double, double* %7
%66 = load double, double* %6
%67 = fdiv double %65, %66
%68 = call double @llvm.fabs.f64(double %67)
%69 = fcmp ogt double %68, 1.000000e-10
br i1 %69, label %25, label %70
70: ; preds = %64
%71 = load double, double* %6
store double %71, double* %3
br label %72
72: ; preds = %70, %61, %50, %14
%73 = load double, double* %3
ret double %73
}

LLVM IR (-O2):
@.str = [9 x i8] c"smirnovi\00"
define double @smirnovi(i32 %0, double %1) {
%3 = fcmp ole double %1, 0.000000e+00
%4 = fcmp ogt double %1, 1.000000e+00
%5 = or i1 %3, %4
br i1 %5, label %35, label %6
6: ; preds = %2
%7 = tail call double @log(double %1)
%8 = fneg double %7
%9 = sitofp i32 %0 to double
%10 = fmul double %9, 2.000000e+00
%11 = fdiv double %8, %10
%12 = tail call double @sqrt(double %11)
%13 = fmul double %9, -2.000000e+00
br label %14
14: ; preds = %31, %6
%15 = phi double [ %12, %6 ], [ %27, %31 ]
%16 = fmul double %13, %15
%17 = fmul double %16, 2.000000e+00
%18 = fmul double %15, %16
%19 = tail call double @exp(double %18)
%20 = fmul double %19, %17
%21 = fcmp ueq double %20, 0.000000e+00
br i1 %21, label %35, label %22
22: ; preds = %14
%23 = tail call i32 (i32, double, ...) bitcast (i32 (...)* @smirnov to i32 (i32, double, ...)*)(i32 %0, double %15)
%24 = sitofp i32 %23 to double
%25 = fsub double %1, %24
%26 = fdiv double %25, %20
%27 = fadd double %15, %26
%28 = fcmp oge double %27, 1.000000e+00
%29 = fcmp ole double %27, 0.000000e+00
%30 = or i1 %28, %29
br i1 %30, label %35, label %31
31: ; preds = %22
%32 = fdiv double %26, %27
%33 = tail call double @llvm.fabs.f64(double %32)
%34 = fcmp ogt double %33, 1.000000e-10
br i1 %34, label %14, label %38
35: ; preds = %22, %14, %2
%36 = phi i32 [ 1, %2 ], [ 4, %14 ], [ 3, %22 ]
%37 = tail call i32 (i8*, i32, ...) bitcast (i32 (...)* @mtherr to i32 (i8*, i32, ...)*)(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str, i64 0, i64 0), i32 %36)
br label %38
38: ; preds = %31, %35
%39 = phi double [ 0.000000e+00, %35 ], [ %27, %31 ]
ret double %39
}