#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 */
float fmin(float, float);
float apply_curve(float delta, float min_delta, float max_delta, float slope) {
  float ds, stable_curve;
  ds = delta * slope;
  ds = (ds * ds) + min_delta;
  stable_curve = fmin(max_delta, ds);
  if (delta < 0.0f)
    return stable_curve * -1.0f;
  else
    return stable_curve;
}


x86 assembly (clang, -O0):
<apply_curve>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movss  %xmm0,-0x8(%rbp)
movss  %xmm1,-0xc(%rbp)
movss  %xmm2,-0x10(%rbp)
movss  %xmm3,-0x14(%rbp)
movss  -0x8(%rbp),%xmm0
mulss  -0x14(%rbp),%xmm0
movss  %xmm0,-0x18(%rbp)
movss  -0x18(%rbp),%xmm0
movss  -0x18(%rbp),%xmm2
movss  -0xc(%rbp),%xmm1
mulss  %xmm2,%xmm0
addss  %xmm1,%xmm0
movss  %xmm0,-0x18(%rbp)
movss  -0x10(%rbp),%xmm0
movss  -0x18(%rbp),%xmm1
call   1030 <fmin@plt>
movss  %xmm0,-0x1c(%rbp)
xorps  %xmm0,%xmm0
ucomiss -0x8(%rbp),%xmm0
jbe    118f <apply_curve+0x7f>
movss  0xe80(%rip),%xmm0
mulss  -0x1c(%rbp),%xmm0
movss  %xmm0,-0x4(%rbp)
jmp    1199 <apply_curve+0x89>
movss  -0x1c(%rbp),%xmm0
movss  %xmm0,-0x4(%rbp)
movss  -0x4(%rbp),%xmm0
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<apply_curve>:
mulss  %xmm0,%xmm3
mulss  %xmm3,%xmm3
addss  %xmm1,%xmm3
movaps %xmm2,%xmm1
cmpunordss %xmm2,%xmm1
movaps %xmm1,%xmm4
andps  %xmm3,%xmm4
minss  %xmm2,%xmm3
andnps %xmm3,%xmm1
orps   %xmm4,%xmm1
movaps 0xed5(%rip),%xmm2
xorps  %xmm1,%xmm2
xorps  %xmm3,%xmm3
cmpltss %xmm3,%xmm0
movaps %xmm0,%xmm3
andnps %xmm1,%xmm3
andps  %xmm2,%xmm0
orps   %xmm3,%xmm0
ret

LLVM IR (-O0):
define float @apply_curve(float %0, float %1, float %2, float %3) {
%5 = alloca float
%6 = alloca float
%7 = alloca float
%8 = alloca float
%9 = alloca float
%10 = alloca float
%11 = alloca float
store float %0, float* %6
store float %1, float* %7
store float %2, float* %8
store float %3, float* %9
%12 = load float, float* %6
%13 = load float, float* %9
%14 = fmul float %12, %13
store float %14, float* %10
%15 = load float, float* %10
%16 = load float, float* %10
%17 = load float, float* %7
%18 = call float @llvm.fmuladd.f32(float %15, float %16, float %17)
store float %18, float* %10
%19 = load float, float* %8
%20 = load float, float* %10
%21 = call float @fmin(float %19, float %20)
store float %21, float* %11
%22 = load float, float* %6
%23 = fcmp olt float %22, 0.000000e+00
br i1 %23, label %24, label %27
24: ; preds = %4
%25 = load float, float* %11
%26 = fmul float %25, -1.000000e+00
store float %26, float* %5
br label %29
27: ; preds = %4
%28 = load float, float* %11
store float %28, float* %5
br label %29
29: ; preds = %27, %24
%30 = load float, float* %5
ret float %30
}

LLVM IR (-O2):
define float @apply_curve(float %0, float %1, float %2, float %3) {
%5 = fmul float %0, %3
%6 = tail call float @llvm.fmuladd.f32(float %5, float %5, float %1)
%7 = tail call nsz float @llvm.minnum.f32(float %2, float %6)
%8 = fcmp olt float %0, 0.000000e+00
%9 = fneg float %7
%10 = select i1 %8, float %9, float %7
ret float %10
}