#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 M_PI;
double fabs(double);
double sin(double x) {
  const double B = 4 / M_PI;
  const double C = -4 / (M_PI * M_PI);
  double y = B * x + C * x * fabs(x);
  const double P = 0.225;
  y = P * (y * fabs(y) - y) + y;
  return y;
}


x86 assembly (clang, -O0):
<sin>:
push   %rbp
mov    %rsp,%rbp
movsd  %xmm0,-0x8(%rbp)
mov    $0x4,%eax
mov    0x2ed3(%rip),%rcx
cltd
idivl  (%rcx)
cvtsi2sd %eax,%xmm0
movsd  %xmm0,-0x10(%rbp)
mov    0x2ec0(%rip),%rax
mov    (%rax),%ecx
mov    0x2eb7(%rip),%rax
imul   (%rax),%ecx
mov    $0xfffffffc,%eax
cltd
idiv   %ecx
cvtsi2sd %eax,%xmm0
movsd  %xmm0,-0x18(%rbp)
movsd  -0x10(%rbp),%xmm0
movsd  -0x8(%rbp),%xmm2
movsd  -0x18(%rbp),%xmm1
mulsd  -0x8(%rbp),%xmm1
movsd  -0x8(%rbp),%xmm3
movaps 0xeab(%rip),%xmm4
pand   %xmm4,%xmm3
mulsd  %xmm3,%xmm1
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
movsd  %xmm0,-0x20(%rbp)
movsd  0xe7e(%rip),%xmm0
movsd  %xmm0,-0x28(%rbp)
movsd  -0x20(%rbp),%xmm0
movsd  -0x20(%rbp),%xmm2
movaps 0xe78(%rip),%xmm1
pand   %xmm1,%xmm2
movsd  -0x20(%rbp),%xmm1
movq   %xmm1,%rax
movabs $0x8000000000000000,%rcx
xor    %rcx,%rax
movq   %rax,%xmm1
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
movsd  -0x20(%rbp),%xmm1
movsd  0xe33(%rip),%xmm2
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
movsd  %xmm0,-0x20(%rbp)
movsd  -0x20(%rbp),%xmm0
pop    %rbp
ret

x86 assembly (clang, -O2):
<sin>:
mov    0x2ee1(%rip),%rax
mov    (%rax),%ecx
mov    $0x4,%eax
xor    %edx,%edx
idiv   %ecx
cvtsi2sd %eax,%xmm1
imul   %ecx,%ecx
mov    $0xfffffffc,%eax
cltd
idiv   %ecx
cvtsi2sd %eax,%xmm2
mulsd  %xmm0,%xmm2
movapd 0xecf(%rip),%xmm3
mulsd  %xmm0,%xmm1
andpd  %xmm3,%xmm0
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
andpd  %xmm0,%xmm3
mulsd  %xmm0,%xmm3
subsd  %xmm0,%xmm3
mulsd  0xebb(%rip),%xmm3
addsd  %xmm3,%xmm0
ret

LLVM IR (-O0):
@M_PI = global i32 0
define double @sin(double %0) {
%2 = alloca double
%3 = alloca double
%4 = alloca double
%5 = alloca double
%6 = alloca double
store double %0, double* %2
%7 = load i32, i32* @M_PI
%8 = sdiv i32 4, %7
%9 = sitofp i32 %8 to double
store double %9, double* %3
%10 = load i32, i32* @M_PI
%11 = load i32, i32* @M_PI
%12 = mul nsw i32 %10, %11
%13 = sdiv i32 -4, %12
%14 = sitofp i32 %13 to double
store double %14, double* %4
%15 = load double, double* %3
%16 = load double, double* %2
%17 = load double, double* %4
%18 = load double, double* %2
%19 = fmul double %17, %18
%20 = load double, double* %2
%21 = call double @llvm.fabs.f64(double %20)
%22 = fmul double %19, %21
%23 = call double @llvm.fmuladd.f64(double %15, double %16, double %22)
store double %23, double* %5
store double 2.250000e-01, double* %6
%24 = load double, double* %5
%25 = load double, double* %5
%26 = call double @llvm.fabs.f64(double %25)
%27 = load double, double* %5
%28 = fneg double %27
%29 = call double @llvm.fmuladd.f64(double %24, double %26, double %28)
%30 = load double, double* %5
%31 = call double @llvm.fmuladd.f64(double 2.250000e-01, double %29, double %30)
store double %31, double* %5
%32 = load double, double* %5
ret double %32
}

LLVM IR (-O2):
@M_PI = global i32 0
define double @sin(double %0) {
%2 = load i32, i32* @M_PI
%3 = sdiv i32 4, %2
%4 = sitofp i32 %3 to double
%5 = mul nsw i32 %2, %2
%6 = sdiv i32 -4, %5
%7 = sitofp i32 %6 to double
%8 = fmul double %7, %0
%9 = tail call double @llvm.fabs.f64(double %0)
%10 = fmul double %9, %8
%11 = tail call double @llvm.fmuladd.f64(double %4, double %0, double %10)
%12 = tail call double @llvm.fabs.f64(double %11)
%13 = fneg double %11
%14 = tail call double @llvm.fmuladd.f64(double %11, double %12, double %13)
%15 = tail call double @llvm.fmuladd.f64(double %14, double 2.250000e-01, double %11)
ret double %15
}