float _fclipf(float x, float clipLimit) {
  float x_abs = x;
  float clipLimit_abs = clipLimit;
  int inputIsNegative = 0;
  float result = x;
  if (x < 0) {
    inputIsNegative = 1;
    x_abs = -x_abs;
  }
  if (clipLimit < 0) {
    clipLimit_abs = -clipLimit_abs;
  }
  if (x_abs >= clipLimit_abs) {
    result = clipLimit_abs;
    if (inputIsNegative) {
      result = -result;
    }
  }
  return result;
}


x86 assembly (clang, -O0):
<_fclipf>:
push   %rbp
mov    %rsp,%rbp
movss  %xmm0,-0x4(%rbp)
movss  %xmm1,-0x8(%rbp)
movss  -0x4(%rbp),%xmm0
movss  %xmm0,-0xc(%rbp)
movss  -0x8(%rbp),%xmm0
movss  %xmm0,-0x10(%rbp)
movl   $0x0,-0x14(%rbp)
movss  -0x4(%rbp),%xmm0
movss  %xmm0,-0x18(%rbp)
xorps  %xmm0,%xmm0
ucomiss -0x4(%rbp),%xmm0
jbe    115e <_fclipf+0x5e>
movl   $0x1,-0x14(%rbp)
movss  -0xc(%rbp),%xmm0
movd   %xmm0,%eax
xor    $0x80000000,%eax
movd   %eax,%xmm0
movss  %xmm0,-0xc(%rbp)
xorps  %xmm0,%xmm0
ucomiss -0x8(%rbp),%xmm0
jbe    1182 <_fclipf+0x82>
movss  -0x10(%rbp),%xmm0
movd   %xmm0,%eax
xor    $0x80000000,%eax
movd   %eax,%xmm0
movss  %xmm0,-0x10(%rbp)
movss  -0xc(%rbp),%xmm0
ucomiss -0x10(%rbp),%xmm0
jb     11c1 <_fclipf+0xc1>
movss  -0x10(%rbp),%xmm0
movss  %xmm0,-0x18(%rbp)
cmpl   $0x0,-0x14(%rbp)
je     11bc <_fclipf+0xbc>
movss  -0x18(%rbp),%xmm0
movd   %xmm0,%eax
xor    $0x80000000,%eax
movd   %eax,%xmm0
movss  %xmm0,-0x18(%rbp)
jmp    11c1 <_fclipf+0xc1>
movss  -0x18(%rbp),%xmm0
pop    %rbp
ret

x86 assembly (clang, -O2):
<_fclipf>:
movaps %xmm0,%xmm2
xorps  %xmm0,%xmm0
ucomiss %xmm2,%xmm0
movaps 0xef0(%rip),%xmm3
movaps %xmm2,%xmm5
xorps  %xmm3,%xmm5
movaps %xmm2,%xmm4
cmpltss %xmm0,%xmm4
andps  %xmm4,%xmm5
andnps %xmm2,%xmm4
orps   %xmm5,%xmm4
movaps %xmm1,%xmm6
xorps  %xmm3,%xmm6
movaps %xmm1,%xmm5
cmpltss %xmm0,%xmm5
andps  %xmm5,%xmm6
andnps %xmm1,%xmm5
orps   %xmm6,%xmm5
movaps %xmm5,%xmm0
cmpnless %xmm4,%xmm0
andps  %xmm0,%xmm2
andnps %xmm5,%xmm0
orps   %xmm2,%xmm0
ja     115b <_fclipf+0x5b>
movaps %xmm0,%xmm3
ucomiss %xmm5,%xmm4
jae    1163 <_fclipf+0x63>
jmp    1166 <_fclipf+0x66>
xorps  %xmm5,%xmm3
ucomiss %xmm5,%xmm4
jb     1166 <_fclipf+0x66>
movaps %xmm3,%xmm0
ret

LLVM IR (-O0):
define float @_fclipf(float %0, float %1) {
%3 = alloca float
%4 = alloca float
%5 = alloca float
%6 = alloca float
%7 = alloca i32
%8 = alloca float
store float %0, float* %3
store float %1, float* %4
%9 = load float, float* %3
store float %9, float* %5
%10 = load float, float* %4
store float %10, float* %6
store i32 0, i32* %7
%11 = load float, float* %3
store float %11, float* %8
%12 = load float, float* %3
%13 = fcmp olt float %12, 0.000000e+00
br i1 %13, label %14, label %17
14: ; preds = %2
store i32 1, i32* %7
%15 = load float, float* %5
%16 = fneg float %15
store float %16, float* %5
br label %17
17: ; preds = %14, %2
%18 = load float, float* %4
%19 = fcmp olt float %18, 0.000000e+00
br i1 %19, label %20, label %23
20: ; preds = %17
%21 = load float, float* %6
%22 = fneg float %21
store float %22, float* %6
br label %23
23: ; preds = %20, %17
%24 = load float, float* %5
%25 = load float, float* %6
%26 = fcmp oge float %24, %25
br i1 %26, label %27, label %35
27: ; preds = %23
%28 = load float, float* %6
store float %28, float* %8
%29 = load i32, i32* %7
%30 = icmp ne i32 %29, 0
br i1 %30, label %31, label %34
31: ; preds = %27
%32 = load float, float* %8
%33 = fneg float %32
store float %33, float* %8
br label %34
34: ; preds = %31, %27
br label %35
35: ; preds = %34, %23
%36 = load float, float* %8
ret float %36
}

LLVM IR (-O2):
define float @_fclipf(float %0, float %1) {
%3 = fcmp olt float %0, 0.000000e+00
%4 = fneg float %0
%5 = select i1 %3, float %4, float %0
%6 = fcmp olt float %1, 0.000000e+00
%7 = fneg float %1
%8 = select i1 %6, float %7, float %1
%9 = fcmp ult float %5, %8
%10 = xor i1 %3, true
%11 = or i1 %9, %10
%12 = select i1 %9, float %0, float %8
%13 = fneg float %8
%14 = select i1 %11, float %12, float %13
ret float %14
}