double cephes_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(-cephes_log(p) / (2.0 * n));
  do {
    t = -2.0 * n * e;
    dpde = 2.0 * t * cephes_exp(t * e);
    if (fabs(dpde) > 0.0)
      t = (p - cephes_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):
<cephes_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 <cephes_smirnovi+0x35>
movsd  -0x18(%rbp),%xmm0
movsd  0xe85(%rip),%xmm1
ucomisd %xmm1,%xmm0
jbe    11a5 <cephes_smirnovi+0x55>
lea    0xea4(%rip),%rdi
mov    $0x1,%esi
mov    $0x0,%al
call   1070 <mtherr@plt>
xorps  %xmm0,%xmm0
movsd  %xmm0,-0x8(%rbp)
jmp    1326 <cephes_smirnovi+0x1d6>
movsd  -0x18(%rbp),%xmm0
mov    $0x1,%al
call   1030 <cephes_log@plt>
mov    %eax,%ecx
xor    %eax,%eax
sub    %ecx,%eax
cvtsi2sd %eax,%xmm0
cvtsi2sdl -0xc(%rbp),%xmm2
movsd  0xe40(%rip),%xmm1
mulsd  %xmm2,%xmm1
divsd  %xmm1,%xmm0
call   1060 <sqrt@plt>
movsd  %xmm0,-0x20(%rbp)
cvtsi2sdl -0xc(%rbp),%xmm1
movsd  0xe29(%rip),%xmm0
mulsd  %xmm1,%xmm0
mulsd  -0x20(%rbp),%xmm0
movsd  %xmm0,-0x28(%rbp)
movsd  0xe0b(%rip),%xmm0
mulsd  -0x28(%rbp),%xmm0
movsd  %xmm0,-0x38(%rbp)
movsd  -0x28(%rbp),%xmm0
mulsd  -0x20(%rbp),%xmm0
mov    $0x1,%al
call   1040 <cephes_exp@plt>
movsd  -0x38(%rbp),%xmm0
cvtsi2sd %eax,%xmm1
mulsd  %xmm1,%xmm0
movsd  %xmm0,-0x30(%rbp)
movsd  -0x30(%rbp),%xmm0
movaps 0xdea(%rip),%xmm1
pand   %xmm1,%xmm0
xorps  %xmm1,%xmm1
ucomisd %xmm1,%xmm0
jbe    127c <cephes_smirnovi+0x12c>
movsd  -0x18(%rbp),%xmm0
movsd  %xmm0,-0x40(%rbp)
mov    -0xc(%rbp),%edi
movsd  -0x20(%rbp),%xmm0
mov    $0x1,%al
call   1050 <cephes_smirnov@plt>
movsd  -0x40(%rbp),%xmm0
cvtsi2sd %eax,%xmm1
subsd  %xmm1,%xmm0
divsd  -0x30(%rbp),%xmm0
movsd  %xmm0,-0x28(%rbp)
jmp    129c <cephes_smirnovi+0x14c>
lea    0xdad(%rip),%rdi
mov    $0x4,%esi
mov    $0x0,%al
call   1070 <mtherr@plt>
xorps  %xmm0,%xmm0
movsd  %xmm0,-0x8(%rbp)
jmp    1326 <cephes_smirnovi+0x1d6>
movsd  -0x20(%rbp),%xmm0
addsd  -0x28(%rbp),%xmm0
movsd  %xmm0,-0x20(%rbp)
movsd  -0x20(%rbp),%xmm0
movsd  0xd48(%rip),%xmm1
ucomisd %xmm1,%xmm0
jae    12d0 <cephes_smirnovi+0x180>
xorps  %xmm0,%xmm0
ucomisd -0x20(%rbp),%xmm0
jb     12f0 <cephes_smirnovi+0x1a0>
lea    0xd59(%rip),%rdi
mov    $0x3,%esi
mov    $0x0,%al
call   1070 <mtherr@plt>
xorps  %xmm0,%xmm0
movsd  %xmm0,-0x8(%rbp)
jmp    1326 <cephes_smirnovi+0x1d6>
jmp    12f5 <cephes_smirnovi+0x1a5>
movsd  -0x28(%rbp),%xmm0
divsd  -0x20(%rbp),%xmm0
movaps 0xd1a(%rip),%xmm1
pand   %xmm1,%xmm0
movsd  0xd06(%rip),%xmm1
ucomisd %xmm1,%xmm0
ja     11da <cephes_smirnovi+0x8a>
movsd  -0x20(%rbp),%xmm0
movsd  %xmm0,-0x8(%rbp)
movsd  -0x8(%rbp),%xmm0
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<cephes_smirnovi>:
push   %rbx
sub    $0x20,%rsp
xorpd  %xmm1,%xmm1
ucomisd %xmm0,%xmm1
mov    $0x1,%esi
jae    127f <cephes_smirnovi+0x12f>
ucomisd 0xe90(%rip),%xmm0
ja     127f <cephes_smirnovi+0x12f>
mov    %edi,%ebx
movsd  %xmm0,0x18(%rsp)
mov    $0x1,%al
call   1030 <cephes_log@plt>
neg    %eax
xorps  %xmm0,%xmm0
cvtsi2sd %eax,%xmm0
xorps  %xmm1,%xmm1
cvtsi2sd %ebx,%xmm1
movsd  %xmm1,(%rsp)
addsd  %xmm1,%xmm1
divsd  %xmm1,%xmm0
xorpd  %xmm1,%xmm1
ucomisd %xmm1,%xmm0
jb     11b2 <cephes_smirnovi+0x62>
sqrtsd %xmm0,%xmm2
jmp    11bb <cephes_smirnovi+0x6b>
call   1060 <sqrt@plt>
movapd %xmm0,%xmm2
movsd  (%rsp),%xmm0
mulsd  0xe40(%rip),%xmm0
movsd  %xmm0,(%rsp)
nopl   (%rax)
movsd  %xmm2,0x10(%rsp)
movsd  (%rsp),%xmm1
mulsd  %xmm2,%xmm1
mulsd  %xmm1,%xmm2
addsd  %xmm1,%xmm1
movsd  %xmm1,0x8(%rsp)
movapd %xmm2,%xmm0
mov    $0x1,%al
call   1040 <cephes_exp@plt>
xorps  %xmm1,%xmm1
cvtsi2sd %eax,%xmm1
mulsd  0x8(%rsp),%xmm1
ucomisd 0xe0b(%rip),%xmm1
je     127a <cephes_smirnovi+0x12a>
mov    %ebx,%edi
movsd  %xmm1,0x8(%rsp)
movsd  0x10(%rsp),%xmm0
mov    $0x1,%al
call   1050 <cephes_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 0xdb3(%rip),%xmm2
mov    $0x3,%esi
jae    127f <cephes_smirnovi+0x12f>
xorpd  %xmm1,%xmm1
ucomisd %xmm2,%xmm1
jae    127f <cephes_smirnovi+0x12f>
divsd  %xmm2,%xmm0
andpd  0xdb6(%rip),%xmm0
ucomisd 0xd9e(%rip),%xmm0
ja     11d0 <cephes_smirnovi+0x80>
jmp    1291 <cephes_smirnovi+0x141>
mov    $0x4,%esi
lea    0xdaa(%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 @cephes_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 %74
16: ; preds = %11
%17 = load double, double* %5
%18 = call i32 (double, ...) bitcast (i32 (...)* @cephes_log to i32 (double, ...)*)(double %17)
%19 = sub nsw i32 0, %18
%20 = sitofp i32 %19 to double
%21 = load i32, i32* %4
%22 = sitofp i32 %21 to double
%23 = fmul double 2.000000e+00, %22
%24 = fdiv double %20, %23
%25 = call double @sqrt(double %24)
store double %25, double* %6
br label %26
26: ; preds = %66, %16
%27 = load i32, i32* %4
%28 = sitofp i32 %27 to double
%29 = fmul double -2.000000e+00, %28
%30 = load double, double* %6
%31 = fmul double %29, %30
store double %31, double* %7
%32 = load double, double* %7
%33 = fmul double 2.000000e+00, %32
%34 = load double, double* %7
%35 = load double, double* %6
%36 = fmul double %34, %35
%37 = call i32 (double, ...) bitcast (i32 (...)* @cephes_exp to i32 (double, ...)*)(double %36)
%38 = sitofp i32 %37 to double
%39 = fmul double %33, %38
store double %39, double* %8
%40 = load double, double* %8
%41 = call double @llvm.fabs.f64(double %40)
%42 = fcmp ogt double %41, 0.000000e+00
br i1 %42, label %43, label %52
43: ; preds = %26
%44 = load double, double* %5
%45 = load i32, i32* %4
%46 = load double, double* %6
%47 = call i32 (i32, double, ...) bitcast (i32 (...)* @cephes_smirnov to i32 (i32, double, ...)*)(i32 %45, double %46)
%48 = sitofp i32 %47 to double
%49 = fsub double %44, %48
%50 = load double, double* %8
%51 = fdiv double %49, %50
store double %51, double* %7
br label %54
52: ; preds = %26
%53 = 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 %74
54: ; preds = %43
%55 = load double, double* %6
%56 = load double, double* %7
%57 = fadd double %55, %56
store double %57, double* %6
%58 = load double, double* %6
%59 = fcmp oge double %58, 1.000000e+00
br i1 %59, label %63, label %60
60: ; preds = %54
%61 = load double, double* %6
%62 = fcmp ole double %61, 0.000000e+00
br i1 %62, label %63, label %65
63: ; preds = %60, %54
%64 = 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 %74
65: ; preds = %60
br label %66
66: ; preds = %65
%67 = load double, double* %7
%68 = load double, double* %6
%69 = fdiv double %67, %68
%70 = call double @llvm.fabs.f64(double %69)
%71 = fcmp ogt double %70, 1.000000e-10
br i1 %71, label %26, label %72
72: ; preds = %66
%73 = load double, double* %6
store double %73, double* %3
br label %74
74: ; preds = %72, %63, %52, %14
%75 = load double, double* %3
ret double %75
}

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