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

/* Variables and functions */
float sin_approx(float x) {
  int32_t xint = x;
  if (xint < -32 || xint > 32)
    return 0.0f;
  while (x > 3.14159265358979323846f)
    x -= (2.0f * 3.14159265358979323846f);
  while (x < -3.14159265358979323846f)
    x += (2.0f * 3.14159265358979323846f);
  if (x > (0.5f * 3.14159265358979323846f))
    x = (0.5f * 3.14159265358979323846f) -
        (x - (0.5f * 3.14159265358979323846f));
  else if (x < -(0.5f * 3.14159265358979323846f))
    x = -(0.5f * 3.14159265358979323846f) -
        ((0.5f * 3.14159265358979323846f) + x);
  float x2 = x * x;
  return x + x * x2 *
                 (-1.666568107e-1f +
                  x2 * (8.312366210e-3f + x2 * (-1.849218155e-4f + x2 * 0)));
}


x86 assembly (clang, -O0):
<sin_approx>:
push   %rbp
mov    %rsp,%rbp
movss  %xmm0,-0x8(%rbp)
cvttss2si -0x8(%rbp),%eax
mov    %eax,-0xc(%rbp)
cmpl   $0xffffffe0,-0xc(%rbp)
jl     1125 <sin_approx+0x25>
cmpl   $0x20,-0xc(%rbp)
jle    1132 <sin_approx+0x32>
xorps  %xmm0,%xmm0
movss  %xmm0,-0x4(%rbp)
jmp    1275 <sin_approx+0x175>
jmp    1137 <sin_approx+0x37>
movss  -0x8(%rbp),%xmm0
movss  0xebc(%rip),%xmm1
ucomiss %xmm1,%xmm0
jbe    1168 <sin_approx+0x68>
movss  -0x8(%rbp),%xmm0
movss  0xec2(%rip),%xmm1
subss  %xmm1,%xmm0
movss  %xmm0,-0x8(%rbp)
jmp    1137 <sin_approx+0x37>
jmp    116d <sin_approx+0x6d>
movss  0xe8f(%rip),%xmm0
ucomiss -0x8(%rbp),%xmm0
jbe    1196 <sin_approx+0x96>
movss  0xe95(%rip),%xmm0
addss  -0x8(%rbp),%xmm0
movss  %xmm0,-0x8(%rbp)
jmp    116d <sin_approx+0x6d>
movss  -0x8(%rbp),%xmm0
movss  0xe65(%rip),%xmm1
ucomiss %xmm1,%xmm0
jbe    11d3 <sin_approx+0xd3>
movss  -0x8(%rbp),%xmm1
movss  0xe4f(%rip),%xmm0
subss  %xmm0,%xmm1
movss  0xe43(%rip),%xmm0
subss  %xmm1,%xmm0
movss  %xmm0,-0x8(%rbp)
jmp    1208 <sin_approx+0x108>
movss  0xe31(%rip),%xmm0
ucomiss -0x8(%rbp),%xmm0
jbe    1203 <sin_approx+0x103>
movss  0xe1b(%rip),%xmm1
addss  -0x8(%rbp),%xmm1
movss  0xe12(%rip),%xmm0
subss  %xmm1,%xmm0
movss  %xmm0,-0x8(%rbp)
jmp    1208 <sin_approx+0x108>
movss  -0x8(%rbp),%xmm0
mulss  -0x8(%rbp),%xmm0
movss  %xmm0,-0x10(%rbp)
movss  -0x8(%rbp),%xmm1
movss  -0x8(%rbp),%xmm0
mulss  -0x10(%rbp),%xmm0
movss  -0x10(%rbp),%xmm2
movss  -0x10(%rbp),%xmm3
movss  -0x10(%rbp),%xmm4
xorps  %xmm5,%xmm5
mulss  %xmm5,%xmm4
movss  0xdd4(%rip),%xmm5
addss  %xmm5,%xmm4
mulss  %xmm4,%xmm3
movss  0xdc0(%rip),%xmm4
addss  %xmm4,%xmm3
mulss  %xmm3,%xmm2
movss  0xdac(%rip),%xmm3
addss  %xmm3,%xmm2
mulss  %xmm2,%xmm0
addss  %xmm1,%xmm0
movss  %xmm0,-0x4(%rbp)
movss  -0x4(%rbp),%xmm0
pop    %rbp
ret

x86 assembly (clang, -O2):
<sin_approx>:
cvttss2si %xmm0,%eax
add    $0xffffffdf,%eax
cmp    $0xffffffbf,%eax
jae    1110 <sin_approx+0x10>
xorps  %xmm0,%xmm0
ret
ucomiss 0xee9(%rip),%xmm0
jbe    1139 <sin_approx+0x39>
movss  0xee3(%rip),%xmm1
movss  0xed7(%rip),%xmm2
nopl   0x0(%rax)
addss  %xmm1,%xmm0
ucomiss %xmm2,%xmm0
ja     1130 <sin_approx+0x30>
movss  0xec7(%rip),%xmm1
ucomiss %xmm0,%xmm1
jbe    1159 <sin_approx+0x59>
movss  0xebe(%rip),%xmm2
xchg   %ax,%ax
addss  %xmm2,%xmm0
ucomiss %xmm0,%xmm1
ja     1150 <sin_approx+0x50>
ucomiss 0xeb0(%rip),%xmm0
jbe    1174 <sin_approx+0x74>
addss  0xeaa(%rip),%xmm0
movss  0xe9e(%rip),%xmm1
jmp    1189 <sin_approx+0x89>
movss  0xe98(%rip),%xmm1
ucomiss %xmm0,%xmm1
jbe    1190 <sin_approx+0x90>
addss  0xe87(%rip),%xmm0
subss  %xmm0,%xmm1
movaps %xmm1,%xmm0
movaps %xmm0,%xmm2
mulss  %xmm0,%xmm2
movaps %xmm0,%xmm3
mulss  %xmm2,%xmm3
xorps  %xmm1,%xmm1
mulss  %xmm2,%xmm1
addss  0xe6b(%rip),%xmm1
mulss  %xmm2,%xmm1
addss  0xe63(%rip),%xmm1
mulss  %xmm2,%xmm1
addss  0xe5b(%rip),%xmm1
mulss  %xmm3,%xmm1
addss  %xmm0,%xmm1
movaps %xmm1,%xmm0
ret

LLVM IR (-O0):
define float @sin_approx(float %0) {
%2 = alloca float
%3 = alloca float
%4 = alloca i32
%5 = alloca float
store float %0, float* %3
%6 = load float, float* %3
%7 = fptosi float %6 to i32
store i32 %7, i32* %4
%8 = load i32, i32* %4
%9 = icmp slt i32 %8, -32
br i1 %9, label %13, label %10
10: ; preds = %1
%11 = load i32, i32* %4
%12 = icmp sgt i32 %11, 32
br i1 %12, label %13, label %14
13: ; preds = %10, %1
store float 0.000000e+00, float* %2
br label %58
14: ; preds = %10
br label %15
15: ; preds = %18, %14
%16 = load float, float* %3
%17 = fcmp ogt float %16, 0x400921FB60000000
br i1 %17, label %18, label %21
18: ; preds = %15
%19 = load float, float* %3
%20 = fsub float %19, 0x401921FB60000000
store float %20, float* %3
br label %15
21: ; preds = %15
br label %22
22: ; preds = %25, %21
%23 = load float, float* %3
%24 = fcmp olt float %23, 0xC00921FB60000000
br i1 %24, label %25, label %28
25: ; preds = %22
%26 = load float, float* %3
%27 = fadd float %26, 0x401921FB60000000
store float %27, float* %3
br label %22
28: ; preds = %22
%29 = load float, float* %3
%30 = fcmp ogt float %29, 0x3FF921FB60000000
br i1 %30, label %31, label %35
31: ; preds = %28
%32 = load float, float* %3
%33 = fsub float %32, 0x3FF921FB60000000
%34 = fsub float 0x3FF921FB60000000, %33
store float %34, float* %3
br label %43
35: ; preds = %28
%36 = load float, float* %3
%37 = fcmp olt float %36, 0xBFF921FB60000000
br i1 %37, label %38, label %42
38: ; preds = %35
%39 = load float, float* %3
%40 = fadd float 0x3FF921FB60000000, %39
%41 = fsub float 0xBFF921FB60000000, %40
store float %41, float* %3
br label %42
42: ; preds = %38, %35
br label %43
43: ; preds = %42, %31
%44 = load float, float* %3
%45 = load float, float* %3
%46 = fmul float %44, %45
store float %46, float* %5
%47 = load float, float* %3
%48 = load float, float* %3
%49 = load float, float* %5
%50 = fmul float %48, %49
%51 = load float, float* %5
%52 = load float, float* %5
%53 = load float, float* %5
%54 = call float @llvm.fmuladd.f32(float %53, float 0.000000e+00, float 0xBF283CF240000000)
%55 = call float @llvm.fmuladd.f32(float %52, float %54, float 0x3F810612E0000000)
%56 = call float @llvm.fmuladd.f32(float %51, float %55, float 0xBFC55502A0000000)
%57 = call float @llvm.fmuladd.f32(float %50, float %56, float %47)
store float %57, float* %2
br label %58
58: ; preds = %43, %13
%59 = load float, float* %2
ret float %59
}

LLVM IR (-O2):
define float @sin_approx(float %0) {
%2 = fptosi float %0 to i32
%3 = add i32 %2, -33
%4 = icmp ult i32 %3, -65
br i1 %4, label %37, label %5
5: ; preds = %1
%6 = fcmp ogt float %0, 0x400921FB60000000
br i1 %6, label %10, label %7
7: ; preds = %10, %5
%8 = phi float [ %0, %5 ], [ %12, %10 ]
%9 = fcmp olt float %8, 0xC00921FB60000000
br i1 %9, label %14, label %18
10: ; preds = %5, %10
%11 = phi float [ %12, %10 ], [ %0, %5 ]
%12 = fadd float %11, 0xC01921FB60000000
%13 = fcmp ogt float %12, 0x400921FB60000000
br i1 %13, label %10, label %7
14: ; preds = %7, %14
%15 = phi float [ %16, %14 ], [ %8, %7 ]
%16 = fadd float %15, 0x401921FB60000000
%17 = fcmp olt float %16, 0xC00921FB60000000
br i1 %17, label %14, label %18
18: ; preds = %14, %7
%19 = phi float [ %8, %7 ], [ %16, %14 ]
%20 = fcmp ogt float %19, 0x3FF921FB60000000
br i1 %20, label %21, label %24
21: ; preds = %18
%22 = fadd float %19, 0xBFF921FB60000000
%23 = fsub float 0x3FF921FB60000000, %22
br label %29
24: ; preds = %18
%25 = fcmp olt float %19, 0xBFF921FB60000000
br i1 %25, label %26, label %29
26: ; preds = %24
%27 = fadd float %19, 0x3FF921FB60000000
%28 = fsub float 0xBFF921FB60000000, %27
br label %29
29: ; preds = %24, %26, %21
%30 = phi float [ %23, %21 ], [ %28, %26 ], [ %19, %24 ]
%31 = fmul float %30, %30
%32 = fmul float %30, %31
%33 = tail call float @llvm.fmuladd.f32(float %31, float 0.000000e+00, float 0xBF283CF240000000)
%34 = tail call float @llvm.fmuladd.f32(float %31, float %33, float 0x3F810612E0000000)
%35 = tail call float @llvm.fmuladd.f32(float %31, float %34, float 0xBFC55502A0000000)
%36 = tail call float @llvm.fmuladd.f32(float %32, float %35, float %30)
br label %37
37: ; preds = %1, %29
%38 = phi float [ %36, %29 ], [ 0.000000e+00, %1 ]
ret float %38
}