#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 uint32_t;

/* Variables and functions */
float fastsin(float x) {
  static const float fouroverpi = 1.2732395447351627f;
  static const float fouroverpisq = 0.40528473456935109f;
  static const float q = 0.78444488374548933f;
  union {
    float f;
    uint32_t i;
  } p = {0.20363937680730309f};
  union {
    float f;
    uint32_t i;
  } r = {0.015124940802184233f};
  union {
    float f;
    uint32_t i;
  } s = {-0.0032225901625579573f};
  union {
    float f;
    uint32_t i;
  } vx = {x};
  uint32_t sign = vx.i & 0x80000000;
  vx.i = vx.i & 0x7FFFFFFF;
  float qpprox = fouroverpi * x - fouroverpisq * x * vx.f;
  float qpproxsq = qpprox * qpprox;
  p.i |= sign;
  r.i |= sign;
  s.i ^= sign;
  return q * qpprox + qpproxsq * (p.f + qpproxsq * (r.f + qpproxsq * s.f));
}


x86 assembly (clang, -O0):
<fastsin>:
push   %rbp
mov    %rsp,%rbp
movss  %xmm0,-0x4(%rbp)
mov    0xefd(%rip),%eax
mov    %eax,-0x8(%rbp)
mov    0xef8(%rip),%eax
mov    %eax,-0x10(%rbp)
mov    0xef3(%rip),%eax
mov    %eax,-0x18(%rbp)
movss  -0x4(%rbp),%xmm0
movss  %xmm0,-0x20(%rbp)
mov    -0x20(%rbp),%eax
and    $0x80000000,%eax
mov    %eax,-0x24(%rbp)
mov    -0x20(%rbp),%eax
and    $0x7fffffff,%eax
mov    %eax,-0x20(%rbp)
movss  -0x4(%rbp),%xmm0
movss  0xeb7(%rip),%xmm1
mulss  -0x4(%rbp),%xmm1
mulss  -0x20(%rbp),%xmm1
movd   %xmm1,%eax
xor    $0x80000000,%eax
movd   %eax,%xmm1
movss  0xe94(%rip),%xmm2
mulss  %xmm2,%xmm0
addss  %xmm1,%xmm0
movss  %xmm0,-0x28(%rbp)
movss  -0x28(%rbp),%xmm0
mulss  -0x28(%rbp),%xmm0
movss  %xmm0,-0x2c(%rbp)
mov    -0x24(%rbp),%eax
or     -0x8(%rbp),%eax
mov    %eax,-0x8(%rbp)
mov    -0x24(%rbp),%eax
or     -0x10(%rbp),%eax
mov    %eax,-0x10(%rbp)
mov    -0x24(%rbp),%eax
xor    -0x18(%rbp),%eax
mov    %eax,-0x18(%rbp)
movss  -0x28(%rbp),%xmm0
movss  -0x2c(%rbp),%xmm1
movss  -0x8(%rbp),%xmm3
movss  -0x2c(%rbp),%xmm2
movss  -0x10(%rbp),%xmm5
movss  -0x2c(%rbp),%xmm4
movss  -0x18(%rbp),%xmm6
mulss  %xmm6,%xmm4
addss  %xmm5,%xmm4
mulss  %xmm4,%xmm2
addss  %xmm3,%xmm2
mulss  %xmm2,%xmm1
movss  0xe1a(%rip),%xmm2
mulss  %xmm2,%xmm0
addss  %xmm1,%xmm0
pop    %rbp
ret

x86 assembly (clang, -O2):
<fastsin>:
movmskps %xmm0,%eax
shl    $0x1f,%eax
movaps 0xef3(%rip),%xmm1
andps  %xmm0,%xmm1
movss  0xef8(%rip),%xmm2
mulss  %xmm0,%xmm2
mulss  %xmm1,%xmm2
mulss  0xeec(%rip),%xmm0
addss  %xmm2,%xmm0
movaps %xmm0,%xmm1
mulss  %xmm0,%xmm1
lea    0x3e5086d7(%rax),%ecx
movd   %ecx,%xmm2
lea    0x3c77ce9a(%rax),%ecx
movd   %ecx,%xmm3
xor    $0xbb533217,%eax
movd   %eax,%xmm4
mulss  %xmm1,%xmm4
addss  %xmm3,%xmm4
mulss  %xmm1,%xmm4
addss  %xmm2,%xmm4
mulss  %xmm1,%xmm4
mulss  0xeac(%rip),%xmm0
addss  %xmm4,%xmm0
ret

LLVM IR (-O0):
%union.anon = type { float }
%union.anon.0 = type { float }
%union.anon.1 = type { float }
%union.anon.2 = type { float }
@fastsin.fouroverpi = internal constant float 0x3FF45F3060000000
@fastsin.fouroverpisq = internal constant float 0x3FD9F02F60000000
@fastsin.q = internal constant float 0x3FE91A2C20000000
@__const.fastsin.p = %union.anon { float 0x3FCA10DAE0000000 }
@__const.fastsin.r = %union.anon.0 { float 0x3F8EF9D340000000 }
@__const.fastsin.s = %union.anon.1 { float 0xBF6A6642E0000000 }
define float @fastsin(float %0) {
%2 = alloca float
%3 = alloca %union.anon
%4 = alloca %union.anon.0
%5 = alloca %union.anon.1
%6 = alloca %union.anon.2
%7 = alloca i32
%8 = alloca float
%9 = alloca float
store float %0, float* %2
%10 = bitcast %union.anon* %3 to i8*
%11 = bitcast %union.anon.0* %4 to i8*
%12 = bitcast %union.anon.1* %5 to i8*
%13 = bitcast %union.anon.2* %6 to float*
%14 = load float, float* %2
store float %14, float* %13
%15 = bitcast %union.anon.2* %6 to i32*
%16 = load i32, i32* %15
%17 = and i32 %16, -2147483648
store i32 %17, i32* %7
%18 = bitcast %union.anon.2* %6 to i32*
%19 = load i32, i32* %18
%20 = and i32 %19, 2147483647
%21 = bitcast %union.anon.2* %6 to i32*
store i32 %20, i32* %21
%22 = load float, float* %2
%23 = load float, float* %2
%24 = fmul float 0x3FD9F02F60000000, %23
%25 = bitcast %union.anon.2* %6 to float*
%26 = load float, float* %25
%27 = fmul float %24, %26
%28 = fneg float %27
%29 = call float @llvm.fmuladd.f32(float 0x3FF45F3060000000, float %22, float %28)
store float %29, float* %8
%30 = load float, float* %8
%31 = load float, float* %8
%32 = fmul float %30, %31
store float %32, float* %9
%33 = load i32, i32* %7
%34 = bitcast %union.anon* %3 to i32*
%35 = load i32, i32* %34
%36 = or i32 %35, %33
store i32 %36, i32* %34
%37 = load i32, i32* %7
%38 = bitcast %union.anon.0* %4 to i32*
%39 = load i32, i32* %38
%40 = or i32 %39, %37
store i32 %40, i32* %38
%41 = load i32, i32* %7
%42 = bitcast %union.anon.1* %5 to i32*
%43 = load i32, i32* %42
%44 = xor i32 %43, %41
store i32 %44, i32* %42
%45 = load float, float* %8
%46 = load float, float* %9
%47 = bitcast %union.anon* %3 to float*
%48 = load float, float* %47
%49 = load float, float* %9
%50 = bitcast %union.anon.0* %4 to float*
%51 = load float, float* %50
%52 = load float, float* %9
%53 = bitcast %union.anon.1* %5 to float*
%54 = load float, float* %53
%55 = call float @llvm.fmuladd.f32(float %52, float %54, float %51)
%56 = call float @llvm.fmuladd.f32(float %49, float %55, float %48)
%57 = fmul float %46, %56
%58 = call float @llvm.fmuladd.f32(float 0x3FE91A2C20000000, float %45, float %57)
ret float %58
}

LLVM IR (-O2):
define float @fastsin(float %0) {
%2 = bitcast float %0 to i32
%3 = and i32 %2, -2147483648
%4 = and i32 %2, 2147483647
%5 = bitcast i32 %4 to float
%6 = fmul float %0, 0xBFD9F02F60000000
%7 = fmul float %6, %5
%8 = tail call float @llvm.fmuladd.f32(float %0, float 0x3FF45F3060000000, float %7)
%9 = fmul float %8, %8
%10 = or i32 %3, 1045464791
%11 = bitcast i32 %10 to float
%12 = or i32 %3, 1014484634
%13 = bitcast i32 %12 to float
%14 = xor i32 %3, -1152175593
%15 = bitcast i32 %14 to float
%16 = tail call float @llvm.fmuladd.f32(float %9, float %15, float %13)
%17 = tail call float @llvm.fmuladd.f32(float %9, float %16, float %11)
%18 = fmul float %9, %17
%19 = tail call float @llvm.fmuladd.f32(float %8, float 0x3FE91A2C20000000, float %18)
ret float %19
}