#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 cos(double);
double const fabs(double);
int /*<<< orphan*/ printf(char *, double, double, double);
double sin(double);
int /*<<< orphan*/ sincos(double, double *, double *);
int TestSinCosD(double a) {
  const double maxerr = 0.000000000001;
  double sincos_sin, sincos_cos, sin_sin, cos_cos;
  sincos(a, &sincos_sin, &sincos_cos);
  sin_sin = sin(a);
  cos_cos = cos(a);
  if (fabs(sincos_sin - sin_sin) > maxerr ||
      fabs(sincos_cos - cos_cos) > maxerr) {
    printf("sincosf(%12.12f) outside tolerance: sin:%12.12f, cos:%12.12f\n", a,
           sincos_sin - sin_sin, sincos_cos - cos_cos);
    return 1;
  } else {
    return 0;
  }
}


x86 assembly (clang, -O0):
<TestSinCosD>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
movsd  %xmm0,-0x10(%rbp)
movsd  0xe9b(%rip),%xmm0
movsd  %xmm0,-0x18(%rbp)
movsd  -0x10(%rbp),%xmm0
lea    -0x20(%rbp),%rdi
lea    -0x28(%rbp),%rsi
call   1030 <sincos@plt>
movsd  -0x10(%rbp),%xmm0
call   1060 <sin@plt>
movsd  %xmm0,-0x30(%rbp)
movsd  -0x10(%rbp),%xmm0
call   1070 <cos@plt>
movsd  %xmm0,-0x38(%rbp)
movsd  -0x20(%rbp),%xmm0
subsd  -0x30(%rbp),%xmm0
call   1050 <fabs@plt>
movsd  0xe4f(%rip),%xmm1
ucomisd %xmm1,%xmm0
ja     11dc <TestSinCosD+0x8c>
movsd  -0x28(%rbp),%xmm0
subsd  -0x38(%rbp),%xmm0
call   1050 <fabs@plt>
movsd  0xe2e(%rip),%xmm1
ucomisd %xmm1,%xmm0
jbe    120d <TestSinCosD+0xbd>
movsd  -0x10(%rbp),%xmm0
movsd  -0x20(%rbp),%xmm1
subsd  -0x30(%rbp),%xmm1
movsd  -0x28(%rbp),%xmm2
subsd  -0x38(%rbp),%xmm2
lea    0xe0c(%rip),%rdi
call   1040 <printf@plt>
movl   $0x1,-0x4(%rbp)
jmp    1214 <TestSinCosD+0xc4>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<TestSinCosD>:
sub    $0x28,%rsp
movsd  %xmm0,0x8(%rsp)
lea    0x20(%rsp),%rdi
lea    0x18(%rsp),%rsi
call   1030 <sincos@plt>
movsd  0x8(%rsp),%xmm0
call   1050 <sin@plt>
movsd  %xmm0,0x10(%rsp)
movsd  0x8(%rsp),%xmm0
call   1060 <cos@plt>
movsd  0x20(%rsp),%xmm1
subsd  0x10(%rsp),%xmm1
movapd 0xe77(%rip),%xmm3
movapd %xmm1,%xmm2
andpd  %xmm3,%xmm2
ucomisd 0xe77(%rip),%xmm2
movsd  0x18(%rsp),%xmm2
subsd  %xmm0,%xmm2
ja     11ba <TestSinCosD+0x7a>
xor    %eax,%eax
andpd  %xmm2,%xmm3
ucomisd 0xe5d(%rip),%xmm3
ja     11ba <TestSinCosD+0x7a>
add    $0x28,%rsp
ret
lea    0xe57(%rip),%rdi
movsd  0x8(%rsp),%xmm0
call   1040 <printf@plt>
mov    $0x1,%eax
add    $0x28,%rsp
ret

LLVM IR (-O0):
@.str = [62 x i8] c"sincosf(%12.12f) outside tolerance: sin:%12.12f, cos:%12.12f\0A\00"
define i32 @TestSinCosD(double %0) {
%2 = alloca i32
%3 = alloca double
%4 = alloca double
%5 = alloca double
%6 = alloca double
%7 = alloca double
%8 = alloca double
store double %0, double* %3
store double 0x3D719799812DEA11, double* %4
%9 = load double, double* %3
%10 = call i32 @sincos(double %9, double* %5, double* %6)
%11 = load double, double* %3
%12 = call double @sin(double %11)
store double %12, double* %7
%13 = load double, double* %3
%14 = call double @cos(double %13)
store double %14, double* %8
%15 = load double, double* %5
%16 = load double, double* %7
%17 = fsub double %15, %16
%18 = call double @fabs(double %17)
%19 = fcmp ogt double %18, 0x3D719799812DEA11
br i1 %19, label %26, label %20
20: ; preds = %1
%21 = load double, double* %6
%22 = load double, double* %8
%23 = fsub double %21, %22
%24 = call double @fabs(double %23)
%25 = fcmp ogt double %24, 0x3D719799812DEA11
br i1 %25, label %26, label %35
26: ; preds = %20, %1
%27 = load double, double* %3
%28 = load double, double* %5
%29 = load double, double* %7
%30 = fsub double %28, %29
%31 = load double, double* %6
%32 = load double, double* %8
%33 = fsub double %31, %32
%34 = call i32 @printf(i8* getelementptr inbounds ([62 x i8], [62 x i8]* @.str, i64 0, i64 0), double %27, double %30, double %33)
store i32 1, i32* %2
br label %36
35: ; preds = %20
store i32 0, i32* %2
br label %36
36: ; preds = %35, %26
%37 = load i32, i32* %2
ret i32 %37
}

LLVM IR (-O2):
@.str = [62 x i8] c"sincosf(%12.12f) outside tolerance: sin:%12.12f, cos:%12.12f\0A\00"
define i32 @TestSinCosD(double %0) {
%2 = alloca double
%3 = alloca double
%4 = bitcast double* %2 to i8*
%5 = bitcast double* %3 to i8*
%6 = call i32 @sincos(double %0, double* %2, double* %3)
%7 = call double @sin(double %0)
%8 = call double @cos(double %0)
%9 = load double, double* %2
%10 = fsub double %9, %7
%11 = call double @llvm.fabs.f64(double %10)
%12 = fcmp ogt double %11, 0x3D719799812DEA11
%13 = load double, double* %3
%14 = fsub double %13, %8
%15 = call double @llvm.fabs.f64(double %14)
%16 = fcmp ogt double %15, 0x3D719799812DEA11
%17 = select i1 %12, i1 true, i1 %16
br i1 %17, label %18, label %20
18: ; preds = %1
%19 = call i32 @printf(i8* getelementptr inbounds ([62 x i8], [62 x i8]* @.str, i64 0, i64 0), double %0, double %10, double %14)
br label %20
20: ; preds = %1, %18
%21 = phi i32 [ 1, %18 ], [ 0, %1 ]
ret i32 %21
}