#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 /*<<< orphan*/ *createFile(char *);
int /*<<< orphan*/ fclose(int /*<<< orphan*/ *);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/ *, char *);
int /*<<< orphan*/ nextafter(double, int);
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("Long_Test_Both_");
  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");
  for (double i = -710; i <= 710; nextafter((double)i, 712)) {
    testCase(i, &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    $0x40,%rsp
movl   $0x0,-0x4(%rbp)
xorps  %xmm0,%xmm0
movsd  %xmm0,-0x10(%rbp)
xorps  %xmm0,%xmm0
movsd  %xmm0,-0x20(%rbp)
lea    0xe8a(%rip),%rdi
call   1050 <createFile@plt>
mov    %rax,-0x38(%rbp)
mov    -0x38(%rbp),%rdi
lea    0xe86(%rip),%rsi
call   1060 <fprintf@plt>
mov    -0x38(%rbp),%rdi
lea    0xea8(%rip),%rsi
call   1060 <fprintf@plt>
movsd  0xe49(%rip),%xmm0
movsd  %xmm0,-0x40(%rbp)
movsd  0xe44(%rip),%xmm0
ucomisd -0x40(%rbp),%xmm0
jb     1201 <main+0xa1>
movsd  -0x40(%rbp),%xmm0
mov    -0x38(%rbp),%r8
lea    -0x10(%rbp),%rdi
lea    -0x18(%rbp),%rsi
lea    -0x20(%rbp),%rdx
lea    -0x28(%rbp),%rcx
call   1070 <testCase@plt>
movsd  -0x40(%rbp),%xmm0
mov    $0x2c8,%edi
call   1080 <nextafter@plt>
jmp    11bc <main+0x5c>
mov    -0x38(%rbp),%rdi
call   1030 <fclose@plt>
movsd  -0x20(%rbp),%xmm0
movsd  -0x28(%rbp),%xmm1
lea    0xe72(%rip),%rdi
call   1040 <printf@plt>
movsd  -0x10(%rbp),%xmm0
movsd  -0x18(%rbp),%xmm1
lea    0xe75(%rip),%rdi
call   1040 <printf@plt>
mov    -0x4(%rbp),%eax
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x20,%rsp
movq   $0x0,0x8(%rsp)
movq   $0x0,(%rsp)
lea    0xea3(%rip),%rdi
call   1030 <createFile@plt>
mov    %rax,%rbx
lea    0xea4(%rip),%rdi
mov    $0x31,%esi
mov    $0x1,%edx
mov    %rax,%rcx
call   1060 <fwrite@plt>
lea    0xebd(%rip),%rdi
mov    $0x3a,%esi
mov    $0x1,%edx
mov    %rbx,%rcx
call   1060 <fwrite@plt>
lea    0x8(%rsp),%r14
lea    0x18(%rsp),%r15
mov    %rsp,%r12
lea    0x10(%rsp),%r13
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax,%rax,1)
movsd  0xe38(%rip),%xmm0
mov    %r14,%rdi
mov    %r15,%rsi
mov    %r12,%rdx
mov    %r13,%rcx
mov    %rbx,%r8
call   1040 <testCase@plt>
movsd  0xe1c(%rip),%xmm0
mov    $0x2c8,%edi
call   1050 <nextafter@plt>
jmp    11c0 <main+0x80>

LLVM IR (-O0):
@.str = [16 x i8] c"Long_Test_Both_\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"
@.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 i32
%2 = alloca double
%3 = alloca double
%4 = alloca double
%5 = alloca double
%6 = alloca double
%7 = alloca i32*
%8 = alloca double
store i32 0, i32* %1
store double 0.000000e+00, double* %2
store double 0.000000e+00, double* %4
%9 = call i32* @createFile(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str, i64 0, i64 0))
store i32* %9, i32** %7
%10 = load i32*, i32** %7
%11 = call i32 @fprintf(i32* %10, i8* getelementptr inbounds ([50 x i8], [50 x i8]* @.str.1, i64 0, i64 0))
%12 = load i32*, i32** %7
%13 = call i32 @fprintf(i32* %12, i8* getelementptr inbounds ([59 x i8], [59 x i8]* @.str.2, i64 0, i64 0))
store double -7.100000e+02, double* %8
br label %14
14: ; preds = %21, %0
%15 = load double, double* %8
%16 = fcmp ole double %15, 7.100000e+02
br i1 %16, label %17, label %24
17: ; preds = %14
%18 = load double, double* %8
%19 = load i32*, i32** %7
%20 = call i32 @testCase(double %18, double* %2, double* %3, double* %4, double* %5, i32* %19)
br label %21
21: ; preds = %17
%22 = load double, double* %8
%23 = call i32 @nextafter(double %22, i32 712)
br label %14
24: ; preds = %14
%25 = load i32*, i32** %7
%26 = call i32 @fclose(i32* %25)
%27 = load double, double* %4
%28 = load double, double* %5
%29 = call i32 @printf(i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str.3, i64 0, i64 0), double %27, double %28)
%30 = load double, double* %2
%31 = load double, double* %3
%32 = call i32 @printf(i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str.4, i64 0, i64 0), double %30, double %31)
%33 = load i32, i32* %1
ret i32 %33
}

LLVM IR (-O2):
@.str = [16 x i8] c"Long_Test_Both_\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"
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 ([16 x i8], [16 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)
br label %12
12: ; preds = %12, %0
%13 = call i32 @testCase(double -7.100000e+02, double* %1, double* %2, double* %3, double* %4, i32* %9)
%14 = call i32 @nextafter(double -7.100000e+02, i32 712)
br label %12
}