#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 ft_taylor_sin(double);
double ft_sin(double angle) {
  int sign;
  double pi;
  pi = 3.141592653589793;
  sign = 1;
  if (angle < 0) {
    angle = -angle;
    sign = -1;
  }
  if (angle == 0)
    return (0);
  else if (angle == pi / 2)
    return (1);
  else if (angle > pi / 2)
    angle = pi - angle;
  return (sign * ft_taylor_sin(angle));
}


x86 assembly (clang, -O0):
<ft_sin>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
movsd  %xmm0,-0x10(%rbp)
movsd  0xedb(%rip),%xmm0
movsd  %xmm0,-0x20(%rbp)
movl   $0x1,-0x14(%rbp)
xorps  %xmm0,%xmm0
ucomisd -0x10(%rbp),%xmm0
jbe    1167 <ft_sin+0x57>
movsd  -0x10(%rbp),%xmm0
movq   %xmm0,%rax
movabs $0x8000000000000000,%rcx
xor    %rcx,%rax
movq   %rax,%xmm0
movsd  %xmm0,-0x10(%rbp)
movl   $0xffffffff,-0x14(%rbp)
movsd  -0x10(%rbp),%xmm0
xorps  %xmm1,%xmm1
ucomisd %xmm1,%xmm0
jne    118c <ft_sin+0x7c>
jp     118c <ft_sin+0x7c>
xorps  %xmm0,%xmm0
movsd  %xmm0,-0x8(%rbp)
jmp    121e <ft_sin+0x10e>
movsd  -0x10(%rbp),%xmm0
movsd  -0x20(%rbp),%xmm1
movsd  0xe6a(%rip),%xmm2
divsd  %xmm2,%xmm1
ucomisd %xmm1,%xmm0
jne    11c4 <ft_sin+0xb4>
jp     11c4 <ft_sin+0xb4>
movsd  0xe56(%rip),%xmm0
movsd  %xmm0,-0x8(%rbp)
jmp    121e <ft_sin+0x10e>
movsd  -0x10(%rbp),%xmm0
movsd  -0x20(%rbp),%xmm1
movsd  0xe32(%rip),%xmm2
divsd  %xmm2,%xmm1
ucomisd %xmm1,%xmm0
jbe    11f3 <ft_sin+0xe3>
movsd  -0x20(%rbp),%xmm0
subsd  -0x10(%rbp),%xmm0
movsd  %xmm0,-0x10(%rbp)
jmp    11f8 <ft_sin+0xe8>
jmp    11fd <ft_sin+0xed>
mov    -0x14(%rbp),%eax
mov    %eax,-0x24(%rbp)
movsd  -0x10(%rbp),%xmm0
call   1030 <ft_taylor_sin@plt>
mov    %eax,%ecx
mov    -0x24(%rbp),%eax
imul   %ecx,%eax
cvtsi2sd %eax,%xmm0
movsd  %xmm0,-0x8(%rbp)
movsd  -0x8(%rbp),%xmm0
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<ft_sin>:
sub    $0x18,%rsp
movapd %xmm0,%xmm3
movapd 0xee0(%rip),%xmm2
xorpd  %xmm0,%xmm2
xorpd  %xmm0,%xmm0
movapd %xmm3,%xmm1
cmpltsd %xmm0,%xmm1
andpd  %xmm1,%xmm2
andnpd %xmm3,%xmm1
orpd   %xmm2,%xmm1
ucomisd %xmm0,%xmm1
jne    114a <ft_sin+0x3a>
jp     114a <ft_sin+0x3a>
add    $0x18,%rsp
ret
ucomisd 0xec6(%rip),%xmm1
jne    1163 <ft_sin+0x53>
jp     1163 <ft_sin+0x53>
movsd  0xeb2(%rip),%xmm0
add    $0x18,%rsp
ret
movsd  0xeb5(%rip),%xmm2
subsd  %xmm1,%xmm2
movsd  0xea1(%rip),%xmm0
cmpltsd %xmm1,%xmm0
andpd  %xmm0,%xmm2
andnpd %xmm1,%xmm0
orpd   %xmm2,%xmm0
movapd %xmm3,(%rsp)
call   1030 <ft_taylor_sin@plt>
mov    %eax,%ecx
neg    %ecx
xorpd  %xmm0,%xmm0
ucomisd (%rsp),%xmm0
cmovbe %eax,%ecx
xorps  %xmm0,%xmm0
cvtsi2sd %ecx,%xmm0
add    $0x18,%rsp
ret

LLVM IR (-O0):
define double @ft_sin(double %0) {
%2 = alloca double
%3 = alloca double
%4 = alloca i32
%5 = alloca double
store double %0, double* %3
store double 0x400921FB54442D18, double* %5
store i32 1, i32* %4
%6 = load double, double* %3
%7 = fcmp olt double %6, 0.000000e+00
br i1 %7, label %8, label %11
8: ; preds = %1
%9 = load double, double* %3
%10 = fneg double %9
store double %10, double* %3
store i32 -1, i32* %4
br label %11
11: ; preds = %8, %1
%12 = load double, double* %3
%13 = fcmp oeq double %12, 0.000000e+00
br i1 %13, label %14, label %15
14: ; preds = %11
store double 0.000000e+00, double* %2
br label %38
15: ; preds = %11
%16 = load double, double* %3
%17 = load double, double* %5
%18 = fdiv double %17, 2.000000e+00
%19 = fcmp oeq double %16, %18
br i1 %19, label %20, label %21
20: ; preds = %15
store double 1.000000e+00, double* %2
br label %38
21: ; preds = %15
%22 = load double, double* %3
%23 = load double, double* %5
%24 = fdiv double %23, 2.000000e+00
%25 = fcmp ogt double %22, %24
br i1 %25, label %26, label %30
26: ; preds = %21
%27 = load double, double* %5
%28 = load double, double* %3
%29 = fsub double %27, %28
store double %29, double* %3
br label %30
30: ; preds = %26, %21
br label %31
31: ; preds = %30
br label %32
32: ; preds = %31
%33 = load i32, i32* %4
%34 = load double, double* %3
%35 = call i32 @ft_taylor_sin(double %34)
%36 = mul nsw i32 %33, %35
%37 = sitofp i32 %36 to double
store double %37, double* %2
br label %38
38: ; preds = %32, %20, %14
%39 = load double, double* %2
ret double %39
}

LLVM IR (-O2):
define double @ft_sin(double %0) {
%2 = fcmp olt double %0, 0.000000e+00
%3 = fneg double %0
%4 = select i1 %2, double %3, double %0
%5 = fcmp oeq double %4, 0.000000e+00
br i1 %5, label %16, label %6
6: ; preds = %1
%7 = fcmp oeq double %4, 0x3FF921FB54442D18
br i1 %7, label %16, label %8
8: ; preds = %6
%9 = fcmp ogt double %4, 0x3FF921FB54442D18
%10 = fsub double 0x400921FB54442D18, %4
%11 = select i1 %9, double %10, double %4
%12 = tail call i32 @ft_taylor_sin(double %11)
%13 = sub nsw i32 0, %12
%14 = select i1 %2, i32 %13, i32 %12
%15 = sitofp i32 %14 to double
br label %16
16: ; preds = %6, %1, %8
%17 = phi double [ %15, %8 ], [ 0.000000e+00, %1 ], [ 1.000000e+00, %6 ]
ret double %17
}