#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 fbarSpecial(int n, double x) {
  const double w = n * x * x;
  if ((w >= 370.0) || (x >= 1.0))
    return 0.0;
  if ((w <= 0.0274) || (x <= 0.5 / n))
    return 1.0;
  if (n == 1)
    return 2.0 - 2.0 * x;
  if (x <= 1.0 / n) {
    double z;
    double t = 2.0 * x * n - 1.0;
    if (n <= 500) {
      z = rapfac(n);
      return 1.0 - z * pow(t, (double)n);
    }
    z = getLogFactorial(n) + n * log(t / n);
    return 1.0 - exp(z);
  }
  if (x >= 1.0 - 1.0 / n) {
    return 2.0 * pow(1.0 - x, (double)n);
  }
  return -1.0;
}


x86 assembly (clang, -O0):
<fbarSpecial>:
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  %xmm0,-0x20(%rbp)
movsd  -0x20(%rbp),%xmm0
movsd  0xe7f(%rip),%xmm1
ucomisd %xmm1,%xmm0
jae    11a2 <fbarSpecial+0x52>
movsd  -0x18(%rbp),%xmm0
movsd  0xe70(%rip),%xmm1
ucomisd %xmm1,%xmm0
jb     11af <fbarSpecial+0x5f>
xorps  %xmm0,%xmm0
movsd  %xmm0,-0x8(%rbp)
jmp    1396 <fbarSpecial+0x246>
movsd  0xe59(%rip),%xmm0
ucomisd -0x20(%rbp),%xmm0
jae    11e2 <fbarSpecial+0x92>
movsd  -0x18(%rbp),%xmm1
cvtsi2sdl -0xc(%rbp),%xmm2
movsd  0xe44(%rip),%xmm0
divsd  %xmm2,%xmm0
ucomisd %xmm1,%xmm0
jb     11f4 <fbarSpecial+0xa4>
movsd  0xe1e(%rip),%xmm0
movsd  %xmm0,-0x8(%rbp)
jmp    1396 <fbarSpecial+0x246>
cmpl   $0x1,-0xc(%rbp)
jne    121d <fbarSpecial+0xcd>
movsd  -0x18(%rbp),%xmm1
addsd  %xmm1,%xmm1
movsd  0xe19(%rip),%xmm0
subsd  %xmm1,%xmm0
movsd  %xmm0,-0x8(%rbp)
jmp    1396 <fbarSpecial+0x246>
movsd  -0x18(%rbp),%xmm1
cvtsi2sdl -0xc(%rbp),%xmm2
movsd  0xdd9(%rip),%xmm0
divsd  %xmm2,%xmm0
ucomisd %xmm1,%xmm0
jb     132d <fbarSpecial+0x1dd>
movsd  0xde3(%rip),%xmm0
mulsd  -0x18(%rbp),%xmm0
cvtsi2sdl -0xc(%rbp),%xmm1
mulsd  %xmm1,%xmm0
movsd  0xdc5(%rip),%xmm1
addsd  %xmm1,%xmm0
movsd  %xmm0,-0x30(%rbp)
cmpl   $0x1f4,-0xc(%rbp)
jg     12d0 <fbarSpecial+0x180>
mov    -0xc(%rbp),%edi
call   1070 <rapfac@plt>
movsd  %xmm0,-0x28(%rbp)
movsd  -0x28(%rbp),%xmm0
movsd  %xmm0,-0x38(%rbp)
movsd  -0x30(%rbp),%xmm0
cvtsi2sdl -0xc(%rbp),%xmm1
call   1060 <pow@plt>
movaps %xmm0,%xmm1
movsd  -0x38(%rbp),%xmm0
movq   %xmm0,%rax
movabs $0x8000000000000000,%rcx
xor    %rcx,%rax
movq   %rax,%xmm0
mulsd  %xmm1,%xmm0
movsd  0xd46(%rip),%xmm1
addsd  %xmm1,%xmm0
movsd  %xmm0,-0x8(%rbp)
jmp    1396 <fbarSpecial+0x246>
mov    -0xc(%rbp),%edi
call   1030 <getLogFactorial@plt>
mov    %eax,-0x3c(%rbp)
mov    -0xc(%rbp),%eax
mov    %eax,-0x40(%rbp)
movsd  -0x30(%rbp),%xmm0
cvtsi2sdl -0xc(%rbp),%xmm1
divsd  %xmm1,%xmm0
call   1050 <log@plt>
mov    -0x40(%rbp),%ecx
mov    %eax,%edx
mov    -0x3c(%rbp),%eax
imul   %edx,%ecx
add    %ecx,%eax
cvtsi2sd %eax,%xmm0
movsd  %xmm0,-0x28(%rbp)
movsd  -0x28(%rbp),%xmm0
call   1040 <exp@plt>
movaps %xmm0,%xmm1
movsd  0xce9(%rip),%xmm0
subsd  %xmm1,%xmm0
movsd  %xmm0,-0x8(%rbp)
jmp    1396 <fbarSpecial+0x246>
movsd  -0x18(%rbp),%xmm0
cvtsi2sdl -0xc(%rbp),%xmm1
movsd  0xcc9(%rip),%xmm2
divsd  %xmm1,%xmm2
movsd  0xcbd(%rip),%xmm1
subsd  %xmm2,%xmm1
ucomisd %xmm1,%xmm0
jb     1389 <fbarSpecial+0x239>
movsd  0xca7(%rip),%xmm0
subsd  -0x18(%rbp),%xmm0
cvtsi2sdl -0xc(%rbp),%xmm1
call   1060 <pow@plt>
movaps %xmm0,%xmm1
movsd  0xcad(%rip),%xmm0
mulsd  %xmm1,%xmm0
movsd  %xmm0,-0x8(%rbp)
jmp    1396 <fbarSpecial+0x246>
movsd  0xc8f(%rip),%xmm0
movsd  %xmm0,-0x8(%rbp)
movsd  -0x8(%rbp),%xmm0
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<fbarSpecial>:
push   %rbp
push   %rbx
sub    $0x18,%rsp
ucomisd 0xea2(%rip),%xmm0
xorpd  %xmm2,%xmm2
jae    12a8 <fbarSpecial+0x158>
movapd %xmm0,%xmm3
mov    %edi,%ebx
cvtsi2sd %edi,%xmm1
movapd %xmm1,%xmm0
mulsd  %xmm3,%xmm0
mulsd  %xmm3,%xmm0
ucomisd 0xe82(%rip),%xmm0
jae    12a8 <fbarSpecial+0x158>
movsd  0xe7c(%rip),%xmm2
divsd  %xmm1,%xmm2
ucomisd %xmm3,%xmm2
movsd  0xe5c(%rip),%xmm2
jae    12a8 <fbarSpecial+0x158>
movsd  0xe66(%rip),%xmm4
ucomisd %xmm0,%xmm4
jae    12a8 <fbarSpecial+0x158>
cmp    $0x1,%ebx
jne    11d6 <fbarSpecial+0x86>
addsd  %xmm3,%xmm3
movsd  0xe5b(%rip),%xmm0
subsd  %xmm3,%xmm0
jmp    12ac <fbarSpecial+0x15c>
movsd  0xe22(%rip),%xmm0
movapd %xmm0,%xmm2
divsd  %xmm1,%xmm2
ucomisd %xmm3,%xmm2
jae    1207 <fbarSpecial+0xb7>
movapd %xmm0,%xmm4
subsd  %xmm2,%xmm4
ucomisd %xmm4,%xmm3
jae    125f <fbarSpecial+0x10f>
movsd  0xe1e(%rip),%xmm2
jmp    12a8 <fbarSpecial+0x158>
addsd  %xmm3,%xmm3
mulsd  %xmm1,%xmm3
addsd  0xe09(%rip),%xmm3
movsd  %xmm3,0x8(%rsp)
cmp    $0x1f4,%ebx
movsd  %xmm1,(%rsp)
jg     1272 <fbarSpecial+0x122>
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
movsd  0xdab(%rip),%xmm1
subsd  %xmm0,%xmm1
movapd %xmm1,%xmm0
jmp    12ac <fbarSpecial+0x15c>
subsd  %xmm3,%xmm0
call   1060 <pow@plt>
movapd %xmm0,%xmm2
addsd  %xmm0,%xmm2
jmp    12a8 <fbarSpecial+0x158>
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
call   1040 <exp@plt>
movsd  0xd5c(%rip),%xmm2
subsd  %xmm0,%xmm2
movapd %xmm2,%xmm0
add    $0x18,%rsp
pop    %rbx
pop    %rbp
ret

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

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