#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 */
int fabs(float);
int pow(int, int);
float weight(float s) {
  float w;
  if (fabs(s) < 1 && fabs(s) >= 0)
    w = 1. / 6. * (4 - 6 * s * s + 3 * pow(fabs(s), 3));
  else if (fabs(s) >= 1 && fabs(s) < 2)
    w = 1. / 6. * pow(2 - fabs(s), 3);
  else
    w = 0;
  return w;
}


x86 assembly (clang, -O0):
<weight>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
movss  %xmm0,-0x4(%rbp)
movss  -0x4(%rbp),%xmm0
call   1030 <fabs@plt>
cmp    $0x1,%eax
jge    11cb <weight+0xab>
movss  -0x4(%rbp),%xmm0
call   1030 <fabs@plt>
cmp    $0x0,%eax
jl     11cb <weight+0xab>
movss  0xeb1(%rip),%xmm0
mulss  -0x4(%rbp),%xmm0
movss  -0x4(%rbp),%xmm1
movd   %xmm0,%eax
xor    $0x80000000,%eax
movd   %eax,%xmm0
mulss  %xmm1,%xmm0
movss  0xe8a(%rip),%xmm1
addss  %xmm1,%xmm0
movss  %xmm0,-0xc(%rbp)
movss  -0x4(%rbp),%xmm0
call   1030 <fabs@plt>
mov    %eax,%edi
mov    $0x3,%esi
call   1040 <pow@plt>
movss  -0xc(%rbp),%xmm0
imul   $0x3,%eax,%eax
cvtsi2ss %eax,%xmm1
addss  %xmm1,%xmm0
cvtss2sd %xmm0,%xmm1
movsd  0xe47(%rip),%xmm0
mulsd  %xmm1,%xmm0
cvtsd2ss %xmm0,%xmm0
movss  %xmm0,-0x8(%rbp)
jmp    1237 <weight+0x117>
movss  -0x4(%rbp),%xmm0
call   1030 <fabs@plt>
cmp    $0x1,%eax
jl     122a <weight+0x10a>
movss  -0x4(%rbp),%xmm0
call   1030 <fabs@plt>
cmp    $0x2,%eax
jge    122a <weight+0x10a>
movss  -0x4(%rbp),%xmm0
call   1030 <fabs@plt>
mov    $0x2,%edi
sub    %eax,%edi
mov    $0x3,%esi
call   1040 <pow@plt>
cvtsi2sd %eax,%xmm1
movsd  0xde8(%rip),%xmm0
mulsd  %xmm1,%xmm0
cvtsd2ss %xmm0,%xmm0
movss  %xmm0,-0x8(%rbp)
jmp    1232 <weight+0x112>
xorps  %xmm0,%xmm0
movss  %xmm0,-0x8(%rbp)
jmp    1237 <weight+0x117>
movss  -0x8(%rbp),%xmm0
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<weight>:
push   %rax
movss  %xmm0,(%rsp)
call   1030 <fabs@plt>
test   %eax,%eax
jle    117e <weight+0x5e>
movss  (%rsp),%xmm0
call   1030 <fabs@plt>
xorps  %xmm0,%xmm0
test   %eax,%eax
jle    11e0 <weight+0xc0>
movss  (%rsp),%xmm0
call   1030 <fabs@plt>
xorps  %xmm0,%xmm0
cmp    $0x1,%eax
jg     11e0 <weight+0xc0>
movss  (%rsp),%xmm0
call   1030 <fabs@plt>
mov    $0x2,%edi
sub    %eax,%edi
mov    $0x3,%esi
call   1040 <pow@plt>
xorps  %xmm0,%xmm0
cvtsi2sd %eax,%xmm0
jmp    11d4 <weight+0xb4>
movss  (%rsp),%xmm0
call   1030 <fabs@plt>
test   %eax,%eax
js     112f <weight+0xf>
movss  0xe74(%rip),%xmm1
movss  (%rsp),%xmm0
mulss  %xmm0,%xmm1
mulss  %xmm0,%xmm1
addss  0xe63(%rip),%xmm1
movss  %xmm1,0x4(%rsp)
call   1030 <fabs@plt>
mov    %eax,%edi
mov    $0x3,%esi
call   1040 <pow@plt>
lea    (%rax,%rax,2),%eax
xorps  %xmm0,%xmm0
cvtsi2ss %eax,%xmm0
addss  0x4(%rsp),%xmm0
cvtss2sd %xmm0,%xmm0
mulsd  0xe24(%rip),%xmm0
cvtsd2ss %xmm0,%xmm0
pop    %rax
ret

LLVM IR (-O0):
define float @weight(float %0) {
%2 = alloca float
%3 = alloca float
store float %0, float* %2
%4 = load float, float* %2
%5 = call i32 @fabs(float %4)
%6 = icmp slt i32 %5, 1
br i1 %6, label %7, label %26
7: ; preds = %1
%8 = load float, float* %2
%9 = call i32 @fabs(float %8)
%10 = icmp sge i32 %9, 0
br i1 %10, label %11, label %26
11: ; preds = %7
%12 = load float, float* %2
%13 = fmul float 6.000000e+00, %12
%14 = load float, float* %2
%15 = fneg float %13
%16 = call float @llvm.fmuladd.f32(float %15, float %14, float 4.000000e+00)
%17 = load float, float* %2
%18 = call i32 @fabs(float %17)
%19 = call i32 @pow(i32 %18, i32 3)
%20 = mul nsw i32 3, %19
%21 = sitofp i32 %20 to float
%22 = fadd float %16, %21
%23 = fpext float %22 to double
%24 = fmul double 0x3FC5555555555555, %23
%25 = fptrunc double %24 to float
store float %25, float* %3
br label %44
26: ; preds = %7, %1
%27 = load float, float* %2
%28 = call i32 @fabs(float %27)
%29 = icmp sge i32 %28, 1
br i1 %29, label %30, label %42
30: ; preds = %26
%31 = load float, float* %2
%32 = call i32 @fabs(float %31)
%33 = icmp slt i32 %32, 2
br i1 %33, label %34, label %42
34: ; preds = %30
%35 = load float, float* %2
%36 = call i32 @fabs(float %35)
%37 = sub nsw i32 2, %36
%38 = call i32 @pow(i32 %37, i32 3)
%39 = sitofp i32 %38 to double
%40 = fmul double 0x3FC5555555555555, %39
%41 = fptrunc double %40 to float
store float %41, float* %3
br label %43
42: ; preds = %30, %26
store float 0.000000e+00, float* %3
br label %43
43: ; preds = %42, %34
br label %44
44: ; preds = %43, %11
%45 = load float, float* %3
ret float %45
}

LLVM IR (-O2):
define float @weight(float %0) {
%2 = tail call i32 @fabs(float %0)
%3 = icmp slt i32 %2, 1
br i1 %3, label %4, label %18
4: ; preds = %1
%5 = tail call i32 @fabs(float %0)
%6 = icmp sgt i32 %5, -1
br i1 %6, label %7, label %18
7: ; preds = %4
%8 = fmul float %0, -6.000000e+00
%9 = tail call float @llvm.fmuladd.f32(float %8, float %0, float 4.000000e+00)
%10 = tail call i32 @fabs(float %0)
%11 = tail call i32 @pow(i32 %10, i32 3)
%12 = mul nsw i32 %11, 3
%13 = sitofp i32 %12 to float
%14 = fadd float %9, %13
%15 = fpext float %14 to double
%16 = fmul double %15, 0x3FC5555555555555
%17 = fptrunc double %16 to float
br label %31
18: ; preds = %4, %1
%19 = tail call i32 @fabs(float %0)
%20 = icmp sgt i32 %19, 0
br i1 %20, label %21, label %31
21: ; preds = %18
%22 = tail call i32 @fabs(float %0)
%23 = icmp slt i32 %22, 2
br i1 %23, label %24, label %31
24: ; preds = %21
%25 = tail call i32 @fabs(float %0)
%26 = sub nsw i32 2, %25
%27 = tail call i32 @pow(i32 %26, i32 3)
%28 = sitofp i32 %27 to double
%29 = fmul double %28, 0x3FC5555555555555
%30 = fptrunc double %29 to float
br label %31
31: ; preds = %18, %21, %24, %7
%32 = phi float [ %17, %7 ], [ %30, %24 ], [ 0.000000e+00, %21 ], [ 0.000000e+00, %18 ]
ret float %32
}