#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 */
typedef int /*<<< orphan*/ s;

/* Variables and functions */
scalar_t__ fabs(float);
float stbir__filter_cubic(float x, float s) {
  (void)sizeof(s);
  x = (float)fabs(x);
  if (x < 1.0f)
    return (4 + x * x * (3 * x - 6)) / 6;
  else if (x < 2.0f)
    return (8 + x * (-12 + x * (6 - x))) / 6;
  return (0.0f);
}


x86 assembly (clang, -O0):
<stbir__filter_cubic>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
movss  %xmm0,-0x8(%rbp)
movss  %xmm1,-0xc(%rbp)
movss  -0x8(%rbp),%xmm0
call   1030 <fabs@plt>
cvtsi2ss %rax,%xmm0
movss  %xmm0,-0x8(%rbp)
movss  0xec2(%rip),%xmm0
ucomiss -0x8(%rbp),%xmm0
jbe    1195 <stbir__filter_cubic+0x85>
movss  -0x8(%rbp),%xmm0
mulss  -0x8(%rbp),%xmm0
movss  -0x8(%rbp),%xmm1
movss  0xeb9(%rip),%xmm2
mulss  %xmm2,%xmm1
movss  0xeb1(%rip),%xmm2
addss  %xmm2,%xmm1
mulss  %xmm1,%xmm0
movss  0xe99(%rip),%xmm1
addss  %xmm1,%xmm0
movss  0xe81(%rip),%xmm1
divss  %xmm1,%xmm0
movss  %xmm0,-0x4(%rbp)
jmp    1201 <stbir__filter_cubic+0xf1>
movss  0xe67(%rip),%xmm0
ucomiss -0x8(%rbp),%xmm0
jbe    11f4 <stbir__filter_cubic+0xe4>
movss  -0x8(%rbp),%xmm0
movss  -0x8(%rbp),%xmm1
movss  0xe4f(%rip),%xmm2
subss  -0x8(%rbp),%xmm2
mulss  %xmm2,%xmm1
movss  0xe46(%rip),%xmm2
addss  %xmm2,%xmm1
mulss  %xmm1,%xmm0
movss  0xe32(%rip),%xmm1
addss  %xmm1,%xmm0
movss  0xe22(%rip),%xmm1
divss  %xmm1,%xmm0
movss  %xmm0,-0x4(%rbp)
jmp    1201 <stbir__filter_cubic+0xf1>
jmp    11f9 <stbir__filter_cubic+0xe9>
xorps  %xmm0,%xmm0
movss  %xmm0,-0x4(%rbp)
movss  -0x4(%rbp),%xmm0
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<stbir__filter_cubic>:
push   %rax
call   1030 <fabs@plt>
cvtsi2ss %rax,%xmm1
test   %rax,%rax
jle    1156 <stbir__filter_cubic+0x46>
xorps  %xmm0,%xmm0
cmp    $0x1,%rax
jne    1154 <stbir__filter_cubic+0x44>
movss  0xecf(%rip),%xmm2
movaps %xmm2,%xmm0
subss  %xmm1,%xmm0
mulss  %xmm1,%xmm0
addss  0xec0(%rip),%xmm0
mulss  %xmm1,%xmm0
addss  0xeb8(%rip),%xmm0
divss  %xmm2,%xmm0
pop    %rax
ret
movaps %xmm1,%xmm0
mulss  0xeab(%rip),%xmm1
mulss  %xmm0,%xmm0
addss  0xea3(%rip),%xmm1
mulss  %xmm0,%xmm1
addss  0xe9b(%rip),%xmm1
divss  0xe7f(%rip),%xmm1
movaps %xmm1,%xmm0
pop    %rax
ret

LLVM IR (-O0):
define float @stbir__filter_cubic(float %0, float %1) {
%3 = alloca float
%4 = alloca float
%5 = alloca float
store float %0, float* %4
store float %1, float* %5
%6 = load float, float* %4
%7 = call i64 @fabs(float %6)
%8 = sitofp i64 %7 to float
store float %8, float* %4
%9 = load float, float* %4
%10 = fcmp olt float %9, 1.000000e+00
br i1 %10, label %11, label %19
11: ; preds = %2
%12 = load float, float* %4
%13 = load float, float* %4
%14 = fmul float %12, %13
%15 = load float, float* %4
%16 = call float @llvm.fmuladd.f32(float 3.000000e+00, float %15, float -6.000000e+00)
%17 = call float @llvm.fmuladd.f32(float %14, float %16, float 4.000000e+00)
%18 = fdiv float %17, 6.000000e+00
store float %18, float* %3
br label %32
19: ; preds = %2
%20 = load float, float* %4
%21 = fcmp olt float %20, 2.000000e+00
br i1 %21, label %22, label %30
22: ; preds = %19
%23 = load float, float* %4
%24 = load float, float* %4
%25 = load float, float* %4
%26 = fsub float 6.000000e+00, %25
%27 = call float @llvm.fmuladd.f32(float %24, float %26, float -1.200000e+01)
%28 = call float @llvm.fmuladd.f32(float %23, float %27, float 8.000000e+00)
%29 = fdiv float %28, 6.000000e+00
store float %29, float* %3
br label %32
30: ; preds = %19
br label %31
31: ; preds = %30
store float 0.000000e+00, float* %3
br label %32
32: ; preds = %31, %22, %11
%33 = load float, float* %3
ret float %33
}

LLVM IR (-O2):
define float @stbir__filter_cubic(float %0, float %1) {
%3 = tail call i64 @fabs(float %0)
%4 = sitofp i64 %3 to float
%5 = icmp slt i64 %3, 1
br i1 %5, label %6, label %11
6: ; preds = %2
%7 = fmul float %4, %4
%8 = tail call float @llvm.fmuladd.f32(float %4, float 3.000000e+00, float -6.000000e+00)
%9 = tail call float @llvm.fmuladd.f32(float %7, float %8, float 4.000000e+00)
%10 = fdiv float %9, 6.000000e+00
br label %18
11: ; preds = %2
%12 = icmp eq i64 %3, 1
br i1 %12, label %13, label %18
13: ; preds = %11
%14 = fsub float 6.000000e+00, %4
%15 = tail call float @llvm.fmuladd.f32(float %4, float %14, float -1.200000e+01)
%16 = tail call float @llvm.fmuladd.f32(float %4, float %15, float 8.000000e+00)
%17 = fdiv float %16, 6.000000e+00
br label %18
18: ; preds = %11, %13, %6
%19 = phi float [ %10, %6 ], [ %17, %13 ], [ 0.000000e+00, %11 ]
ret float %19
}