#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 */
float cosf(float);
float const fabsf(float);
int /*<<< orphan*/ printf(char *, float, float, float);
int /*<<< orphan*/ sincosf(float, float *, float *);
float sinf(float);
int TestSinCosF(float a) {
  const float maxerr = 0.000000000001;
  float sincos_sin, sincos_cos, sin_sin, cos_cos;
  sincosf(a, &sincos_sin, &sincos_cos);
  sin_sin = sinf(a);
  cos_cos = cosf(a);
  if (fabsf(sincos_sin - sin_sin) > maxerr ||
      fabsf(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):
<TestSinCosF>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movss  %xmm0,-0x8(%rbp)
movss  0xe9b(%rip),%xmm0
movss  %xmm0,-0xc(%rbp)
movss  -0x8(%rbp),%xmm0
lea    -0x10(%rbp),%rdi
lea    -0x14(%rbp),%rsi
call   1070 <sincosf@plt>
movss  -0x8(%rbp),%xmm0
call   1040 <sinf@plt>
movss  %xmm0,-0x18(%rbp)
movss  -0x8(%rbp),%xmm0
call   1050 <cosf@plt>
movss  %xmm0,-0x1c(%rbp)
movss  -0x10(%rbp),%xmm0
subss  -0x18(%rbp),%xmm0
call   1030 <fabsf@plt>
movss  0xe4f(%rip),%xmm1
ucomiss %xmm1,%xmm0
ja     11da <TestSinCosF+0x8a>
movss  -0x14(%rbp),%xmm0
subss  -0x1c(%rbp),%xmm0
call   1030 <fabsf@plt>
movss  0xe2f(%rip),%xmm1
ucomiss %xmm1,%xmm0
jbe    120b <TestSinCosF+0xbb>
movss  -0x8(%rbp),%xmm0
movss  -0x10(%rbp),%xmm1
subss  -0x18(%rbp),%xmm1
movss  -0x14(%rbp),%xmm2
subss  -0x1c(%rbp),%xmm2
lea    0xe0a(%rip),%rdi
call   1060 <printf@plt>
movl   $0x1,-0x4(%rbp)
jmp    1212 <TestSinCosF+0xc2>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<TestSinCosF>:
sub    $0x18,%rsp
movss  %xmm0,0x8(%rsp)
lea    0x14(%rsp),%rdi
lea    0x10(%rsp),%rsi
call   1060 <sincosf@plt>
movss  0x8(%rsp),%xmm0
call   1030 <sinf@plt>
movss  %xmm0,0xc(%rsp)
movss  0x8(%rsp),%xmm0
call   1040 <cosf@plt>
movss  0x14(%rsp),%xmm1
subss  0xc(%rsp),%xmm1
movaps 0xe78(%rip),%xmm3
movaps %xmm1,%xmm2
andps  %xmm3,%xmm2
ucomiss 0xe7b(%rip),%xmm2
movss  0x10(%rsp),%xmm2
subss  %xmm0,%xmm2
ja     11b4 <TestSinCosF+0x74>
xor    %eax,%eax
andps  %xmm2,%xmm3
ucomiss 0xe63(%rip),%xmm3
ja     11b4 <TestSinCosF+0x74>
add    $0x18,%rsp
ret
lea    0xe59(%rip),%rdi
movss  0x8(%rsp),%xmm0
call   1050 <printf@plt>
mov    $0x1,%eax
add    $0x18,%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 @TestSinCosF(float %0) {
%2 = alloca i32
%3 = alloca float
%4 = alloca float
%5 = alloca float
%6 = alloca float
%7 = alloca float
%8 = alloca float
store float %0, float* %3
store float 0x3D71979980000000, float* %4
%9 = load float, float* %3
%10 = call i32 @sincosf(float %9, float* %5, float* %6)
%11 = load float, float* %3
%12 = call float @sinf(float %11)
store float %12, float* %7
%13 = load float, float* %3
%14 = call float @cosf(float %13)
store float %14, float* %8
%15 = load float, float* %5
%16 = load float, float* %7
%17 = fsub float %15, %16
%18 = call float @fabsf(float %17)
%19 = fcmp ogt float %18, 0x3D71979980000000
br i1 %19, label %26, label %20
20: ; preds = %1
%21 = load float, float* %6
%22 = load float, float* %8
%23 = fsub float %21, %22
%24 = call float @fabsf(float %23)
%25 = fcmp ogt float %24, 0x3D71979980000000
br i1 %25, label %26, label %35
26: ; preds = %20, %1
%27 = load float, float* %3
%28 = load float, float* %5
%29 = load float, float* %7
%30 = fsub float %28, %29
%31 = load float, float* %6
%32 = load float, float* %8
%33 = fsub float %31, %32
%34 = call i32 @printf(i8* getelementptr inbounds ([62 x i8], [62 x i8]* @.str, i64 0, i64 0), float %27, float %30, float %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 @TestSinCosF(float %0) {
%2 = alloca float
%3 = alloca float
%4 = bitcast float* %2 to i8*
%5 = bitcast float* %3 to i8*
%6 = call i32 @sincosf(float %0, float* %2, float* %3)
%7 = call float @sinf(float %0)
%8 = call float @cosf(float %0)
%9 = load float, float* %2
%10 = fsub float %9, %7
%11 = call float @llvm.fabs.f32(float %10)
%12 = fcmp ogt float %11, 0x3D71979980000000
%13 = load float, float* %3
%14 = fsub float %13, %8
%15 = call float @llvm.fabs.f32(float %14)
%16 = fcmp ogt float %15, 0x3D71979980000000
%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), float %0, float %10, float %14)
br label %20
20: ; preds = %1, %18
%21 = phi i32 [ 1, %18 ], [ 0, %1 ]
ret i32 %21
}