#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 */
double INFINITY;
double NAN;
int /*<<< orphan*/ *createFile(char *);
int /*<<< orphan*/ fclose(int /*<<< orphan*/ *);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/ *, char *);
int /*<<< orphan*/ printf(char *, double, double);
int /*<<< orphan*/ testCase(double, double *, double *, double *, double *,
                            int /*<<< orphan*/ *);
int main() {
  double worstSpeed = 0, indexSpeed, worstError = 0, indexError, tmp;
  FILE *fp;
  fp = createFile("Error_Test_");
  fprintf(fp, "Test Var,Our Output,Std Output,The Deviation Was,");
  fprintf(fp, "Our Output (in ms),Std Output (in ms),We Took X Ms Longer\n");
  tmp = NAN;
  testCase(tmp, &worstSpeed, &indexSpeed, &worstError, &indexError, fp);
  tmp = INFINITY;
  testCase(tmp, &worstSpeed, &indexSpeed, &worstError, &indexError, fp);
  tmp = -INFINITY;
  testCase(tmp, &worstSpeed, &indexSpeed, &worstError, &indexError, fp);
  tmp = 720;
  testCase(tmp, &worstSpeed, &indexSpeed, &worstError, &indexError, fp);
  tmp = -720;
  testCase(tmp, &worstSpeed, &indexSpeed, &worstError, &indexError, fp);
  fclose(fp);
  printf("Worst error is %e at %e\n", worstError, indexError);
  printf("Worst speed is %e at %e\n", worstSpeed, indexSpeed);
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
xorps  %xmm0,%xmm0
movsd  %xmm0,-0x8(%rbp)
xorps  %xmm0,%xmm0
movsd  %xmm0,-0x18(%rbp)
lea    0xea1(%rip),%rdi
call   1050 <createFile@plt>
mov    %rax,-0x30(%rbp)
mov    -0x30(%rbp),%rdi
lea    0xe99(%rip),%rsi
call   1060 <fprintf@plt>
mov    -0x30(%rbp),%rdi
lea    0xebb(%rip),%rsi
call   1060 <fprintf@plt>
mov    0x2e59(%rip),%rax
movsd  (%rax),%xmm0
movsd  %xmm0,-0x28(%rbp)
movsd  -0x28(%rbp),%xmm0
mov    -0x30(%rbp),%r8
lea    -0x8(%rbp),%rdi
lea    -0x10(%rbp),%rsi
lea    -0x18(%rbp),%rdx
lea    -0x20(%rbp),%rcx
call   1070 <testCase@plt>
mov    0x2e13(%rip),%rax
movsd  (%rax),%xmm0
movsd  %xmm0,-0x28(%rbp)
movsd  -0x28(%rbp),%xmm0
mov    -0x30(%rbp),%r8
lea    -0x8(%rbp),%rdi
lea    -0x10(%rbp),%rsi
lea    -0x18(%rbp),%rdx
lea    -0x20(%rbp),%rcx
call   1070 <testCase@plt>
mov    0x2de5(%rip),%rax
movsd  (%rax),%xmm0
movq   %xmm0,%rax
movabs $0x8000000000000000,%rcx
xor    %rcx,%rax
movq   %rax,%xmm0
movsd  %xmm0,-0x28(%rbp)
movsd  -0x28(%rbp),%xmm0
mov    -0x30(%rbp),%r8
lea    -0x8(%rbp),%rdi
lea    -0x10(%rbp),%rsi
lea    -0x18(%rbp),%rdx
lea    -0x20(%rbp),%rcx
call   1070 <testCase@plt>
movsd  0xdc7(%rip),%xmm0
movsd  %xmm0,-0x28(%rbp)
movsd  -0x28(%rbp),%xmm0
mov    -0x30(%rbp),%r8
lea    -0x8(%rbp),%rdi
lea    -0x10(%rbp),%rsi
lea    -0x18(%rbp),%rdx
lea    -0x20(%rbp),%rcx
call   1070 <testCase@plt>
movsd  0xd94(%rip),%xmm0
movsd  %xmm0,-0x28(%rbp)
movsd  -0x28(%rbp),%xmm0
mov    -0x30(%rbp),%r8
lea    -0x8(%rbp),%rdi
lea    -0x10(%rbp),%rsi
lea    -0x18(%rbp),%rdx
lea    -0x20(%rbp),%rcx
call   1070 <testCase@plt>
mov    -0x30(%rbp),%rdi
call   1030 <fclose@plt>
movsd  -0x18(%rbp),%xmm0
movsd  -0x20(%rbp),%xmm1
lea    0xde0(%rip),%rdi
call   1040 <printf@plt>
movsd  -0x8(%rbp),%xmm0
movsd  -0x10(%rbp),%xmm1
lea    0xde3(%rip),%rdi
call   1040 <printf@plt>
xor    %eax,%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x28,%rsp
movq   $0x0,0x10(%rsp)
movq   $0x0,0x8(%rsp)
lea    0xea9(%rip),%rdi
call   1050 <createFile@plt>
mov    %rax,%rbx
lea    0xea6(%rip),%rdi
mov    $0x31,%esi
mov    $0x1,%edx
mov    %rax,%rcx
call   1070 <fwrite@plt>
lea    0xebf(%rip),%rdi
mov    $0x3a,%esi
mov    $0x1,%edx
mov    %rbx,%rcx
call   1070 <fwrite@plt>
mov    0x2e40(%rip),%rax
movsd  (%rax),%xmm0
lea    0x10(%rsp),%r14
lea    0x20(%rsp),%r15
lea    0x8(%rsp),%r12
lea    0x18(%rsp),%r13
mov    %r14,%rdi
mov    %r15,%rsi
mov    %r12,%rdx
mov    %r13,%rcx
mov    %rbx,%r8
call   1060 <testCase@plt>
mov    0x2df5(%rip),%rbp
movsd  0x0(%rbp),%xmm0
mov    %r14,%rdi
mov    %r15,%rsi
mov    %r12,%rdx
mov    %r13,%rcx
mov    %rbx,%r8
call   1060 <testCase@plt>
movsd  0x0(%rbp),%xmm0
xorps  0xdf0(%rip),%xmm0
mov    %r14,%rdi
mov    %r15,%rsi
mov    %r12,%rdx
mov    %r13,%rcx
mov    %rbx,%r8
call   1060 <testCase@plt>
movsd  0xde4(%rip),%xmm0
mov    %r14,%rdi
mov    %r15,%rsi
mov    %r12,%rdx
mov    %r13,%rcx
mov    %rbx,%r8
call   1060 <testCase@plt>
movsd  0xdd0(%rip),%xmm0
mov    %r14,%rdi
mov    %r15,%rsi
mov    %r12,%rdx
mov    %r13,%rcx
mov    %rbx,%r8
call   1060 <testCase@plt>
mov    %rbx,%rdi
call   1030 <fclose@plt>
movsd  0x8(%rsp),%xmm0
movsd  0x18(%rsp),%xmm1
lea    0xe22(%rip),%rdi
call   1040 <printf@plt>
movsd  0x10(%rsp),%xmm0
movsd  0x20(%rsp),%xmm1
lea    0xe23(%rip),%rdi
call   1040 <printf@plt>
xor    %eax,%eax
add    $0x28,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [12 x i8] c"Error_Test_\00"
@.str.1 = [50 x i8] c"Test Var,Our Output,Std Output,The Deviation Was,\00"
@.str.2 = [59 x i8] c"Our Output (in ms),Std Output (in ms),We Took X Ms Longer\0A\00"
@NAN = global double 0.000000e+00
@INFINITY = global double 0.000000e+00
@.str.3 = [25 x i8] c"Worst error is %e at %e\0A\00"
@.str.4 = [25 x i8] c"Worst speed is %e at %e\0A\00"
define i32 @main() {
%1 = alloca double
%2 = alloca double
%3 = alloca double
%4 = alloca double
%5 = alloca double
%6 = alloca i32*
store double 0.000000e+00, double* %1
store double 0.000000e+00, double* %3
%7 = call i32* @createFile(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str, i64 0, i64 0))
store i32* %7, i32** %6
%8 = load i32*, i32** %6
%9 = call i32 @fprintf(i32* %8, i8* getelementptr inbounds ([50 x i8], [50 x i8]* @.str.1, i64 0, i64 0))
%10 = load i32*, i32** %6
%11 = call i32 @fprintf(i32* %10, i8* getelementptr inbounds ([59 x i8], [59 x i8]* @.str.2, i64 0, i64 0))
%12 = load double, double* @NAN
store double %12, double* %5
%13 = load double, double* %5
%14 = load i32*, i32** %6
%15 = call i32 @testCase(double %13, double* %1, double* %2, double* %3, double* %4, i32* %14)
%16 = load double, double* @INFINITY
store double %16, double* %5
%17 = load double, double* %5
%18 = load i32*, i32** %6
%19 = call i32 @testCase(double %17, double* %1, double* %2, double* %3, double* %4, i32* %18)
%20 = load double, double* @INFINITY
%21 = fneg double %20
store double %21, double* %5
%22 = load double, double* %5
%23 = load i32*, i32** %6
%24 = call i32 @testCase(double %22, double* %1, double* %2, double* %3, double* %4, i32* %23)
store double 7.200000e+02, double* %5
%25 = load double, double* %5
%26 = load i32*, i32** %6
%27 = call i32 @testCase(double %25, double* %1, double* %2, double* %3, double* %4, i32* %26)
store double -7.200000e+02, double* %5
%28 = load double, double* %5
%29 = load i32*, i32** %6
%30 = call i32 @testCase(double %28, double* %1, double* %2, double* %3, double* %4, i32* %29)
%31 = load i32*, i32** %6
%32 = call i32 @fclose(i32* %31)
%33 = load double, double* %3
%34 = load double, double* %4
%35 = call i32 @printf(i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str.3, i64 0, i64 0), double %33, double %34)
%36 = load double, double* %1
%37 = load double, double* %2
%38 = call i32 @printf(i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str.4, i64 0, i64 0), double %36, double %37)
ret i32 0
}

LLVM IR (-O2):
@.str = [12 x i8] c"Error_Test_\00"
@.str.1 = [50 x i8] c"Test Var,Our Output,Std Output,The Deviation Was,\00"
@.str.2 = [59 x i8] c"Our Output (in ms),Std Output (in ms),We Took X Ms Longer\0A\00"
@NAN = global double 0.000000e+00
@INFINITY = global double 0.000000e+00
@.str.3 = [25 x i8] c"Worst error is %e at %e\0A\00"
@.str.4 = [25 x i8] c"Worst speed is %e at %e\0A\00"
define i32 @main() {
%1 = alloca double
%2 = alloca double
%3 = alloca double
%4 = alloca double
%5 = bitcast double* %1 to i8*
store double 0.000000e+00, double* %1
%6 = bitcast double* %2 to i8*
%7 = bitcast double* %3 to i8*
store double 0.000000e+00, double* %3
%8 = bitcast double* %4 to i8*
%9 = tail call i32* @createFile(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str, i64 0, i64 0))
%10 = tail call i64 @fwrite(i8* getelementptr inbounds ([50 x i8], [50 x i8]* @.str.1, i64 0, i64 0), i64 49, i64 1, i32* %9)
%11 = tail call i64 @fwrite(i8* getelementptr inbounds ([59 x i8], [59 x i8]* @.str.2, i64 0, i64 0), i64 58, i64 1, i32* %9)
%12 = load double, double* @NAN
%13 = call i32 @testCase(double %12, double* %1, double* %2, double* %3, double* %4, i32* %9)
%14 = load double, double* @INFINITY
%15 = call i32 @testCase(double %14, double* %1, double* %2, double* %3, double* %4, i32* %9)
%16 = load double, double* @INFINITY
%17 = fneg double %16
%18 = call i32 @testCase(double %17, double* %1, double* %2, double* %3, double* %4, i32* %9)
%19 = call i32 @testCase(double 7.200000e+02, double* %1, double* %2, double* %3, double* %4, i32* %9)
%20 = call i32 @testCase(double -7.200000e+02, double* %1, double* %2, double* %3, double* %4, i32* %9)
%21 = call i32 @fclose(i32* %9)
%22 = load double, double* %3
%23 = load double, double* %4
%24 = call i32 @printf(i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str.3, i64 0, i64 0), double %22, double %23)
%25 = load double, double* %1
%26 = load double, double* %2
%27 = call i32 @printf(i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str.4, i64 0, i64 0), double %25, double %26)
ret i32 0
}