#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 */
scalar_t__ compare_trig_functions(double, double, int, int, int, int);
int /*<<< orphan*/ printf(char *, int, unsigned long long, double, double,
                          double);
int test_range(double from, double to, double inc, double tolerance,
               int test_inv, int verbose, int test_sin, int test_cos,
               int test_tan) {
  int errors;
  double d;
  size_t i;
  errors = 0;
  i = 0;
  for (d = from; d <= to; d += inc) {
    errors += compare_trig_functions(d, tolerance, verbose, test_sin, test_cos,
                                     test_tan);
    ++i;
    if (test_inv) {
      errors += compare_trig_functions(-d, tolerance, verbose, test_sin,
                                       test_cos, test_tan);
      ++i;
    }
  }
  printf("%d errors testing %llu values from %f t/m %f\n"
         "\t(within %.20f)\n",
         errors, (unsigned long long)i, (test_inv) ? -to : from, to, tolerance);
  return errors;
}


x86 assembly (clang, -O0):
<test_range>:
push   %rbp
mov    %rsp,%rbp
sub    $0x60,%rsp
movsd  %xmm0,-0x8(%rbp)
movsd  %xmm1,-0x10(%rbp)
movsd  %xmm2,-0x18(%rbp)
movsd  %xmm3,-0x20(%rbp)
mov    %edi,-0x24(%rbp)
mov    %esi,-0x28(%rbp)
mov    %edx,-0x2c(%rbp)
mov    %ecx,-0x30(%rbp)
mov    %r8d,-0x34(%rbp)
movl   $0x0,-0x38(%rbp)
movq   $0x0,-0x48(%rbp)
movsd  -0x8(%rbp),%xmm0
movsd  %xmm0,-0x40(%rbp)
movsd  -0x40(%rbp),%xmm1
movsd  -0x10(%rbp),%xmm0
ucomisd %xmm1,%xmm0
jb     121b <test_range+0xfb>
movsd  -0x40(%rbp),%xmm0
movsd  -0x20(%rbp),%xmm1
mov    -0x28(%rbp),%edi
mov    -0x2c(%rbp),%esi
mov    -0x30(%rbp),%edx
mov    -0x34(%rbp),%ecx
call   1040 <compare_trig_functions@plt>
mov    %rax,%rcx
movslq -0x38(%rbp),%rax
add    %rcx,%rax
mov    %eax,-0x38(%rbp)
mov    -0x48(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x48(%rbp)
cmpl   $0x0,-0x24(%rbp)
je     1202 <test_range+0xe2>
movsd  -0x40(%rbp),%xmm0
movq   %xmm0,%rax
movabs $0x8000000000000000,%rcx
xor    %rcx,%rax
movq   %rax,%xmm0
movsd  -0x20(%rbp),%xmm1
mov    -0x28(%rbp),%edi
mov    -0x2c(%rbp),%esi
mov    -0x30(%rbp),%edx
mov    -0x34(%rbp),%ecx
call   1040 <compare_trig_functions@plt>
mov    %rax,%rcx
movslq -0x38(%rbp),%rax
add    %rcx,%rax
mov    %eax,-0x38(%rbp)
mov    -0x48(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x48(%rbp)
jmp    1207 <test_range+0xe7>
movsd  -0x18(%rbp),%xmm0
addsd  -0x40(%rbp),%xmm0
movsd  %xmm0,-0x40(%rbp)
jmp    1165 <test_range+0x45>
mov    -0x38(%rbp),%eax
mov    %eax,-0x54(%rbp)
mov    -0x48(%rbp),%rax
mov    %rax,-0x50(%rbp)
cmpl   $0x0,-0x24(%rbp)
je     1259 <test_range+0x139>
movsd  -0x10(%rbp),%xmm0
movq   %xmm0,%rax
movabs $0x8000000000000000,%rcx
xor    %rcx,%rax
movq   %rax,%xmm0
movsd  %xmm0,-0x60(%rbp)
jmp    1263 <test_range+0x143>
movsd  -0x8(%rbp),%xmm0
movsd  %xmm0,-0x60(%rbp)
mov    -0x50(%rbp),%rdx
mov    -0x54(%rbp),%esi
movsd  -0x60(%rbp),%xmm0
movsd  -0x10(%rbp),%xmm1
movsd  -0x20(%rbp),%xmm2
lea    0xd80(%rip),%rdi
call   1030 <printf@plt>
mov    -0x38(%rbp),%eax
add    $0x60,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<test_range>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x68,%rsp
mov    %edi,0xc(%rsp)
movsd  %xmm2,0x48(%rsp)
movapd %xmm1,0x20(%rsp)
ucomisd %xmm0,%xmm1
movapd %xmm0,0x50(%rsp)
jae    118d <test_range+0x6d>
xor    %ebp,%ebp
xor    %edx,%edx
cmpl   $0x0,0xc(%rsp)
movaps 0x50(%rsp),%xmm0
je     1166 <test_range+0x46>
movaps 0xe9f(%rip),%xmm0
xorps  0x20(%rsp),%xmm0
lea    0xea3(%rip),%rdi
mov    %ebp,%esi
movaps 0x20(%rsp),%xmm1
movaps %xmm3,%xmm2
call   1030 <printf@plt>
mov    %ebp,%eax
add    $0x68,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret
mov    %r8d,%r12d
mov    %ecx,%r13d
mov    %edx,%r14d
mov    %esi,%ebx
xor    %edx,%edx
movapd %xmm0,%xmm1
xor    %r15d,%r15d
movsd  %xmm3,0x10(%rsp)
jmp    1204 <test_range+0xe4>
nopl   0x0(%rax)
movapd 0x30(%rsp),%xmm0
xorpd  0xe42(%rip),%xmm0
movsd  0x10(%rsp),%xmm1
mov    %ebx,%edi
mov    %r14d,%esi
mov    %r13d,%edx
mov    %r12d,%ecx
call   1040 <compare_trig_functions@plt>
add    %eax,%ebp
mov    0x18(%rsp),%rdx
add    $0x2,%rdx
movsd  0x10(%rsp),%xmm3
movapd 0x30(%rsp),%xmm1
addsd  0x48(%rsp),%xmm1
movapd 0x20(%rsp),%xmm0
ucomisd %xmm1,%xmm0
mov    %ebp,%r15d
jb     114e <test_range+0x2e>
movapd %xmm1,0x30(%rsp)
mov    %rdx,0x18(%rsp)
movapd %xmm1,%xmm0
movaps %xmm3,%xmm1
mov    %ebx,%edi
mov    %r14d,%esi
mov    %r13d,%edx
mov    %r12d,%ecx
call   1040 <compare_trig_functions@plt>
mov    %rax,%rbp
add    %r15d,%ebp
cmpl   $0x0,0xc(%rsp)
jne    11b0 <test_range+0x90>
mov    0x18(%rsp),%rdx
add    $0x1,%rdx
jmp    11df <test_range+0xbf>

LLVM IR (-O0):
@.str = [62 x i8] c"%d errors testing %llu values from %f t/m %f\0A\09(within %.20f)\0A\00"
define i32 @test_range(double %0, double %1, double %2, double %3, i32 %4, i32 %5, i32 %6, i32 %7, i32 %8) {
%10 = alloca double
%11 = alloca double
%12 = alloca double
%13 = alloca double
%14 = alloca i32
%15 = alloca i32
%16 = alloca i32
%17 = alloca i32
%18 = alloca i32
%19 = alloca i32
%20 = alloca double
%21 = alloca i64
store double %0, double* %10
store double %1, double* %11
store double %2, double* %12
store double %3, double* %13
store i32 %4, i32* %14
store i32 %5, i32* %15
store i32 %6, i32* %16
store i32 %7, i32* %17
store i32 %8, i32* %18
store i32 0, i32* %19
store i64 0, i64* %21
%22 = load double, double* %10
store double %22, double* %20
br label %23
23: ; preds = %59, %9
%24 = load double, double* %20
%25 = load double, double* %11
%26 = fcmp ole double %24, %25
br i1 %26, label %27, label %63
27: ; preds = %23
%28 = load double, double* %20
%29 = load double, double* %13
%30 = load i32, i32* %15
%31 = load i32, i32* %16
%32 = load i32, i32* %17
%33 = load i32, i32* %18
%34 = call i64 @compare_trig_functions(double %28, double %29, i32 %30, i32 %31, i32 %32, i32 %33)
%35 = load i32, i32* %19
%36 = sext i32 %35 to i64
%37 = add nsw i64 %36, %34
%38 = trunc i64 %37 to i32
store i32 %38, i32* %19
%39 = load i64, i64* %21
%40 = add i64 %39, 1
store i64 %40, i64* %21
%41 = load i32, i32* %14
%42 = icmp ne i32 %41, 0
br i1 %42, label %43, label %58
43: ; preds = %27
%44 = load double, double* %20
%45 = fneg double %44
%46 = load double, double* %13
%47 = load i32, i32* %15
%48 = load i32, i32* %16
%49 = load i32, i32* %17
%50 = load i32, i32* %18
%51 = call i64 @compare_trig_functions(double %45, double %46, i32 %47, i32 %48, i32 %49, i32 %50)
%52 = load i32, i32* %19
%53 = sext i32 %52 to i64
%54 = add nsw i64 %53, %51
%55 = trunc i64 %54 to i32
store i32 %55, i32* %19
%56 = load i64, i64* %21
%57 = add i64 %56, 1
store i64 %57, i64* %21
br label %58
58: ; preds = %43, %27
br label %59
59: ; preds = %58
%60 = load double, double* %12
%61 = load double, double* %20
%62 = fadd double %61, %60
store double %62, double* %20
br label %23
63: ; preds = %23
%64 = load i32, i32* %19
%65 = load i64, i64* %21
%66 = load i32, i32* %14
%67 = icmp ne i32 %66, 0
br i1 %67, label %68, label %71
68: ; preds = %63
%69 = load double, double* %11
%70 = fneg double %69
br label %73
71: ; preds = %63
%72 = load double, double* %10
br label %73
73: ; preds = %71, %68
%74 = phi double [ %70, %68 ], [ %72, %71 ]
%75 = load double, double* %11
%76 = load double, double* %13
%77 = call i32 @printf(i8* getelementptr inbounds ([62 x i8], [62 x i8]* @.str, i64 0, i64 0), i32 %64, i64 %65, double %74, double %75, double %76)
%78 = load i32, i32* %19
ret i32 %78
}

LLVM IR (-O2):
@.str = [62 x i8] c"%d errors testing %llu values from %f t/m %f\0A\09(within %.20f)\0A\00"
define i32 @test_range(double %0, double %1, double %2, double %3, i32 %4, i32 %5, i32 %6, i32 %7, i32 %8) {
%10 = fcmp ugt double %0, %1
br i1 %10, label %32, label %11
11: ; preds = %9
%12 = icmp eq i32 %4, 0
br label %13
13: ; preds = %11, %27
%14 = phi i64 [ 0, %11 ], [ %29, %27 ]
%15 = phi double [ %0, %11 ], [ %30, %27 ]
%16 = phi i32 [ 0, %11 ], [ %28, %27 ]
%17 = tail call i64 @compare_trig_functions(double %15, double %3, i32 %5, i32 %6, i32 %7, i32 %8)
%18 = trunc i64 %17 to i32
%19 = add i32 %16, %18
%20 = add i64 %14, 1
br i1 %12, label %27, label %21
21: ; preds = %13
%22 = fneg double %15
%23 = tail call i64 @compare_trig_functions(double %22, double %3, i32 %5, i32 %6, i32 %7, i32 %8)
%24 = trunc i64 %23 to i32
%25 = add i32 %19, %24
%26 = add i64 %14, 2
br label %27
27: ; preds = %13, %21
%28 = phi i32 [ %25, %21 ], [ %19, %13 ]
%29 = phi i64 [ %26, %21 ], [ %20, %13 ]
%30 = fadd double %15, %2
%31 = fcmp ugt double %30, %1
br i1 %31, label %32, label %13
32: ; preds = %27, %9
%33 = phi i32 [ 0, %9 ], [ %28, %27 ]
%34 = phi i64 [ 0, %9 ], [ %29, %27 ]
%35 = icmp eq i32 %4, 0
%36 = fneg double %1
%37 = select i1 %35, double %0, double %36
%38 = tail call i32 @printf(i8* getelementptr inbounds ([62 x i8], [62 x i8]* @.str, i64 0, i64 0), i32 %33, i64 %34, double %37, double %1, double %3)
ret i32 %33
}