#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 */
typedef int /*<<< orphan*/ FILE;

/* Variables and functions */
int RAND_MAX;
int /*<<< orphan*/ *createFile(char *);
int /*<<< orphan*/ errorTestCase(double, double *, double *,
                                 int /*<<< orphan*/ *);
int /*<<< orphan*/ fclose(int /*<<< orphan*/ *);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/ *, char *);
double nextafter(double, int);
int /*<<< orphan*/ printf(char *, double, double);
scalar_t__ rand();
int main() {
  double worstError = 0, index, tmp;
  FILE *fp;
  fp = createFile("Quick_Test_Error_");
  fprintf(fp, "Test Var,Our Output,Std Output,The Deviation Was\n");
  for (double i = -711; i < 711; i += 0.25) {
    tmp = i;
    errorTestCase(tmp, &worstError, &index, fp);
    tmp = nextafter(i, 712);
    errorTestCase(tmp, &worstError, &index, fp);
    tmp = nextafter(i, -712);
    errorTestCase(tmp, &worstError, &index, fp);
  }
  for (int i = 0; i < 1500; i++) {
    tmp = (double)rand() / (double)(RAND_MAX / 712);
    errorTestCase(tmp, &worstError, &index, fp);
  }
  for (int i = 0; i < 1500; i++) {
    tmp = (double)rand() / (double)(RAND_MAX / 712);
    tmp = -tmp;
    errorTestCase(tmp, &worstError, &index, fp);
  }
  fclose(fp);
  printf("Worst error is %e at %e\n", worstError, index);
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
movl   $0x0,-0x4(%rbp)
xorps  %xmm0,%xmm0
movsd  %xmm0,-0x10(%rbp)
lea    0xe8a(%rip),%rdi
call   1060 <createFile@plt>
mov    %rax,-0x28(%rbp)
mov    -0x28(%rbp),%rdi
lea    0xe88(%rip),%rsi
call   1070 <fprintf@plt>
movsd  0xe51(%rip),%xmm0
movsd  %xmm0,-0x30(%rbp)
movsd  0xe4c(%rip),%xmm0
ucomisd -0x30(%rbp),%xmm0
jbe    1252 <main+0xe2>
movsd  -0x30(%rbp),%xmm0
movsd  %xmm0,-0x20(%rbp)
movsd  -0x20(%rbp),%xmm0
mov    -0x28(%rbp),%rdx
lea    -0x10(%rbp),%rdi
lea    -0x18(%rbp),%rsi
call   1040 <errorTestCase@plt>
movsd  -0x30(%rbp),%xmm0
mov    $0x2c8,%edi
call   1080 <nextafter@plt>
movsd  %xmm0,-0x20(%rbp)
movsd  -0x20(%rbp),%xmm0
mov    -0x28(%rbp),%rdx
lea    -0x10(%rbp),%rdi
lea    -0x18(%rbp),%rsi
call   1040 <errorTestCase@plt>
movsd  -0x30(%rbp),%xmm0
mov    $0xfffffd38,%edi
call   1080 <nextafter@plt>
movsd  %xmm0,-0x20(%rbp)
movsd  -0x20(%rbp),%xmm0
mov    -0x28(%rbp),%rdx
lea    -0x10(%rbp),%rdi
lea    -0x18(%rbp),%rsi
call   1040 <errorTestCase@plt>
movsd  0xdcd(%rip),%xmm0
addsd  -0x30(%rbp),%xmm0
movsd  %xmm0,-0x30(%rbp)
jmp    11b4 <main+0x44>
movl   $0x0,-0x34(%rbp)
cmpl   $0x5dc,-0x34(%rbp)
jge    12b4 <main+0x144>
mov    $0x0,%al
call   1090 <rand@plt>
cvtsi2sd %rax,%xmm0
mov    0x2d6f(%rip),%rax
mov    (%rax),%eax
mov    $0x2c8,%ecx
cltd
idiv   %ecx
cvtsi2sd %eax,%xmm1
divsd  %xmm1,%xmm0
movsd  %xmm0,-0x20(%rbp)
movsd  -0x20(%rbp),%xmm0
mov    -0x28(%rbp),%rdx
lea    -0x10(%rbp),%rdi
lea    -0x18(%rbp),%rsi
call   1040 <errorTestCase@plt>
mov    -0x34(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x34(%rbp)
jmp    1259 <main+0xe9>
movl   $0x0,-0x38(%rbp)
cmpl   $0x5dc,-0x38(%rbp)
jge    1337 <main+0x1c7>
mov    $0x0,%al
call   1090 <rand@plt>
cvtsi2sd %rax,%xmm0
mov    0x2d0d(%rip),%rax
mov    (%rax),%eax
mov    $0x2c8,%ecx
cltd
idiv   %ecx
cvtsi2sd %eax,%xmm1
divsd  %xmm1,%xmm0
movsd  %xmm0,-0x20(%rbp)
movsd  -0x20(%rbp),%xmm0
movq   %xmm0,%rax
movabs $0x8000000000000000,%rcx
xor    %rcx,%rax
movq   %rax,%xmm0
movsd  %xmm0,-0x20(%rbp)
movsd  -0x20(%rbp),%xmm0
mov    -0x28(%rbp),%rdx
lea    -0x10(%rbp),%rdi
lea    -0x18(%rbp),%rsi
call   1040 <errorTestCase@plt>
mov    -0x38(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x38(%rbp)
jmp    12bb <main+0x14b>
mov    -0x28(%rbp),%rdi
call   1030 <fclose@plt>
movsd  -0x10(%rbp),%xmm0
movsd  -0x18(%rbp),%xmm1
lea    0xd0b(%rip),%rdi
call   1050 <printf@plt>
mov    -0x4(%rbp),%eax
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r12
push   %rbx
sub    $0x20,%rsp
movq   $0x0,0x10(%rsp)
lea    0xea4(%rip),%rdi
call   1060 <createFile@plt>
mov    %rax,%rbx
lea    0xea7(%rip),%rdi
mov    $0x31,%esi
mov    $0x1,%edx
mov    %rax,%rcx
call   1080 <fwrite@plt>
movsd  0xe4b(%rip),%xmm0
lea    0x10(%rsp),%r14
lea    0x18(%rsp),%r15
nop
movsd  %xmm0,0x8(%rsp)
movsd  0x8(%rsp),%xmm0
mov    %r14,%rdi
mov    %r15,%rsi
mov    %rbx,%rdx
call   1040 <errorTestCase@plt>
movsd  0x8(%rsp),%xmm0
mov    $0x2c8,%edi
call   1070 <nextafter@plt>
mov    %r14,%rdi
mov    %r15,%rsi
mov    %rbx,%rdx
call   1040 <errorTestCase@plt>
movsd  0x8(%rsp),%xmm0
mov    $0xfffffd38,%edi
call   1070 <nextafter@plt>
mov    %r14,%rdi
mov    %r15,%rsi
mov    %rbx,%rdx
call   1040 <errorTestCase@plt>
movsd  0x8(%rsp),%xmm0
addsd  0xde4(%rip),%xmm0
movsd  0xde4(%rip),%xmm1
ucomisd %xmm0,%xmm1
ja     11c0 <main+0x50>
mov    $0x5dc,%ebp
mov    0x2daa(%rip),%r12
lea    0x10(%rsp),%r14
lea    0x18(%rsp),%r15
nopl   0x0(%rax,%rax,1)
xor    %eax,%eax
call   1090 <rand@plt>
xorps  %xmm0,%xmm0
cvtsi2sd %rax,%xmm0
movslq (%r12),%rax
imul   $0xffffffffb81702e1,%rax,%rcx
shr    $0x20,%rcx
add    %eax,%ecx
mov    %ecx,%eax
shr    $0x1f,%eax
sar    $0x9,%ecx
add    %eax,%ecx
xorps  %xmm1,%xmm1
cvtsi2sd %ecx,%xmm1
divsd  %xmm1,%xmm0
mov    %r14,%rdi
mov    %r15,%rsi
mov    %rbx,%rdx
call   1040 <errorTestCase@plt>
add    $0xffffffff,%ebp
jne    1250 <main+0xe0>
mov    $0x5dc,%ebp
lea    0x10(%rsp),%r14
lea    0x18(%rsp),%r15
nopw   0x0(%rax,%rax,1)
xor    %eax,%eax
call   1090 <rand@plt>
xorps  %xmm0,%xmm0
cvtsi2sd %rax,%xmm0
xorpd  0xd59(%rip),%xmm0
movslq (%r12),%rax
imul   $0xffffffffb81702e1,%rax,%rcx
shr    $0x20,%rcx
add    %eax,%ecx
mov    %ecx,%eax
shr    $0x1f,%eax
sar    $0x9,%ecx
add    %eax,%ecx
xorps  %xmm1,%xmm1
cvtsi2sd %ecx,%xmm1
divsd  %xmm1,%xmm0
mov    %r14,%rdi
mov    %r15,%rsi
mov    %rbx,%rdx
call   1040 <errorTestCase@plt>
add    $0xffffffff,%ebp
jne    12b0 <main+0x140>
mov    %rbx,%rdi
call   1030 <fclose@plt>
movsd  0x10(%rsp),%xmm0
movsd  0x18(%rsp),%xmm1
lea    0xd59(%rip),%rdi
call   1050 <printf@plt>
xor    %eax,%eax
add    $0x20,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [18 x i8] c"Quick_Test_Error_\00"
@.str.1 = [50 x i8] c"Test Var,Our Output,Std Output,The Deviation Was\0A\00"
@RAND_MAX = global i32 0
@.str.2 = [25 x i8] c"Worst error is %e at %e\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca double
%3 = alloca double
%4 = alloca double
%5 = alloca i32*
%6 = alloca double
%7 = alloca i32
%8 = alloca i32
store i32 0, i32* %1
store double 0.000000e+00, double* %2
%9 = call i32* @createFile(i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str, i64 0, i64 0))
store i32* %9, i32** %5
%10 = load i32*, i32** %5
%11 = call i32 @fprintf(i32* %10, i8* getelementptr inbounds ([50 x i8], [50 x i8]* @.str.1, i64 0, i64 0))
store double -7.110000e+02, double* %6
br label %12
12: ; preds = %30, %0
%13 = load double, double* %6
%14 = fcmp olt double %13, 7.110000e+02
br i1 %14, label %15, label %33
15: ; preds = %12
%16 = load double, double* %6
store double %16, double* %4
%17 = load double, double* %4
%18 = load i32*, i32** %5
%19 = call i32 @errorTestCase(double %17, double* %2, double* %3, i32* %18)
%20 = load double, double* %6
%21 = call double @nextafter(double %20, i32 712)
store double %21, double* %4
%22 = load double, double* %4
%23 = load i32*, i32** %5
%24 = call i32 @errorTestCase(double %22, double* %2, double* %3, i32* %23)
%25 = load double, double* %6
%26 = call double @nextafter(double %25, i32 -712)
store double %26, double* %4
%27 = load double, double* %4
%28 = load i32*, i32** %5
%29 = call i32 @errorTestCase(double %27, double* %2, double* %3, i32* %28)
br label %30
30: ; preds = %15
%31 = load double, double* %6
%32 = fadd double %31, 2.500000e-01
store double %32, double* %6
br label %12
33: ; preds = %12
store i32 0, i32* %7
br label %34
34: ; preds = %47, %33
%35 = load i32, i32* %7
%36 = icmp slt i32 %35, 1500
br i1 %36, label %37, label %50
37: ; preds = %34
%38 = call i64 (...) @rand()
%39 = sitofp i64 %38 to double
%40 = load i32, i32* @RAND_MAX
%41 = sdiv i32 %40, 712
%42 = sitofp i32 %41 to double
%43 = fdiv double %39, %42
store double %43, double* %4
%44 = load double, double* %4
%45 = load i32*, i32** %5
%46 = call i32 @errorTestCase(double %44, double* %2, double* %3, i32* %45)
br label %47
47: ; preds = %37
%48 = load i32, i32* %7
%49 = add nsw i32 %48, 1
store i32 %49, i32* %7
br label %34
50: ; preds = %34
store i32 0, i32* %8
br label %51
51: ; preds = %66, %50
%52 = load i32, i32* %8
%53 = icmp slt i32 %52, 1500
br i1 %53, label %54, label %69
54: ; preds = %51
%55 = call i64 (...) @rand()
%56 = sitofp i64 %55 to double
%57 = load i32, i32* @RAND_MAX
%58 = sdiv i32 %57, 712
%59 = sitofp i32 %58 to double
%60 = fdiv double %56, %59
store double %60, double* %4
%61 = load double, double* %4
%62 = fneg double %61
store double %62, double* %4
%63 = load double, double* %4
%64 = load i32*, i32** %5
%65 = call i32 @errorTestCase(double %63, double* %2, double* %3, i32* %64)
br label %66
66: ; preds = %54
%67 = load i32, i32* %8
%68 = add nsw i32 %67, 1
store i32 %68, i32* %8
br label %51
69: ; preds = %51
%70 = load i32*, i32** %5
%71 = call i32 @fclose(i32* %70)
%72 = load double, double* %2
%73 = load double, double* %3
%74 = call i32 @printf(i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str.2, i64 0, i64 0), double %72, double %73)
%75 = load i32, i32* %1
ret i32 %75
}

LLVM IR (-O2):
@.str = [18 x i8] c"Quick_Test_Error_\00"
@.str.1 = [50 x i8] c"Test Var,Our Output,Std Output,The Deviation Was\0A\00"
@RAND_MAX = global i32 0
@.str.2 = [25 x i8] c"Worst error is %e at %e\0A\00"
define i32 @main() {
%1 = alloca double
%2 = alloca double
%3 = bitcast double* %1 to i8*
store double 0.000000e+00, double* %1
%4 = bitcast double* %2 to i8*
%5 = tail call i32* @createFile(i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str, i64 0, i64 0))
%6 = tail call i64 @fwrite(i8* getelementptr inbounds ([50 x i8], [50 x i8]* @.str.1, i64 0, i64 0), i64 49, i64 1, i32* %5)
br label %7
7: ; preds = %0, %7
%8 = phi double [ -7.110000e+02, %0 ], [ %14, %7 ]
%9 = call i32 @errorTestCase(double %8, double* %1, double* %2, i32* %5)
%10 = call double @nextafter(double %8, i32 712)
%11 = call i32 @errorTestCase(double %10, double* %1, double* %2, i32* %5)
%12 = call double @nextafter(double %8, i32 -712)
%13 = call i32 @errorTestCase(double %12, double* %1, double* %2, i32* %5)
%14 = fadd double %8, 2.500000e-01
%15 = fcmp olt double %14, 7.110000e+02
br i1 %15, label %7, label %16
16: ; preds = %7, %16
%17 = phi i32 [ %25, %16 ], [ 0, %7 ]
%18 = call i64 (...) @rand()
%19 = sitofp i64 %18 to double
%20 = load i32, i32* @RAND_MAX
%21 = sdiv i32 %20, 712
%22 = sitofp i32 %21 to double
%23 = fdiv double %19, %22
%24 = call i32 @errorTestCase(double %23, double* %1, double* %2, i32* %5)
%25 = add nuw nsw i32 %17, 1
%26 = icmp eq i32 %25, 1500
br i1 %26, label %32, label %16
27: ; preds = %32
%28 = call i32 @fclose(i32* %5)
%29 = load double, double* %1
%30 = load double, double* %2
%31 = call i32 @printf(i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str.2, i64 0, i64 0), double %29, double %30)
ret i32 0
32: ; preds = %16, %32
%33 = phi i32 [ %42, %32 ], [ 0, %16 ]
%34 = call i64 (...) @rand()
%35 = sitofp i64 %34 to double
%36 = load i32, i32* @RAND_MAX
%37 = sdiv i32 %36, 712
%38 = sitofp i32 %37 to double
%39 = fneg double %35
%40 = fdiv double %39, %38
%41 = call i32 @errorTestCase(double %40, double* %1, double* %2, i32* %5)
%42 = add nuw nsw i32 %33, 1
%43 = icmp eq i32 %42, 1500
br i1 %43, label %27, label %32
}