#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;
struct nyan {
  float f;
  int ui;
};

/* Variables and functions */
float fabsf(float);
float kernel_sin(float a, int flag) {
  float a2 = a * a;
  float answer;
  union nyan {
    float f;
    uint32_t ui;
  } c3, c2, c1;
  c3.ui = 0xb94d64b6;
  c2.ui = 0x3c088666;
  c1.ui = 0xbe2aaaac;
  answer = c3.f * a2;
  answer += c2.f;
  answer *= a2;
  answer += c1.f;
  answer *= a2;
  answer *= a;
  answer += a;
  if (flag == 0) {
    return fabsf(answer);
  } else {
    return -fabsf(answer);
  }
}


x86 assembly (clang, -O0):
<kernel_sin>:
push   %rbp
mov    %rsp,%rbp
movss  %xmm0,-0x8(%rbp)
mov    %edi,-0xc(%rbp)
movss  -0x8(%rbp),%xmm0
mulss  -0x8(%rbp),%xmm0
movss  %xmm0,-0x10(%rbp)
movl   $0xb94d64b6,-0x18(%rbp)
movl   $0x3c088666,-0x20(%rbp)
movl   $0xbe2aaaac,-0x28(%rbp)
movss  -0x18(%rbp),%xmm0
mulss  -0x10(%rbp),%xmm0
movss  %xmm0,-0x14(%rbp)
movss  -0x20(%rbp),%xmm0
addss  -0x14(%rbp),%xmm0
movss  %xmm0,-0x14(%rbp)
movss  -0x10(%rbp),%xmm0
mulss  -0x14(%rbp),%xmm0
movss  %xmm0,-0x14(%rbp)
movss  -0x28(%rbp),%xmm0
addss  -0x14(%rbp),%xmm0
movss  %xmm0,-0x14(%rbp)
movss  -0x10(%rbp),%xmm0
mulss  -0x14(%rbp),%xmm0
movss  %xmm0,-0x14(%rbp)
movss  -0x8(%rbp),%xmm0
mulss  -0x14(%rbp),%xmm0
movss  %xmm0,-0x14(%rbp)
movss  -0x8(%rbp),%xmm0
addss  -0x14(%rbp),%xmm0
movss  %xmm0,-0x14(%rbp)
cmpl   $0x0,-0xc(%rbp)
jne    11bd <kernel_sin+0xbd>
movss  -0x14(%rbp),%xmm0
movaps 0xe51(%rip),%xmm1
pand   %xmm1,%xmm0
movss  %xmm0,-0x4(%rbp)
jmp    11df <kernel_sin+0xdf>
movss  -0x14(%rbp),%xmm0
movaps 0xe37(%rip),%xmm1
pand   %xmm1,%xmm0
movd   %xmm0,%eax
xor    $0x80000000,%eax
movd   %eax,%xmm0
movss  %xmm0,-0x4(%rbp)
movss  -0x4(%rbp),%xmm0
pop    %rbp
ret

x86 assembly (clang, -O2):
<kernel_sin>:
movaps %xmm0,%xmm1
movaps %xmm0,%xmm2
mulss  %xmm0,%xmm2
movss  0xeee(%rip),%xmm0
mulss  %xmm2,%xmm0
addss  0xee6(%rip),%xmm0
mulss  %xmm2,%xmm0
addss  0xede(%rip),%xmm0
mulss  %xmm2,%xmm0
mulss  %xmm1,%xmm0
addss  %xmm1,%xmm0
test   %edi,%edi
je     1142 <kernel_sin+0x42>
orps   0xedf(%rip),%xmm0
ret
andps  0xec7(%rip),%xmm0
ret

LLVM IR (-O0):
%union.nyan = type { float }
define float @kernel_sin(float %0, i32 %1) {
%3 = alloca float
%4 = alloca float
%5 = alloca i32
%6 = alloca float
%7 = alloca float
%8 = alloca %union.nyan
%9 = alloca %union.nyan
%10 = alloca %union.nyan
store float %0, float* %4
store i32 %1, i32* %5
%11 = load float, float* %4
%12 = load float, float* %4
%13 = fmul float %11, %12
store float %13, float* %6
%14 = bitcast %union.nyan* %8 to i32*
store i32 -1186110282, i32* %14
%15 = bitcast %union.nyan* %9 to i32*
store i32 1007191654, i32* %15
%16 = bitcast %union.nyan* %10 to i32*
store i32 -1104500052, i32* %16
%17 = bitcast %union.nyan* %8 to float*
%18 = load float, float* %17
%19 = load float, float* %6
%20 = fmul float %18, %19
store float %20, float* %7
%21 = bitcast %union.nyan* %9 to float*
%22 = load float, float* %21
%23 = load float, float* %7
%24 = fadd float %23, %22
store float %24, float* %7
%25 = load float, float* %6
%26 = load float, float* %7
%27 = fmul float %26, %25
store float %27, float* %7
%28 = bitcast %union.nyan* %10 to float*
%29 = load float, float* %28
%30 = load float, float* %7
%31 = fadd float %30, %29
store float %31, float* %7
%32 = load float, float* %6
%33 = load float, float* %7
%34 = fmul float %33, %32
store float %34, float* %7
%35 = load float, float* %4
%36 = load float, float* %7
%37 = fmul float %36, %35
store float %37, float* %7
%38 = load float, float* %4
%39 = load float, float* %7
%40 = fadd float %39, %38
store float %40, float* %7
%41 = load i32, i32* %5
%42 = icmp eq i32 %41, 0
br i1 %42, label %43, label %46
43: ; preds = %2
%44 = load float, float* %7
%45 = call float @llvm.fabs.f32(float %44)
store float %45, float* %3
br label %50
46: ; preds = %2
%47 = load float, float* %7
%48 = call float @llvm.fabs.f32(float %47)
%49 = fneg float %48
store float %49, float* %3
br label %50
50: ; preds = %46, %43
%51 = load float, float* %3
ret float %51
}

LLVM IR (-O2):
define float @kernel_sin(float %0, i32 %1) {
%3 = fmul float %0, %0
%4 = fmul float %3, 0x3F29AC96C0000000
%5 = fsub float 0x3F8110CCC0000000, %4
%6 = fmul float %3, %5
%7 = fadd float %6, 0xBFC5555580000000
%8 = fmul float %3, %7
%9 = fmul float %8, %0
%10 = fadd float %9, %0
%11 = icmp eq i32 %1, 0
%12 = tail call float @llvm.fabs.f32(float %10)
%13 = fneg float %12
%14 = select i1 %11, float %12, float %13
ret float %14
}