#define NULL ((void *)0)
typedef unsigned long size_t; // Customize by platform.
typedef long intptr_t;
typedef unsigned long uintptr_t;
typedef long scalar_t__; // Either arithmetic or pointer type.
/* By default, we understand bool (as a convenience). */
typedef int bool;
#define false 0
#define true 1

/* Forward declarations */

/* Type definitions */

/* Variables and functions */
double exp(double);
int getLogFactorial(int);
int log(double);
double pow(double, double);
double rapfac(int);
double cdfSpecial(int n, double x) {
  if ((n * x * x >= 18.0) || (x >= 1.0))
    return 1.0;
  if (x <= 0.5 / n)
    return 0.0;
  if (n == 1)
    return 2.0 * x - 1.0;
  if (x <= 1.0 / n) {
    double t = 2.0 * x * n - 1.0;
    double w;
    if (n <= 500) {
      w = rapfac(n);
      return w * pow(t, (double)n);
    }
    w = getLogFactorial(n) + n * log(t / n);
    return exp(w);
  }
  if (x >= 1.0 - 1.0 / n) {
    return 1.0 - 2.0 * pow(1.0 - x, (double)n);
  }
  return -1.0;
}


x86 assembly (clang, -O0):
<cdfSpecial>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
mov    %edi,-0xc(%rbp)
movsd  %xmm0,-0x18(%rbp)
cvtsi2sdl -0xc(%rbp),%xmm0
mulsd  -0x18(%rbp),%xmm0
mulsd  -0x18(%rbp),%xmm0
movsd  0xe89(%rip),%xmm1
ucomisd %xmm1,%xmm0
jae    1198 <cdfSpecial+0x48>
movsd  -0x18(%rbp),%xmm0
movsd  0xe7a(%rip),%xmm1
ucomisd %xmm1,%xmm0
jb     11aa <cdfSpecial+0x5a>
movsd  0xe68(%rip),%xmm0
movsd  %xmm0,-0x8(%rbp)
jmp    134b <cdfSpecial+0x1fb>
movsd  -0x18(%rbp),%xmm1
cvtsi2sdl -0xc(%rbp),%xmm2
movsd  0xe54(%rip),%xmm0
divsd  %xmm2,%xmm0
ucomisd %xmm1,%xmm0
jb     11d7 <cdfSpecial+0x87>
xorps  %xmm0,%xmm0
movsd  %xmm0,-0x8(%rbp)
jmp    134b <cdfSpecial+0x1fb>
cmpl   $0x1,-0xc(%rbp)
jne    1200 <cdfSpecial+0xb0>
movsd  -0x18(%rbp),%xmm0
addsd  %xmm0,%xmm0
movsd  0xe26(%rip),%xmm1
addsd  %xmm1,%xmm0
movsd  %xmm0,-0x8(%rbp)
jmp    134b <cdfSpecial+0x1fb>
movsd  -0x18(%rbp),%xmm1
cvtsi2sdl -0xc(%rbp),%xmm2
movsd  0xdf6(%rip),%xmm0
divsd  %xmm2,%xmm0
ucomisd %xmm1,%xmm0
jb     12de <cdfSpecial+0x18e>
movsd  0xdf8(%rip),%xmm0
mulsd  -0x18(%rbp),%xmm0
cvtsi2sdl -0xc(%rbp),%xmm1
mulsd  %xmm1,%xmm0
movsd  0xdda(%rip),%xmm1
addsd  %xmm1,%xmm0
movsd  %xmm0,-0x20(%rbp)
cmpl   $0x1f4,-0xc(%rbp)
jg     1290 <cdfSpecial+0x140>
mov    -0xc(%rbp),%edi
call   1070 <rapfac@plt>
movsd  %xmm0,-0x28(%rbp)
movsd  -0x28(%rbp),%xmm0
movsd  %xmm0,-0x30(%rbp)
movsd  -0x20(%rbp),%xmm0
cvtsi2sdl -0xc(%rbp),%xmm1
call   1060 <pow@plt>
movaps %xmm0,%xmm1
movsd  -0x30(%rbp),%xmm0
mulsd  %xmm1,%xmm0
movsd  %xmm0,-0x8(%rbp)
jmp    134b <cdfSpecial+0x1fb>
mov    -0xc(%rbp),%edi
call   1030 <getLogFactorial@plt>
mov    %eax,-0x34(%rbp)
mov    -0xc(%rbp),%eax
mov    %eax,-0x38(%rbp)
movsd  -0x20(%rbp),%xmm0
cvtsi2sdl -0xc(%rbp),%xmm1
divsd  %xmm1,%xmm0
call   1050 <log@plt>
mov    -0x38(%rbp),%ecx
mov    %eax,%edx
mov    -0x34(%rbp),%eax
imul   %edx,%ecx
add    %ecx,%eax
cvtsi2sd %eax,%xmm0
movsd  %xmm0,-0x28(%rbp)
movsd  -0x28(%rbp),%xmm0
call   1040 <exp@plt>
movsd  %xmm0,-0x8(%rbp)
jmp    134b <cdfSpecial+0x1fb>
movsd  -0x18(%rbp),%xmm0
cvtsi2sdl -0xc(%rbp),%xmm1
movsd  0xd18(%rip),%xmm2
divsd  %xmm1,%xmm2
movsd  0xd0c(%rip),%xmm1
subsd  %xmm2,%xmm1
ucomisd %xmm1,%xmm0
jb     133e <cdfSpecial+0x1ee>
movsd  0xcf6(%rip),%xmm0
subsd  -0x18(%rbp),%xmm0
cvtsi2sdl -0xc(%rbp),%xmm1
call   1060 <pow@plt>
movaps %xmm0,%xmm1
addsd  %xmm1,%xmm1
movsd  0xcd8(%rip),%xmm0
subsd  %xmm1,%xmm0
movsd  %xmm0,-0x8(%rbp)
jmp    134b <cdfSpecial+0x1fb>
movsd  0xcd2(%rip),%xmm0
movsd  %xmm0,-0x8(%rbp)
movsd  -0x8(%rbp),%xmm0
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<cdfSpecial>:
push   %rbp
push   %rbx
sub    $0x18,%rsp
movapd %xmm0,%xmm2
movsd  0xe9e(%rip),%xmm0
ucomisd %xmm0,%xmm2
jae    1257 <cdfSpecial+0x107>
mov    %edi,%ebx
cvtsi2sd %edi,%xmm1
movapd %xmm1,%xmm3
mulsd  %xmm2,%xmm3
mulsd  %xmm2,%xmm3
ucomisd 0xe82(%rip),%xmm3
jae    1257 <cdfSpecial+0x107>
movsd  0xe7c(%rip),%xmm3
divsd  %xmm1,%xmm3
xorpd  %xmm0,%xmm0
ucomisd %xmm2,%xmm3
jae    1257 <cdfSpecial+0x107>
cmp    $0x1,%ebx
jne    11c0 <cdfSpecial+0x70>
addsd  %xmm2,%xmm2
addsd  0xe61(%rip),%xmm2
movapd %xmm2,%xmm0
jmp    1257 <cdfSpecial+0x107>
movsd  0xe38(%rip),%xmm4
movapd %xmm4,%xmm0
divsd  %xmm1,%xmm0
ucomisd %xmm2,%xmm0
jae    11ee <cdfSpecial+0x9e>
movapd %xmm4,%xmm3
subsd  %xmm0,%xmm3
ucomisd %xmm3,%xmm2
jae    1236 <cdfSpecial+0xe6>
movsd  0xe2c(%rip),%xmm0
jmp    1257 <cdfSpecial+0x107>
addsd  %xmm2,%xmm2
mulsd  %xmm1,%xmm2
addsd  0xe1a(%rip),%xmm2
movsd  %xmm2,0x8(%rsp)
cmp    $0x1f4,%ebx
movsd  %xmm1,(%rsp)
jg     125e <cdfSpecial+0x10e>
mov    %ebx,%edi
call   1070 <rapfac@plt>
movsd  %xmm0,0x10(%rsp)
movsd  0x8(%rsp),%xmm0
movsd  (%rsp),%xmm1
call   1060 <pow@plt>
mulsd  0x10(%rsp),%xmm0
jmp    1257 <cdfSpecial+0x107>
movapd %xmm4,%xmm0
subsd  %xmm2,%xmm0
call   1060 <pow@plt>
addsd  %xmm0,%xmm0
movsd  0xdb1(%rip),%xmm1
subsd  %xmm0,%xmm1
movapd %xmm1,%xmm0
add    $0x18,%rsp
pop    %rbx
pop    %rbp
ret
mov    %ebx,%edi
call   1030 <getLogFactorial@plt>
mov    %eax,%ebp
movsd  0x8(%rsp),%xmm0
divsd  (%rsp),%xmm0
call   1050 <log@plt>
imul   %ebx,%eax
add    %ebp,%eax
xorps  %xmm0,%xmm0
cvtsi2sd %eax,%xmm0
add    $0x18,%rsp
pop    %rbx
pop    %rbp
jmp    1040 <exp@plt>

LLVM IR (-O0):
define double @cdfSpecial(i32 %0, double %1) {
%3 = alloca double
%4 = alloca i32
%5 = alloca double
%6 = alloca double
%7 = alloca double
store i32 %0, i32* %4
store double %1, double* %5
%8 = load i32, i32* %4
%9 = sitofp i32 %8 to double
%10 = load double, double* %5
%11 = fmul double %9, %10
%12 = load double, double* %5
%13 = fmul double %11, %12
%14 = fcmp oge double %13, 1.800000e+01
br i1 %14, label %18, label %15
15: ; preds = %2
%16 = load double, double* %5
%17 = fcmp oge double %16, 1.000000e+00
br i1 %17, label %18, label %19
18: ; preds = %15, %2
store double 1.000000e+00, double* %3
br label %84
19: ; preds = %15
%20 = load double, double* %5
%21 = load i32, i32* %4
%22 = sitofp i32 %21 to double
%23 = fdiv double 5.000000e-01, %22
%24 = fcmp ole double %20, %23
br i1 %24, label %25, label %26
25: ; preds = %19
store double 0.000000e+00, double* %3
br label %84
26: ; preds = %19
%27 = load i32, i32* %4
%28 = icmp eq i32 %27, 1
br i1 %28, label %29, label %32
29: ; preds = %26
%30 = load double, double* %5
%31 = call double @llvm.fmuladd.f64(double 2.000000e+00, double %30, double -1.000000e+00)
store double %31, double* %3
br label %84
32: ; preds = %26
%33 = load double, double* %5
%34 = load i32, i32* %4
%35 = sitofp i32 %34 to double
%36 = fdiv double 1.000000e+00, %35
%37 = fcmp ole double %33, %36
br i1 %37, label %38, label %69
38: ; preds = %32
%39 = load double, double* %5
%40 = fmul double 2.000000e+00, %39
%41 = load i32, i32* %4
%42 = sitofp i32 %41 to double
%43 = call double @llvm.fmuladd.f64(double %40, double %42, double -1.000000e+00)
store double %43, double* %6
%44 = load i32, i32* %4
%45 = icmp sle i32 %44, 500
br i1 %45, label %46, label %55
46: ; preds = %38
%47 = load i32, i32* %4
%48 = call double @rapfac(i32 %47)
store double %48, double* %7
%49 = load double, double* %7
%50 = load double, double* %6
%51 = load i32, i32* %4
%52 = sitofp i32 %51 to double
%53 = call double @pow(double %50, double %52)
%54 = fmul double %49, %53
store double %54, double* %3
br label %84
55: ; preds = %38
%56 = load i32, i32* %4
%57 = call i32 @getLogFactorial(i32 %56)
%58 = load i32, i32* %4
%59 = load double, double* %6
%60 = load i32, i32* %4
%61 = sitofp i32 %60 to double
%62 = fdiv double %59, %61
%63 = call i32 @log(double %62)
%64 = mul nsw i32 %58, %63
%65 = add nsw i32 %57, %64
%66 = sitofp i32 %65 to double
store double %66, double* %7
%67 = load double, double* %7
%68 = call double @exp(double %67)
store double %68, double* %3
br label %84
69: ; preds = %32
%70 = load double, double* %5
%71 = load i32, i32* %4
%72 = sitofp i32 %71 to double
%73 = fdiv double 1.000000e+00, %72
%74 = fsub double 1.000000e+00, %73
%75 = fcmp oge double %70, %74
br i1 %75, label %76, label %83
76: ; preds = %69
%77 = load double, double* %5
%78 = fsub double 1.000000e+00, %77
%79 = load i32, i32* %4
%80 = sitofp i32 %79 to double
%81 = call double @pow(double %78, double %80)
%82 = call double @llvm.fmuladd.f64(double -2.000000e+00, double %81, double 1.000000e+00)
store double %82, double* %3
br label %84
83: ; preds = %69
store double -1.000000e+00, double* %3
br label %84
84: ; preds = %83, %76, %55, %46, %29, %25, %18
%85 = load double, double* %3
ret double %85
}

LLVM IR (-O2):
define double @cdfSpecial(i32 %0, double %1) {
%3 = sitofp i32 %0 to double
%4 = fmul double %3, %1
%5 = fmul double %4, %1
%6 = fcmp oge double %5, 1.800000e+01
%7 = fcmp oge double %1, 1.000000e+00
%8 = or i1 %7, %6
br i1 %8, label %42, label %9
9: ; preds = %2
%10 = fdiv double 5.000000e-01, %3
%11 = fcmp ult double %10, %1
br i1 %11, label %12, label %42
12: ; preds = %9
%13 = icmp eq i32 %0, 1
br i1 %13, label %14, label %16
14: ; preds = %12
%15 = tail call double @llvm.fmuladd.f64(double %1, double 2.000000e+00, double -1.000000e+00)
br label %42
16: ; preds = %12
%17 = fdiv double 1.000000e+00, %3
%18 = fcmp ult double %17, %1
br i1 %18, label %35, label %19
19: ; preds = %16
%20 = fmul double %1, 2.000000e+00
%21 = tail call double @llvm.fmuladd.f64(double %20, double %3, double -1.000000e+00)
%22 = icmp slt i32 %0, 501
br i1 %22, label %23, label %27
23: ; preds = %19
%24 = tail call double @rapfac(i32 %0)
%25 = tail call double @pow(double %21, double %3)
%26 = fmul double %24, %25
br label %42
27: ; preds = %19
%28 = tail call i32 @getLogFactorial(i32 %0)
%29 = fdiv double %21, %3
%30 = tail call i32 @log(double %29)
%31 = mul nsw i32 %30, %0
%32 = add nsw i32 %31, %28
%33 = sitofp i32 %32 to double
%34 = tail call double @exp(double %33)
br label %42
35: ; preds = %16
%36 = fsub double 1.000000e+00, %17
%37 = fcmp ugt double %36, %1
br i1 %37, label %42, label %38
38: ; preds = %35
%39 = fsub double 1.000000e+00, %1
%40 = tail call double @pow(double %39, double %3)
%41 = tail call double @llvm.fmuladd.f64(double %40, double -2.000000e+00, double 1.000000e+00)
br label %42
42: ; preds = %35, %23, %27, %9, %2, %38, %14
%43 = phi double [ %15, %14 ], [ %41, %38 ], [ 1.000000e+00, %2 ], [ 0.000000e+00, %9 ], [ %26, %23 ], [ %34, %27 ], [ -1.000000e+00, %35 ]
ret double %43
}