#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);
double KSPlusbarAsymp(int n, double x) {
  double t = (6.0 * n * x + 1);
  double z = t * t / (18.0 * n);
  double v = 1.0 - (2.0 * z * z - 4.0 * z - 1.0) / (18.0 * n);
  if (v <= 0.0)
    return 0.0;
  v = v * exp(-z);
  if (v >= 1.0)
    return 1.0;
  return v;
}


x86 assembly (clang, -O0):
<KSPlusbarAsymp>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
mov    %edi,-0xc(%rbp)
movsd  %xmm0,-0x18(%rbp)
cvtsi2sdl -0xc(%rbp),%xmm1
movsd  0xef3(%rip),%xmm0
mulsd  %xmm1,%xmm0
movsd  -0x18(%rbp),%xmm1
mulsd  %xmm1,%xmm0
movsd  0xebe(%rip),%xmm1
addsd  %xmm1,%xmm0
movsd  %xmm0,-0x20(%rbp)
movsd  -0x20(%rbp),%xmm0
mulsd  -0x20(%rbp),%xmm0
cvtsi2sdl -0xc(%rbp),%xmm2
movsd  0xea6(%rip),%xmm1
mulsd  %xmm2,%xmm1
divsd  %xmm1,%xmm0
movsd  %xmm0,-0x28(%rbp)
movsd  0xea1(%rip),%xmm1
mulsd  -0x28(%rbp),%xmm1
movsd  -0x28(%rbp),%xmm2
movsd  0xe87(%rip),%xmm0
mulsd  -0x28(%rbp),%xmm0
movq   %xmm0,%rax
movabs $0x8000000000000000,%rcx
xor    %rcx,%rax
movq   %rax,%xmm0
mulsd  %xmm2,%xmm1
addsd  %xmm0,%xmm1
movsd  0xe4b(%rip),%xmm0
subsd  %xmm0,%xmm1
cvtsi2sdl -0xc(%rbp),%xmm2
movsd  0xe42(%rip),%xmm0
mulsd  %xmm2,%xmm0
divsd  %xmm0,%xmm1
movsd  0xe2a(%rip),%xmm0
subsd  %xmm1,%xmm0
movsd  %xmm0,-0x30(%rbp)
xorps  %xmm0,%xmm0
ucomisd -0x30(%rbp),%xmm0
jb     11fa <KSPlusbarAsymp+0xea>
xorps  %xmm0,%xmm0
movsd  %xmm0,-0x8(%rbp)
jmp    1269 <KSPlusbarAsymp+0x159>
movsd  -0x30(%rbp),%xmm0
movsd  %xmm0,-0x38(%rbp)
movsd  -0x28(%rbp),%xmm0
movq   %xmm0,%rax
movabs $0x8000000000000000,%rcx
xor    %rcx,%rax
movq   %rax,%xmm0
call   1030 <exp@plt>
movaps %xmm0,%xmm1
movsd  -0x38(%rbp),%xmm0
mulsd  %xmm1,%xmm0
movsd  %xmm0,-0x30(%rbp)
movsd  -0x30(%rbp),%xmm0
movsd  0xdbd(%rip),%xmm1
ucomisd %xmm1,%xmm0
jb     125f <KSPlusbarAsymp+0x14f>
movsd  0xdab(%rip),%xmm0
movsd  %xmm0,-0x8(%rbp)
jmp    1269 <KSPlusbarAsymp+0x159>
movsd  -0x30(%rbp),%xmm0
movsd  %xmm0,-0x8(%rbp)
movsd  -0x8(%rbp),%xmm0
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<KSPlusbarAsymp>:
push   %rax
movapd %xmm0,%xmm1
cvtsi2sd %edi,%xmm2
movsd  0xedf(%rip),%xmm0
mulsd  %xmm2,%xmm0
mulsd  %xmm1,%xmm0
movsd  0xed7(%rip),%xmm4
addsd  %xmm4,%xmm0
mulsd  %xmm0,%xmm0
mulsd  0xecf(%rip),%xmm2
divsd  %xmm2,%xmm0
movapd %xmm0,%xmm1
addsd  %xmm0,%xmm1
movsd  0xec3(%rip),%xmm3
mulsd  %xmm0,%xmm3
mulsd  %xmm0,%xmm1
addsd  %xmm3,%xmm1
addsd  0xeb7(%rip),%xmm1
divsd  %xmm2,%xmm1
movapd %xmm4,%xmm2
subsd  %xmm1,%xmm2
xorpd  %xmm1,%xmm1
ucomisd %xmm2,%xmm1
jae    11a6 <KSPlusbarAsymp+0x96>
xorpd  0xea9(%rip),%xmm0
movsd  %xmm2,(%rsp)
call   1030 <exp@plt>
movsd  (%rsp),%xmm2
mulsd  %xmm0,%xmm2
movsd  0xe66(%rip),%xmm1
minsd  %xmm2,%xmm1
movapd %xmm1,%xmm0
pop    %rax
ret

LLVM IR (-O0):
define double @KSPlusbarAsymp(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 = fmul double 6.000000e+00, %10
%12 = load double, double* %5
%13 = call double @llvm.fmuladd.f64(double %11, double %12, double 1.000000e+00)
store double %13, double* %6
%14 = load double, double* %6
%15 = load double, double* %6
%16 = fmul double %14, %15
%17 = load i32, i32* %4
%18 = sitofp i32 %17 to double
%19 = fmul double 1.800000e+01, %18
%20 = fdiv double %16, %19
store double %20, double* %7
%21 = load double, double* %7
%22 = fmul double 2.000000e+00, %21
%23 = load double, double* %7
%24 = load double, double* %7
%25 = fmul double 4.000000e+00, %24
%26 = fneg double %25
%27 = call double @llvm.fmuladd.f64(double %22, double %23, double %26)
%28 = fsub double %27, 1.000000e+00
%29 = load i32, i32* %4
%30 = sitofp i32 %29 to double
%31 = fmul double 1.800000e+01, %30
%32 = fdiv double %28, %31
%33 = fsub double 1.000000e+00, %32
store double %33, double* %8
%34 = load double, double* %8
%35 = fcmp ole double %34, 0.000000e+00
br i1 %35, label %36, label %37
36: ; preds = %2
store double 0.000000e+00, double* %3
br label %48
37: ; preds = %2
%38 = load double, double* %8
%39 = load double, double* %7
%40 = fneg double %39
%41 = call double @exp(double %40)
%42 = fmul double %38, %41
store double %42, double* %8
%43 = load double, double* %8
%44 = fcmp oge double %43, 1.000000e+00
br i1 %44, label %45, label %46
45: ; preds = %37
store double 1.000000e+00, double* %3
br label %48
46: ; preds = %37
%47 = load double, double* %8
store double %47, double* %3
br label %48
48: ; preds = %46, %45, %36
%49 = load double, double* %3
ret double %49
}

LLVM IR (-O2):
define double @KSPlusbarAsymp(i32 %0, double %1) {
%3 = sitofp i32 %0 to double
%4 = fmul double %3, 6.000000e+00
%5 = tail call double @llvm.fmuladd.f64(double %4, double %1, double 1.000000e+00)
%6 = fmul double %5, %5
%7 = fmul double %3, 1.800000e+01
%8 = fdiv double %6, %7
%9 = fmul double %8, 2.000000e+00
%10 = fmul double %8, -4.000000e+00
%11 = tail call double @llvm.fmuladd.f64(double %9, double %8, double %10)
%12 = fadd double %11, -1.000000e+00
%13 = fdiv double %12, %7
%14 = fsub double 1.000000e+00, %13
%15 = fcmp ugt double %14, 0.000000e+00
br i1 %15, label %16, label %22
16: ; preds = %2
%17 = fneg double %8
%18 = tail call double @exp(double %17)
%19 = fmul double %14, %18
%20 = fcmp oge double %19, 1.000000e+00
%21 = select i1 %20, double 1.000000e+00, double %19
br label %22
22: ; preds = %16, %2
%23 = phi double [ 0.000000e+00, %2 ], [ %21, %16 ]
ret double %23
}