float sine(float x) {
  const float B = 4 / ((float)3.14159265);
  const float C = -4 / (((float)3.14159265) * ((float)3.14159265));
  float y = B * x + C * x * ((x) < 0 ? -(x) : (x));
  const float P = 0.225;
  y = P * (y * ((y) < 0 ? -(y) : (y)) - y) + y;
  return y;
}


x86 assembly (clang, -O0):
<sine>:
push   %rbp
mov    %rsp,%rbp
movss  %xmm0,-0x4(%rbp)
movss  0xef3(%rip),%xmm0
movss  %xmm0,-0x8(%rbp)
movss  0xee2(%rip),%xmm0
movss  %xmm0,-0xc(%rbp)
movss  -0x4(%rbp),%xmm0
movss  %xmm0,-0x1c(%rbp)
movss  0xecb(%rip),%xmm0
mulss  -0x4(%rbp),%xmm0
movss  %xmm0,-0x18(%rbp)
xorps  %xmm0,%xmm0
ucomiss -0x4(%rbp),%xmm0
jbe    1168 <sine+0x68>
movss  -0x4(%rbp),%xmm0
movd   %xmm0,%eax
xor    $0x80000000,%eax
movd   %eax,%xmm0
movss  %xmm0,-0x20(%rbp)
jmp    1172 <sine+0x72>
movss  -0x4(%rbp),%xmm0
movss  %xmm0,-0x20(%rbp)
movss  -0x1c(%rbp),%xmm0
movss  -0x18(%rbp),%xmm1
movss  -0x20(%rbp),%xmm2
mulss  %xmm2,%xmm1
movss  0xe77(%rip),%xmm2
mulss  %xmm2,%xmm0
addss  %xmm1,%xmm0
movss  %xmm0,-0x10(%rbp)
movss  0xe66(%rip),%xmm0
movss  %xmm0,-0x14(%rbp)
movss  -0x10(%rbp),%xmm0
movss  %xmm0,-0x24(%rbp)
xorps  %xmm0,%xmm0
ucomiss -0x10(%rbp),%xmm0
jbe    11da <sine+0xda>
movss  -0x10(%rbp),%xmm0
movd   %xmm0,%eax
xor    $0x80000000,%eax
movd   %eax,%xmm0
movss  %xmm0,-0x28(%rbp)
jmp    11e4 <sine+0xe4>
movss  -0x10(%rbp),%xmm0
movss  %xmm0,-0x28(%rbp)
movss  -0x24(%rbp),%xmm0
movss  -0x28(%rbp),%xmm2
movss  -0x10(%rbp),%xmm1
movd   %xmm1,%eax
xor    $0x80000000,%eax
movd   %eax,%xmm1
mulss  %xmm2,%xmm0
addss  %xmm1,%xmm0
movss  -0x10(%rbp),%xmm1
movss  0xdf3(%rip),%xmm2
mulss  %xmm2,%xmm0
addss  %xmm1,%xmm0
movss  %xmm0,-0x10(%rbp)
movss  -0x10(%rbp),%xmm0
pop    %rbp
ret

x86 assembly (clang, -O2):
<sine>:
movss  0xef8(%rip),%xmm1
mulss  %xmm0,%xmm1
movaps 0xefd(%rip),%xmm2
movaps %xmm0,%xmm3
xorps  %xmm2,%xmm3
xorps  %xmm4,%xmm4
movaps %xmm0,%xmm5
cmpltss %xmm4,%xmm5
andps  %xmm5,%xmm3
andnps %xmm0,%xmm5
orps   %xmm3,%xmm5
mulss  0xecf(%rip),%xmm0
mulss  %xmm1,%xmm5
addss  %xmm5,%xmm0
xorps  %xmm0,%xmm2
movaps %xmm0,%xmm1
cmpltss %xmm4,%xmm1
andps  %xmm1,%xmm2
andnps %xmm0,%xmm1
orps   %xmm2,%xmm1
mulss  %xmm0,%xmm1
subss  %xmm0,%xmm1
mulss  0xea7(%rip),%xmm1
addss  %xmm1,%xmm0
ret

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

LLVM IR (-O2):
define float @sine(float %0) {
%2 = fmul float %0, 0xBFD9F02F40000000
%3 = fcmp olt float %0, 0.000000e+00
%4 = fneg float %0
%5 = select i1 %3, float %4, float %0
%6 = fmul float %2, %5
%7 = tail call float @llvm.fmuladd.f32(float %0, float 0x3FF45F3060000000, float %6)
%8 = fcmp olt float %7, 0.000000e+00
%9 = fneg float %7
%10 = select i1 %8, float %9, float %7
%11 = tail call float @llvm.fmuladd.f32(float %7, float %10, float %9)
%12 = tail call float @llvm.fmuladd.f32(float %11, float 0x3FCCCCCCC0000000, float %7)
ret float %12
}