#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 KSPlusbarUpper(int, double);
double KScdf(int, double);
double fbarSpecial(int, double);
double KSfbar(int n, double x) {
  const double w = n * x * x;
  double v = fbarSpecial(n, x);
  if (v >= 0.0)
    return v;
  if (n <= 500) {
    if (w < 4.0)
      return 1.0 - KScdf(n, x);
    else
      return 2.0 * KSPlusbarUpper(n, x);
  }
  if (w >= 2.65)
    return 2.0 * KSPlusbarUpper(n, x);
  return 1.0 - KScdf(n, x);
}


x86 assembly (clang, -O0):
<KSfbar>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%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)
mov    -0xc(%rbp),%edi
movsd  -0x18(%rbp),%xmm0
call   1040 <fbarSpecial@plt>
movsd  %xmm0,-0x28(%rbp)
movsd  -0x28(%rbp),%xmm0
xorps  %xmm1,%xmm1
ucomisd %xmm1,%xmm0
jb     1187 <KSfbar+0x57>
movsd  -0x28(%rbp),%xmm0
movsd  %xmm0,-0x8(%rbp)
jmp    1251 <KSfbar+0x121>
cmpl   $0x1f4,-0xc(%rbp)
jg     11f3 <KSfbar+0xc3>
movsd  0xe7c(%rip),%xmm0
ucomisd -0x20(%rbp),%xmm0
jbe    11cd <KSfbar+0x9d>
mov    -0xc(%rbp),%edi
movsd  -0x18(%rbp),%xmm0
call   1050 <KScdf@plt>
movaps %xmm0,%xmm1
movsd  0xe49(%rip),%xmm0
subsd  %xmm1,%xmm0
movsd  %xmm0,-0x8(%rbp)
jmp    1251 <KSfbar+0x121>
mov    -0xc(%rbp),%edi
movsd  -0x18(%rbp),%xmm0
call   1030 <KSPlusbarUpper@plt>
movaps %xmm0,%xmm1
movsd  0xe2b(%rip),%xmm0
mulsd  %xmm1,%xmm0
movsd  %xmm0,-0x8(%rbp)
jmp    1251 <KSfbar+0x121>
movsd  -0x20(%rbp),%xmm0
movsd  0xe00(%rip),%xmm1
ucomisd %xmm1,%xmm0
jb     1230 <KSfbar+0x100>
mov    -0xc(%rbp),%edi
movsd  -0x18(%rbp),%xmm0
call   1030 <KSPlusbarUpper@plt>
movaps %xmm0,%xmm1
movsd  0xdee(%rip),%xmm0
mulsd  %xmm1,%xmm0
movsd  %xmm0,-0x8(%rbp)
jmp    1251 <KSfbar+0x121>
mov    -0xc(%rbp),%edi
movsd  -0x18(%rbp),%xmm0
call   1050 <KScdf@plt>
movaps %xmm0,%xmm1
movsd  0xdc0(%rip),%xmm0
subsd  %xmm1,%xmm0
movsd  %xmm0,-0x8(%rbp)
movsd  -0x8(%rbp),%xmm0
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<KSfbar>:
push   %rbx
sub    $0x10,%rsp
mov    %edi,%ebx
movsd  %xmm0,0x8(%rsp)
call   1040 <fbarSpecial@plt>
xorpd  %xmm1,%xmm1
ucomisd %xmm1,%xmm0
jae    11a2 <KSfbar+0x72>
cvtsi2sd %ebx,%xmm2
movsd  0x8(%rsp),%xmm0
mulsd  %xmm0,%xmm2
mulsd  %xmm0,%xmm2
cmp    $0x1f4,%ebx
jg     1181 <KSfbar+0x51>
movsd  0xea2(%rip),%xmm1
ucomisd %xmm2,%xmm1
ja     118b <KSfbar+0x5b>
mov    %ebx,%edi
call   1030 <KSPlusbarUpper@plt>
addsd  %xmm0,%xmm0
jmp    11a2 <KSfbar+0x72>
ucomisd 0xe77(%rip),%xmm2
jae    1174 <KSfbar+0x44>
mov    %ebx,%edi
call   1050 <KScdf@plt>
movapd %xmm0,%xmm1
movsd  0xe6a(%rip),%xmm0
subsd  %xmm1,%xmm0
add    $0x10,%rsp
pop    %rbx
ret

LLVM IR (-O0):
define double @KSfbar(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
store double %13, double* %6
%14 = load i32, i32* %4
%15 = load double, double* %5
%16 = call double @fbarSpecial(i32 %14, double %15)
store double %16, double* %7
%17 = load double, double* %7
%18 = fcmp oge double %17, 0.000000e+00
br i1 %18, label %19, label %21
19: ; preds = %2
%20 = load double, double* %7
store double %20, double* %3
br label %50
21: ; preds = %2
%22 = load i32, i32* %4
%23 = icmp sle i32 %22, 500
br i1 %23, label %24, label %37
24: ; preds = %21
%25 = load double, double* %6
%26 = fcmp olt double %25, 4.000000e+00
br i1 %26, label %27, label %32
27: ; preds = %24
%28 = load i32, i32* %4
%29 = load double, double* %5
%30 = call double @KScdf(i32 %28, double %29)
%31 = fsub double 1.000000e+00, %30
store double %31, double* %3
br label %50
32: ; preds = %24
%33 = load i32, i32* %4
%34 = load double, double* %5
%35 = call double @KSPlusbarUpper(i32 %33, double %34)
%36 = fmul double 2.000000e+00, %35
store double %36, double* %3
br label %50
37: ; preds = %21
%38 = load double, double* %6
%39 = fcmp oge double %38, 2.650000e+00
br i1 %39, label %40, label %45
40: ; preds = %37
%41 = load i32, i32* %4
%42 = load double, double* %5
%43 = call double @KSPlusbarUpper(i32 %41, double %42)
%44 = fmul double 2.000000e+00, %43
store double %44, double* %3
br label %50
45: ; preds = %37
%46 = load i32, i32* %4
%47 = load double, double* %5
%48 = call double @KScdf(i32 %46, double %47)
%49 = fsub double 1.000000e+00, %48
store double %49, double* %3
br label %50
50: ; preds = %45, %40, %32, %27, %19
%51 = load double, double* %3
ret double %51
}

LLVM IR (-O2):
define double @KSfbar(i32 %0, double %1) {
%3 = sitofp i32 %0 to double
%4 = fmul double %3, %1
%5 = fmul double %4, %1
%6 = tail call double @fbarSpecial(i32 %0, double %1)
%7 = fcmp ult double %6, 0.000000e+00
br i1 %7, label %8, label %26
8: ; preds = %2
%9 = icmp slt i32 %0, 501
br i1 %9, label %10, label %18
10: ; preds = %8
%11 = fcmp olt double %5, 4.000000e+00
br i1 %11, label %12, label %15
12: ; preds = %10
%13 = tail call double @KScdf(i32 %0, double %1)
%14 = fsub double 1.000000e+00, %13
br label %26
15: ; preds = %10
%16 = tail call double @KSPlusbarUpper(i32 %0, double %1)
%17 = fmul double %16, 2.000000e+00
br label %26
18: ; preds = %8
%19 = fcmp ult double %5, 2.650000e+00
br i1 %19, label %23, label %20
20: ; preds = %18
%21 = tail call double @KSPlusbarUpper(i32 %0, double %1)
%22 = fmul double %21, 2.000000e+00
br label %26
23: ; preds = %18
%24 = tail call double @KScdf(i32 %0, double %1)
%25 = fsub double 1.000000e+00, %24
br label %26
26: ; preds = %2, %23, %20, %15, %12
%27 = phi double [ %14, %12 ], [ %17, %15 ], [ %22, %20 ], [ %25, %23 ], [ %6, %2 ]
ret double %27
}