#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 /*<<< orphan*/ dd_inc_d(double *, double);
int dd_is_zero(double const *);
int /*<<< orphan*/ dd_minus(double *);
int /*<<< orphan*/ dd_sin_taylor(double const *, double *);
int /*<<< orphan*/ dd_sqr(double *, double *);
int /*<<< orphan*/ dd_sqrt(double *, double *);
void dd_sincos_taylor(const double *a, double *sin_a, double *cos_a) {
  if (dd_is_zero(a) == 1) {
    sin_a[0] = 0.0;
    sin_a[1] = 0.0;
    cos_a[0] = 1.0;
    cos_a[1] = 0.0;
  } else {
    double tmp[2];
    dd_sin_taylor(a, sin_a);
    dd_sqr(sin_a, tmp);
    dd_minus(tmp);
    dd_inc_d(tmp, 1.0);
    dd_sqrt(tmp, cos_a);
  }
}


x86 assembly (clang, -O0):
<dd_sincos_taylor>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
mov    -0x8(%rbp),%rdi
call   1030 <dd_is_zero@plt>
cmp    $0x1,%eax
jne    11be <dd_sincos_taylor+0x5e>
mov    -0x10(%rbp),%rax
xorps  %xmm0,%xmm0
movsd  %xmm0,(%rax)
mov    -0x10(%rbp),%rax
xorps  %xmm0,%xmm0
movsd  %xmm0,0x8(%rax)
mov    -0x18(%rbp),%rax
movsd  0xe57(%rip),%xmm0
movsd  %xmm0,(%rax)
mov    -0x18(%rbp),%rax
xorps  %xmm0,%xmm0
movsd  %xmm0,0x8(%rax)
jmp    11ff <dd_sincos_taylor+0x9f>
mov    -0x8(%rbp),%rdi
mov    -0x10(%rbp),%rsi
call   1070 <dd_sin_taylor@plt>
mov    -0x10(%rbp),%rdi
lea    -0x30(%rbp),%rsi
call   1060 <dd_sqr@plt>
lea    -0x30(%rbp),%rdi
call   1080 <dd_minus@plt>
lea    -0x30(%rbp),%rdi
movsd  0xe13(%rip),%xmm0
call   1050 <dd_inc_d@plt>
lea    -0x30(%rbp),%rdi
mov    -0x18(%rbp),%rsi
call   1040 <dd_sqrt@plt>
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<dd_sincos_taylor>:
push   %r15
push   %r14
push   %rbx
sub    $0x10,%rsp
mov    %rdx,%r14
mov    %rsi,%r15
mov    %rdi,%rbx
call   1030 <dd_is_zero@plt>
cmp    $0x1,%eax
jne    1191 <dd_sincos_taylor+0x31>
xorps  %xmm0,%xmm0
movups %xmm0,(%r15)
movsd  0xe75(%rip),%xmm0
movups %xmm0,(%r14)
jmp    11cd <dd_sincos_taylor+0x6d>
mov    %rbx,%rdi
mov    %r15,%rsi
call   1070 <dd_sin_taylor@plt>
mov    %rsp,%rbx
mov    %r15,%rdi
mov    %rbx,%rsi
call   1060 <dd_sqr@plt>
mov    %rbx,%rdi
call   1080 <dd_minus@plt>
movsd  0xe46(%rip),%xmm0
mov    %rbx,%rdi
call   1050 <dd_inc_d@plt>
mov    %rbx,%rdi
mov    %r14,%rsi
call   1040 <dd_sqrt@plt>
add    $0x10,%rsp
pop    %rbx
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
define void @dd_sincos_taylor(double* %0, double* %1, double* %2) {
%4 = alloca double*
%5 = alloca double*
%6 = alloca double*
%7 = alloca [2 x double]
store double* %0, double** %4
store double* %1, double** %5
store double* %2, double** %6
%8 = load double*, double** %4
%9 = call i32 @dd_is_zero(double* %8)
%10 = icmp eq i32 %9, 1
br i1 %10, label %11, label %20
11: ; preds = %3
%12 = load double*, double** %5
%13 = getelementptr inbounds double, double* %12, i64 0
store double 0.000000e+00, double* %13
%14 = load double*, double** %5
%15 = getelementptr inbounds double, double* %14, i64 1
store double 0.000000e+00, double* %15
%16 = load double*, double** %6
%17 = getelementptr inbounds double, double* %16, i64 0
store double 1.000000e+00, double* %17
%18 = load double*, double** %6
%19 = getelementptr inbounds double, double* %18, i64 1
store double 0.000000e+00, double* %19
br label %34
20: ; preds = %3
%21 = load double*, double** %4
%22 = load double*, double** %5
%23 = call i32 @dd_sin_taylor(double* %21, double* %22)
%24 = load double*, double** %5
%25 = getelementptr inbounds [2 x double], [2 x double]* %7, i64 0, i64 0
%26 = call i32 @dd_sqr(double* %24, double* %25)
%27 = getelementptr inbounds [2 x double], [2 x double]* %7, i64 0, i64 0
%28 = call i32 @dd_minus(double* %27)
%29 = getelementptr inbounds [2 x double], [2 x double]* %7, i64 0, i64 0
%30 = call i32 @dd_inc_d(double* %29, double 1.000000e+00)
%31 = getelementptr inbounds [2 x double], [2 x double]* %7, i64 0, i64 0
%32 = load double*, double** %6
%33 = call i32 @dd_sqrt(double* %31, double* %32)
br label %34
34: ; preds = %20, %11
ret void
}

LLVM IR (-O2):
define void @dd_sincos_taylor(double* %0, double* %1, double* %2) {
%4 = alloca [2 x double]
%5 = tail call i32 @dd_is_zero(double* %0)
%6 = icmp eq i32 %5, 1
br i1 %6, label %7, label %10
7: ; preds = %3
%8 = bitcast double* %1 to i8*
%9 = bitcast double* %2 to <2 x double>*
store <2 x double> <double 1.000000e+00, double 0.000000e+00>, <2 x double>* %9
br label %18
10: ; preds = %3
%11 = bitcast [2 x double]* %4 to i8*
%12 = tail call i32 @dd_sin_taylor(double* %0, double* %1)
%13 = getelementptr inbounds [2 x double], [2 x double]* %4, i64 0, i64 0
%14 = call i32 @dd_sqr(double* %1, double* %13)
%15 = call i32 @dd_minus(double* %13)
%16 = call i32 @dd_inc_d(double* %13, double 1.000000e+00)
%17 = call i32 @dd_sqrt(double* %13, double* %2)
br label %18
18: ; preds = %10, %7
ret void
}