#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 */
double DBL_EPSILON;
double DBL_MAX;
scalar_t__ M_PI_2;
double M_PI_4;
double NAN;
scalar_t__ _double_approx_eq(double, double, double);
double _factorial(int);
double _mod_unit_circle_radians(double);
double _pow(double, int);
double cosine_taylor(scalar_t__);
scalar_t__ isfinite(double);
scalar_t__ isnan(double);
double sine_taylor(double radians) {
  double x, y, s, t, b, v, last_y;
  size_t n;
  double tolerance;
  ((void)(0));
  if (isnan(radians)) {
    return radians;
  }
  if (isfinite(radians) == 0) {
    return NAN;
  }
  x = _mod_unit_circle_radians(radians);
  if (((x > (1.0 * M_PI_4)) && (x < (3.0 * M_PI_4))) ||
      ((x > (5.0 * M_PI_4)) && (x < (7.0 * M_PI_4)))) {
    return cosine_taylor(x - M_PI_2);
  }
  last_y = -DBL_MAX;
  y = 0;
  tolerance = (1.1 * DBL_EPSILON);
  for (n = 0; n <= 400U; ++n) {
    last_y = y;
    s = (n % 2 == 0) ? 1.0 : -1.0;
    t = _pow(x, (2 * n) + 1);
    b = _factorial((2 * n) + 1);
    v = ((s * t) / b);
    y = y + v;
    ((void)(0));
    ((void)(0));
    ((void)(0));
    ((void)(0));
    ((void)(0));
    ((void)(0));
    ((void)(0));
    ((void)(0));
    if (n >= 5U && _double_approx_eq(last_y, y, tolerance)) {
      break;
    }
  }
  ((void)(0));
  return y;
}


x86 assembly (clang, -O0):
<sine_taylor>:
push   %rbp
mov    %rsp,%rbp
sub    $0x70,%rsp
movsd  %xmm0,-0x10(%rbp)
movsd  -0x10(%rbp),%xmm0
call   1090 <isnan@plt>
cmp    $0x0,%rax
je     11a0 <sine_taylor+0x30>
movsd  -0x10(%rbp),%xmm0
movsd  %xmm0,-0x8(%rbp)
jmp    13d6 <sine_taylor+0x266>
movsd  -0x10(%rbp),%xmm0
call   1080 <isfinite@plt>
cmp    $0x0,%rax
jne    11c9 <sine_taylor+0x59>
mov    0x2e3d(%rip),%rax
movsd  (%rax),%xmm0
movsd  %xmm0,-0x8(%rbp)
jmp    13d6 <sine_taylor+0x266>
movsd  -0x10(%rbp),%xmm0
call   1030 <_mod_unit_circle_radians@plt>
movsd  %xmm0,-0x18(%rbp)
movsd  -0x18(%rbp),%xmm0
movsd  0xe1b(%rip),%xmm1
mov    0x2df4(%rip),%rax
mulsd  (%rax),%xmm1
ucomisd %xmm1,%xmm0
jbe    121c <sine_taylor+0xac>
movsd  -0x18(%rbp),%xmm1
movsd  0xe01(%rip),%xmm0
mov    0x2dd2(%rip),%rax
mulsd  (%rax),%xmm0
ucomisd %xmm1,%xmm0
ja     1260 <sine_taylor+0xf0>
movsd  -0x18(%rbp),%xmm0
movsd  0xde7(%rip),%xmm1
mov    0x2db0(%rip),%rax
mulsd  (%rax),%xmm1
ucomisd %xmm1,%xmm0
jbe    1289 <sine_taylor+0x119>
movsd  -0x18(%rbp),%xmm1
movsd  0xdcd(%rip),%xmm0
mov    0x2d8e(%rip),%rax
mulsd  (%rax),%xmm0
ucomisd %xmm1,%xmm0
jbe    1289 <sine_taylor+0x119>
movsd  -0x18(%rbp),%xmm0
mov    0x2d6c(%rip),%rax
cvtsi2sdq (%rax),%xmm1
subsd  %xmm1,%xmm0
cvttsd2si %xmm0,%rdi
call   1040 <cosine_taylor@plt>
movsd  %xmm0,-0x8(%rbp)
jmp    13d6 <sine_taylor+0x266>
mov    0x2d30(%rip),%rax
movsd  (%rax),%xmm0
movq   %xmm0,%rax
movabs $0x8000000000000000,%rcx
xor    %rcx,%rax
movq   %rax,%xmm0
movsd  %xmm0,-0x48(%rbp)
xorps  %xmm0,%xmm0
movsd  %xmm0,-0x20(%rbp)
movsd  0xd60(%rip),%xmm0
mov    0x2d09(%rip),%rax
mulsd  (%rax),%xmm0
movsd  %xmm0,-0x58(%rbp)
movq   $0x0,-0x50(%rbp)
cmpq   $0x190,-0x50(%rbp)
ja     13cc <sine_taylor+0x25c>
movsd  -0x20(%rbp),%xmm0
movsd  %xmm0,-0x48(%rbp)
mov    -0x50(%rbp),%rax
and    $0x1,%rax
movsd  0xd00(%rip),%xmm0
movsd  0xd20(%rip),%xmm1
movsd  %xmm1,-0x68(%rbp)
cmp    $0x0,%rax
movsd  %xmm0,-0x60(%rbp)
je     1326 <sine_taylor+0x1b6>
movsd  -0x68(%rbp),%xmm0
movsd  %xmm0,-0x60(%rbp)
movsd  -0x60(%rbp),%xmm0
movsd  %xmm0,-0x28(%rbp)
movsd  -0x18(%rbp),%xmm0
mov    -0x50(%rbp),%rax
shl    $0x1,%rax
add    $0x1,%rax
mov    %eax,%edi
call   1060 <_pow@plt>
movsd  %xmm0,-0x30(%rbp)
mov    -0x50(%rbp),%rax
shl    $0x1,%rax
add    $0x1,%rax
mov    %eax,%edi
call   1070 <_factorial@plt>
movsd  %xmm0,-0x38(%rbp)
movsd  -0x28(%rbp),%xmm0
mulsd  -0x30(%rbp),%xmm0
divsd  -0x38(%rbp),%xmm0
movsd  %xmm0,-0x40(%rbp)
movsd  -0x20(%rbp),%xmm0
addsd  -0x40(%rbp),%xmm0
movsd  %xmm0,-0x20(%rbp)
cmpq   $0x5,-0x50(%rbp)
jb     13b6 <sine_taylor+0x246>
movsd  -0x48(%rbp),%xmm0
movsd  -0x20(%rbp),%xmm1
movsd  -0x58(%rbp),%xmm2
call   1050 <_double_approx_eq@plt>
cmp    $0x0,%rax
je     13b6 <sine_taylor+0x246>
jmp    13cc <sine_taylor+0x25c>
jmp    13bb <sine_taylor+0x24b>
mov    -0x50(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x50(%rbp)
jmp    12d8 <sine_taylor+0x168>
movsd  -0x20(%rbp),%xmm0
movsd  %xmm0,-0x8(%rbp)
movsd  -0x8(%rbp),%xmm0
add    $0x70,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<sine_taylor>:
push   %rbp
push   %rbx
sub    $0x28,%rsp
movapd %xmm0,(%rsp)
call   1090 <isnan@plt>
test   %rax,%rax
je     1194 <sine_taylor+0x24>
movaps (%rsp),%xmm1
movapd %xmm1,%xmm0
add    $0x28,%rsp
pop    %rbx
pop    %rbp
ret
movapd (%rsp),%xmm0
call   1080 <isfinite@plt>
test   %rax,%rax
je     1213 <sine_taylor+0xa3>
movapd (%rsp),%xmm0
call   1030 <_mod_unit_circle_radians@plt>
mov    0x2e2c(%rip),%rax
movsd  (%rax),%xmm2
ucomisd %xmm2,%xmm0
jbe    11d0 <sine_taylor+0x60>
movsd  0xe3a(%rip),%xmm1
mulsd  %xmm2,%xmm1
ucomisd %xmm0,%xmm1
ja     11f0 <sine_taylor+0x80>
movsd  0xe30(%rip),%xmm1
mulsd  %xmm2,%xmm1
ucomisd %xmm1,%xmm0
jbe    1223 <sine_taylor+0xb3>
mulsd  0xe26(%rip),%xmm2
ucomisd %xmm0,%xmm2
jbe    1223 <sine_taylor+0xb3>
mov    0x2de1(%rip),%rax
xorps  %xmm1,%xmm1
cvtsi2sdq (%rax),%xmm1
subsd  %xmm1,%xmm0
cvttsd2si %xmm0,%rdi
add    $0x28,%rsp
pop    %rbx
pop    %rbp
jmp    1040 <cosine_taylor@plt>
mov    0x2dde(%rip),%rax
movsd  (%rax),%xmm1
jmp    1189 <sine_taylor+0x19>
mov    0x2da6(%rip),%rax
movsd  (%rax),%xmm1
mulsd  0xde2(%rip),%xmm1
movsd  %xmm1,0x18(%rsp)
xorpd  %xmm1,%xmm1
movsd  %xmm1,0x10(%rsp)
mov    $0x1,%ebp
xor    %ebx,%ebx
movsd  %xmm0,0x20(%rsp)
jmp    1273 <sine_taylor+0x103>
cs nopw 0x0(%rax,%rax,1)
nop
add    $0x1,%rbx
add    $0x2,%ebp
movsd  %xmm1,0x10(%rsp)
movsd  0x20(%rsp),%xmm0
mov    %ebp,%edi
call   1060 <_pow@plt>
movapd %xmm0,(%rsp)
mov    %ebp,%edi
call   1070 <_factorial@plt>
test   $0x1,%bl
je     12a0 <sine_taylor+0x130>
movapd (%rsp),%xmm1
xorpd  0xd88(%rip),%xmm1
jmp    12a5 <sine_taylor+0x135>
nopw   0x0(%rax,%rax,1)
movapd (%rsp),%xmm1
divsd  %xmm0,%xmm1
movsd  0x10(%rsp),%xmm0
addsd  %xmm0,%xmm1
cmp    $0x5,%rbx
jb     1260 <sine_taylor+0xf0>
movapd %xmm1,(%rsp)
movsd  0x18(%rsp),%xmm2
call   1050 <_double_approx_eq@plt>
test   %rax,%rax
jne    1185 <sine_taylor+0x15>
cmp    $0x18f,%rbx
movapd (%rsp),%xmm1
jbe    1260 <sine_taylor+0xf0>
jmp    1189 <sine_taylor+0x19>

LLVM IR (-O0):
@NAN = global double 0.000000e+00
@M_PI_4 = global double 0.000000e+00
@M_PI_2 = global i64 0
@DBL_MAX = global double 0.000000e+00
@DBL_EPSILON = global double 0.000000e+00
define double @sine_taylor(double %0) {
%2 = alloca double
%3 = alloca double
%4 = alloca double
%5 = alloca double
%6 = alloca double
%7 = alloca double
%8 = alloca double
%9 = alloca double
%10 = alloca double
%11 = alloca i64
%12 = alloca double
store double %0, double* %3
%13 = load double, double* %3
%14 = call i64 @isnan(double %13)
%15 = icmp ne i64 %14, 0
br i1 %15, label %16, label %18
16: ; preds = %1
%17 = load double, double* %3
store double %17, double* %2
br label %102
18: ; preds = %1
%19 = load double, double* %3
%20 = call i64 @isfinite(double %19)
%21 = icmp eq i64 %20, 0
br i1 %21, label %22, label %24
22: ; preds = %18
%23 = load double, double* @NAN
store double %23, double* %2
br label %102
24: ; preds = %18
%25 = load double, double* %3
%26 = call double @_mod_unit_circle_radians(double %25)
store double %26, double* %4
%27 = load double, double* %4
%28 = load double, double* @M_PI_4
%29 = fmul double 1.000000e+00, %28
%30 = fcmp ogt double %27, %29
br i1 %30, label %31, label %36
31: ; preds = %24
%32 = load double, double* %4
%33 = load double, double* @M_PI_4
%34 = fmul double 3.000000e+00, %33
%35 = fcmp olt double %32, %34
br i1 %35, label %46, label %36
36: ; preds = %31, %24
%37 = load double, double* %4
%38 = load double, double* @M_PI_4
%39 = fmul double 5.000000e+00, %38
%40 = fcmp ogt double %37, %39
br i1 %40, label %41, label %53
41: ; preds = %36
%42 = load double, double* %4
%43 = load double, double* @M_PI_4
%44 = fmul double 7.000000e+00, %43
%45 = fcmp olt double %42, %44
br i1 %45, label %46, label %53
46: ; preds = %41, %31
%47 = load double, double* %4
%48 = load i64, i64* @M_PI_2
%49 = sitofp i64 %48 to double
%50 = fsub double %47, %49
%51 = fptosi double %50 to i64
%52 = call double @cosine_taylor(i64 %51)
store double %52, double* %2
br label %102
53: ; preds = %41, %36
%54 = load double, double* @DBL_MAX
%55 = fneg double %54
store double %55, double* %10
store double 0.000000e+00, double* %5
%56 = load double, double* @DBL_EPSILON
%57 = fmul double 1.100000e+00, %56
store double %57, double* %12
store i64 0, i64* %11
br label %58
58: ; preds = %97, %53
%59 = load i64, i64* %11
%60 = icmp ule i64 %59, 400
br i1 %60, label %61, label %100
61: ; preds = %58
%62 = load double, double* %5
store double %62, double* %10
%63 = load i64, i64* %11
%64 = urem i64 %63, 2
%65 = icmp eq i64 %64, 0
%66 = zext i1 %65 to i64
%67 = select i1 %65, double 1.000000e+00, double -1.000000e+00
store double %67, double* %6
%68 = load double, double* %4
%69 = load i64, i64* %11
%70 = mul i64 2, %69
%71 = add i64 %70, 1
%72 = trunc i64 %71 to i32
%73 = call double @_pow(double %68, i32 %72)
store double %73, double* %7
%74 = load i64, i64* %11
%75 = mul i64 2, %74
%76 = add i64 %75, 1
%77 = trunc i64 %76 to i32
%78 = call double @_factorial(i32 %77)
store double %78, double* %8
%79 = load double, double* %6
%80 = load double, double* %7
%81 = fmul double %79, %80
%82 = load double, double* %8
%83 = fdiv double %81, %82
store double %83, double* %9
%84 = load double, double* %5
%85 = load double, double* %9
%86 = fadd double %84, %85
store double %86, double* %5
%87 = load i64, i64* %11
%88 = icmp uge i64 %87, 5
br i1 %88, label %89, label %96
89: ; preds = %61
%90 = load double, double* %10
%91 = load double, double* %5
%92 = load double, double* %12
%93 = call i64 @_double_approx_eq(double %90, double %91, double %92)
%94 = icmp ne i64 %93, 0
br i1 %94, label %95, label %96
95: ; preds = %89
br label %100
96: ; preds = %89, %61
br label %97
97: ; preds = %96
%98 = load i64, i64* %11
%99 = add i64 %98, 1
store i64 %99, i64* %11
br label %58
100: ; preds = %95, %58
%101 = load double, double* %5
store double %101, double* %2
br label %102
102: ; preds = %100, %46, %22, %16
%103 = load double, double* %2
ret double %103
}

LLVM IR (-O2):
@NAN = global double 0.000000e+00
@M_PI_4 = global double 0.000000e+00
@M_PI_2 = global i64 0
@DBL_MAX = global double 0.000000e+00
@DBL_EPSILON = global double 0.000000e+00
define double @sine_taylor(double %0) {
%2 = tail call i64 @isnan(double %0)
%3 = icmp eq i64 %2, 0
br i1 %3, label %4, label %53
4: ; preds = %1
%5 = tail call i64 @isfinite(double %0)
%6 = icmp eq i64 %5, 0
br i1 %6, label %7, label %9
7: ; preds = %4
%8 = load double, double* @NAN
br label %53
9: ; preds = %4
%10 = tail call double @_mod_unit_circle_radians(double %0)
%11 = load double, double* @M_PI_4
%12 = fcmp ogt double %10, %11
%13 = fmul double %11, 3.000000e+00
%14 = fcmp olt double %10, %13
%15 = and i1 %12, %14
br i1 %15, label %22, label %16
16: ; preds = %9
%17 = fmul double %11, 5.000000e+00
%18 = fcmp ogt double %10, %17
%19 = fmul double %11, 7.000000e+00
%20 = fcmp olt double %10, %19
%21 = and i1 %18, %20
br i1 %21, label %22, label %28
22: ; preds = %16, %9
%23 = load i64, i64* @M_PI_2
%24 = sitofp i64 %23 to double
%25 = fsub double %10, %24
%26 = fptosi double %25 to i64
%27 = tail call double @cosine_taylor(i64 %26)
br label %53
28: ; preds = %16
%29 = load double, double* @DBL_EPSILON
%30 = fmul double %29, 1.100000e+00
br label %31
31: ; preds = %51, %28
%32 = phi i64 [ 0, %28 ], [ %52, %51 ]
%33 = phi double [ 0.000000e+00, %28 ], [ %44, %51 ]
%34 = and i64 %32, 1
%35 = icmp eq i64 %34, 0
%36 = trunc i64 %32 to i32
%37 = shl nuw nsw i32 %36, 1
%38 = or i32 %37, 1
%39 = tail call double @_pow(double %10, i32 %38)
%40 = tail call double @_factorial(i32 %38)
%41 = fneg double %39
%42 = select i1 %35, double %39, double %41
%43 = fdiv double %42, %40
%44 = fadd double %33, %43
%45 = icmp ugt i64 %32, 4
br i1 %45, label %46, label %51
46: ; preds = %31
%47 = tail call i64 @_double_approx_eq(double %33, double %44, double %30)
%48 = icmp eq i64 %47, 0
%49 = icmp ult i64 %32, 400
%50 = select i1 %48, i1 %49, i1 false
br i1 %50, label %51, label %53
51: ; preds = %31, %46
%52 = add nuw nsw i64 %32, 1
br label %31
53: ; preds = %46, %1, %22, %7
%54 = phi double [ %8, %7 ], [ %27, %22 ], [ %0, %1 ], [ %44, %46 ]
ret double %54
}