#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 fabs(scalar_t__);
scalar_t__ floor(double);
double pow(double, double);
double b_param(double y, double u, double A, double B, double C) {
  double v = A - (1.0 - 2.0 * u) * fabs(floor(0.5 - u) + A);
  double result = pow(y, B + (C - B) * v);
  if (result > 1)
    result = 1;
  if (result < 0)
    result = 0;
  return result;
}


x86 assembly (clang, -O0):
<b_param>:
push   %rbp
mov    %rsp,%rbp
sub    $0x50,%rsp
movsd  %xmm0,-0x8(%rbp)
movsd  %xmm1,-0x10(%rbp)
movsd  %xmm2,-0x18(%rbp)
movsd  %xmm3,-0x20(%rbp)
movsd  %xmm4,-0x28(%rbp)
movsd  -0x18(%rbp),%xmm0
movsd  %xmm0,-0x48(%rbp)
movsd  -0x10(%rbp),%xmm1
addsd  %xmm1,%xmm1
movsd  0xe94(%rip),%xmm0
subsd  %xmm1,%xmm0
movsd  %xmm0,-0x40(%rbp)
movsd  0xe8b(%rip),%xmm0
subsd  -0x10(%rbp),%xmm0
call   1050 <floor@plt>
cvtsi2sd %rax,%xmm0
addsd  -0x18(%rbp),%xmm0
cvttsd2si %xmm0,%rdi
call   1030 <fabs@plt>
movsd  -0x48(%rbp),%xmm1
movaps %xmm0,%xmm2
movsd  -0x40(%rbp),%xmm0
movq   %xmm0,%rax
movabs $0x8000000000000000,%rcx
xor    %rcx,%rax
movq   %rax,%xmm0
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
movsd  %xmm0,-0x30(%rbp)
movsd  -0x8(%rbp),%xmm0
movsd  -0x20(%rbp),%xmm2
movsd  -0x28(%rbp),%xmm1
subsd  -0x20(%rbp),%xmm1
movsd  -0x30(%rbp),%xmm3
mulsd  %xmm3,%xmm1
addsd  %xmm2,%xmm1
call   1040 <pow@plt>
movsd  %xmm0,-0x38(%rbp)
movsd  -0x38(%rbp),%xmm0
movsd  0xdfc(%rip),%xmm1
ucomisd %xmm1,%xmm0
jbe    121b <b_param+0xeb>
movsd  0xdea(%rip),%xmm0
movsd  %xmm0,-0x38(%rbp)
xorps  %xmm0,%xmm0
ucomisd -0x38(%rbp),%xmm0
jbe    1231 <b_param+0x101>
xorps  %xmm0,%xmm0
movsd  %xmm0,-0x38(%rbp)
movsd  -0x38(%rbp),%xmm0
add    $0x50,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<b_param>:
sub    $0x28,%rsp
movsd  %xmm4,0x18(%rsp)
movsd  %xmm3,0x10(%rsp)
movsd  %xmm2,(%rsp)
movsd  %xmm0,0x20(%rsp)
movsd  0xeb5(%rip),%xmm0
subsd  %xmm1,%xmm0
addsd  %xmm1,%xmm1
movsd  0xe9d(%rip),%xmm2
subsd  %xmm1,%xmm2
movsd  %xmm2,0x8(%rsp)
call   1050 <floor@plt>
xorps  %xmm0,%xmm0
cvtsi2sd %rax,%xmm0
addsd  (%rsp),%xmm0
cvttsd2si %xmm0,%rdi
call   1030 <fabs@plt>
mulsd  0x8(%rsp),%xmm0
movsd  (%rsp),%xmm2
subsd  %xmm0,%xmm2
movsd  0x18(%rsp),%xmm1
movsd  0x10(%rsp),%xmm0
subsd  %xmm0,%xmm1
mulsd  %xmm2,%xmm1
addsd  %xmm0,%xmm1
movsd  0x20(%rsp),%xmm0
call   1040 <pow@plt>
movsd  0xe3d(%rip),%xmm1
minsd  %xmm0,%xmm1
xorpd  %xmm0,%xmm0
maxsd  %xmm1,%xmm0
add    $0x28,%rsp
ret

LLVM IR (-O0):
define double @b_param(double %0, double %1, double %2, double %3, double %4) {
%6 = alloca double
%7 = alloca double
%8 = alloca double
%9 = alloca double
%10 = alloca double
%11 = alloca double
%12 = alloca double
store double %0, double* %6
store double %1, double* %7
store double %2, double* %8
store double %3, double* %9
store double %4, double* %10
%13 = load double, double* %8
%14 = load double, double* %7
%15 = call double @llvm.fmuladd.f64(double -2.000000e+00, double %14, double 1.000000e+00)
%16 = load double, double* %7
%17 = fsub double 5.000000e-01, %16
%18 = call i64 @floor(double %17)
%19 = sitofp i64 %18 to double
%20 = load double, double* %8
%21 = fadd double %19, %20
%22 = fptosi double %21 to i64
%23 = call double @fabs(i64 %22)
%24 = fneg double %15
%25 = call double @llvm.fmuladd.f64(double %24, double %23, double %13)
store double %25, double* %11
%26 = load double, double* %6
%27 = load double, double* %9
%28 = load double, double* %10
%29 = load double, double* %9
%30 = fsub double %28, %29
%31 = load double, double* %11
%32 = call double @llvm.fmuladd.f64(double %30, double %31, double %27)
%33 = call double @pow(double %26, double %32)
store double %33, double* %12
%34 = load double, double* %12
%35 = fcmp ogt double %34, 1.000000e+00
br i1 %35, label %36, label %37
36: ; preds = %5
store double 1.000000e+00, double* %12
br label %37
37: ; preds = %36, %5
%38 = load double, double* %12
%39 = fcmp olt double %38, 0.000000e+00
br i1 %39, label %40, label %41
40: ; preds = %37
store double 0.000000e+00, double* %12
br label %41
41: ; preds = %40, %37
%42 = load double, double* %12
ret double %42
}

LLVM IR (-O2):
define double @b_param(double %0, double %1, double %2, double %3, double %4) {
%6 = tail call double @llvm.fmuladd.f64(double %1, double -2.000000e+00, double 1.000000e+00)
%7 = fsub double 5.000000e-01, %1
%8 = tail call i64 @floor(double %7)
%9 = sitofp i64 %8 to double
%10 = fadd double %9, %2
%11 = fptosi double %10 to i64
%12 = tail call double @fabs(i64 %11)
%13 = fneg double %6
%14 = tail call double @llvm.fmuladd.f64(double %13, double %12, double %2)
%15 = fsub double %4, %3
%16 = tail call double @llvm.fmuladd.f64(double %15, double %14, double %3)
%17 = tail call double @pow(double %0, double %16)
%18 = fcmp ogt double %17, 1.000000e+00
%19 = select i1 %18, double 1.000000e+00, double %17
%20 = fcmp olt double %19, 0.000000e+00
%21 = select i1 %20, double 0.000000e+00, double %19
ret double %21
}