#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 INT32_MAX;
int /*<<< orphan*/ bot_fasttrig_init();
int /*<<< orphan*/ bot_fasttrig_sincos(double, double *, double *);
double cos(double);
int /*<<< orphan*/ exit(int /*<<< orphan*/);
double fabs(double);
int /*<<< orphan*/ printf(char *, double, double, double, double, double);
double rand();
double sin(double);
void bot_fasttrig_sincos_test() {
  bot_fasttrig_init();
  double eps = 1.0 / (1 << 17);
  int limit = INT32_MAX;
  for (int iters = 0; iters < limit; iters++) {
    double theta = rand() / 1000.0;
    double s = sin(theta), c = cos(theta);
    double s2, c2;
    bot_fasttrig_sincos(theta, &s2, &c2);
    if (1) {
      double s_err = fabs(s - s2), c_err = fabs(c - c2);
      if (s_err > eps)
        printf("sin %20.5f : %15.12f %15.12f %15.12f %10.5f\n", theta, s, s2,
               s_err, s_err / eps);
      if (c_err > eps)
        printf("cos %20.5f : %15.12f %15.12f %15.12f %10.5f\n", theta, c, c2,
               c_err, c_err / eps);
    }
  }
  exit(0);
}


x86 assembly (clang, -O0):
<bot_fasttrig_sincos_test>:
push   %rbp
mov    %rsp,%rbp
sub    $0x50,%rsp
mov    $0x0,%al
call   1030 <bot_fasttrig_init@plt>
movsd  0xe79(%rip),%xmm0
movsd  %xmm0,-0x8(%rbp)
mov    0x2e4d(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0xc(%rbp)
movl   $0x0,-0x10(%rbp)
mov    -0x10(%rbp),%eax
cmp    -0xc(%rbp),%eax
jge    12ae <bot_fasttrig_sincos_test+0x13e>
mov    $0x0,%al
call   1090 <rand@plt>
movsd  0xe4e(%rip),%xmm1
divsd  %xmm1,%xmm0
movsd  %xmm0,-0x18(%rbp)
movsd  -0x18(%rbp),%xmm0
call   1050 <sin@plt>
movsd  %xmm0,-0x20(%rbp)
movsd  -0x18(%rbp),%xmm0
call   1070 <cos@plt>
movsd  %xmm0,-0x28(%rbp)
movsd  -0x18(%rbp),%xmm0
lea    -0x30(%rbp),%rdi
lea    -0x38(%rbp),%rsi
call   1060 <bot_fasttrig_sincos@plt>
movsd  -0x20(%rbp),%xmm0
subsd  -0x30(%rbp),%xmm0
movaps 0xe0c(%rip),%xmm1
pand   %xmm1,%xmm0
movsd  %xmm0,-0x40(%rbp)
movsd  -0x28(%rbp),%xmm0
subsd  -0x38(%rbp),%xmm0
movaps 0xdf2(%rip),%xmm1
pand   %xmm1,%xmm0
movsd  %xmm0,-0x48(%rbp)
movsd  -0x40(%rbp),%xmm0
ucomisd -0x8(%rbp),%xmm0
jbe    1261 <bot_fasttrig_sincos_test+0xf1>
movsd  -0x18(%rbp),%xmm0
movsd  -0x20(%rbp),%xmm1
movsd  -0x30(%rbp),%xmm2
movsd  -0x40(%rbp),%xmm3
movsd  -0x40(%rbp),%xmm4
divsd  -0x8(%rbp),%xmm4
lea    0xdc4(%rip),%rdi
call   1040 <printf@plt>
movsd  -0x48(%rbp),%xmm0
ucomisd -0x8(%rbp),%xmm0
jbe    129b <bot_fasttrig_sincos_test+0x12b>
movsd  -0x18(%rbp),%xmm0
movsd  -0x28(%rbp),%xmm1
movsd  -0x38(%rbp),%xmm2
movsd  -0x48(%rbp),%xmm3
movsd  -0x48(%rbp),%xmm4
divsd  -0x8(%rbp),%xmm4
lea    0xdb7(%rip),%rdi
call   1040 <printf@plt>
jmp    12a0 <bot_fasttrig_sincos_test+0x130>
mov    -0x10(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x10(%rbp)
jmp    119f <bot_fasttrig_sincos_test+0x2f>
xor    %edi,%edi
call   1080 <exit@plt>

x86 assembly (clang, -O2):
<bot_fasttrig_sincos_test>:
push   %rbp
push   %r15
push   %r14
push   %r12
push   %rbx
sub    $0x40,%rsp
xor    %eax,%eax
call   1030 <bot_fasttrig_init@plt>
mov    0x2e56(%rip),%rax
mov    (%rax),%ebp
test   %ebp,%ebp
jle    12ac <bot_fasttrig_sincos_test+0x13c>
lea    0x38(%rsp),%r14
lea    0x18(%rsp),%rbx
lea    0xe8b(%rip),%r15
lea    0xeb1(%rip),%r12
jmp    11b9 <bot_fasttrig_sincos_test+0x49>
xchg   %ax,%ax
add    $0xffffffff,%ebp
je     12ac <bot_fasttrig_sincos_test+0x13c>
xor    %eax,%eax
call   1090 <rand@plt>
divsd  0xe38(%rip),%xmm0
movsd  %xmm0,0x8(%rsp)
call   1050 <sin@plt>
movsd  %xmm0,0x20(%rsp)
movsd  0x8(%rsp),%xmm0
call   1070 <cos@plt>
movsd  %xmm0,0x10(%rsp)
movsd  0x8(%rsp),%xmm0
mov    %r14,%rdi
mov    %rbx,%rsi
call   1060 <bot_fasttrig_sincos@plt>
movsd  0x20(%rsp),%xmm6
movsd  0x38(%rsp),%xmm2
movapd %xmm6,%xmm3
subsd  %xmm2,%xmm3
movapd 0xe09(%rip),%xmm0
andpd  %xmm0,%xmm3
movsd  0x10(%rsp),%xmm5
subsd  0x18(%rsp),%xmm5
movsd  0xdd9(%rip),%xmm1
ucomisd %xmm1,%xmm3
jbe    126f <bot_fasttrig_sincos_test+0xff>
movapd %xmm3,%xmm4
mulsd  0xdcf(%rip),%xmm4
mov    %r15,%rdi
movsd  0x8(%rsp),%xmm0
movapd %xmm6,%xmm1
movapd %xmm5,0x20(%rsp)
call   1040 <printf@plt>
movapd 0x20(%rsp),%xmm5
movsd  0xda1(%rip),%xmm1
movapd 0xdb1(%rip),%xmm0
andpd  %xmm0,%xmm5
ucomisd %xmm1,%xmm5
jbe    11b0 <bot_fasttrig_sincos_test+0x40>
movsd  0x18(%rsp),%xmm2
movapd %xmm5,%xmm4
mulsd  0xd81(%rip),%xmm4
mov    %r12,%rdi
movsd  0x8(%rsp),%xmm0
movsd  0x10(%rsp),%xmm1
movapd %xmm5,%xmm3
call   1040 <printf@plt>
jmp    11b0 <bot_fasttrig_sincos_test+0x40>
xor    %edi,%edi
call   1080 <exit@plt>

LLVM IR (-O0):
@INT32_MAX = global i32 0
@.str = [45 x i8] c"sin %20.5f : %15.12f %15.12f %15.12f %10.5f\0A\00"
@.str.1 = [45 x i8] c"cos %20.5f : %15.12f %15.12f %15.12f %10.5f\0A\00"
define void @bot_fasttrig_sincos_test() {
%1 = alloca double
%2 = alloca i32
%3 = alloca i32
%4 = alloca double
%5 = alloca double
%6 = alloca double
%7 = alloca double
%8 = alloca double
%9 = alloca double
%10 = alloca double
%11 = call i32 (...) @bot_fasttrig_init()
store double 0x3EE0000000000000, double* %1
%12 = load i32, i32* @INT32_MAX
store i32 %12, i32* %2
store i32 0, i32* %3
br label %13
13: ; preds = %60, %0
%14 = load i32, i32* %3
%15 = load i32, i32* %2
%16 = icmp slt i32 %14, %15
br i1 %16, label %17, label %63
17: ; preds = %13
%18 = call double (...) @rand()
%19 = fdiv double %18, 1.000000e+03
store double %19, double* %4
%20 = load double, double* %4
%21 = call double @sin(double %20)
store double %21, double* %5
%22 = load double, double* %4
%23 = call double @cos(double %22)
store double %23, double* %6
%24 = load double, double* %4
%25 = call i32 @bot_fasttrig_sincos(double %24, double* %7, double* %8)
%26 = load double, double* %5
%27 = load double, double* %7
%28 = fsub double %26, %27
%29 = call double @llvm.fabs.f64(double %28)
store double %29, double* %9
%30 = load double, double* %6
%31 = load double, double* %8
%32 = fsub double %30, %31
%33 = call double @llvm.fabs.f64(double %32)
store double %33, double* %10
%34 = load double, double* %9
%35 = load double, double* %1
%36 = fcmp ogt double %34, %35
br i1 %36, label %37, label %46
37: ; preds = %17
%38 = load double, double* %4
%39 = load double, double* %5
%40 = load double, double* %7
%41 = load double, double* %9
%42 = load double, double* %9
%43 = load double, double* %1
%44 = fdiv double %42, %43
%45 = call i32 @printf(i8* getelementptr inbounds ([45 x i8], [45 x i8]* @.str, i64 0, i64 0), double %38, double %39, double %40, double %41, double %44)
br label %46
46: ; preds = %37, %17
%47 = load double, double* %10
%48 = load double, double* %1
%49 = fcmp ogt double %47, %48
br i1 %49, label %50, label %59
50: ; preds = %46
%51 = load double, double* %4
%52 = load double, double* %6
%53 = load double, double* %8
%54 = load double, double* %10
%55 = load double, double* %10
%56 = load double, double* %1
%57 = fdiv double %55, %56
%58 = call i32 @printf(i8* getelementptr inbounds ([45 x i8], [45 x i8]* @.str.1, i64 0, i64 0), double %51, double %52, double %53, double %54, double %57)
br label %59
59: ; preds = %50, %46
br label %60
60: ; preds = %59
%61 = load i32, i32* %3
%62 = add nsw i32 %61, 1
store i32 %62, i32* %3
br label %13
63: ; preds = %13
%64 = call i32 @exit(i32 0)
unreachable
}

LLVM IR (-O2):
@INT32_MAX = global i32 0
@.str = [45 x i8] c"sin %20.5f : %15.12f %15.12f %15.12f %10.5f\0A\00"
@.str.1 = [45 x i8] c"cos %20.5f : %15.12f %15.12f %15.12f %10.5f\0A\00"
define void @bot_fasttrig_sincos_test() {
%1 = alloca double
%2 = alloca double
%3 = tail call i32 (...) @bot_fasttrig_init()
%4 = load i32, i32* @INT32_MAX
%5 = icmp sgt i32 %4, 0
br i1 %5, label %6, label %9
6: ; preds = %0
%7 = bitcast double* %1 to i8*
%8 = bitcast double* %2 to i8*
br label %11
9: ; preds = %34, %0
%10 = call i32 @exit(i32 0)
unreachable
11: ; preds = %6, %34
%12 = phi i32 [ 0, %6 ], [ %35, %34 ]
%13 = call double (...) @rand()
%14 = fdiv double %13, 1.000000e+03
%15 = call double @sin(double %14)
%16 = call double @cos(double %14)
%17 = call i32 @bot_fasttrig_sincos(double %14, double* %1, double* %2)
%18 = load double, double* %1
%19 = fsub double %15, %18
%20 = call double @llvm.fabs.f64(double %19)
%21 = load double, double* %2
%22 = fsub double %16, %21
%23 = call double @llvm.fabs.f64(double %22)
%24 = fcmp ogt double %20, 0x3EE0000000000000
br i1 %24, label %25, label %28
25: ; preds = %11
%26 = fmul double %20, 1.310720e+05
%27 = call i32 @printf(i8* getelementptr inbounds ([45 x i8], [45 x i8]* @.str, i64 0, i64 0), double %14, double %15, double %18, double %20, double %26)
br label %28
28: ; preds = %25, %11
%29 = fcmp ogt double %23, 0x3EE0000000000000
br i1 %29, label %30, label %34
30: ; preds = %28
%31 = load double, double* %2
%32 = fmul double %23, 1.310720e+05
%33 = call i32 @printf(i8* getelementptr inbounds ([45 x i8], [45 x i8]* @.str.1, i64 0, i64 0), double %14, double %16, double %31, double %23, double %32)
br label %34
34: ; preds = %30, %28
%35 = add nuw nsw i32 %12, 1
%36 = icmp eq i32 %35, %4
br i1 %36, label %9, label %11
}